feat:(c/cpp) Add new type: file (#31)

This commit is contained in:
danymat
2022-01-09 13:20:12 +01:00
parent 0fdfd7ee82
commit ff5f7de750
3 changed files with 27 additions and 11 deletions

View File

@@ -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" },

View File

@@ -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