Write annotation before template declarations

Prior to this fix the annotation was written after the template
declaration in case the cursor did not happen to be on the same line as
the template declaration.
This commit is contained in:
Thomas Fehér
2021-11-10 10:56:16 +01:00
parent 1a51f4f991
commit 7d9572c05f

View File

@@ -104,6 +104,23 @@ return {
},
},
locator = function(node_info, nodes_to_match)
local result = neogen.default_locator(node_info, nodes_to_match)
if not result then
return nil
end
-- if the function happens to be a function template we want to place
-- the annotation before the template statement and extract the
-- template parameters names as well
if node_info.current:parent() == nil then
return result
end
if node_info.current:parent():type() == "template_declaration" then
return result:parent()
end
return result
end,
-- Use default granulator and generator
granulator = nil,
generator = nil,