diff options
| author | Afiq Nazrie <afnazrie@gmail.com> | 2024-12-15 17:31:32 +0700 |
|---|---|---|
| committer | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2025-02-18 16:59:33 +0100 |
| commit | 1110787f1b464888c59a044c48c5119d14078044 (patch) | |
| tree | b909389f9048550a735079dd90ee93c66d4c2d6a /lua | |
| parent | fix(eslint): openDoc breaks on some URLs #3615 (diff) | |
| download | nvim-lspconfig-1110787f1b464888c59a044c48c5119d14078044.tar nvim-lspconfig-1110787f1b464888c59a044c48c5119d14078044.tar.gz nvim-lspconfig-1110787f1b464888c59a044c48c5119d14078044.tar.bz2 nvim-lspconfig-1110787f1b464888c59a044c48c5119d14078044.tar.lz nvim-lspconfig-1110787f1b464888c59a044c48c5119d14078044.tar.xz nvim-lspconfig-1110787f1b464888c59a044c48c5119d14078044.tar.zst nvim-lspconfig-1110787f1b464888c59a044c48c5119d14078044.zip | |
fix(lua_ls): return longest root path
This commit doesn't address the case when root path == vim.env.HOME as
the case lack return when it's true (#2110)
Fix #3508
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/lspconfig/configs/lua_ls.lua | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/lua/lspconfig/configs/lua_ls.lua b/lua/lspconfig/configs/lua_ls.lua index a545b34b..4253337d 100644 --- a/lua/lspconfig/configs/lua_ls.lua +++ b/lua/lspconfig/configs/lua_ls.lua @@ -15,16 +15,15 @@ return { cmd = { 'lua-language-server' }, filetypes = { 'lua' }, root_dir = function(fname) - local root = util.root_pattern(unpack(root_files))(fname) - if root and root ~= vim.env.HOME then - return root - end + local root_file = util.root_pattern(unpack(root_files))(fname) or '' local root_lua = util.root_pattern 'lua/'(fname) or '' local root_git = vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1]) or '' - if root_lua == '' and root_git == '' then + if root_file == '' and root_lua == '' and root_git == '' then return end - return #root_lua >= #root_git and root_lua or root_git + local root = #root_file >= #root_lua and root_file or root_lua + root = #root >= #root_git and root or root_git + return root end, single_file_support = true, log_level = vim.lsp.protocol.MessageType.Warning, |
