dotfiles

Configuration for the software I use.
git clone https://git.sr.ht/~jbauer/dotfiles
Log | Files | Refs | README | LICENSE

init.vim (4184B)


      1 "Plugins Used:
      2 " vim-commentary    — (shortcuts for (un)commenting lines/blocks of code)
      3 " vim-buftabline    — (show a tab line for buffers)
      4 " vim-gutentags     — (auto-generate tags)
      5 " vim-monochrome    — (custom colorscheme)
      6 " vim-fastline      — (custom status bar)
      7 
      8 let mapleader = ","
      9 
     10 " Plugin Settings
     11 let g:buftabline_show = 1
     12 let g:gutentags_project_root = ['Makefile']
     13 let g:gutentags_add_default_project_roots = 1
     14 let g:gutentags_cache_dir = "~/.local/share/nvim/"
     15 
     16 " Syntax Highlighting and Colourscheme
     17 syntax on
     18 colorscheme monochrome-light
     19 
     20 " Show Matching Parens/Brackets
     21 set showmatch
     22 
     23 " Disable folding by default (but use Tab to expand folds if they exist)
     24 set nofoldenable
     25 nnoremap <Tab> za
     26 
     27 " Shortcut to open the file underneath the cursor that mimics the 'gf' command
     28 :noremap <leader>gf :e <cfile><cr>
     29 
     30 " Enable Filetype Plugins/Indentation
     31 filetype plugin indent on
     32 
     33 " Make common typos behave as their lowercase counterparts
     34 cabbr W w
     35 cabbr Q q
     36 cabbr E e
     37 
     38 " Convenient shortcut for :center
     39 nnoremap cc :center<CR>
     40 
     41 " Longer History
     42 set history=100
     43 
     44 " Ensure Externally Modified Files Stay Up To Date
     45 set autoread
     46 au FocusGained,BufEnter * :checktime
     47 
     48 " Before Writing to File, Remove Trailing White Spaces
     49 autocmd BufWritePre * :%s/\s\+$//e
     50 
     51 " Undo File to Allow Undoing From Previous Sessions
     52 set undofile
     53 set undodir=~/.local/share/nvim/undo/
     54 
     55 " Set the Location of the viminfo File
     56 set viminfo+=n~/.local/share/nvim/viminfo
     57 
     58 " Move visually selected lines up and down
     59 xnoremap K :move '<-2<CR>gv-gv
     60 xnoremap J :move '>+1<CR>gv-gv
     61 
     62 " Toggle display of special chars for tab, eol, space
     63 nmap <leader>l :set list!<CR>
     64 set listchars=tab:▸\ ,eol:¬,space:.
     65 
     66 " Highlight entire line that cursor is on
     67 set cursorline
     68 
     69 " Make < and > shifts retain selection
     70 vnoremap < <gv
     71 vnoremap > >gv
     72 
     73 " Line number settings
     74 set number relativenumber
     75 " Courtesy: Jeff Kreeftmeijer @ jeffkreeftmeijer.com/vim-number/
     76 augroup numbertoggle
     77 	autocmd!
     78 	autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
     79 	autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
     80 augroup END
     81 
     82 " Indentation Settings
     83 set smartindent
     84 set autoindent
     85 set textwidth=80
     86 set colorcolumn=+1
     87 " Toggle between 4 spaces and pure tab indentation styles
     88 func! ToggleIndentStyle()
     89 	if &expandtab == 1
     90 		set noexpandtab softtabstop& shiftwidth&
     91 		echom "Switched to: Indent with tabs."
     92 	else
     93 		set expandtab softtabstop=4 shiftwidth=4
     94 		echom "Switched to: Indent with 4 spaces."
     95 	endif
     96 endfu
     97 noremap <C-_> :call ToggleIndentStyle()<CR>
     98 
     99 " Search Settings
    100 set hlsearch
    101 set ignorecase
    102 set smartcase
    103 nnoremap \\ :noh<CR>
    104 
    105 " Printing
    106 set printfont=IBM\ Plex\ Mono\ Text:h10
    107 command! -range=% HardcopyPdf <line1>,<line2> hardcopy > %.ps | !ps2pdf %.ps && rm %.ps && echo "Created: %.pdf"
    108 
    109 " Buffer Settings and Fuzzy Search
    110 set hidden
    111 set splitright splitbelow
    112 set wildmenu
    113 set wildcharm=<C-Z>
    114 set path+=**
    115 nnoremap <C-N> :bn<CR>
    116 nnoremap <C-P> :bp<CR>
    117 nnoremap <C-H> <C-W><C-H>
    118 nnoremap <C-J> <C-W><C-J>
    119 nnoremap <C-K> <C-W><C-K>
    120 nnoremap <C-L> <C-W><C-L>
    121 nnoremap <Up> :resize +2<CR>
    122 nnoremap <Down> :resize -2<CR>
    123 nnoremap <Left> :vertical resize +2<CR>
    124 nnoremap <Right> :vertical resize -2<CR>
    125 
    126 " Enable Spell Check
    127 " Thesaurus: gutenberg.org/files/3202/files/mthesaur.txt
    128 " SpellFile: ftp.vim.org/pub/vim/runtime/spell/en/
    129 func! SpellCheckToggle()
    130 	set thesaurus+="~/.config/nvim/mthesaurus.txt"
    131 	set spellfile="~/.config/nvim/spell_en_CA.diff"
    132 	set complete+=s
    133 	setlocal spell! spelllang=en_ca
    134 endfu
    135 noremap <silent> <C-S> :call SpellCheckToggle()<CR>
    136 
    137 func! WordProcessor()
    138   map j gj
    139   map k gk
    140   setl formatoptions=1
    141   setl noexpandtab
    142   setl wrap
    143   setl linebreak
    144   setl textwidth=0
    145   setl nosmartindent
    146   call SpellCheckToggle()
    147 endfu
    148 noremap <silent> <C-W> :call WordProcessor()<CR>
    149 
    150 " Preferences for File Formats
    151 autocmd FileType gmi call WordProcessor()
    152 autocmd FileType gitcommit call SpellCheckToggle()
    153 autocmd FileType gitcommit setl tw=72
    154 autocmd FileType mail call SpellCheckToggle()
    155 autocmd FileType mail setl tw=72
    156 autocmd FileType markdown call WordProcessor()
    157 autocmd FileType python setl expandtab tabstop=4 shiftwidth=4
    158 autocmd FileType vim setl foldmethod=marker