From 5f9e043922969aa93f555a68ce10868ef7222867 Mon Sep 17 00:00:00 2001 From: glepnir Date: Mon, 23 Sep 2024 14:28:32 +0800 Subject: fix: root_dir support string value directly (#3313) 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. --- lua/lspconfig/manager.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lua/lspconfig/manager.lua') diff --git a/lua/lspconfig/manager.lua b/lua/lspconfig/manager.lua index 9b2c7d02..26fdc7de 100644 --- a/lua/lspconfig/manager.lua +++ b/lua/lspconfig/manager.lua @@ -270,12 +270,14 @@ function M:try_add(bufnr, project_root) async.run(function() local root_dir - if get_root_dir then + if type(get_root_dir) == 'function' then root_dir = get_root_dir(buf_path, bufnr) async.reenter() if not api.nvim_buf_is_valid(bufnr) then return end + elseif type(get_root_dir) == 'string' then + root_dir = get_root_dir end if root_dir then -- cgit v1.2.3-70-g09d2