Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ There is a list of supported languages and fields, with their annotation style
| typescript | [JSDoc](https://jsdoc.app) (`"jsdoc"`) <br> [TSDoc](https://tsdoc.org) (`"tsdoc"`) | `func`, `class`, `type`, `file` |
| typescriptreact | [JSDoc](https://jsdoc.app) (`"jsdoc"`) <br> [TSDoc](https://tsdoc.org) (`"tsdoc"`) | `func`, `class`, `type`, `file` |
| vue | [JSDoc](https://jsdoc.app) (`"jsdoc"`) | `func`, `class`, `type`, `file` |
| zig | [Zig](https://ziglang.org/documentation/master/#toc-Doc-Comments) (`"zig"`) | `func`, `type`, `file` |

## Adding Languages

Expand Down
56 changes: 56 additions & 0 deletions lua/neogen/configurations/zig.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
local template = require("neogen.template")

local function noop(_)
return {}
end

return {
-- Search for these nodes
parent = {
func = { "function_declaration" },
type = { "variable_declaration", "container_field" },
file = { "source_file" },
container = { "struct_declaration" },
},

data = {
func = {
-- When the function is in the root tree
["function_declaration"] = {
["0"] = {
extract = noop,
},
},
},
type = {
["variable_declaration|container_field"] = {
["0"] = {
extract = noop,
},
},
},
file = {
["source_file"] = {
["0"] = {
extract = function() return { _ } end,
},
},
},
container = {
["struct_declaration"] = {
["0"] = {
extract = function() return { _ } end,
},
},
},
},

template = template:config({
use_default_comment = true,

append = {
position = "after",
disabled = { "func", "type", "file", },
}
}):add_default_annotation("zig"),
}
4 changes: 4 additions & 0 deletions lua/neogen/templates/zig.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
return {
{ nil, "! $1", { type = "file" } },
{ nil, "/ $1", { no_results = true, } },
}