diff --git a/lua/neogen/configurations/lua.lua b/lua/neogen/configurations/lua.lua index 8b6c68c..6b6054a 100644 --- a/lua/neogen/configurations/lua.lua +++ b/lua/neogen/configurations/lua.lua @@ -61,6 +61,7 @@ return { func = { "function", "local_function", "local_variable_declaration", "field", "variable_declaration" }, class = { "local_variable_declaration", "variable_declaration" }, type = { "local_variable_declaration", "variable_declaration" }, + file = { "program" }, }, data = { @@ -119,6 +120,15 @@ return { }, }, }, + file = { + ["program"] = { + ["0"] = { + extract = function() + return {} + end, + }, + }, + }, }, -- Custom lua locator that escapes from comments @@ -133,7 +143,13 @@ return { annotation_convention = "emmylua", emmylua = { { nil, "- $1", { type = { "class", "func" } } }, -- add this string only on requested types - { nil, "- $1", { no_results = true } }, -- Shows only when there's no results from the granulator + { nil, "- $1", { no_results = true, type = { "class", "func" } } }, -- Shows only when there's no results from the granulator + { nil, "- @module $1", { no_results = true, type = { "file" } } }, + { nil, "- @author $1", { no_results = true, type = { "file" } } }, + { nil, "- @license $1", { no_results = true, type = { "file" } } }, + { nil, "- @license $1", { no_results = true, type = { "file" } } }, + { nil, "", { no_results = true, type = { "file" } } }, + { "parameters", "- @param %s $1|any" }, { "vararg", "- @vararg $1|any" }, { "return_statement", "- @return $1|any" }, diff --git a/lua/neogen/locators/lua.lua b/lua/neogen/locators/lua.lua index 07b3956..c1f48cd 100644 --- a/lua/neogen/locators/lua.lua +++ b/lua/neogen/locators/lua.lua @@ -2,7 +2,7 @@ local ts_utils = require("nvim-treesitter.ts_utils") return function(node_info, nodes_to_match) -- We're dealing with a lua comment and we need to escape its grasp - if node_info.current:type() == "source" then + if node_info.current and node_info.current:type() == "source" then local start_row, _, _, _ = ts_utils.get_node_range(node_info.current) vim.api.nvim_win_set_cursor(0, { start_row, 0 }) node_info.current = ts_utils.get_node_at_cursor()