<Tab> only works if you're in annotated range
This commit is contained in:
@@ -84,6 +84,8 @@ neogen.generate = function(opts)
|
|||||||
|
|
||||||
-- Place cursor after annotations and start editing
|
-- Place cursor after annotations and start editing
|
||||||
if neogen.configuration.input_after_comment == true then
|
if neogen.configuration.input_after_comment == true then
|
||||||
|
-- Creates extmark for the beggining of the content
|
||||||
|
neogen.utilities.cursor.create(to_place + 1, start_column)
|
||||||
-- Creates extmarks for the content
|
-- Creates extmarks for the content
|
||||||
for i, value in pairs(content_with_marks) do
|
for i, value in pairs(content_with_marks) do
|
||||||
local input_start, _ = string.find(value, jump_text)
|
local input_start, _ = string.find(value, jump_text)
|
||||||
@@ -91,9 +93,11 @@ neogen.generate = function(opts)
|
|||||||
neogen.utilities.cursor.create(to_place + i, input_start)
|
neogen.utilities.cursor.create(to_place + i, input_start)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if neogen.utilities.cursor.jumpable() then
|
|
||||||
neogen.utilities.cursor.jump({ first_time = true })
|
-- Creates extmark for the end of the content
|
||||||
end
|
neogen.utilities.cursor.create(to_place + #content+ 1, 0)
|
||||||
|
|
||||||
|
neogen.utilities.cursor.jump({ first_time = true })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -12,10 +12,11 @@ end
|
|||||||
|
|
||||||
--- Find next created extmark and goes to it.
|
--- Find next created extmark and goes to it.
|
||||||
--- It removes the extmark afterwards.
|
--- It removes the extmark afterwards.
|
||||||
neogen.utilities.cursor.go_next_extmark = function(first_time)
|
--- First jumpable extmark is the one after the extmarks responsible of start/end of annotation
|
||||||
|
neogen.utilities.cursor.go_next_extmark = function()
|
||||||
local extm_list = vim.api.nvim_buf_get_extmarks(0, neogen_ns, 0, -1, {})
|
local extm_list = vim.api.nvim_buf_get_extmarks(0, neogen_ns, 0, -1, {})
|
||||||
if #extm_list ~= 0 then
|
if #extm_list ~= 2 then
|
||||||
local pos = { extm_list[1][2] + 1, extm_list[1][3] }
|
local pos = { extm_list[2][2] + 1, extm_list[2][3] }
|
||||||
|
|
||||||
vim.api.nvim_win_set_cursor(0, pos)
|
vim.api.nvim_win_set_cursor(0, pos)
|
||||||
if #extm_list ~= 0 then
|
if #extm_list ~= 0 then
|
||||||
@@ -39,7 +40,7 @@ neogen.utilities.cursor.jump = function(opts)
|
|||||||
vim.api.nvim_command("startinsert")
|
vim.api.nvim_command("startinsert")
|
||||||
end
|
end
|
||||||
|
|
||||||
if neogen.utilities.cursor.go_next_extmark(opts.first_time) then
|
if neogen.utilities.cursor.go_next_extmark() then
|
||||||
vim.api.nvim_command("startinsert")
|
vim.api.nvim_command("startinsert")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -53,9 +54,14 @@ neogen.utilities.cursor.del_extmarks = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Checks if there are still possible jump positions to perform
|
--- Checks if there are still possible jump positions to perform
|
||||||
|
--- Verifies if the cursor is in the last annotated part
|
||||||
neogen.utilities.cursor.jumpable = function()
|
neogen.utilities.cursor.jumpable = function()
|
||||||
local extm_list = vim.api.nvim_buf_get_extmarks(0, neogen_ns, 0, -1, {})
|
local extm_list = vim.api.nvim_buf_get_extmarks(0, neogen_ns, 0, -1, {})
|
||||||
if #extm_list ~= 0 then
|
local cursor = vim.api.nvim_win_get_cursor(0)
|
||||||
|
if cursor[1] > extm_list[#extm_list][2] or cursor[1] < extm_list[1][2] then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
if #extm_list > 2 then
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
return false
|
return false
|
||||||
|
|||||||
Reference in New Issue
Block a user