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.

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