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.

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