From 7e585e3f37bcf46761adf5e76dd343fb2d8e6670 Mon Sep 17 00:00:00 2001 From: Julio GarcĂ­a Date: Mon, 1 Sep 2025 19:40:46 +0200 Subject: feat(gh_actions_ls): handle "actions/readFile" request #4046 Fixes https://github.com/lttb/gh-actions-language-server/issues/5 Implement a custom handler for the "actions/readFile" request in the gh_actions_ls config. This handler reads the requested file from disk and returns its contents if the file is readable. This improves integration with the GitHub Actions language server by supporting file content requests. Here is how the vscode github actions extension sets the handler: https://github.com/github/vscode-github-actions/blob/main/src/workflow/languageServer.ts#L68 TODO: We could also provide an implementation for populating the init_options properly, docs currently suggest an empty table. For the lsp to work properly, it should be populated with this "shape": init_options = { sessionToken = session_token, repos = { { id = 1008200293, owner = org_name, name = repo_name, workspaceUri = "file://" .. vim.fn.getcwd(), organizationOwned = true, }, }, }, --- lsp/gh_actions_ls.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lsp') diff --git a/lsp/gh_actions_ls.lua b/lsp/gh_actions_ls.lua index 2e7bd1fd..f029ea72 100644 --- a/lsp/gh_actions_ls.lua +++ b/lsp/gh_actions_ls.lua @@ -30,7 +30,22 @@ return { on_dir(parent) end end, + handlers = { + ['actions/readFile'] = function(_, result) + if type(result.path) ~= 'string' then + return nil, nil + end + local file_path = vim.uri_to_fname(result.path) + if vim.fn.filereadable(file_path) == 1 then + local f = assert(io.open(file_path, 'r')) + local text = f:read('*a') + f:close() + return text, nil + end + return nil, nil + end, + }, init_options = {}, -- needs to be present https://github.com/neovim/nvim-lspconfig/pull/3713#issuecomment-2857394868 capabilities = { workspace = { -- cgit v1.2.3-70-g09d2