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.

310 lines
8.8 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
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 <F8> :!clear && shellcheck %<CR>
  138. map <F9> :VimtexCompile<CR>:VimtexView<CR>
  139. " map <F9> :VimtexCompile<CR>
  140. nnoremap <F10> :set paste<CR>"+p:set nopaste<CR>
  141. " }}} function keys "
  142. map <S-Enter> O<ESC>
  143. " swap text visually
  144. vnoremap <C-P> <Esc>`.``gvP``P
  145. " splits {{{ "
  146. nnoremap <C-Down> <C-W><C-J>
  147. nnoremap <C-Up> <C-W><C-K>
  148. nnoremap <C-Right> <C-W><C-L>
  149. nnoremap <C-Left> <C-W><C-H>
  150. " Maximize height/width.
  151. nnoremap <C-g> <C-W>_
  152. nnoremap <C-w> <C-W>|
  153. " }}} splits "
  154. " leader mappings {{{ "
  155. let mapleader="\<Space>"
  156. " replace until end of line
  157. nnoremap <leader>c c$
  158. " delete entire buffer
  159. nnoremap <leader>d d$
  160. " delete entire buffer
  161. nnoremap <leader>dg ggdG
  162. " delete line into system clipboard
  163. nnoremap <leader>D "+dd
  164. " delete entire buffer into system clipboard
  165. nnoremap <leader>DA "+ggdG
  166. " find merge conflicts
  167. nnoremap <leader>fc /[<>=\|]\{7\}<CR>
  168. " reload folds
  169. nnoremap <leader>ff :set foldmethod=marker<CR> zM
  170. " toggle search highlighting
  171. nnoremap <leader>h :set hlsearch! hlsearch?<CR>
  172. " help
  173. nnoremap <leader>he :help
  174. nnoremap <leader>ht :set tabstop=2 shiftwidth=2 expandtab<CR>
  175. nnoremap <leader>vhe :vert help
  176. " move cursor to middle of line
  177. nnoremap <leader>m :call cursor(0, len(getline('.'))/2)<CR>
  178. " apply normal command to selection
  179. vnoremap <leader>n q:anorm
  180. " don't wrap lines
  181. nnoremap <leader>nw :set nowrap<CR>
  182. " check if in neovim
  183. nnoremap <leader>nv :echo has('nvim')<CR>
  184. " Plug commands
  185. nnoremap <leader>p "*p
  186. nnoremap <leader>pli :PlugInstall<CR>
  187. nnoremap <leader>plc :PlugClean<CR>
  188. nnoremap <leader>plu :PlugUpdate<CR>
  189. " don't break lines
  190. nnoremap <leader>py :set tw=0<CR>
  191. " reload file
  192. nnoremap <leader>r :e<CR>
  193. " replace in next x lines
  194. nnoremap <leader>re q:i.,.+s///g<ESC>Fsi
  195. " replace in line
  196. nnoremap <leader>rl q:i.s///g<left><left><left>
  197. " replace in visual selection
  198. vnoremap <leader>r q:is///g<ESC>3ha
  199. " reload vim config
  200. nnoremap <leader>rv :source $MYVIMRC<CR>
  201. " replace in entire file
  202. nnoremap <leader>R q:i%s///g<ESC>2F/i
  203. " run current file in shell
  204. nnoremap <leader>sh :!%:p<CR>
  205. " sort lines until end of file
  206. nnoremap <leader>so q:i.,$sort<CR>
  207. " sort lines
  208. nnoremap <leader>sol q:i.,.+sort<ESC>Fsi
  209. " set syntax to shell (for dotfiles)
  210. nnoremap <leader>sys :set syn=sh<CR>
  211. " open vimrc in vertical split
  212. nnoremap <leader>vv :vsp ~/.vimrc<CR>
  213. " format current line
  214. nnoremap <leader>ww Vgq
  215. " format this and next line
  216. nnoremap <leader>www Vjgq
  217. " copy next thing to system clipboard
  218. " nnoremap <leader>y "+
  219. " nnoremap <leader>Y "+Y
  220. nnoremap <leader>y y$
  221. " yank entire buffer
  222. nnoremap <leader>yg ggyG
  223. " toggle fold
  224. nnoremap <leader>z za
  225. " }}} leader mappings "
  226. " }}} Mappings "
  227. " (tex) Local Mappings {{{ "
  228. let maplocalleader="-"
  229. autocmd Filetype c inoremap <localleader>s struct pixel
  230. autocmd Filetype tex inoremap <localleader>bt \bowtie
  231. autocmd Filetype tex inoremap <localleader>c \checkmark
  232. autocmd Filetype tex inoremap <localleader>d \delta
  233. autocmd Filetype tex inoremap <localleader>D \Delta
  234. autocmd Filetype tex inoremap <localleader>e \exists
  235. autocmd Filetype tex inoremap <localleader>ep \epsilon
  236. autocmd Filetype tex inoremap <localleader>fa \forall
  237. autocmd Filetype tex inoremap <localleader>g \geq
  238. autocmd Filetype tex inoremap <localleader>i \in
  239. autocmd Filetype tex inoremap <localleader>l \leq
  240. autocmd Filetype tex inoremap <localleader>lr \Leftrightarrow
  241. " autocmd Filetype tex inoremap <localleader>n \neg
  242. autocmd Filetype tex inoremap <localleader>n \neq
  243. autocmd Filetype tex inoremap <localleader>N \mathbb{N}
  244. autocmd Filetype tex inoremap <localleader>q \qquad
  245. autocmd Filetype tex inoremap <localleader>r \rightarrow
  246. autocmd Filetype tex inoremap <localleader>R \Rightarrow
  247. autocmd Filetype tex inoremap <localleader>s \subset
  248. autocmd Filetype tex inoremap <localleader>st such that
  249. autocmd Filetype tex inoremap <localleader>S \Sigma
  250. autocmd Filetype tex inoremap <localleader>t \times
  251. " autocmd Filetype tex inoremap <localleader>T $T$
  252. autocmd Filetype tex inoremap <localleader>T \Theta
  253. " replace bars/underscores in URL
  254. autocmd Filetype tex inoremap <localleader>url :.s/\([-_]\)/\\\1/g<CR>
  255. autocmd Filetype tex inoremap <localleader>v \vee
  256. autocmd Filetype tex inoremap <localleader>w \wedge
  257. autocmd Filetype tex inoremap <localleader>x $x$-axis
  258. autocmd Filetype tex inoremap <localleader>y $y$-axis
  259. autocmd Filetype tex inoremap <localleader>Z \mathbb{Z}
  260. " par3
  261. autocmd Filetype tex inoremap <localleader>wx $w(x)$
  262. autocmd Filetype tex inoremap <localleader>tx $t(x)$
  263. autocmd Filetype md inoremap <localleader>x 0f[lRX
  264. " }}} Local Mappings "