diff options
| author | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2024-11-26 22:42:28 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-26 13:42:28 -0800 |
| commit | 830ec3893eeb2b21d182864b56931ca6d23d3e29 (patch) | |
| tree | bddf3b5be5c9886642dcaa8cd78569e5eb4cc28f /lua | |
| parent | ci: check for deprecated util functions #3462 (diff) | |
| download | nvim-lspconfig-830ec3893eeb2b21d182864b56931ca6d23d3e29.tar nvim-lspconfig-830ec3893eeb2b21d182864b56931ca6d23d3e29.tar.gz nvim-lspconfig-830ec3893eeb2b21d182864b56931ca6d23d3e29.tar.bz2 nvim-lspconfig-830ec3893eeb2b21d182864b56931ca6d23d3e29.tar.lz nvim-lspconfig-830ec3893eeb2b21d182864b56931ca6d23d3e29.tar.xz nvim-lspconfig-830ec3893eeb2b21d182864b56931ca6d23d3e29.tar.zst nvim-lspconfig-830ec3893eeb2b21d182864b56931ca6d23d3e29.zip | |
refactor: remove internal implementation of `util.path.sanitize` #3464
Return value from `vim.fs.normalize` instead.
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/lspconfig/configs.lua | 6 | ||||
| -rw-r--r-- | lua/lspconfig/configs/lean3ls.lua | 2 | ||||
| -rw-r--r-- | lua/lspconfig/configs/leanls.lua | 2 | ||||
| -rw-r--r-- | lua/lspconfig/configs/relay_lsp.lua | 2 | ||||
| -rw-r--r-- | lua/lspconfig/configs/rust_analyzer.lua | 4 | ||||
| -rw-r--r-- | lua/lspconfig/manager.lua | 4 | ||||
| -rw-r--r-- | lua/lspconfig/util.lua | 9 |
7 files changed, 12 insertions, 17 deletions
diff --git a/lua/lspconfig/configs.lua b/lua/lspconfig/configs.lua index 4a13c1f6..0d23dffc 100644 --- a/lua/lspconfig/configs.lua +++ b/lua/lspconfig/configs.lua @@ -133,7 +133,7 @@ function configs.__newindex(t, config_name, config_def) async.run(function() local root_dir if type(get_root_dir) == 'function' then - root_dir = get_root_dir(util.path.sanitize(bufname), bufnr) + root_dir = get_root_dir(vim.fs.normalize(bufname), bufnr) async.reenter() if not api.nvim_buf_is_valid(bufnr) then return @@ -162,7 +162,7 @@ function configs.__newindex(t, config_name, config_def) for _, buf in ipairs(api.nvim_list_bufs()) do local buf_name = api.nvim_buf_get_name(buf) if util.bufname_valid(buf_name) then - local buf_dir = util.path.sanitize(buf_name) + local buf_dir = vim.fs.normalize(buf_name) if buf_dir:sub(1, root_dir:len()) == root_dir then M.manager:try_add_wrapper(buf, root_dir) end @@ -176,7 +176,7 @@ function configs.__newindex(t, config_name, config_def) if not api.nvim_buf_is_valid(bufnr) or (#bufname ~= 0 and not util.bufname_valid(bufname)) then return end - local pseudo_root = #bufname == 0 and pwd or vim.fs.dirname(util.path.sanitize(bufname)) + local pseudo_root = #bufname == 0 and pwd or vim.fs.dirname(vim.fs.normalize(bufname)) M.manager:add(pseudo_root, true, bufnr, config.silent) end end) diff --git a/lua/lspconfig/configs/lean3ls.lua b/lua/lspconfig/configs/lean3ls.lua index 01479898..645fbbbe 100644 --- a/lua/lspconfig/configs/lean3ls.lua +++ b/lua/lspconfig/configs/lean3ls.lua @@ -6,7 +6,7 @@ return { filetypes = { 'lean3' }, offset_encoding = 'utf-32', root_dir = function(fname) - fname = util.path.sanitize(fname) + fname = vim.fs.normalize(fname) -- check if inside elan stdlib local stdlib_dir do diff --git a/lua/lspconfig/configs/leanls.lua b/lua/lspconfig/configs/leanls.lua index cde899d9..c29b6417 100644 --- a/lua/lspconfig/configs/leanls.lua +++ b/lua/lspconfig/configs/leanls.lua @@ -6,7 +6,7 @@ return { filetypes = { 'lean' }, root_dir = function(fname) -- check if inside elan stdlib - fname = util.path.sanitize(fname) + fname = vim.fs.normalize(fname) local stdlib_dir do local _, endpos = fname:find '/src/lean' diff --git a/lua/lspconfig/configs/relay_lsp.lua b/lua/lspconfig/configs/relay_lsp.lua index 2c14efb6..9f2b3776 100644 --- a/lua/lspconfig/configs/relay_lsp.lua +++ b/lua/lspconfig/configs/relay_lsp.lua @@ -34,7 +34,7 @@ return { end if config.path_to_config then - config.path_to_config = util.path.sanitize(config.path_to_config) + config.path_to_config = vim.fs.normalize(config.path_to_config) local path_to_config = util.path.join(root_dir, config.path_to_config) if util.path.exists(path_to_config) then vim.list_extend(config.cmd, { config.path_to_config }) diff --git a/lua/lspconfig/configs/rust_analyzer.lua b/lua/lspconfig/configs/rust_analyzer.lua index a8f11208..8bcde6c9 100644 --- a/lua/lspconfig/configs/rust_analyzer.lua +++ b/lua/lspconfig/configs/rust_analyzer.lua @@ -16,7 +16,7 @@ local function reload_workspace(bufnr) end local function is_library(fname) - local user_home = util.path.sanitize(vim.env.HOME) + local user_home = vim.fs.normalize(vim.env.HOME) local cargo_home = os.getenv 'CARGO_HOME' or util.path.join(user_home, '.cargo') local registry = util.path.join(cargo_home, 'registry', 'src') local git_registry = util.path.join(cargo_home, 'git', 'checkouts') @@ -62,7 +62,7 @@ return { if result and result[1] then result = vim.json.decode(table.concat(result, '')) if result['workspace_root'] then - cargo_workspace_root = util.path.sanitize(result['workspace_root']) + cargo_workspace_root = vim.fs.normalize(result['workspace_root']) end end end diff --git a/lua/lspconfig/manager.lua b/lua/lspconfig/manager.lua index 45a9e425..16bf17c0 100644 --- a/lua/lspconfig/manager.lua +++ b/lua/lspconfig/manager.lua @@ -157,7 +157,7 @@ end ---@param bufnr integer ---@param silent boolean function M:add(root_dir, single_file, bufnr, silent) - root_dir = util.path.sanitize(root_dir) + root_dir = vim.fs.normalize(root_dir) local new_config = self.make_config(root_dir) self:_start_client(bufnr, new_config, root_dir, single_file, silent) end @@ -199,7 +199,7 @@ function M:try_add(bufnr, project_root, silent) return end - local buf_path = util.path.sanitize(bufname) + local buf_path = vim.fs.normalize(bufname) local get_root_dir = self.config.root_dir diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua index 041f56e6..f89ceb6f 100644 --- a/lua/lspconfig/util.lua +++ b/lua/lspconfig/util.lua @@ -102,14 +102,9 @@ M.path = (function() return path:gsub('([%[%]%?%*])', '\\%1') end - --- @param path string - --- @return string + --- @deprecated use `vim.fs.normalize` instead local function sanitize(path) - if iswin then - path = path:sub(1, 1):upper() .. path:sub(2) - path = path:gsub('\\', '/') - end - return path + return vim.fs.normalize(path) end --- @param filename string |
