Created wrapped around jump + Doc
You can now jump to next annotation field with:
require('neogen').jump_next()
Added docs for cursor utilities
This commit is contained in:
@@ -97,6 +97,10 @@ neogen.generate = function(opts)
|
||||
end)
|
||||
end
|
||||
|
||||
function neogen.jump_next()
|
||||
neogen.utilities.cursor.jump()
|
||||
end
|
||||
|
||||
function neogen.generate_command()
|
||||
vim.api.nvim_command('command! -range -bar Neogen lua require("neogen").generate()')
|
||||
end
|
||||
|
||||
@@ -2,27 +2,21 @@ neogen.utilities.cursor = {}
|
||||
|
||||
local neogen_ns = vim.api.nvim_create_namespace("neogen")
|
||||
|
||||
--- Wrapper around set_extmark with 1-based numbering for `line` and `col`, and returns the id of the created extmark
|
||||
--- @param line string
|
||||
--- @param col string
|
||||
--- @return number
|
||||
neogen.utilities.cursor.create = function(line, col)
|
||||
return vim.api.nvim_buf_set_extmark(0, neogen_ns, line - 1, col - 1, {})
|
||||
end
|
||||
|
||||
--- Find next created extmark and goes to it.
|
||||
--- It removes the extmark afterwards.
|
||||
neogen.utilities.cursor.go_next_extmark = function()
|
||||
local extm_list = vim.api.nvim_buf_get_extmarks(0, neogen_ns, 0, -1, {})
|
||||
if #extm_list ~= 0 then
|
||||
vim.api.nvim_buf_del_extmark(0, neogen_ns, extm_list[1][1])
|
||||
end
|
||||
if #extm_list ~= 0 then
|
||||
vim.api.nvim_win_set_cursor(0, { extm_list[1][2] + 1, extm_list[1][3] + 1 })
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
neogen.utilities.cursor.go_next_extmark = function()
|
||||
local extm_list = vim.api.nvim_buf_get_extmarks(0, neogen_ns, 0, -1, {})
|
||||
if #extm_list ~= 0 then
|
||||
vim.api.nvim_buf_del_extmark(0, neogen_ns, extm_list[1][1])
|
||||
P("remaning marks", #extm_list - 1)
|
||||
end
|
||||
if #extm_list ~= 0 then
|
||||
vim.api.nvim_win_set_cursor(0, { extm_list[1][2] + 1, extm_list[1][3] })
|
||||
return true
|
||||
@@ -31,12 +25,14 @@ neogen.utilities.cursor.go_next_extmark = function()
|
||||
end
|
||||
end
|
||||
|
||||
--- Goes to next extmark and start insert mode
|
||||
neogen.utilities.cursor.jump = function()
|
||||
if neogen.utilities.cursor.go_next_extmark() then
|
||||
vim.api.nvim_command("startinsert!")
|
||||
end
|
||||
end
|
||||
|
||||
--- Delete all active extmarks
|
||||
neogen.utilities.cursor.del_extmarks = function()
|
||||
local extmarks = vim.api.nvim_buf_get_extmarks(0, neogen_ns, 0, -1, {})
|
||||
for _, v in pairs(extmarks) do
|
||||
|
||||
Reference in New Issue
Block a user