diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2025-04-09 22:01:12 -0600 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2025-04-09 22:01:54 -0600 |
commit | b3b09ff479510abc51ffb88743bb353bcc15e165 (patch) | |
tree | a2b7486a7146dfe4074faf9f1856fc25f461b466 /plugin/mark.lua | |
parent | 8495168e18c5d9f0dc1a7f5b8fcd23d2d0ab4652 (diff) | |
download | rneovim-userregs-b3b09ff479510abc51ffb88743bb353bcc15e165.tar.gz rneovim-userregs-b3b09ff479510abc51ffb88743bb353bcc15e165.tar.bz2 rneovim-userregs-b3b09ff479510abc51ffb88743bb353bcc15e165.zip |
Update rneovim userregs to be compatible with userregs 2.0.
Diffstat (limited to 'plugin/mark.lua')
-rw-r--r-- | plugin/mark.lua | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/plugin/mark.lua b/plugin/mark.lua deleted file mode 100644 index ccc6374..0000000 --- a/plugin/mark.lua +++ /dev/null @@ -1,75 +0,0 @@ --- Implementation of middle mark. This mark is always in the middle of the --- viewport. - -local api = vim.api - --- Compatibility check. -if not api.nvim_call_function('has', {'usermarks'}) then - return nil -end - -local usermark = require("vim.usermark") - --- The middle mark is on the middle of the screen. -local middle_mark = {} -function middle_mark.get(self) - local topline = vim.api.nvim_call_function('line', {'w0'}) - local bottomline = vim.api.nvim_call_function('line', {'w$'}) - - return math.floor((topline + bottomline) / 2) -end - --- Setting the middle mark sets the current cusor line to the middle of the --- window. Principally this is the same as z. -function middle_mark.set(self) - api.nvim_command('norm z.') -end - --- The top mark is the first line on the window. This does respect scrolloff. -local top_mark = {} -function top_mark.get(self) - return vim.api.nvim_call_function('line', {'w0'}) + vim.o.scrolloff -end --- Setting the top mark move the current line to the top. Principally this is --- the same mas z<cr> -function top_mark.set(self) - api.nvim_command('norm z<cr>') -end - --- Setting the bottom mark moves the current line to the bottom. Principally --- this is the same as z- -local bottom_mark = {} -function bottom_mark.get(self) - return vim.api.nvim_call_function('line', {'w$'}) - vim.o.scrolloff -end --- Setting the bottom mark doesn't do anything. -function bottom_mark.set(self) - api.nvim_command('norm z-') -end - --- Mark that's like the expression register, but for a mark. -local expr_mark = {} -function expr_mark.get(self) - local mode = vim.api.nvim_call_function('mode', {}) - - if mode == "c" then - -- Avoid recurring asking for a value while in command mode. - return nil - end - - local expr = vim.api.nvim_call_function('input', {'='}) - if expr ~= "" then - return vim.api.nvim_eval(expr) - end - - return nil -end - --- Setting the expr_mark does'nt do anything -function expr_mark.set(self) end - --- Register all the marks with their respective characters. -usermark.register_handler('-', middle_mark) -usermark.register_handler('+', top_mark) -usermark.register_handler('_', bottom_mark) -usermark.register_handler('=', expr_mark) |