diff options
| author | Dmytro Meleshko <dmytro.meleshko@gmail.com> | 2025-06-20 15:07:25 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-20 06:07:25 -0700 |
| commit | 0112e1f77983141e1453bd37d124302f1c876c46 (patch) | |
| tree | 860eaf1a98cba84bc04706b3e327f4afb75eed71 /lsp/texlab.lua | |
| parent | fix(powershell_es): set LogLevel to "Information" #3914 (diff) | |
| download | nvim-lspconfig-0112e1f77983141e1453bd37d124302f1c876c46.tar nvim-lspconfig-0112e1f77983141e1453bd37d124302f1c876c46.tar.gz nvim-lspconfig-0112e1f77983141e1453bd37d124302f1c876c46.tar.bz2 nvim-lspconfig-0112e1f77983141e1453bd37d124302f1c876c46.tar.lz nvim-lspconfig-0112e1f77983141e1453bd37d124302f1c876c46.tar.xz nvim-lspconfig-0112e1f77983141e1453bd37d124302f1c876c46.tar.zst nvim-lspconfig-0112e1f77983141e1453bd37d124302f1c876c46.zip | |
fix: some `on_attach` callbacks may act on the wrong buffer #3916
Problem:
If a server is attached to a non-current buffer by
`vim.lsp.buf_attach_client`, then the Language Server-related
commands may be created in the current (wrong) buffer.
Solution:
Always use the `bufnr` arg provided to `on_attach`.
Diffstat (limited to 'lsp/texlab.lua')
| -rw-r--r-- | lsp/texlab.lua | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/lsp/texlab.lua b/lsp/texlab.lua index c4be0bc0..dbff0bba 100644 --- a/lsp/texlab.lua +++ b/lsp/texlab.lua @@ -192,29 +192,29 @@ return { formatterLineLength = 80, }, }, - on_attach = function() - vim.api.nvim_buf_create_user_command(0, 'LspTexlabBuild', client_with_fn(buf_build), { + on_attach = function(_, buf) + vim.api.nvim_buf_create_user_command(buf, 'LspTexlabBuild', client_with_fn(buf_build), { desc = 'Build the current buffer', }) - vim.api.nvim_buf_create_user_command(0, 'LspTexlabForward', client_with_fn(buf_search), { + vim.api.nvim_buf_create_user_command(buf, 'LspTexlabForward', client_with_fn(buf_search), { desc = 'Forward search from current position', }) - vim.api.nvim_buf_create_user_command(0, 'LspTexlabCancelBuild', client_with_fn(buf_cancel_build), { + vim.api.nvim_buf_create_user_command(buf, 'LspTexlabCancelBuild', client_with_fn(buf_cancel_build), { desc = 'Cancel the current build', }) - vim.api.nvim_buf_create_user_command(0, 'LspTexlabDependencyGraph', client_with_fn(dependency_graph), { + vim.api.nvim_buf_create_user_command(buf, 'LspTexlabDependencyGraph', client_with_fn(dependency_graph), { desc = 'Show the dependency graph', }) - vim.api.nvim_buf_create_user_command(0, 'LspTexlabCleanArtifacts', client_with_fn(command_factory('Artifacts')), { + vim.api.nvim_buf_create_user_command(buf, 'LspTexlabCleanArtifacts', client_with_fn(command_factory('Artifacts')), { desc = 'Clean the artifacts', }) - vim.api.nvim_buf_create_user_command(0, 'LspTexlabCleanAuxiliary', client_with_fn(command_factory('Auxiliary')), { + vim.api.nvim_buf_create_user_command(buf, 'LspTexlabCleanAuxiliary', client_with_fn(command_factory('Auxiliary')), { desc = 'Clean the auxiliary files', }) - vim.api.nvim_buf_create_user_command(0, 'LspTexlabFindEnvironments', client_with_fn(buf_find_envs), { + vim.api.nvim_buf_create_user_command(buf, 'LspTexlabFindEnvironments', client_with_fn(buf_find_envs), { desc = 'Find the environments at current position', }) - vim.api.nvim_buf_create_user_command(0, 'LspTexlabChangeEnvironment', client_with_fn(buf_change_env), { + vim.api.nvim_buf_create_user_command(buf, 'LspTexlabChangeEnvironment', client_with_fn(buf_change_env), { desc = 'Change the environment at current position', }) end, |
