From cd8fd184271e370230dd657a6ea9513208e2c4bd Mon Sep 17 00:00:00 2001 From: Noah Masur Date: Sat, 10 Apr 2021 13:15:19 -0400 Subject: [PATCH] clean up vimrc --- nvim.configlink/init.vim | 151 ++++++++++++++++++++------------------- 1 file changed, 79 insertions(+), 72 deletions(-) diff --git a/nvim.configlink/init.vim b/nvim.configlink/init.vim index 215ac9c..7aed0fc 100644 --- a/nvim.configlink/init.vim +++ b/nvim.configlink/init.vim @@ -34,7 +34,7 @@ Plug 'tpope/vim-vinegar' " Fixes netrw file explorer Plug 'lambdalisue/fern.vim' " File explorer / project drawer Plug 'christoomey/vim-tmux-navigator' " Hotkeys for tmux panes -" CoC +" CoC (Language Server Protocol, requires NodeJS) Plug 'neoclide/coc.nvim', {'branch': 'release'} " Code completion call plug#end() @@ -52,24 +52,22 @@ set relativenumber " Relative numbers instead of absolute set list " Reveal whitespace with --- set expandtab " Tabs into spaces set shiftwidth=4 " Amount to shift with > key -set softtabstop=4 " Amount to shift with TAB key +set softtabstop=4 " Amount to shift with key set ignorecase " Ignore case when searching set smartcase " Check case when using capitals in search set incsearch " Search while typing set visualbell " No sounds set scrolljump=1 " Scroll more than one line (or 1 line) -set scrolloff=3 " Margin of lines when scrolling -set pastetoggle= " Use F3 to enter paste mode +set scrolloff=3 " Margin of lines when to start scrolling +set pastetoggle= " Use F3 to enter raw paste mode set clipboard+=unnamedplus " Uses system clipboard for yanking set updatetime=300 " Faster diagnostics +set mouse=nv " Mouse interaction / scrolling " Neovim only -set inccommand=split " Live preview search and replace +set inccommand=split " Live preview search and replace -" Mouse interaction / scrolling -set mouse=nv - -" Remember last position +" Remember last position when reopening file if has("autocmd") au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif endif @@ -79,7 +77,7 @@ set noswapfile " Instead of swaps, create backups (les set backup " Easier to recover and more secure set undofile " Keeps undos after quit set backupdir=~/.config/nvim/dirs/backup -set undodir=~/.config/vim/dirs/undo +set undodir=~/.config/nvim/dirs/undo " Create backup directories if they don't exist if !isdirectory(&backupdir) @@ -89,7 +87,9 @@ if !isdirectory(&undodir) call mkdir(&undodir, "p") endif -" Custom commands +" Custom Commands +"---------------- + command Vimrc edit ~/.config/nvim/init.vim " Edit .vimrc (this file) " Custom Keybinds @@ -113,6 +113,12 @@ nnoremap q :quit " Save file nnoremap fs :write +" Make file executable +nnoremap fe :!chmod 755 % + +" Make file normal permissions +nnoremap fn :!chmod 644 % + " Open file in this directory nnoremap ff :Files @@ -149,9 +155,71 @@ nnoremap wm :only " Open file tree noremap ft :Fern . -drawer -width=35 -toggle= +" LaTeX Settings +"--------------- + +" LaTeX Hotkeys +autocmd FileType tex inoremap ;bf \textbf{}i +" Jump to the next occurence of <> and replace it with insert mode +autocmd FileType tex nnoremap /<>:nohc2l + +" Autocompile LaTeX on save +autocmd BufWritePost *.tex silent! execute "!pdflatex -output-directory=%:p:h % >/dev/null 2>&1" | redraw! + +" Plugin Settings +"---------------- + +" Built-in file explorer plugin +let g:netrw_liststyle = 3 " Change style to 'tree' view +let g:netrw_banner = 0 " Remove useless banner +let g:netrw_winsize = 15 " Explore window takes % of page +let g:netrw_browse_split = 4 " Open in previous window +let g:netrw_altv = 1 " Always split left + +" Gitgutter plugin +let g:gitgutter_enabled = 1 " Enabled on start + +" Polyglot syntax plugin +let g:terraform_fmt_on_save=1 " Formats with terraform plugin +let g:rustfmt_autosave = 1 " Formats with rust plugin + +" VimWiki plugin +let g:vimwiki_list = [ + \ { + \ 'path': $NOTES_PATH, + \ 'syntax': 'markdown', + \ 'index': 'home', + \ 'ext': '.md' + \ } + \ ] +let g:vimwiki_key_mappings = + \ { + \ 'all_maps': 1, + \ 'mouse': 1, + \ } +let g:vimwiki_auto_chdir = 1 + +" Quickscope only highlight on keypress +let g:qs_highlight_on_keys = ['f', 'F', 't', 'T'] + +" Lightline status bar plugin +let g:lightline = { + \ 'colorscheme': 'jellybeans', + \ 'active': { + \ 'right': [[ 'lineinfo' ]], + \ 'left': [[ 'mode', 'paste' ], + \ [ 'cocstatus', 'readonly', 'relativepath', 'gitbranch', 'modified' ]] + \ }, + \ 'component_function': { + \ 'gitbranch': 'fugitive#head', + \ 'cocstatus': 'coc#status' + \ }, + \ } + " CoC Settings "------------- +" Extensions to auto-install and enable let g:coc_global_extensions = [ \ 'coc-rust-analyzer', \ 'coc-pairs', @@ -207,66 +275,5 @@ nmap rn (coc-rename) nmap (coc-range-select) xmap (coc-range-select) -" LaTeX Settings -"--------------- - -" LaTeX Hotkeys -autocmd FileType tex inoremap ;bf \textbf{}i -" Jump to the next occurence of <> and replace it with insert mode -autocmd FileType tex nnoremap /<>:nohc2l - -" Autocompile LaTeX on save -autocmd BufWritePost *.tex silent! execute "!pdflatex -output-directory=%:p:h % >/dev/null 2>&1" | redraw! - -" Plugin Settings -"---------------- - -" Built-in explorer plugin -let g:netrw_liststyle = 3 " Change style to 'tree' view -let g:netrw_banner = 0 " Remove useless banner -let g:netrw_winsize = 15 " Explore window takes % of page -let g:netrw_browse_split = 4 " Open in previous window -let g:netrw_altv = 1 " Always split left - -" Gitgutter plugin -let g:gitgutter_enabled = 1 " Enabled on start - -" Polyglot syntax plugin -let g:terraform_fmt_on_save=1 " Formats with terraform plugin -let g:rustfmt_autosave = 1 " Formats with rust plugin - -" VimWiki plugin -let g:vimwiki_list = [ - \ { - \ 'path': $NOTES_PATH, - \ 'syntax': 'markdown', - \ 'index': 'home', - \ 'ext': '.md' - \ } - \ ] -let g:vimwiki_key_mappings = - \ { - \ 'all_maps': 1, - \ 'mouse': 1, - \ } -let g:vimwiki_auto_chdir = 1 - -" Quickscope only highlight on keypress -let g:qs_highlight_on_keys = ['f', 'F', 't', 'T'] - -" Lightline status bar plugin -let g:lightline = { - \ 'colorscheme': 'jellybeans', - \ 'active': { - \ 'right': [[ 'lineinfo' ]], - \ 'left': [[ 'mode', 'paste' ], - \ [ 'cocstatus', 'readonly', 'relativepath', 'gitbranch', 'modified' ]] - \ }, - \ 'component_function': { - \ 'gitbranch': 'fugitive#head', - \ 'cocstatus': 'coc#status' - \ }, - \ } - " Use autocmd to force lightline update. autocmd User CocStatusChange,CocDiagnosticChange call lightline#update()