fix(ts) Do not offset function annotations (#111)
This commit is contained in:
@@ -177,5 +177,22 @@ return {
|
|||||||
|
|
||||||
locator = require("neogen.locators.typescript"),
|
locator = require("neogen.locators.typescript"),
|
||||||
|
|
||||||
template = template:add_default_annotation("jsdoc"):add_default_annotation("tsdoc"),
|
template = template
|
||||||
|
:config({
|
||||||
|
append = { position = "after", child_name = "comment", fallback = "block", disabled = { "file" } },
|
||||||
|
position = function(node, type)
|
||||||
|
if vim.tbl_contains({ "func", "class" }, type) then
|
||||||
|
local parent = node:parent()
|
||||||
|
|
||||||
|
-- Verify if the parent is an export_statement (prevents offset of generated annotation)
|
||||||
|
if parent and parent:type() == "export_statement" then
|
||||||
|
local row, col = vim.treesitter.get_node_range(parent)
|
||||||
|
return row, col
|
||||||
|
end
|
||||||
|
return 0, 0
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
:add_default_annotation("jsdoc")
|
||||||
|
:add_default_annotation("tsdoc"),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -285,7 +285,7 @@ end
|
|||||||
--- with multiple annotation conventions.
|
--- with multiple annotation conventions.
|
||||||
---@tag neogen-changelog
|
---@tag neogen-changelog
|
||||||
---@toc_entry Changes in neogen plugin
|
---@toc_entry Changes in neogen plugin
|
||||||
neogen.version = "2.10.0"
|
neogen.version = "2.10.1"
|
||||||
--minidoc_afterlines_end
|
--minidoc_afterlines_end
|
||||||
|
|
||||||
return neogen
|
return neogen
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ local default_locator = require("neogen.locators.default")
|
|||||||
return function(node_info, nodes_to_match)
|
return function(node_info, nodes_to_match)
|
||||||
local found_node = default_locator(node_info, nodes_to_match)
|
local found_node = default_locator(node_info, nodes_to_match)
|
||||||
|
|
||||||
if found_node and vim.tbl_contains({ "class_declaration", "function_declaration" }, found_node:type()) then
|
if found_node and vim.tbl_contains({ "class_declaration" }, found_node:type()) then
|
||||||
local parent = found_node:parent()
|
local parent = found_node:parent()
|
||||||
if parent and parent:type() == "export_statement" then
|
if parent and parent:type() == "export_statement" then
|
||||||
return parent
|
return parent
|
||||||
|
|||||||
Reference in New Issue
Block a user