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.

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