aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorChris Grieser <73286100+chrisgrieser@users.noreply.github.com>2025-01-13 15:22:28 +0100
committerGitHub <noreply@github.com>2025-01-13 06:22:28 -0800
commit0c24b48da1b70bbf06075c51fa0e1c87d1337c11 (patch)
tree62825b8c4e455c56895ab44882a42d1a0518928b /lua
parentdocs: update configs.md (diff)
downloadnvim-lspconfig-0c24b48da1b70bbf06075c51fa0e1c87d1337c11.tar
nvim-lspconfig-0c24b48da1b70bbf06075c51fa0e1c87d1337c11.tar.gz
nvim-lspconfig-0c24b48da1b70bbf06075c51fa0e1c87d1337c11.tar.bz2
nvim-lspconfig-0c24b48da1b70bbf06075c51fa0e1c87d1337c11.tar.lz
nvim-lspconfig-0c24b48da1b70bbf06075c51fa0e1c87d1337c11.tar.xz
nvim-lspconfig-0c24b48da1b70bbf06075c51fa0e1c87d1337c11.tar.zst
nvim-lspconfig-0c24b48da1b70bbf06075c51fa0e1c87d1337c11.zip
feat(gh_actions_ls): use `root_dir` to decide enablement #3558
This saves the user the extra setup work of copypasting the `vim.filetype.add` snippet, making this language server work out of the box.
Diffstat (limited to 'lua')
-rw-r--r--lua/lspconfig/configs/gh_actions_ls.lua25
1 files changed, 12 insertions, 13 deletions
diff --git a/lua/lspconfig/configs/gh_actions_ls.lua b/lua/lspconfig/configs/gh_actions_ls.lua
index b7451585..6bdfa62b 100644
--- a/lua/lspconfig/configs/gh_actions_ls.lua
+++ b/lua/lspconfig/configs/gh_actions_ls.lua
@@ -3,9 +3,18 @@ local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'gh-actions-language-server', '--stdio' },
- filetypes = { 'yaml.github' },
- root_dir = util.root_pattern('.github'),
- single_file_support = true,
+ filetypes = { 'yaml' },
+
+ -- Only attach to yaml files that are GitHub workflows instead of all yaml
+ -- 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/workflows/.+%.ya?ml') and util.root_pattern('.github') or nil
+ end,
+ -- Disabling "single file support" is a hack to avoid enabling this LS for
+ -- every random yaml file, so `root_dir()` can control the enablement.
+ single_file_support = false,
+
capabilities = {
workspace = {
didChangeWorkspaceFolders = {
@@ -20,16 +29,6 @@ https://github.com/lttb/gh-actions-language-server
Language server for GitHub Actions.
-The server is registered for the special `yaml.github` filetype. You need to configure this filetype pattern for GitHub workflow files.
-
-```lua
-vim.filetype.add({
- pattern = {
- ['.*/%.github[%w/]+workflows[%w/]+.*%.ya?ml'] = 'yaml.github',
- },
-})
-```
-
`gh-actions-language-server` can be installed via `npm`:
```sh