feat:(c/cpp) Add new type: file (#31)
This commit is contained in:
@@ -69,7 +69,7 @@ You can provide some options for the generate, like so:
|
||||
|
||||
```lua
|
||||
require('neogen').generate({
|
||||
type = "func" -- the annotation type to generate. Currently supported: func, class, type
|
||||
type = "func" -- the annotation type to generate. Currently supported: func, class, type, file
|
||||
})
|
||||
```
|
||||
|
||||
@@ -186,9 +186,9 @@ There is a list of supported languages and fields, with their annotation style
|
||||
| | [JSDoc](https://jsdoc.app) (`"jsdoc"`) | `@param`, `@returns`, `@class`, `@classdesc` |
|
||||
| typescript | | | `func`, `class` |
|
||||
| | [JSDoc](https://jsdoc.app) (`"jsdoc"`) | `@param`, `@returns`, `@class`, `@classdesc`, `@type` |
|
||||
| c | | | `func` |
|
||||
| c | | | `func`, `file`|
|
||||
| | [Doxygen](https://www.doxygen.nl/manual/commands.html) (`"doxygen"`) | `@param`, `@return`, `@brief`|
|
||||
| cpp | | | `func` |
|
||||
| cpp | | | `func`, `file` |
|
||||
| | [Doxygen](https://www.doxygen.nl/manual/commands.html) (`"doxygen"`) | `@param`, `@return`, `@tparam`, `@brief`|
|
||||
| go | | | |
|
||||
| | [Godoc](https://go.dev/blog/godoc) (`"godoc"`) | |
|
||||
|
||||
@@ -113,6 +113,7 @@ return {
|
||||
"field_declaration",
|
||||
"template_declaration",
|
||||
},
|
||||
file = { "translation_unit" },
|
||||
},
|
||||
|
||||
data = {
|
||||
@@ -123,6 +124,15 @@ return {
|
||||
},
|
||||
},
|
||||
},
|
||||
file = {
|
||||
["translation_unit"] = {
|
||||
["0"] = {
|
||||
extract = function()
|
||||
return {}
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
locator = function(node_info, nodes_to_match)
|
||||
@@ -151,13 +161,15 @@ return {
|
||||
use_default_comment = false,
|
||||
|
||||
doxygen = {
|
||||
{ nil, "/**", { no_results = true } },
|
||||
{ nil, " * @brief $1", { no_results = true } },
|
||||
{ nil, " */", { no_results = true } },
|
||||
{ nil, "/**", { no_results = true, type = { "func", "file" } } },
|
||||
{ nil, " * @file", { no_results = true, type = { "file" } } },
|
||||
{ nil, " * @brief $1", { no_results = true, type = { "func", "file" } } },
|
||||
{ nil, " */", { no_results = true, type = { "func", "file" } } },
|
||||
{ nil, "", { no_results = true, type = { "file" } } },
|
||||
|
||||
{ nil, "/**" },
|
||||
{ nil, " * @brief $1" },
|
||||
{ nil, " *" },
|
||||
{ nil, "/**", type = { "func" } },
|
||||
{ nil, " * @brief $1", type = { "func" } },
|
||||
{ nil, " *", type = { "func" } },
|
||||
{ "tparam", " * @tparam %s $1" },
|
||||
{ "parameters", " * @param %s $1" },
|
||||
{ "return_statement", " * @return $1" },
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
--- @class node_info
|
||||
--- @field current userdata the current node from cursor
|
||||
--- @field root userdata the root node
|
||||
|
||||
--- The default locator tries to find one of the nodes to match in the current node
|
||||
--- If it does not find one, will fetch the parents until he finds one
|
||||
--- @param node_info table a node informations
|
||||
--- @param node_info node_info a node informations
|
||||
--- @param nodes_to_match table a list of parent nodes to match
|
||||
--- @return node_info.current node one of the nodes to match directly above the given node
|
||||
--- @return userdata node one of the nodes to match directly above the given node
|
||||
neogen.default_locator = function(node_info, nodes_to_match)
|
||||
-- If we find one of the wanted nodes in current one, return the current node
|
||||
if vim.tbl_contains(nodes_to_match, node_info.current:type()) then
|
||||
|
||||
Reference in New Issue
Block a user