From 71be9bbe9ed2d51d9114f92a5dcb7b5f1dcb0830 Mon Sep 17 00:00:00 2001 From: Chris Grieser <73286100+chrisgrieser@users.noreply.github.com> Date: Wed, 21 May 2025 15:37:54 +0200 Subject: 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: https://github.com/neovim/nvim-lspconfig/pull/3713#issuecomment-2857394868 --- lsp/gh_actions_ls.lua | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lsp/gh_actions_ls.lua b/lsp/gh_actions_ls.lua index 9fe42193..62e3d9e7 100644 --- a/lsp/gh_actions_ls.lua +++ b/lsp/gh_actions_ls.lua @@ -15,14 +15,21 @@ --- ``` return { cmd = { 'gh-actions-language-server', '--stdio' }, - -- the `root_markers` with `workspace_required` prevent attaching to every yaml file filetypes = { 'yaml' }, - root_markers = { - '.github/workflows', - '.forgejo/workflows', - '.gitea/workflows', - }, - workspace_required = true, + + -- `root_dir` ensures that the LSP does not attach to all yaml files + root_dir = function(bufnr, on_dir) + local parent = vim.fs.dirname(vim.api.nvim_buf_get_name(bufnr)) + if + vim.endswith(parent, '/.github/workflows') + or vim.endswith(parent, '/.forgejo/workflows') + or vim.endswith(parent, '/.gitea/workflows') + then + on_dir(parent) + end + end, + + init_options = {}, -- needs to be present https://github.com/neovim/nvim-lspconfig/pull/3713#issuecomment-2857394868 capabilities = { workspace = { didChangeWorkspaceFolders = { -- cgit v1.2.3-70-g09d2