diff options
| author | Michael Lingelbach <m.j.lbach@gmail.com> | 2021-03-28 01:27:27 -0700 |
|---|---|---|
| committer | Michael Lingelbach <m.j.lbach@gmail.com> | 2021-03-28 01:48:57 -0700 |
| commit | 1dfab4f50f03efb304ec8c996728bb5dc90962d6 (patch) | |
| tree | 23986591d61b041dfcc8b502c0814c1371c38e0a /lua/lspconfig.lua | |
| parent | Merge pull request #799 from mjlbach/fixes (diff) | |
| download | nvim-lspconfig-1dfab4f50f03efb304ec8c996728bb5dc90962d6.tar nvim-lspconfig-1dfab4f50f03efb304ec8c996728bb5dc90962d6.tar.gz nvim-lspconfig-1dfab4f50f03efb304ec8c996728bb5dc90962d6.tar.bz2 nvim-lspconfig-1dfab4f50f03efb304ec8c996728bb5dc90962d6.tar.lz nvim-lspconfig-1dfab4f50f03efb304ec8c996728bb5dc90962d6.tar.xz nvim-lspconfig-1dfab4f50f03efb304ec8c996728bb5dc90962d6.tar.zst nvim-lspconfig-1dfab4f50f03efb304ec8c996728bb5dc90962d6.zip | |
Add stop, start, and restart commands
Diffstat (limited to 'lua/lspconfig.lua')
| -rw-r--r-- | lua/lspconfig.lua | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/lua/lspconfig.lua b/lua/lspconfig.lua index 462b4ddb..4c9fbda4 100644 --- a/lua/lspconfig.lua +++ b/lua/lspconfig.lua @@ -19,9 +19,46 @@ function M._root._setup() function() lspinfo() end; - "-nargs=?"; + "-nargs=0"; description = '`:LspInfo` Displays attached, active, and configured language servers'; }; + LspStart = { + function(server_name) + require('lspconfig')[server_name].autostart() + end; + "-nargs=1 -complete=custom,v:lua.lsp_complete_configured_servers"; + description = '`:LspStart` Manually launches a language server.'; + }; + LspStop = { + function(client_id) + if not client_id then + vim.lsp.stop_client(vim.lsp.get_active_clients()) + else + local client = vim.lsp.get_client_by_id(tonumber(client_id)) + if client then + client.stop() + end + end + end; + "-nargs=? -complete=customlist,v:lua.lsp_get_active_client_ids"; + description = '`:LspStop` Manually stops the given language client.'; + }; + LspRestart = { + function(client_id) + if client_id then + local client = vim.lsp.get_client_by_id(tonumber(client_id)) + if client then + local client_name = client.name + client.stop() + vim.defer_fn(function() + require('lspconfig')[client_name].autostart() + end, 500) + end + end + end; + "-nargs=? -complete=customlist,v:lua.lsp_get_active_client_ids"; + description = '`:LspRestart` Manually restart the given language client.'; + }; }; M.util.create_module_commands("_root", M._root.commands) |
