dotfiles

My dotfiles used for LARBS
Log | Files | Refs | README | LICENSE

init.vim (4019B)


      1 let mapleader =","
      2 
      3 if ! filereadable(expand('~/.config/nvim/autoload/plug.vim'))
      4 	echo "Downloading junegunn/vim-plug to manage plugins..."
      5 	silent !mkdir -p ~/.config/nvim/autoload/
      6 	silent !curl "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" > ~/.config/nvim/autoload/plug.vim
      7 	autocmd VimEnter * PlugInstall
      8 endif
      9 
     10 call plug#begin('~/.config/nvim/plugged')
     11 Plug 'tpope/vim-surround'
     12 Plug 'scrooloose/nerdtree'
     13 Plug 'junegunn/goyo.vim'
     14 Plug 'PotatoesMaster/i3-vim-syntax'
     15 Plug 'jreybert/vimagit'
     16 Plug 'lukesmithxyz/vimling'
     17 Plug 'vimwiki/vimwiki'
     18 Plug 'bling/vim-airline'
     19 Plug 'tpope/vim-commentary'
     20 Plug 'kovetskiy/sxhkd-vim'
     21 call plug#end()
     22 
     23 set bg=light
     24 set go=a
     25 set mouse=a
     26 set nohlsearch
     27 set clipboard+=unnamedplus
     28 
     29 " Some basics:
     30 	nnoremap c "_c
     31 	set nocompatible
     32 	filetype plugin on
     33 	syntax on
     34 	set encoding=utf-8
     35 	set number relativenumber
     36 " Enable autocompletion:
     37 	set wildmode=longest,list,full
     38 " Disables automatic commenting on newline:
     39 	autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
     40 
     41 " Goyo plugin makes text more readable when writing prose:
     42 	map <leader>f :Goyo \| set bg=light \| set linebreak<CR>
     43 
     44 " Spell-check set to <leader>o, 'o' for 'orthography':
     45 	map <leader>o :setlocal spell! spelllang=en_us<CR>
     46 
     47 " Splits open at the bottom and right, which is non-retarded, unlike vim defaults.
     48 	set splitbelow splitright
     49 
     50 " Nerd tree
     51 	map <leader>n :NERDTreeToggle<CR>
     52 	autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
     53 
     54 " vimling:
     55 	nm <leader>d :call ToggleDeadKeys()<CR>
     56 	imap <leader>d <esc>:call ToggleDeadKeys()<CR>a
     57 	nm <leader>i :call ToggleIPA()<CR>
     58 	imap <leader>i <esc>:call ToggleIPA()<CR>a
     59 	nm <leader>q :call ToggleProse()<CR>
     60 
     61 " Shortcutting split navigation, saving a keypress:
     62 	map <C-h> <C-w>h
     63 	map <C-j> <C-w>j
     64 	map <C-k> <C-w>k
     65 	map <C-l> <C-w>l
     66 
     67 " Check file in shellcheck:
     68 	map <leader>s :!clear && shellcheck %<CR>
     69 
     70 " Open my bibliography file in split
     71 	map <leader>b :vsp<space>$BIB<CR>
     72 	map <leader>r :vsp<space>$REFER<CR>
     73 
     74 " Replace all is aliased to S.
     75 	nnoremap S :%s//g<Left><Left>
     76 
     77 " Compile document, be it groff/LaTeX/markdown/etc.
     78 	map <leader>c :w! \| !compiler <c-r>%<CR>
     79 
     80 " Open corresponding .pdf/.html or preview
     81 	map <leader>p :!opout <c-r>%<CR><CR>
     82 
     83 " Runs a script that cleans out tex build files whenever I close out of a .tex file.
     84 	autocmd VimLeave *.tex !texclear %
     85 
     86 " Ensure files are read as what I want:
     87 	let g:vimwiki_ext2syntax = {'.Rmd': 'markdown', '.rmd': 'markdown','.md': 'markdown', '.markdown': 'markdown', '.mdown': 'markdown'}
     88 	map <leader>v :VimwikiIndex
     89 	let g:vimwiki_list = [{'path': '~/vimwiki', 'syntax': 'markdown', 'ext': '.md'}]
     90 	autocmd BufRead,BufNewFile /tmp/calcurse*,~/.calcurse/notes/* set filetype=markdown
     91 	autocmd BufRead,BufNewFile *.ms,*.me,*.mom,*.man set filetype=groff
     92 	autocmd BufRead,BufNewFile *.tex set filetype=tex
     93 
     94 " Save file as sudo on files that require root permission
     95 	cnoremap w!! execute 'silent! write !sudo tee % >/dev/null' <bar> edit!
     96 
     97 " Enable Goyo by default for mutt writting
     98 	autocmd BufRead,BufNewFile /tmp/neomutt* let g:goyo_width=80
     99 	autocmd BufRead,BufNewFile /tmp/neomutt* :Goyo | set bg=light
    100 	autocmd BufRead,BufNewFile /tmp/neomutt* map ZZ :Goyo\|x!<CR>
    101 	autocmd BufRead,BufNewFile /tmp/neomutt* map ZQ :Goyo\|q!<CR>
    102 
    103 " Automatically deletes all trailing whitespace on save.
    104 	autocmd BufWritePre * %s/\s\+$//e
    105 
    106 " When shortcut files are updated, renew bash and ranger configs with new material:
    107 	autocmd BufWritePost files,directories !shortcuts
    108 " Run xrdb whenever Xdefaults or Xresources are updated.
    109 	autocmd BufWritePost *Xresources,*Xdefaults !xrdb %
    110 " Update binds when sxhkdrc is updated.
    111 	autocmd BufWritePost *sxhkdrc !pkill -USR1 sxhkd
    112 
    113 " Turns off highlighting on the bits of code that are changed, so the line that is changed is highlighted but the actual text that has changed stands out on the line and is readable.
    114 if &diff
    115     highlight! link DiffText MatchParen
    116 endif