Skip to content

Commit 90f66f8

Browse files
committed
feat: zizmor
1 parent fb5fa30 commit 90f66f8

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

lsp/zizmor.lua

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---@brief
2+
---
3+
--- https://github.com/zizmorcore/zizmor
4+
---
5+
--- Zizmor language server.
6+
---
7+
--- `zizmor` can be installed by following the instructions [here](https://docs.zizmor.sh/installation/).
8+
---
9+
--- The default `cmd` assumes that the `zizmor` binary can be found in `$PATH`.
10+
---
11+
--- See `zizmor`'s [documentation](https://docs.zizmor.sh/) for additional documentation.
12+
13+
---@type vim.lsp.Config
14+
return {
15+
cmd = { 'zizmor', '--lsp' },
16+
filetypes = { 'yaml' },
17+
18+
-- `root_dir` ensures that the LSP does not attach to all yaml files
19+
root_dir = function(bufnr, on_dir)
20+
local parent = vim.fs.dirname(vim.api.nvim_buf_get_name(bufnr))
21+
if
22+
vim.endswith(parent, '/.github/workflows')
23+
or vim.endswith(parent, '/.forgejo/workflows')
24+
or vim.endswith(parent, '/.gitea/workflows')
25+
then
26+
on_dir(parent)
27+
end
28+
end,
29+
handlers = {
30+
['actions/readFile'] = function(_, result)
31+
if type(result.path) ~= 'string' then
32+
return nil, nil
33+
end
34+
local file_path = vim.uri_to_fname(result.path)
35+
if vim.fn.filereadable(file_path) == 1 then
36+
local f = assert(io.open(file_path, 'r'))
37+
local text = f:read('*a')
38+
f:close()
39+
40+
return text, nil
41+
end
42+
return nil, nil
43+
end,
44+
},
45+
init_options = {}, -- needs to be present https://github.com/neovim/nvim-lspconfig/pull/3713#issuecomment-2857394868
46+
capabilities = {
47+
workspace = {
48+
didChangeWorkspaceFolders = {
49+
dynamicRegistration = true,
50+
},
51+
},
52+
},
53+
}

0 commit comments

Comments
 (0)