aboutsummaryrefslogtreecommitdiffstats
path: root/lua/lspconfig
diff options
context:
space:
mode:
Diffstat (limited to 'lua/lspconfig')
-rw-r--r--lua/lspconfig/configs.lua24
1 files changed, 20 insertions, 4 deletions
diff --git a/lua/lspconfig/configs.lua b/lua/lspconfig/configs.lua
index 3723df1f..025d94bd 100644
--- a/lua/lspconfig/configs.lua
+++ b/lua/lspconfig/configs.lua
@@ -79,7 +79,11 @@ function configs.__newindex(t, config_name, config_def)
function M.launch()
local root_dir
if get_root_dir then
- root_dir = get_root_dir(util.path.sanitize(api.nvim_buf_get_name(0)), api.nvim_get_current_buf())
+ local buf_name = api.nvim_buf_get_name(0)
+ if buf_name == '' or not buf_name then
+ return
+ end
+ root_dir = get_root_dir(util.path.sanitize(buf_name), api.nvim_get_current_buf())
end
if root_dir then
@@ -91,7 +95,11 @@ function configs.__newindex(t, config_name, config_def)
)
)
for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
- local buf_dir = util.path.sanitize(api.nvim_buf_get_name(bufnr))
+ local buf_name = api.nvim_buf_get_name(bufnr)
+ if buf_name == '' or not buf_name then
+ return
+ end
+ local buf_dir = util.path.sanitize(buf_name)
if buf_dir:sub(1, root_dir:len()) == root_dir then
M.manager.try_add_wrapper(bufnr)
end
@@ -101,7 +109,11 @@ 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(util.path.sanitize(api.nvim_buf_get_name(0)))
+ local buf_name = api.nvim_buf_get_name(0)
+ if buf_name == '' or not buf_name then
+ return
+ end
+ local pseudo_root = util.path.dirname(util.path.sanitize(buf_name))
M.manager.add(pseudo_root, true)
else
vim.notify(
@@ -209,7 +221,11 @@ 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))
+ local buf_name = api.nvim_buf_get_name(bufnr)
+ if buf_name == '' or not buf_name then
+ return
+ end
+ local buf_path = util.path.sanitize(buf_name)
if get_root_dir then
root_dir = get_root_dir(buf_path, bufnr)