diff --git a/lua/neogen.lua b/lua/neogen.lua index fa937f6..159a76c 100644 --- a/lua/neogen.lua +++ b/lua/neogen.lua @@ -101,6 +101,10 @@ function neogen.jump_next() neogen.utilities.cursor.jump() end +function neogen.jumpable() + return neogen.utilities.cursor.jumpable() +end + function neogen.generate_command() vim.api.nvim_command('command! -range -bar Neogen lua require("neogen").generate()') end diff --git a/lua/neogen/utilities/cursor.lua b/lua/neogen/utilities/cursor.lua index 943512a..dae4fa4 100644 --- a/lua/neogen/utilities/cursor.lua +++ b/lua/neogen/utilities/cursor.lua @@ -15,10 +15,12 @@ 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]) - end - if #extm_list ~= 0 then + vim.api.nvim_win_set_cursor(0, { extm_list[1][2] + 1, extm_list[1][3] }) + + if #extm_list ~= 0 then + vim.api.nvim_buf_del_extmark(0, neogen_ns, extm_list[1][1]) + end return true else return false @@ -39,3 +41,12 @@ neogen.utilities.cursor.del_extmarks = function() vim.api.nvim_buf_del_extmark(0, neogen_ns, v[1]) end end + +neogen.utilities.cursor.jumpable = function () + local extm_list = vim.api.nvim_buf_get_extmarks(0, neogen_ns, 0, -1, {}) + if #extm_list ~= 0 then + return true + else + return false + end +end