diff options
| author | Julio GarcĂa <jugarpeupv@gmail.com> | 2025-09-01 19:40:46 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-01 10:40:46 -0700 |
| commit | 7e585e3f37bcf46761adf5e76dd343fb2d8e6670 (patch) | |
| tree | 853666f5053d72e48d31e8154ac17185bbdc04b3 /lsp | |
| parent | docs: update configs.md (diff) | |
| download | nvim-lspconfig-7e585e3f37bcf46761adf5e76dd343fb2d8e6670.tar nvim-lspconfig-7e585e3f37bcf46761adf5e76dd343fb2d8e6670.tar.gz nvim-lspconfig-7e585e3f37bcf46761adf5e76dd343fb2d8e6670.tar.bz2 nvim-lspconfig-7e585e3f37bcf46761adf5e76dd343fb2d8e6670.tar.lz nvim-lspconfig-7e585e3f37bcf46761adf5e76dd343fb2d8e6670.tar.xz nvim-lspconfig-7e585e3f37bcf46761adf5e76dd343fb2d8e6670.tar.zst nvim-lspconfig-7e585e3f37bcf46761adf5e76dd343fb2d8e6670.zip | |
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,
},
},
},
Diffstat (limited to 'lsp')
| -rw-r--r-- | lsp/gh_actions_ls.lua | 15 |
1 files changed, 15 insertions, 0 deletions
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 = { |
