254e9c04ac
new file: lua/ale.lua new file: lua/config.lua new file: lua/keybinds.lua new file: lua/nvim_lsp.lua new file: lua/packer_check.lua new file: lua/plugins.lua new file: lua/save_buffer_position.lua new file: plugin/packer_compiled.lua
31 lines
883 B
Lua
31 lines
883 B
Lua
vim.cmd [[
|
|
|
|
" https://vim.fandom.com/wiki/Avoid_scrolling_when_switch_buffers
|
|
" Save current view settings on a per-window, per-buffer basis.
|
|
|
|
function! AutoSaveWinView()
|
|
if !exists("w:SavedBufView")
|
|
let w:SavedBufView = {}
|
|
endif
|
|
let w:SavedBufView[bufnr("%")] = winsaveview()
|
|
endfunction
|
|
|
|
" Restore current view settings.
|
|
|
|
function! AutoRestoreWinView()
|
|
let buf = bufnr("%")
|
|
if exists("w:SavedBufView") && has_key(w:SavedBufView, buf)
|
|
let v = winsaveview()
|
|
let atStartOfFile = v.lnum == 1 && v.col == 0
|
|
if atStartOfFile && !&diff
|
|
call winrestview(w:SavedBufView[buf])
|
|
endif
|
|
unlet w:SavedBufView[buf]
|
|
endif
|
|
endfunction
|
|
|
|
autocmd BufLeave * call AutoSaveWinView()
|
|
autocmd BufEnter * call AutoRestoreWinView()
|
|
|
|
]]
|