Skip to content

Commit

Permalink
refactor(gh_actions_ls): Use vim.fs.dirname
Browse files Browse the repository at this point in the history
  • Loading branch information
Crashdummyy committed Jan 22, 2025
1 parent 0f7f777 commit e2c4b44
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions lua/lspconfig/configs/gh_actions_ls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@ 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)
local patterns = {
{ pattern = '/%.github/workflows/.+%.ya?ml', root = '.github' },
{ pattern = '/%.forgejo/workflows/.+%.ya?ml', root = '.forgejo' },
{ pattern = '/%.gitea/workflows/.+%.ya?ml', root = '.gitea' },
local dirs_to_check = {
'.github/workflows',
'.forgejo/workflows',
'.gitea/workflows',
}

for _, entry in ipairs(patterns) do
if filename:find(entry.pattern) then
local match = vim.fs.find(entry.root, { path = filename, upward = true })[1]
if match then
return match
end
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

Expand Down

0 comments on commit e2c4b44

Please sign in to comment.