diff options
author | Timmy Keller <tjk@tjkeller.xyz> | 2022-03-16 23:34:17 -0500 |
---|---|---|
committer | Timmy Keller <tjk@tjkeller.xyz> | 2022-03-16 23:34:17 -0500 |
commit | 3d5aa2fded077a1cd5bae72fe352e5c1bceddc94 (patch) | |
tree | 39391337cd1f63e9d2ca225d57741678a185d1cb | |
parent | 14a81b1dd3be4d8ea5a947d199ad570128b8879b (diff) | |
download | dotconfig-3d5aa2fded077a1cd5bae72fe352e5c1bceddc94.tar.xz dotconfig-3d5aa2fded077a1cd5bae72fe352e5c1bceddc94.zip |
clean vim init
-rwxr-xr-x | nvim/init.vim | 111 |
1 files changed, 53 insertions, 58 deletions
diff --git a/nvim/init.vim b/nvim/init.vim index 8c46c3a..ab3a9d3 100755 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -7,69 +7,82 @@ 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 'jiangmiao/auto-pairs' -Plug 'junegunn/goyo.vim' +"Plug 'jiangmiao/auto-pairs' Plug 'alvan/vim-closetag' Plug 'ap/vim-css-color' +Plug 'junegunn/goyo.vim' Plug 'vimwiki/vimwiki' call plug#end() -" Basic options +"" Basic options 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 linebreak " Word wrap +set list " Show whitespace characters defined in listchars +set listchars=tab:⇥\ \,space:· " Highlight tabs and spaces set mouse=a " Because sometimes it's just easier to use the mouse 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 termguicolors " Enable GUI colors for the terminal to get truecolor set wildmode=longest,list,full " Enable file auto-complete -set listchars=tab:⇥\ \,space:· " Highlight tabs and spaces -set list " Show whitespace characters defined in listchars syntax on " Enable syntax highlighting +" Get rid of the pointless .viminfo files that clutter the home directory +let skip_defaults_vim=1 +set viminfo="" + +" Disables automatic commenting on newline: +autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o + +"" Plugin options +" Closetag +let g:closetag_filenames = '*.html,*.xhtml,*.phtml' +" VimWiki +let g:vimwiki_list = [{'path': '~/docs/school/arc/docs/wiki/', 'path_html': '~/docs/school/arc/docs/wiki/site/'}] + " Filetype options autocmd BufRead,BufNewFile *.tex set filetype=tex au Filetype tex let b:autopairs_enabled = 0 au Filetype tex setlocal indentexpr= au BufRead,BufNewFile *.tssg set filetype=tssg -" VimWiki options -let g:vimwiki_list = [{'path': '~/docs/school/arc/docs/wiki/', 'path_html': '~/docs/school/arc/docs/wiki/site/'}] - -" Keybindings - " Set leader-key to comma +"" Keybindings +" Set leader-key to comma let mapleader ="," - " Invoke goyo with comma-m +" Invoke goyo with comma-m nmap <leader>m :Goyo 120x<CR> - " Invoke spellcheck mode with comma-o +" Invoke spellcheck mode with comma-l nmap <leader>l :setlocal spell! spelllang=en_us<CR> - " Invoke spellcheck mode with comma-o +" Set cursorcolumn with comma-c nmap <leader>c :set cursorcolumn!<CR> - " Send cursor to top or bottom currently visible line with ctrl-jk -" map <C-j> :call cursor(line('w$'),col('.'))<CR> -" map <C-k> :call cursor(line('w0'),col('.'))<CR> - " Navigate faster than hjkl with ctrl-hjlk +" Navigate faster than hjkl with ctrl-hjlk nmap <C-h> 0 nmap <C-j> <C-d> nmap <C-k> <C-u> nmap <C-l> $ - " Faster split navigation (leader-wasd, as opposed to ctrl-w + hjlk) +" Faster split navigation (leader-wasd, as opposed to ctrl-w + hjlk) map <leader>a <C-w>h map <leader>s <C-w>j map <leader>w <C-w>k map <leader>d <C-w>l - " Streamlined tab navigation with chromium inspired keybindings +" Keys for tab navigation nmap <leader><TAB> gt nmap <leader>t :tabnew<CR> nmap <C-T> :tabnew<CR> - " Copy, paste, and cut with standard bindings +" Copy and cut with standard bindings map <C-c> "+y -"map <C-v> "+gp map <C-x> "+x +" Perform dot commands over visual blocks: +vnoremap . :normal .<CR> +" Save file as sudo on files that require root permission +cnoremap w!! execute 'silent! write !doas tee % >/dev/null' <bar> edit! +" Capitalize every word on the line +nmap gcc :s/\v<(.)(\w*)/\u\1\L\2/g<CR> +"" Extra functionality " Colorscheme for root and normal users (since vimrc is just symlinked to the root user's home) if ($USER) == 'root' colorscheme zellner @@ -83,61 +96,43 @@ else endif endif -" Behaviors exclusive to either the tty or a terminal emulator in a graphical environment +" Functions for changing the terminal emulator's class name to 'Vim' function GetTermPID(temu) let pinfo = ['', getpid(), ''] - while !(pinfo[2] =~ a:temu) + while !(pinfo[2] =~ a:temu || pinfo[1] == '0') let pinfo = split(system('ps h -o pid,ppid,command= -p' . pinfo[1])) endwhile return pinfo[0] endfunction function SetTermClassName(termpid, name) - silent exec "!settitle " . a:termpid . " " . a:name + " Command chaining in xdotool doesn't work here for some reason + silent exec "!xdotool set_window --class " . a:name . " $(xdotool search --pid " . a:termpid . ")" endfunction +" Behaviors exclusive to either a tty or a graphical terminal emulator if empty($DISPLAY) " Clear the tty screen after exiting vim - "autocmd QuitPre * :!clear + autocmd VimLeave * :clear else - set cursorline " Highlight current line - " Change the terminal emulator's window title and class name to vim + " Highlight current line + set cursorline + " Change window title + autocmd BufEnter * :set title + let &titleold="st" + " Change class name let temu = "st" let temupid = GetTermPID(temu) - autocmd BufEnter * :set title - autocmd VimEnter * call SetTermClassName(temupid, "Vim") - autocmd VimLeave * call SetTermClassName(temupid, "st") - "let &titleold="st" + if (temupid != 1) + autocmd VimEnter * call SetTermClassName(temupid, "Vim") + autocmd VimLeave * call SetTermClassName(temupid, temu) + endif endif -" Set the cursor on a per-mode basis (Not needed in NVIM) -"let &t_SI.="\<Esc>[6 q" " Insert mode -"let &t_SR.="\<Esc>[4 q" " Replace mode -"let &t_EI.="\<Esc>[2 q" " Normal mode -"let &t_ti.="\<Esc>[2 q" " Cursor on startup - " 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 + :norm m` + :%s/\s*$//e + :norm g`` 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 .<CR> - -" Save file as sudo on files that require root permission -cnoremap w!! execute 'silent! write !doas tee % >/dev/null' <bar> 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 -set viminfo="" |