aboutsummaryrefslogtreecommitdiffstats
path: root/lua/lspconfig/configs.lua
diff options
context:
space:
mode:
authorRishikesh Vaishnav <rishhvaishnav@gmail.com>2022-06-01 07:43:01 -0700
committerGitHub <noreply@github.com>2022-06-01 07:43:01 -0700
commitc5dae15c0c94703a0565e8ba35a9f5cb96ca7b8a (patch)
treedc6372ba298bec68bcca4af8dc96002cad234399 /lua/lspconfig/configs.lua
parentdocs: update server_configurations.md (diff)
downloadnvim-lspconfig-c5dae15c0c94703a0565e8ba35a9f5cb96ca7b8a.tar
nvim-lspconfig-c5dae15c0c94703a0565e8ba35a9f5cb96ca7b8a.tar.gz
nvim-lspconfig-c5dae15c0c94703a0565e8ba35a9f5cb96ca7b8a.tar.bz2
nvim-lspconfig-c5dae15c0c94703a0565e8ba35a9f5cb96ca7b8a.tar.lz
nvim-lspconfig-c5dae15c0c94703a0565e8ba35a9f5cb96ca7b8a.tar.xz
nvim-lspconfig-c5dae15c0c94703a0565e8ba35a9f5cb96ca7b8a.tar.zst
nvim-lspconfig-c5dae15c0c94703a0565e8ba35a9f5cb96ca7b8a.zip
fix: no-argument :LspStop, :LspRestart with standalone files #1785
The no-argument versions of `:LspStop` and `:LspRestart` currently only apply to buffers that have a valid root directory. It seems that these commands should stop/restart all clients, including those associated with standalone files. Closes #1784
Diffstat (limited to 'lua/lspconfig/configs.lua')
-rw-r--r--lua/lspconfig/configs.lua9
1 files changed, 8 insertions, 1 deletions
diff --git a/lua/lspconfig/configs.lua b/lua/lspconfig/configs.lua
index ab86055d..01275a13 100644
--- a/lua/lspconfig/configs.lua
+++ b/lua/lspconfig/configs.lua
@@ -88,6 +88,7 @@ function configs.__newindex(t, config_name, config_def)
end
if root_dir then
+ -- Lazy-launching: attach when a buffer in this directory is opened.
api.nvim_command(
string.format(
"autocmd BufReadPost %s/* unsilent lua require'lspconfig'[%q].manager.try_add_wrapper()",
@@ -95,6 +96,7 @@ function configs.__newindex(t, config_name, config_def)
config.name
)
)
+ -- Attach for all existing buffers in this directory.
for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
local bufname = api.nvim_buf_get_name(bufnr)
if util.bufname_valid(bufname) then
@@ -157,7 +159,7 @@ function configs.__newindex(t, config_name, config_def)
client.offset_encoding = result.offsetEncoding
end
- -- Send `settings to server via workspace/didChangeConfiguration
+ -- Send `settings` to server via workspace/didChangeConfiguration
function client.workspace_did_change_configuration(settings)
if not settings then
return
@@ -208,6 +210,8 @@ function configs.__newindex(t, config_name, config_def)
return make_config(root_dir)
end)
+ -- Try to attach the buffer `bufnr` to a client using this config, creating
+ -- a new client if one doesn't already exist for `bufnr`.
function manager.try_add(bufnr)
bufnr = bufnr or api.nvim_get_current_buf()
@@ -240,6 +244,8 @@ function configs.__newindex(t, config_name, config_def)
end
end
+ -- Check that the buffer `bufnr` has a valid filetype according to
+ -- `config.filetypes`, then do `manager.try_add(bufnr)`.
function manager.try_add_wrapper(bufnr)
bufnr = bufnr or api.nvim_get_current_buf()
local buf_filetype = vim.api.nvim_buf_get_option(bufnr, 'filetype')
@@ -250,6 +256,7 @@ function configs.__newindex(t, config_name, config_def)
return
end
end
+ -- `config.filetypes = nil` means all filetypes are valid.
else
manager.try_add(bufnr)
end