Dotfiles for my tiling window manager + terminal workflow.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

301 lines
8.6 KiB

7 years ago
7 years ago
7 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
7 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  1. " set x=y {{{ "
  2. au BufWinEnter * set relativenumber
  3. " set background=dark
  4. set encoding=utf-8
  5. set background=light
  6. " set t_Co=256
  7. filetype plugin on
  8. syntax on
  9. set tabstop=4
  10. set tw=80
  11. set linebreak
  12. " set colorcolumn=80
  13. set shiftwidth=4
  14. set autoindent
  15. set mouse=c
  16. set clipboard+=unnamedplus
  17. set foldmethod=marker
  18. set linespace=5
  19. " cursor indicator {{{ "
  20. " set listchars=tab:\|\
  21. " set list
  22. " set cursorcolumn
  23. " set cursorline
  24. " }}} cursor indicator "
  25. set timeoutlen=500
  26. set hlsearch
  27. set noswapfile
  28. " }}} set x=y "
  29. " commands for file types {{{ "
  30. autocmd VimResized * wincmd =
  31. autocmd BufNewFile,BufRead .* set syntax=sh
  32. autocmd Filetype css,htmldjango,html,tex,txt,markdown set tabstop=2 shiftwidth=2 expandtab
  33. autocmd BufRead commit-msg.txt set filetype=gitcommit tw=72
  34. autocmd BufNewFile,BufRead *.md set filetype=markdown
  35. autocmd Filetype markdown set textwidth=0
  36. autocmd BufWritePost key_*.txt !sync-shortcuts
  37. autocmd VimLeave *.tex !tex-clean %
  38. " " auto-reload vimrc {{{ "
  39. " augroup myvimrc
  40. " au!
  41. " au BufWritePost .vimrc,_vimrc,vimrc,.gvimrc,_gvimrc,gvimrc so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif
  42. " augroup END
  43. " " }}} auto-reload vimrc "
  44. " }}} commands for file types "
  45. " vim-plug {{{ "
  46. " plug auto-install
  47. if empty(glob('~/.vim/autoload/plug.vim'))
  48. silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
  49. \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  50. autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
  51. endif
  52. call plug#begin('~/.vim/plugged')
  53. " prequisite for other plugins
  54. Plug 'vim-scripts/L9'
  55. " find files from within Vim
  56. " Plug 'vim-scripts/FuzzyFinder'
  57. " Gotham color scheme
  58. " Plug 'whatyouhide/vim-gotham'
  59. " collection of Vim color schemes
  60. Plug 'flazz/vim-colorschemes'
  61. " preview Vim color scheme easily within Vim
  62. Plug 'xolox/vim-colorscheme-switcher'
  63. " prerequisite for above plugin
  64. Plug 'xolox/vim-misc'
  65. " automatically save buffers upon returning to normal mode
  66. Plug '907th/vim-auto-save'
  67. let g:auto_save = 1
  68. " provides various functionality for writing LaTeX in Vim
  69. Plug 'lervag/vimtex'
  70. au BufWritePost *.tex silent call Tex_RunLaTeX()
  71. au BufWritePost *.tex silent !pkill -USR1 xdvi.bin
  72. let g:vimtex_view_general_viewer = 'zathura'
  73. let g:vimtex_quickfix_latexlog = {
  74. \ 'overfull' : 0,
  75. \ 'underfull' : 0,
  76. \ 'global' : 0,
  77. \ 'unused' : 0,
  78. \}
  79. " auto-completion for various languages
  80. Plug 'Valloric/YouCompleteMe'
  81. " wrote short bits of text that expand into whatever you want
  82. " demo: https://www.youtube.com/watch?v=Zik6u0klD40
  83. Plug 'SirVer/ultisnips'
  84. " better key bindings for UltiSnipsExpandTrigger
  85. let g:UltiSnipsExpandTrigger = "<tab>"
  86. let g:UltiSnipsJumpForwardTrigger = "<tab>"
  87. let g:UltiSnipsJumpBackwardTrigger = "<C-tab>"
  88. " custom snippets
  89. Plug 'Kevin-Mok/vim-snippets'
  90. " to make YouCompleteMe work with UltiSnips (both use Tab)
  91. Plug 'ervandew/supertab'
  92. " make YCM compatible with UltiSnips (using supertab)
  93. let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
  94. let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
  95. let g:SuperTabDefaultCompletionType = '<C-n>'
  96. " easily comment/uncomment lines
  97. Plug 'scrooloose/nerdcommenter'
  98. let g:NERDTrimTrailingWhitespace = 1
  99. let g:NERDSpaceDelims = 1
  100. " add quotes/brackets around chunks of text easily
  101. Plug 'tpope/vim-surround'
  102. " navigate around file easily and precisely
  103. Plug 'easymotion/vim-easymotion'
  104. map <Space> <Plug>(easymotion-prefix)
  105. " status bar displaying various info about the current buffer
  106. Plug 'vim-airline/vim-airline'
  107. let g:airline_section_c = '%F'
  108. Plug 'vim-airline/vim-airline-themes'
  109. let g:airline_powerline_fonts = 1
  110. " continue Markdown lists when started
  111. Plug 'dkarter/bullets.vim'
  112. " coordinate Vim color scheme with terminal color scheme
  113. Plug 'dylanaraps/wal.vim'
  114. " repeat plugin commands
  115. Plug 'tpope/vim-repeat'
  116. " better Django support
  117. Plug 'tweekmonster/django-plus.vim'
  118. " auto-close brackets
  119. Plug 'jiangmiao/auto-pairs'
  120. let g:AutoPairsMapSpace = 0
  121. Plug 'henrik/vim-indexed-search'
  122. Plug 'PotatoesMaster/i3-vim-syntax'
  123. " vim file explorer
  124. Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
  125. Plug 'terryma/vim-multiple-cursors'
  126. " let g:multi_cursor_select_all_word_key='<C-a>'
  127. call plug#end()
  128. " colorscheme gotham256
  129. colorscheme wal
  130. " }}} vim-plug "
  131. " Mappings {{{ "
  132. " function keys {{{ "
  133. map <F4> :xa<CR>
  134. map <F5> :q!<CR>
  135. " map <F6> :make -C ~/Documents/resume cv<CR>
  136. " map <F7> :AutoSaveToggle<CR>
  137. map <F9> :VimtexCompile<CR>:VimtexView<CR>
  138. " map <F9> :VimtexCompile<CR>
  139. nnoremap <F10> :set paste<CR>"+p:set nopaste<CR>
  140. " }}} function keys "
  141. map <S-Enter> O<ESC>
  142. " swap text visually
  143. vnoremap <C-P> <Esc>`.``gvP``P
  144. " splits {{{ "
  145. nnoremap <C-Down> <C-W><C-J>
  146. nnoremap <C-Up> <C-W><C-K>
  147. nnoremap <C-Right> <C-W><C-L>
  148. nnoremap <C-Left> <C-W><C-H>
  149. " Maximize height/width.
  150. nnoremap <C-g> <C-W>_
  151. nnoremap <C-w> <C-W>|
  152. " }}} splits "
  153. " leader mappings {{{ "
  154. let mapleader="\<Space>"
  155. " replace vim-commentary Markdown comments with HTML
  156. nnoremap <leader>cmt :%s/>\(.*\)>/<!---\1-->/g<CR>
  157. " delete entire buffer
  158. nnoremap <leader>dg ggdG
  159. " delete line into system clipboard
  160. nnoremap <leader>D "+dd
  161. " delete entire buffer into system clipboard
  162. nnoremap <leader>DA "+ggdG
  163. " find merge conflicts
  164. nnoremap <leader>fc /[<>=\|]\{7\}<CR>
  165. " reload folds
  166. nnoremap <leader>ff :set foldmethod=marker<CR> zM
  167. " toggle search highlighting
  168. nnoremap <leader>h :set hlsearch! hlsearch?<CR>
  169. " help
  170. nnoremap <leader>he :help
  171. nnoremap <leader>ht :set tabstop=2 shiftwidth=2 expandtab<CR>
  172. nnoremap <leader>vhe :vert help
  173. " move cursor to middle of line
  174. nnoremap <leader>m :call cursor(0, len(getline('.'))/2)<CR>
  175. " apply normal command to selection
  176. vnoremap <leader>n q:anorm
  177. " don't wrap lines
  178. nnoremap <leader>nw :set nowrap<CR>
  179. " check if in neovim
  180. nnoremap <leader>nv :echo has('nvim')<CR>
  181. " Plug commands
  182. nnoremap <leader>pli :PlugInstall<CR>
  183. nnoremap <leader>plc :PlugClean<CR>
  184. nnoremap <leader>plu :PlugUpdate<CR>
  185. " don't break lines
  186. nnoremap <leader>py :set tw=0<CR>
  187. " replace in next x lines
  188. nnoremap <leader>r q:i.,.+s///g<ESC>Fsi
  189. " reload file
  190. nnoremap <leader>rf :e<CR>
  191. " replace in line
  192. nnoremap <leader>rl q:i.s///g<left><left><left>
  193. " replace in visual selection
  194. vnoremap <leader>r q:is///g<ESC>3ha
  195. " reload vim config
  196. nnoremap <leader>rv :source $MYVIMRC<CR>
  197. " replace in entire file
  198. nnoremap <leader>R q:i%s///g<ESC>2F/i
  199. " sort lines
  200. nnoremap <leader>so q:i.,.+sort<ESC>Fsi
  201. " set syntax to shell (for dotfiles)
  202. nnoremap <leader>sh :set syn=sh<CR>
  203. " open vimrc in vertical split
  204. nnoremap <leader>vv :vsp ~/.vimrc<CR>
  205. " format current line
  206. nnoremap <leader>ww Vgq
  207. " format this and next line
  208. nnoremap <leader>www Vjgq
  209. " copy next thing to system clipboard
  210. nnoremap <leader>y "+
  211. nnoremap <leader>Y "+Y
  212. " yank entire buffer
  213. nnoremap <leader>yg ggyG
  214. " toggle fold
  215. nnoremap <leader>z za
  216. " }}} leader mappings "
  217. " }}} Mappings "
  218. " (tex) Local Mappings {{{ "
  219. let maplocalleader="-"
  220. autocmd Filetype c inoremap <localleader>s struct pixel
  221. autocmd Filetype tex inoremap <localleader>bt \bowtie
  222. autocmd Filetype tex inoremap <localleader>c \checkmark
  223. autocmd Filetype tex inoremap <localleader>d \delta
  224. autocmd Filetype tex inoremap <localleader>D \Delta
  225. autocmd Filetype tex inoremap <localleader>e \exists
  226. autocmd Filetype tex inoremap <localleader>ep \epsilon
  227. autocmd Filetype tex inoremap <localleader>fa \forall
  228. autocmd Filetype tex inoremap <localleader>g \geq
  229. autocmd Filetype tex inoremap <localleader>i \in
  230. autocmd Filetype tex inoremap <localleader>l \leq
  231. autocmd Filetype tex inoremap <localleader>lr \Leftrightarrow
  232. " autocmd Filetype tex inoremap <localleader>n \neg
  233. autocmd Filetype tex inoremap <localleader>n \neq
  234. autocmd Filetype tex inoremap <localleader>N \mathbb{N}
  235. autocmd Filetype tex inoremap <localleader>q \qquad
  236. autocmd Filetype tex inoremap <localleader>r \rightarrow
  237. autocmd Filetype tex inoremap <localleader>R \Rightarrow
  238. autocmd Filetype tex inoremap <localleader>s \subset
  239. autocmd Filetype tex inoremap <localleader>st such that
  240. autocmd Filetype tex inoremap <localleader>S \Sigma
  241. autocmd Filetype tex inoremap <localleader>t \times
  242. " autocmd Filetype tex inoremap <localleader>T $T$
  243. autocmd Filetype tex inoremap <localleader>T \Theta
  244. " replace bars/underscores in URL
  245. autocmd Filetype tex inoremap <localleader>url :.s/\([-_]\)/\\\1/g<CR>
  246. autocmd Filetype tex inoremap <localleader>v \vee
  247. autocmd Filetype tex inoremap <localleader>w \wedge
  248. autocmd Filetype tex inoremap <localleader>x $x$-axis
  249. autocmd Filetype tex inoremap <localleader>y $y$-axis
  250. autocmd Filetype tex inoremap <localleader>Z \mathbb{Z}
  251. " par3
  252. autocmd Filetype tex inoremap <localleader>wx $w(x)$
  253. autocmd Filetype tex inoremap <localleader>tx $t(x)$
  254. autocmd Filetype md inoremap <localleader>x 0f[lRX
  255. " }}} Local Mappings "