Add input_after_comment configuration

When set to true (default true), the cursor will go back to the start of
the added comments and trigger insert mode
This commit is contained in:
Daniel Mathiot
2021-08-21 18:20:29 +02:00
parent ec09985e9d
commit 96319356fa
2 changed files with 9 additions and 2 deletions

View File

@@ -35,7 +35,7 @@ neogen.auto_generate = function(custom_template)
if data and not vim.tbl_isempty(data) then if data and not vim.tbl_isempty(data) then
-- Will try to generate the documentation from a template and the data found from the granulator -- Will try to generate the documentation from a template and the data found from the granulator
local to_place, content = language.generator( local to_place, start_column, content = language.generator(
located_parent_node, located_parent_node,
data, data,
custom_template or language.template custom_template or language.template
@@ -43,6 +43,12 @@ neogen.auto_generate = function(custom_template)
-- Append the annotation in required place -- Append the annotation in required place
vim.fn.append(to_place, content) vim.fn.append(to_place, content)
-- Place cursor after annotations ans start editing
if neogen.configuration.input_after_comment == true then
vim.fn.cursor(to_place+1, start_column)
vim.api.nvim_command('startinsert!')
end
end end
end end
end) end)
@@ -54,6 +60,7 @@ end
neogen.setup = function(opts) neogen.setup = function(opts)
neogen.configuration = vim.tbl_deep_extend("keep", opts or {}, { neogen.configuration = vim.tbl_deep_extend("keep", opts or {}, {
input_after_comment = true,
-- DEFAULT CONFIGURATION -- DEFAULT CONFIGURATION
languages = { languages = {
lua = require("neogen.configurations.lua"), lua = require("neogen.configurations.lua"),

View File

@@ -50,5 +50,5 @@ neogen.default_generator = function(parent, data, template)
return result return result
end end
return start_row, parse_generated_template() return start_row, start_column, parse_generated_template()
end end