aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorTomasz N <przepompownia@users.noreply.github.com>2022-05-22 17:30:53 +0200
committerGitHub <noreply@github.com>2022-05-22 08:30:53 -0700
commitb86a37caf7a4e53e62ba883aef5889b590260de9 (patch)
treec2f6e610b551b2fe597ee9773928d74cfba47e9e /lua
parentfeat: add :LspLog command #1917 (diff)
downloadnvim-lspconfig-b86a37caf7a4e53e62ba883aef5889b590260de9.tar
nvim-lspconfig-b86a37caf7a4e53e62ba883aef5889b590260de9.tar.gz
nvim-lspconfig-b86a37caf7a4e53e62ba883aef5889b590260de9.tar.bz2
nvim-lspconfig-b86a37caf7a4e53e62ba883aef5889b590260de9.tar.lz
nvim-lspconfig-b86a37caf7a4e53e62ba883aef5889b590260de9.tar.xz
nvim-lspconfig-b86a37caf7a4e53e62ba883aef5889b590260de9.tar.zst
nvim-lspconfig-b86a37caf7a4e53e62ba883aef5889b590260de9.zip
fix: buffer may be invalid during on_attach #1822
on_attach is a nontrivial callback so it makes sense to check the bufnr.
Diffstat (limited to 'lua')
-rw-r--r--lua/lspconfig/configs.lua18
1 files changed, 10 insertions, 8 deletions
diff --git a/lua/lspconfig/configs.lua b/lua/lspconfig/configs.lua
index 49bac987..ab86055d 100644
--- a/lua/lspconfig/configs.lua
+++ b/lua/lspconfig/configs.lua
@@ -180,15 +180,17 @@ function configs.__newindex(t, config_name, config_def)
if bufnr == api.nvim_get_current_buf() then
M._setup_buffer(client.id, bufnr)
else
- api.nvim_command(
- string.format(
- "autocmd BufEnter <buffer=%d> ++once lua require'lspconfig'[%q]._setup_buffer(%d,%d)",
- bufnr,
- config_name,
- client.id,
- bufnr
+ if vim.api.nvim_buf_is_valid(bufnr) then
+ api.nvim_command(
+ string.format(
+ "autocmd BufEnter <buffer=%d> ++once lua require'lspconfig'[%q]._setup_buffer(%d,%d)",
+ bufnr,
+ config_name,
+ client.id,
+ bufnr
+ )
)
- )
+ end
end
end)