From 7d9572c05f0b8bf122c4c6384bd8268cbd8b8da1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Feh=C3=A9r?= Date: Wed, 10 Nov 2021 10:56:16 +0100 Subject: [PATCH] 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. --- lua/neogen/configurations/c.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lua/neogen/configurations/c.lua b/lua/neogen/configurations/c.lua index 0026021..28ce4c5 100644 --- a/lua/neogen/configurations/c.lua +++ b/lua/neogen/configurations/c.lua @@ -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,