jump to last know cursor position
This commit is contained in:
parent
f25db8737d
commit
768807cbfe
@ -61,6 +61,24 @@ api.nvim_create_autocmd({ 'FocusLost' }, { command = [[wshada]] })
|
||||
-- { command = [[if line("'\"") > 1 && line("'\"") <= line("$") | execute "normal! g`\"" | endif]] }
|
||||
-- )
|
||||
|
||||
-- When editing a file, always jump to the last known cursor position.
|
||||
-- Don't do it when the position is invalid, when inside an event handler
|
||||
-- (happens when dropping a file on gvim) and for a commit message (it's
|
||||
-- likely a different one than last time).
|
||||
local userGrp = api.nvim_create_augroup('UserGroup', { clear = true })
|
||||
vim.api.nvim_create_autocmd('BufReadPost', {
|
||||
group = userGrp,
|
||||
callback = function(args)
|
||||
local valid_line = vim.fn.line([['"]]) >= 1 and vim.fn.line([['"]]) < vim.fn.line('$')
|
||||
local not_commit = vim.b[args.buf].filetype ~= 'commit'
|
||||
|
||||
if valid_line and not_commit then
|
||||
vim.cmd([[normal! g`"]])
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
-- Check if we need to reload the file when it changed
|
||||
api.nvim_create_autocmd({ 'FocusGained', 'BufEnter' },
|
||||
{ command = [[if !bufexists("[Command Line]") | checktime | endif]] })
|
||||
|
Loading…
x
Reference in New Issue
Block a user