diff options
| author | Michael Lingelbach <m.j.lbach@gmail.com> | 2021-04-14 08:35:25 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-14 08:35:25 -0700 |
| commit | bbc3d2c9214181e6ffa056ab5939f03cd795eeae (patch) | |
| tree | 10ab8f4853fe7cb2c3f1de33c64504551d817762 | |
| parent | [docgen] Update CONFIG.md (diff) | |
| parent | LspStart: make start all matching clients by default (diff) | |
| download | nvim-lspconfig-bbc3d2c9214181e6ffa056ab5939f03cd795eeae.tar nvim-lspconfig-bbc3d2c9214181e6ffa056ab5939f03cd795eeae.tar.gz nvim-lspconfig-bbc3d2c9214181e6ffa056ab5939f03cd795eeae.tar.bz2 nvim-lspconfig-bbc3d2c9214181e6ffa056ab5939f03cd795eeae.tar.lz nvim-lspconfig-bbc3d2c9214181e6ffa056ab5939f03cd795eeae.tar.xz nvim-lspconfig-bbc3d2c9214181e6ffa056ab5939f03cd795eeae.tar.zst nvim-lspconfig-bbc3d2c9214181e6ffa056ab5939f03cd795eeae.zip | |
Merge pull request #840 from mjlbach/lsp_start_improvements
LspStart: make start all matching clients by default
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | lua/lspconfig.lua | 17 |
2 files changed, 16 insertions, 3 deletions
@@ -39,7 +39,7 @@ omnifunc completion The following support tab-completion for all arguments: -* `:LspStart <config_name>` Start the requested server name. Will only succesfully start if the command detects a root directory matching the current config. Pass `autostart = false` to your `.setup{}` call for a language server if you would like to launch clients solely with this command. +* `:LspStart <config_name>` Start the requested server name. Will only succesfully start if the command detects a root directory matching the current config. Pass `autostart = false` to your `.setup{}` call for a language server if you would like to launch clients solely with this command. Defaults to all servers matching current buffer filetype. * `:LspStop <client_id>` Defaults to stopping all buffer clients. * `:LspRestart <client_id>` Defaults to restarting all buffer clients. diff --git a/lua/lspconfig.lua b/lua/lspconfig.lua index ba8660ec..a901a1a2 100644 --- a/lua/lspconfig.lua +++ b/lua/lspconfig.lua @@ -24,9 +24,22 @@ function M._root._setup() }; LspStart = { function(server_name) - require('lspconfig')[server_name].autostart() + if server_name then + require('lspconfig')[server_name].autostart() + else + local buffer_filetype = vim.bo.filetype + for client_name, config in pairs(configs) do + if config.filetypes then + for _, filetype_match in ipairs(config.filetypes) do + if buffer_filetype == filetype_match then + require('lspconfig')[client_name].autostart() + end + end + end + end + end end; - "-nargs=1 -complete=custom,v:lua.lsp_complete_configured_servers"; + "-nargs=? -complete=custom,v:lua.lsp_complete_configured_servers"; description = '`:LspStart` Manually launches a language server.'; }; LspStop = { |
