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.

389 lines
11 KiB

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