dotfiles

My dotfiles: zsh, lf, sxiv, i3, ranger, mpd and more
Log | Files | Refs | Submodules | README | LICENSE

init.vim (4448B)


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