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(gh_actions_ls): Fix incorrect rootdir resolution #3573

Open
wants to merge 3 commits 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
20 changes: 15 additions & 5 deletions lua/lspconfig/configs/gh_actions_ls.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
local util = require 'lspconfig.util'

return {
default_config = {
cmd = { 'gh-actions-language-server', '--stdio' },
Expand All @@ -9,9 +7,21 @@ return {
-- files. (A nil root_dir and no single_file_support results in the LSP not
-- attaching.) For details, see #3558
root_dir = function(filename)
return filename:find('/%.(github|forgejo|gitea)/workflows/.+%.ya?ml')
and util.root_pattern('.github', '.forgejo', '.gitea')(filename)
or nil
local dirs_to_check = {
'.github/workflows',
'.forgejo/workflows',
'.gitea/workflows',
}

local dir = vim.fs.dirname(filename)
for _, subdir in ipairs(dirs_to_check) do
local match = vim.fs.find(subdir, { path = dir, upward = true })[1]
if match and vim.fn.isdirectory(match) == 1 and vim.fs.dirname(filename) == match then
return match
end
end

return nil
end,

-- Disabling "single file support" is a hack to avoid enabling this LS for
Expand Down
Loading