|  | 
| 1 | 1 | -- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/configs/gh_actions_ls.lua | 
| 2 | 2 | return { | 
| 3 | 3 | 	cmd = { "gh-actions-language-server", "--stdio" }, | 
| 4 |  | -	filetypes = { "yaml.github" }, | 
|  | 4 | +	filetypes = { "yaml" }, | 
| 5 | 5 | 
 | 
| 6 |  | -	-- Only attach to yaml files that are GitHub workflows instead of all yaml | 
| 7 |  | -	-- files. (A nil root_dir and no single_file_support results in the LSP not | 
| 8 |  | -	-- attaching.) For details, see #3558 | 
| 9 |  | -	root_dir = function(filename) | 
| 10 |  | -		local dirs_to_check = { | 
| 11 |  | -			".github/workflows", | 
| 12 |  | -			".forgejo/workflows", | 
| 13 |  | -			".gitea/workflows", | 
| 14 |  | -		} | 
| 15 |  | - | 
| 16 |  | -		local dir = vim.fs.dirname(filename) | 
| 17 |  | -		for _, subdir in ipairs(dirs_to_check) do | 
| 18 |  | -			local match = vim.fs.find(subdir, { path = dir, upward = true })[1] | 
| 19 |  | -			if match and vim.fn.isdirectory(match) == 1 and vim.fs.dirname(filename) == match then | 
| 20 |  | -				return match | 
| 21 |  | -			end | 
|  | 6 | +	-- `root_dir` ensures that the LSP does not attach to all yaml files | 
|  | 7 | +	root_dir = function(bufnr, on_dir) | 
|  | 8 | +		local parent = vim.fs.dirname(vim.api.nvim_buf_get_name(bufnr)) | 
|  | 9 | +		if | 
|  | 10 | +			vim.endswith(parent, "/.github/workflows") | 
|  | 11 | +			or vim.endswith(parent, "/.forgejo/workflows") | 
|  | 12 | +			or vim.endswith(parent, "/.gitea/workflows") | 
|  | 13 | +		then | 
|  | 14 | +			on_dir(parent) | 
| 22 | 15 | 		end | 
| 23 |  | - | 
| 24 |  | -		return nil | 
| 25 | 16 | 	end, | 
| 26 | 17 | 
 | 
| 27 |  | -	-- Disabling "single file support" is a hack to avoid enabling this LS for | 
| 28 |  | -	-- every random yaml file, so `root_dir()` can control the enablement. | 
| 29 |  | -	single_file_support = false, | 
| 30 |  | - | 
| 31 | 18 | 	capabilities = { | 
| 32 | 19 | 		workspace = { | 
| 33 | 20 | 			didChangeWorkspaceFolders = { | 
|  | 
0 commit comments