Skip to content

Commit

Permalink
fix: root_dir support string value directly
Browse files Browse the repository at this point in the history
root_dir in `vim.lsp.ClientConfig` can be a string type and
in our annoation also mentioned `string|function` type. but
actually root_dir does not support string type. add a type
check of root_dir and then we can use `vim.fs.root` directly.
  • Loading branch information
glepnir committed Sep 22, 2024
1 parent e30efa0 commit ed2208a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lua/lspconfig/configs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function configs.__newindex(t, config_name, config_def)
{ 'f', 't' },
true,
},
root_dir = { user_config.root_dir, 'f', true },
root_dir = { user_config.root_dir, { 's', 'f' }, true },
filetypes = { user_config.filetype, 't', true },
on_new_config = { user_config.on_new_config, 'f', true },
on_attach = { user_config.on_attach, 'f', true },
Expand Down
5 changes: 2 additions & 3 deletions lua/lspconfig/manager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,8 @@ function M:try_add(bufnr, project_root)
local pwd = assert(uv.cwd())

async.run(function()
local root_dir
if get_root_dir then
root_dir = get_root_dir(buf_path, bufnr)
local root_dir = (type(get_root_dir) == 'function') and get_root_dir(buf_path, bufnr) or get_root_dir
if type(get_root_dir) == 'function' then
async.reenter()
if not api.nvim_buf_is_valid(bufnr) then
return
Expand Down

0 comments on commit ed2208a

Please sign in to comment.