From 521b9ff221b49064e993279a19ce4221d6e0ee0a Mon Sep 17 00:00:00 2001 From: Timmy Keller Date: Mon, 23 Aug 2021 17:34:26 -0500 Subject: Changes over vacation to Ga/Sc & first day of college --- nvim/init.vim | 66 +++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 24 deletions(-) (limited to 'nvim/init.vim') diff --git a/nvim/init.vim b/nvim/init.vim index 65e980e..58b0141 100755 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -7,45 +7,51 @@ if ! filereadable(system('echo -n "${XDG_CONFIG_HOME:-$HOME/.config}/nvim/autolo endif call plug#begin(system('echo -n "${XDG_CONFIG_HOME:-$HOME/.config}/nvim/plugged"')) -Plug 'chrisbra/Colorizer' -Plug 'junegunn/goyo.vim' Plug 'jiangmiao/auto-pairs' +Plug 'junegunn/goyo.vim' +Plug 'alvan/vim-closetag' +Plug 'ap/vim-css-color' call plug#end() " Basic options -syntax on " Enable syntax highlighting -set number relativenumber " Enable relative line numbers -set linebreak " Word wrap -set wildmode=longest,list,full " Enable file auto-complete -set splitbelow splitright " Open splits on bottom/right instead of top/left +set autochdir " Always change directory to current file +set autoindent " Keeps indentation on new lines set hlsearch " Highlight search hits set ignorecase " Case-insensitive search... -set smartcase " ...Unless the search term is capital -set autoindent " Keeps indentation on new lines +set linebreak " Word wrap set mouse=a " Because sometimes it's just easier to use the mouse -set autochdir " Always change directory to current file +set number relativenumber " Enable relative line numbers +set smartcase " ...Unless the search term is capital +set splitbelow splitright " Open splits on bottom/right instead of top/left +set wildmode=longest,list,full " Enable file auto-complete +syntax on " Enable syntax highlighting " Keybindings " Set leader-key to comma let mapleader ="," " Invoke goyo with comma-m -map m :Goyo +nmap m :Goyo " Invoke spellcheck mode with comma-o -map l :setlocal spell! spelllang=en_us +nmap l :setlocal spell! spelllang=en_us " Invoke spellcheck mode with comma-o -map c :set cursorcolumn! +nmap c :set cursorcolumn! " Send cursor to top or bottom currently visible line with ctrl-jk " map :call cursor(line('w$'),col('.')) " map :call cursor(line('w0'),col('.')) -map -map -map 0 -map $ + " Navigate faster than hjkl with ctrl-hjlk +nmap 0 +nmap +nmap +nmap $ " Faster split navigation (alt-hjlk, as opposed to ctrl-w + hjlk) "map h "map j "map k "map l + " Streamlined tab navigation with chromium inspired keybindings +nmap gt +nmap gT +nmap :tabnew " Colorscheme for root and normal users (since vimrc is just symlinked to the root user's home) if ($USER) == 'root' @@ -79,13 +85,25 @@ let &t_SR.="\[4 q" " Replace mode let &t_EI.="\[2 q" " Normal mode let &t_ti.="\[2 q" " Cursor on startup -" Automatically deletes all trailing whitespace and newlines at end of file on save -"autocmd BufWritePre * let ccc=col('.') " Set current cursor column -"autocmd BufWritePre * let ccl=line('.') " Set current cursor line -"autocmd BufWritePre * %s/\s\+$//e " \/ -"autocmd BufWritePre * %s/\n\+\%$//e " Remove white space -"autocmd BufWritePre *.[ch] %s/\%$/\r/e " /\ -"autocmd BufWritePre * call cursor(ccl,ccc) " Move cursor to previous position +" Automatically deletes all trailing whitespace on save +function DelWS() + :let ccc=col('.') " Set current cursor column + :let ccl=line('.') " Set current cursor line + :%s/\s\+$//e " Find and remove trailing whitespace on each line + :call cursor(ccl,ccc) " Move cursor to previous position +endfunction +autocmd BufWritePre * call DelWS() + +" Disables automatic commenting on newline: + autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o +" Perform dot commands over visual blocks: + vnoremap . :normal . +" Save file as sudo on files that require root permission + cnoremap w!! execute 'silent! write !sudo tee % >/dev/null' edit! + +" Plugin options + " closetag +let g:closetag_filenames = '*.html,*.xhtml,*.phtml' " Get rid of the pointless .viminfo files that clutter the home directory let skip_defaults_vim=1 -- cgit v1.2.3