diff options
| author | William Boman <william@redwill.se> | 2022-12-18 07:47:53 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-18 14:47:53 +0800 |
| commit | 973aa14d0992df82ff82f714d978a3eb8d676600 (patch) | |
| tree | 84d52de363f45c66c981219fc50aad6035c393d3 /lua | |
| parent | feat: add rockspec (diff) | |
| download | nvim-lspconfig-973aa14d0992df82ff82f714d978a3eb8d676600.tar nvim-lspconfig-973aa14d0992df82ff82f714d978a3eb8d676600.tar.gz nvim-lspconfig-973aa14d0992df82ff82f714d978a3eb8d676600.tar.bz2 nvim-lspconfig-973aa14d0992df82ff82f714d978a3eb8d676600.tar.lz nvim-lspconfig-973aa14d0992df82ff82f714d978a3eb8d676600.tar.xz nvim-lspconfig-973aa14d0992df82ff82f714d978a3eb8d676600.tar.zst nvim-lspconfig-973aa14d0992df82ff82f714d978a3eb8d676600.zip | |
fix(lspinfo): safely expand filenames that don't exist on fs (#2320)
The filename of a buffer may point to a node on the file system that
does not yet exist. `uv.fs_realpath()` will return nil in these cases,
causing a nil exception later on. The builtin `resolve()` function will
return the provided filename as-is if it does not yet exist.
Alternatively we could stick to libuv APIs.
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/lspconfig/ui/lspinfo.lua | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lua/lspconfig/ui/lspinfo.lua b/lua/lspconfig/ui/lspinfo.lua index 40481221..942d65bc 100644 --- a/lua/lspconfig/ui/lspinfo.lua +++ b/lua/lspconfig/ui/lspinfo.lua @@ -103,6 +103,8 @@ local function make_config_info(config, bufnr) return lines end +---@param client table +---@param fname string local function make_client_info(client, fname) local client_info = {} @@ -110,7 +112,7 @@ local function make_client_info(client, fname) local workspace_folders = fn.has 'nvim-0.9' == 1 and client.workspace_folders or client.workspaceFolders local uv = vim.loop local is_windows = uv.os_uname().version:match 'Windows' - fname = uv.fs_realpath(fname) + fname = vim.fn.fnamemodify(vim.fn.resolve(fname), ':p') local sep = is_windows and '\\' or '/' local fname_parts = vim.split(fname, sep, { trimempty = true }) if workspace_folders then |
