diff options
| author | glepnir <glephunter@gmail.com> | 2024-09-23 14:28:32 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-23 14:28:32 +0800 |
| commit | 5f9e043922969aa93f555a68ce10868ef7222867 (patch) | |
| tree | a2243de0f29229107c64725e5df8a170b733433e /lua/lspconfig/configs.lua | |
| parent | fix(c3): fix typo of pattern (#3311) (diff) | |
| download | nvim-lspconfig-5f9e043922969aa93f555a68ce10868ef7222867.tar nvim-lspconfig-5f9e043922969aa93f555a68ce10868ef7222867.tar.gz nvim-lspconfig-5f9e043922969aa93f555a68ce10868ef7222867.tar.bz2 nvim-lspconfig-5f9e043922969aa93f555a68ce10868ef7222867.tar.lz nvim-lspconfig-5f9e043922969aa93f555a68ce10868ef7222867.tar.xz nvim-lspconfig-5f9e043922969aa93f555a68ce10868ef7222867.tar.zst nvim-lspconfig-5f9e043922969aa93f555a68ce10868ef7222867.zip | |
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.
Diffstat (limited to 'lua/lspconfig/configs.lua')
| -rw-r--r-- | lua/lspconfig/configs.lua | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lua/lspconfig/configs.lua b/lua/lspconfig/configs.lua index 62f22c27..5a5fc2e5 100644 --- a/lua/lspconfig/configs.lua +++ b/lua/lspconfig/configs.lua @@ -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 }, @@ -128,12 +128,14 @@ function configs.__newindex(t, config_name, config_def) async.run(function() local root_dir - if get_root_dir then + if type(get_root_dir) == 'function' then root_dir = get_root_dir(util.path.sanitize(bufname), 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 |
