Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lua_ls): return longest root path #3515

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions lua/lspconfig/configs/lua_ls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading