Skip to content

Commit

Permalink
fix(gh_actions_ls): fix incorrect rootdir resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
Crashdummyy authored Jan 23, 2025
1 parent 513f4f0 commit 59760a0
Showing 1 changed file with 15 additions and 5 deletions.
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

0 comments on commit 59760a0

Please sign in to comment.