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.

458 lines
14 KiB

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