diff options
| author | Michael Lingelbach <m.j.lbach@gmail.com> | 2021-12-23 10:43:16 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-23 10:43:16 -0500 |
| commit | bba61ed96829c9088244ed1e83f10de1b0a01f7f (patch) | |
| tree | 8b1bf9e04082633f7a9cc3000bc0305ae489c4cf /lua/lspconfig/configs.lua | |
| parent | docs: update server_configurations.md (diff) | |
| download | nvim-lspconfig-bba61ed96829c9088244ed1e83f10de1b0a01f7f.tar nvim-lspconfig-bba61ed96829c9088244ed1e83f10de1b0a01f7f.tar.gz nvim-lspconfig-bba61ed96829c9088244ed1e83f10de1b0a01f7f.tar.bz2 nvim-lspconfig-bba61ed96829c9088244ed1e83f10de1b0a01f7f.tar.lz nvim-lspconfig-bba61ed96829c9088244ed1e83f10de1b0a01f7f.tar.xz nvim-lspconfig-bba61ed96829c9088244ed1e83f10de1b0a01f7f.tar.zst nvim-lspconfig-bba61ed96829c9088244ed1e83f10de1b0a01f7f.zip | |
fix: internally use forward delineated paths cross-platform (#1593)
* Escape paths used to autocommands
* Always normalize windows path to forward slash for internal use
Diffstat (limited to 'lua/lspconfig/configs.lua')
| -rw-r--r-- | lua/lspconfig/configs.lua | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lua/lspconfig/configs.lua b/lua/lspconfig/configs.lua index da50c5fd..3723df1f 100644 --- a/lua/lspconfig/configs.lua +++ b/lua/lspconfig/configs.lua @@ -79,19 +79,19 @@ function configs.__newindex(t, config_name, config_def) function M.launch() local root_dir if get_root_dir then - root_dir = get_root_dir(api.nvim_buf_get_name(0), api.nvim_get_current_buf()) + root_dir = get_root_dir(util.path.sanitize(api.nvim_buf_get_name(0)), api.nvim_get_current_buf()) end if root_dir then api.nvim_command( string.format( - "autocmd %s unsilent lua require'lspconfig'[%q].manager.try_add_wrapper()", - 'BufReadPost ' .. root_dir .. '/*', + "autocmd BufReadPost %s/* unsilent lua require'lspconfig'[%q].manager.try_add_wrapper()", + vim.fn.fnameescape(root_dir), config.name ) ) for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do - local buf_dir = api.nvim_buf_get_name(bufnr) + local buf_dir = util.path.sanitize(api.nvim_buf_get_name(bufnr)) if buf_dir:sub(1, root_dir:len()) == root_dir then M.manager.try_add_wrapper(bufnr) end @@ -101,7 +101,7 @@ function configs.__newindex(t, config_name, config_def) -- Effectively this is the root from lspconfig's perspective, as we use -- this to attach additional files in the same parent folder to the same server. -- We just no longer send rootDirectory or workspaceFolders during initialization. - local pseudo_root = util.path.dirname(api.nvim_buf_get_name(0)) + local pseudo_root = util.path.dirname(util.path.sanitize(api.nvim_buf_get_name(0))) M.manager.add(pseudo_root, true) else vim.notify( @@ -209,14 +209,16 @@ function configs.__newindex(t, config_name, config_def) local id local root_dir + local buf_path = util.path.sanitize(api.nvim_buf_get_name(bufnr)) + if get_root_dir then - root_dir = get_root_dir(api.nvim_buf_get_name(bufnr), bufnr) + root_dir = get_root_dir(buf_path, bufnr) end if root_dir then id = manager.add(root_dir, false) elseif config.single_file_support then - local pseudo_root = util.path.dirname(api.nvim_buf_get_name(0)) + local pseudo_root = util.path.dirname(buf_path) id = manager.add(pseudo_root, true) else vim.notify( |
