diff --git a/doc/remember.txt b/doc/remember.txt index f0d63c0..cca78c0 100644 --- a/doc/remember.txt +++ b/doc/remember.txt @@ -96,6 +96,16 @@ g:remember_open_folds *g:remember_open_folds* let g:remember_open_folds = true +------------------------------------------------------------------------------ +g:remember_dont_center *g:remember_dont_center* + + Disable screen centering when restoring cursor position. + + Default: false ~ + + Example: > + + let g:remember_dont_center = true ============================================================================== 4. CHANGELOG *remember-changelog* diff --git a/lua/remember.lua b/lua/remember.lua index ce901f7..e085563 100644 --- a/lua/remember.lua +++ b/lua/remember.lua @@ -19,6 +19,7 @@ local config = { ignore_filetype = { "gitcommit", "gitrebase", "svn", "hgcommit" }, ignore_buftype = { "quickfix", "nofile", "help" }, open_folds = true, + dont_center = false, } function M.setup(options) @@ -33,6 +34,10 @@ function M.setup(options) if options["open_folds"] then config["open_folds"] = options["open_folds"] end + + if options["dont_center"] then + config["dont_center"] = options["dont_center"] + end end function set_cursor_position() @@ -62,8 +67,9 @@ function set_cursor_position() -- then continue if row > 0 and row <= api.nvim_buf_line_count(0) then -- If the last row is visible within this window, like in a very short - -- file, just set the cursor position to the saved position - if api.nvim_buf_line_count(0) == fn.line("w$") then + -- file, or user requested us not centering the screen, just set the cursor + -- position to the saved position + if api.nvim_buf_line_count(0) == fn.line("w$") or config["dont_center"] then api.nvim_win_set_cursor(0, cursor_position) -- If we're in the middle of the file, set the cursor position and center