Skip to content

Commit 71be9bb

Browse files
authored
fix(gh_actions_ls): use root_dir, add init_options #3857
1. Replace `root_markers` and `workspace_required = true` with a `root_dir` function that checks the file is located in the correct location. This prevents some edge cases where the LSP would still attach to non-workflow files. This also makes unnecessary to use a `yaml.github` filetype, [as the readme of the lsp describes](https://github.com/lttb/gh-actions-language-server?tab=readme-ov-file#add-yamlgithub-filetype-detection). 2. add an empty `init_options` table, since such a table is apparently needed by the LSP: #3713 (comment)
1 parent 4dbd011 commit 71be9bb

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

lsp/gh_actions_ls.lua

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,21 @@
1515
--- ```
1616
return {
1717
cmd = { 'gh-actions-language-server', '--stdio' },
18-
-- the `root_markers` with `workspace_required` prevent attaching to every yaml file
1918
filetypes = { 'yaml' },
20-
root_markers = {
21-
'.github/workflows',
22-
'.forgejo/workflows',
23-
'.gitea/workflows',
24-
},
25-
workspace_required = true,
19+
20+
-- `root_dir` ensures that the LSP does not attach to all yaml files
21+
root_dir = function(bufnr, on_dir)
22+
local parent = vim.fs.dirname(vim.api.nvim_buf_get_name(bufnr))
23+
if
24+
vim.endswith(parent, '/.github/workflows')
25+
or vim.endswith(parent, '/.forgejo/workflows')
26+
or vim.endswith(parent, '/.gitea/workflows')
27+
then
28+
on_dir(parent)
29+
end
30+
end,
31+
32+
init_options = {}, -- needs to be present https://github.com/neovim/nvim-lspconfig/pull/3713#issuecomment-2857394868
2633
capabilities = {
2734
workspace = {
2835
didChangeWorkspaceFolders = {

0 commit comments

Comments
 (0)