diff options
| author | William Boman <william@redwill.se> | 2022-07-05 12:47:22 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-05 03:47:22 -0700 |
| commit | 4983febe0629e9a0f3890e539a62663e1c1189d0 (patch) | |
| tree | 29ca7b52fadde3d708c7f6660591d6642bf40f45 | |
| parent | docs: update server_configurations.md (diff) | |
| download | nvim-lspconfig-4983febe0629e9a0f3890e539a62663e1c1189d0.tar nvim-lspconfig-4983febe0629e9a0f3890e539a62663e1c1189d0.tar.gz nvim-lspconfig-4983febe0629e9a0f3890e539a62663e1c1189d0.tar.bz2 nvim-lspconfig-4983febe0629e9a0f3890e539a62663e1c1189d0.tar.lz nvim-lspconfig-4983febe0629e9a0f3890e539a62663e1c1189d0.tar.xz nvim-lspconfig-4983febe0629e9a0f3890e539a62663e1c1189d0.tar.zst nvim-lspconfig-4983febe0629e9a0f3890e539a62663e1c1189d0.zip | |
fix(lspinfo): may use wrong buffer #1983
The `vim.fn.expand '%:p:h'` used to acquire the directory of the opened buffer would actually be executed in the context of the floating `:LspInfo` - causing it to return the current working directory instead of the actual buffer directory (the one that was active when opening the `:LspInfo` window).
| -rw-r--r-- | lua/lspconfig/ui/lspinfo.lua | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lua/lspconfig/ui/lspinfo.lua b/lua/lspconfig/ui/lspinfo.lua index 7fc40dec..2fcab94b 100644 --- a/lua/lspconfig/ui/lspinfo.lua +++ b/lua/lspconfig/ui/lspinfo.lua @@ -36,7 +36,7 @@ local function remove_newlines(cmd) return cmd end -local function make_config_info(config) +local function make_config_info(config, bufnr) local config_info = {} config_info.name = config.name config_info.helptags = {} @@ -52,7 +52,9 @@ local function make_config_info(config) config_info.cmd_is_executable = 'NA' end - local buffer_dir = vim.fn.expand '%:p:h' + local buffer_dir = vim.api.nvim_buf_call(bufnr, function() + return vim.fn.expand '%:p:h' + end) local root_dir = config.get_root_dir(buffer_dir) if root_dir then config_info.root_dir = root_dir @@ -148,6 +150,7 @@ return function() local buf_clients = vim.lsp.buf_get_clients() local clients = vim.lsp.get_active_clients() local buffer_filetype = vim.bo.filetype + local original_bufnr = vim.api.nvim_get_current_buf() local win_info = windows.percentage_range_window(0.8, 0.7) local bufnr, win_id = win_info.bufnr, win_info.win_id @@ -214,7 +217,7 @@ return function() if not vim.tbl_isempty(other_matching_configs) then vim.list_extend(buf_lines, other_matching_configs_header) for _, config in pairs(other_matching_configs) do - vim.list_extend(buf_lines, make_config_info(config)) + vim.list_extend(buf_lines, make_config_info(config, original_bufnr)) end end |
