From 2ec62e506ac855e45637cae59c8d61debfaa97ff Mon Sep 17 00:00:00 2001 From: Kevin James Lausen Date: Wed, 1 Jun 2022 10:14:24 -0400 Subject: [PATCH] Added auto-commands for persistance of the cursor, folds, and also centering the text vertically on insert-mode. --- init.lua | 3 +-- lua/user/autocmds.lua | 24 ++++++++++++++++++++++++ lua/user/options.lua | 12 ------------ 3 files changed, 25 insertions(+), 14 deletions(-) create mode 100644 lua/user/autocmds.lua diff --git a/init.lua b/init.lua index 1bb93ae..fb481a2 100644 --- a/init.lua +++ b/init.lua @@ -1,3 +1,2 @@ require "user.options" - - +require "user.autocmds" diff --git a/lua/user/autocmds.lua b/lua/user/autocmds.lua new file mode 100644 index 0000000..57aee61 --- /dev/null +++ b/lua/user/autocmds.lua @@ -0,0 +1,24 @@ +-- Embedded Vim Auto-command, that adds file cursor location persistance. + vim.cmd + [[ + augroup line_return + au! + au BufReadPost * + \ if line("'\"") > 0 && line("'\"") <= line("$") | + \ execute 'normal! g`"zvzz' | + \ endif + augroup END + ]] + +-- Vertically center the buffer, each time I go into insert mode. + vim.cmd + [[ + autocmd InsertEnter * norm zz + ]] + +-- Automatically save & re-fold Documents, when exiting & re-entering the file. + vim.cmd + [[ + autocmd BufWinLeave *.* mkview " Auto-save Folds before leaving a buffer. + autocmd BufWinEnter *.* silent loadview " Auto-re-load saved folds. + ]] diff --git a/lua/user/options.lua b/lua/user/options.lua index 3465c53..50aa80c 100644 --- a/lua/user/options.lua +++ b/lua/user/options.lua @@ -58,15 +58,3 @@ local options = { -- vim.cmd "set whichwrap+=<,>,[,],h,l" Want to find out what it does, before blindly enabling it. vim.cmd [[set iskeyword+=-]] -- Will treat words with a dash as part of a single word. --vim.cmd [[set formatoptions-=cro]] -- TODO: this doesn't seem to work - --- Embedded Vim Auto-command, that adds file cursor location persistance. -vim.cmd -[[ - augroup line_return - au! - au BufReadPost * - \ if line("'\"") > 0 && line("'\"") <= line("$") | - \ execute 'normal! g`"zvzz' | - \ endif - augroup END -]]