From 3764b268dbeaa95a8d4b2da8d4433eab75ad8478 Mon Sep 17 00:00:00 2001 From: Timmy Keller Date: Wed, 7 Jul 2021 15:21:45 -0500 Subject: dotfiles --- nvim/init.vim | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100755 nvim/init.vim (limited to 'nvim/init.vim') diff --git a/nvim/init.vim b/nvim/init.vim new file mode 100755 index 0000000..5cdb9b7 --- /dev/null +++ b/nvim/init.vim @@ -0,0 +1,88 @@ +" Manage plugins using vim-plug +if ! filereadable(system('echo -n "${XDG_CONFIG_HOME:-$HOME/.config}/nvim/autoload/plug.vim"')) + echo "Downloading junegunn/vim-plug to manage plugins..." + silent !mkdir -p ${XDG_CONFIG_HOME:-$HOME/.config}/nvim/autoload/ + silent !curl "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" > ${XDG_CONFIG_HOME:-$HOME/.config}/nvim/autoload/plug.vim + autocmd VimEnter * PlugInstall +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' +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 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 mouse=a " Because sometimes it's just easier to use the mouse +set autochdir " Always change directory to current file +set cursorline " Highlight current line + +" Keybindings + " Set leader-key to comma +let mapleader ="," + " Invoke goyo with comma-m +map m :Goyo + " Invoke spellcheck mode with comma-o +map l :setlocal spell! spelllang=en_us + " Invoke spellcheck mode with comma-o +map 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 $ + " Faster split navigation (alt-hjlk, as opposed to ctrl-w + hjlk) +map h +map j +map k +map l + +" Colorscheme for root and normal users (since vimrc is just symlinked to the root user's home) +if ($HOME) == '/root' + colorscheme zellner +else + set bg=dark + let g:gruvbox_contrast_dark = 'hard' + colorscheme gruvbox-timmy +endif + +" Behavior's exclusive to either the tty or a terminal emulator in a graphical environment +if empty($DISPLAY) + " Then clear the tty screen after exiting vim + autocmd VimLeave * :!clear +else + " Change the terminal emulator's window title and class name to vim + autocmd BufEnter * :set title + autocmd VimEnter * :silent exec "!~/Scripts/st/settitle Vim" + autocmd VimLeave * :silent exec "!~/Scripts/st/settitle st" + let &titleold="st" +endif + +" Set the cursor on a per-mode basis +let &t_SI.="\[6 q" " Insert mode +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 + +" Get rid of the pointless .viminfo files that clutter the home directory +let skip_defaults_vim=1 +set viminfo="" -- cgit v1.2.3