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.

318 lines
9.3 KiB

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