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.

390 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. " find alias
  204. nnoremap <leader>a /^ <Left>
  205. " replace until end of line
  206. nnoremap <leader>c c$
  207. " delete entire buffer
  208. nnoremap <leader>d d$
  209. " delete entire buffer
  210. nnoremap <leader>dg ggdG
  211. " delete line into system clipboard
  212. nnoremap <leader>D "+dd
  213. " delete entire buffer into system clipboard
  214. nnoremap <leader>DA "+ggdG
  215. " find copied text
  216. nnoremap <leader>f q/p<CR>
  217. " find merge conflicts
  218. nnoremap <leader>fc /[<>=\|]\{7\}<CR>
  219. " reload folds
  220. nnoremap <leader>fmi :set foldmethod=indent<CR> zM
  221. nnoremap <leader>fmm :set foldmethod=marker<CR> zM
  222. " add marker foldmethod modeline
  223. nnoremap <leader>fi :YcmCompleter FixIt<CR>
  224. " find copied text
  225. nnoremap <leader>ft /TODO<CR>
  226. nnoremap <leader>g :YcmCompleter GoTo<CR>
  227. " vimdiff split
  228. nnoremap <leader>gd :Gvdiff HEAD
  229. " toggle search highlighting
  230. nnoremap <leader>h :set hlsearch! hlsearch?<CR>
  231. " help
  232. nnoremap <leader>he :help
  233. nnoremap <leader>ht :set tabstop=2 shiftwidth=2 expandtab<CR>
  234. nnoremap <leader>vhe :vert help
  235. " format current line
  236. nnoremap <leader>l Vgq
  237. " format this and next line
  238. nnoremap <leader>ll Vjgq
  239. " move cursor to middle of line
  240. nnoremap <leader>m :call cursor(0, len(getline('.'))/2)<CR>
  241. " apply normal command to selection
  242. vnoremap <leader>n q:anorm
  243. " don't wrap lines
  244. nnoremap <leader>nw :set nowrap<CR>
  245. " check if in neovim
  246. nnoremap <leader>nv :echo has('nvim')<CR>
  247. " Plug commands
  248. nnoremap <leader>p "*p
  249. nnoremap <leader>pli :PlugInstall<CR>
  250. nnoremap <leader>plc :PlugClean<CR>
  251. nnoremap <leader>plu :PlugUpdate<CR>
  252. " don't break lines
  253. nnoremap <leader>py :set tw=0<CR>
  254. " replace in next x lines
  255. nnoremap <leader>r q:i.,.+s///g<ESC>Fsi
  256. " replace in line
  257. nnoremap <leader>rl q:i.s///g<left><left><left>
  258. " replace in visual selection
  259. vnoremap <leader>r q:is///g<ESC>3ha
  260. " reload vim config
  261. nnoremap <leader>rv :source $MYVIMRC<CR>
  262. " replace in entire file
  263. nnoremap <leader>R q:i%s///g<ESC>2F/i
  264. vnoremap <leader>s :sort<CR>
  265. nnoremap <leader>sc :set spell spelllang=en_us<CR>
  266. " run current file in shell
  267. nnoremap <leader>sh :!%:p
  268. " sort lines until end of file
  269. nnoremap <leader>so q:i.,$sort<CR>
  270. " sort lines
  271. nnoremap <leader>sol q:i.,.+sort<ESC>Fsi
  272. " set syntax to shell (for dotfiles)
  273. nnoremap <leader>sys :set syn=sh<CR>
  274. vnoremap <leader>t :!tac<CR>
  275. " open vimrc in vertical split
  276. nnoremap <leader>vv :vsp ~/.vimrc<CR>
  277. " copy next thing to system clipboard
  278. " nnoremap <leader>y "+
  279. " nnoremap <leader>Y "+Y
  280. nnoremap <leader>y y$
  281. " yank entire buffer
  282. nnoremap <leader>yg ggyG
  283. " toggle fold
  284. nnoremap <leader>z za
  285. " }}} leader mappings "
  286. " }}} Mappings "
  287. " Local Mappings {{{ "
  288. let maplocalleader="\\"
  289. " tex {{{ "
  290. autocmd Filetype tex inoremap <localleader>bt \bowtie
  291. autocmd Filetype tex inoremap <localleader>c \checkmark
  292. autocmd Filetype tex inoremap <localleader>d \delta
  293. autocmd Filetype tex inoremap <localleader>D \Delta
  294. autocmd Filetype tex inoremap <localleader>e \exists
  295. autocmd Filetype tex inoremap <localleader>ep \epsilon
  296. autocmd Filetype tex inoremap <localleader>fa \forall
  297. autocmd Filetype tex inoremap <localleader>g \geq
  298. autocmd Filetype tex inoremap <localleader>i \in
  299. autocmd Filetype tex inoremap <localleader>l \leq
  300. autocmd Filetype tex inoremap <localleader>lr \Leftrightarrow
  301. " autocmd Filetype tex inoremap <localleader>n \neg
  302. autocmd Filetype tex inoremap <localleader>n \neq
  303. autocmd Filetype tex inoremap <localleader>N \mathbb{N}
  304. autocmd Filetype tex inoremap <localleader>q \qquad
  305. autocmd Filetype tex inoremap <localleader>r \rightarrow
  306. autocmd Filetype tex inoremap <localleader>R \Rightarrow
  307. autocmd Filetype tex inoremap <localleader>s \subset
  308. autocmd Filetype tex inoremap <localleader>st such that
  309. autocmd Filetype tex inoremap <localleader>S \Sigma
  310. autocmd Filetype tex inoremap <localleader>t \times
  311. " autocmd Filetype tex inoremap <localleader>T $T$
  312. autocmd Filetype tex inoremap <localleader>T \Theta
  313. " replace bars/underscores in URL
  314. autocmd Filetype tex inoremap <localleader>url :.s/\([-_]\)/\\\1/g<CR>
  315. autocmd Filetype tex inoremap <localleader>v \vee
  316. autocmd Filetype tex inoremap <localleader>w \wedge
  317. autocmd Filetype tex inoremap <localleader>x $x$-axis
  318. autocmd Filetype tex inoremap <localleader>y $y$-axis
  319. autocmd Filetype tex inoremap <localleader>Z \mathbb{Z}
  320. " par3
  321. autocmd Filetype tex inoremap <localleader>wx $w(x)$
  322. autocmd Filetype tex inoremap <localleader>tx $t(x)$
  323. " }}} tex "
  324. autocmd Filetype c inoremap <localleader>uc unsigned char
  325. autocmd BufNewFile,BufRead *.h nnoremap <localleader>x 0iextern <Esc>f{hc$;<Esc>
  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 "