Skip to content

feat(gh_actions_ls): add vim.lsp.config support #3713

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

Merged
merged 1 commit into from
Apr 13, 2025

Conversation

chrisgrieser
Copy link
Contributor

@chrisgrieser chrisgrieser commented Apr 13, 2025

gh_actions_ls is missing in the lsp folder, likely due to it using a workaround with single file support to prevent it from attaching to every yaml file, even though it should only attach to certain yaml files, without defining an extra yaml.github filetype (see #3558).

Using .github/workflows and co as root_markers however prevents this issue, allowing us to use the LSP like a regular LSP without it attaching to unrelated yaml files. Thus, there is no problem anymore using git_actions_ls with vim.lsp.config.

cc @disrupted

@chrisgrieser chrisgrieser requested a review from glepnir as a code owner April 13, 2025 11:48
@justinmk
Copy link
Member

Nice, thanks! So we can cross this from #3705

@justinmk justinmk mentioned this pull request Apr 13, 2025
31 tasks
@justinmk justinmk merged commit d872062 into neovim:master Apr 13, 2025
11 checks passed
@chrisgrieser chrisgrieser deleted the dev branch April 13, 2025 12:29
@gstokkink
Copy link

gstokkink commented Apr 13, 2025

Just a headsup, this LSP config did not work for me until I also added the following to the config:

          init_options = {
            sessionToken = <whatever>
          },

Maybe that needs to be documented?

Also, diagnostic error messages don't show up, but maybe there's something broken in my setup, though this only occurs for this particular LSP as far as I can see.

@chrisgrieser
Copy link
Contributor Author

chrisgrieser commented Apr 13, 2025

@gstokkink That's weird, when I tested it earlier, it seemed to work. But I can confirm I now also get the error, and diagnostics not showing up anymore. I am not sure what causes this behavior though, vim.lsp.config and lspconfig[server].setup should be mostly equivalent?

@justinmk
Copy link
Member

vim.lsp.config and lspconfig[server].setup should be mostly equivalent?

yes. and I don't see how init_options could be related to their differences anyway.

does the old config still work? maybe something changes in the LS.

@gstokkink
Copy link

Weird thing is that sometimes the diagnostics do show up, but I haven't yet figured out what causes this erratic behaviour. Maybe some caching issue?

@justinmk
Copy link
Member

Reminds me of neovim/neovim#32247

Maybe neovim/neovim#33391 (comment) provides a hint that could be used here?

@gstokkink
Copy link

Alright, fixed it. I had to set 'event' to VeryLazy instead of LspAttach for the diagnostic plugin I use: https://github.com/rachartier/tiny-inline-diagnostic.nvim. Point about the sessionToken still stands, however.

@justinmk
Copy link
Member

A small update to the docstring would be welcome

@chrisgrieser
Copy link
Contributor Author

Aside from the session-token issue, the LS still attaches to some yaml files it's not supposed to attach. I am very sorry, I assume I messed up my testing of the change by somehow still running lspconfig[server].setup instead of vim.lsp.config.

@gstokkink
Copy link

Yeah, I noticed it attaching to other YAML files as well. Not sure how this can happen, are the root markers not being evaluated correctly?

@justinmk
Copy link
Member

Look at the old config, and figure out how to make it work with the new one.

@chrisgrieser
Copy link
Contributor Author

chrisgrieser commented Apr 14, 2025

@gstokkink

Yeah that one is due to the vim.lsp.config not supporting "disabling" single file mode. nvim 0.11.1 (or nightly riht now) will support workspace_required = true, which I just added via PR.

@gstokkink
Copy link

@chrisgrieser thanks! I've resorted to using the yaml.github workaround in the meantime 🙂

justinmk pushed a commit that referenced this pull request Apr 14, 2025
see #3713 (comment)
(Note that `workspace_required` requires nightly or the upcoming nvim 0.11.1)
@jhoogstraat
Copy link

jhoogstraat commented May 7, 2025

The issue is not so much the sessionToken, but init_options not being present:
https://github.com/actions/languageservices/blob/e2ec264801c7166e011b35424de4dc0a2aa33811/languageserver/src/connection.ts#L54

Here they access options.sessionToken, but options is nil by default.

@chrisgrieser
Copy link
Contributor Author

@gstokkink @jhoogstraat
I made a PR which should fix both issues, if you want to have a look: #3857

justinmk pushed a commit that referenced this pull request May 21, 2025
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants