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.

325 lines
9.5 KiB

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