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.

417 lines
12 KiB

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