Another copy of my dotfiles. Because I don't completely trust GitHub.
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.

223 lines
6.8 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. " XDG Base Directory Specification
  2. set runtimepath^=$XDG_CONFIG_HOME/vim
  3. set runtimepath+=$XDG_DATA_HOME/vim
  4. set runtimepath+=$XDG_CONFIG_HOME/vim/after
  5. set packpath^=$XDG_DATA_HOME/vim,$XDG_CONFIG_HOME/vim
  6. set packpath+=$XDG_CONFIG_HOME/vim/after,$XDG_DATA_HOME/vim/after
  7. let g:netrw_home = $XDG_DATA_HOME."/vim"
  8. call mkdir($XDG_DATA_HOME."/vim/spell", 'p')
  9. set viewdir=$XDG_DATA_HOME/vim/view | call mkdir(&viewdir, 'p')
  10. set backupdir=$XDG_CACHE_HOME/vim/backup | call mkdir(&backupdir, 'p')
  11. set directory=$XDG_CACHE_HOME/vim/swap | call mkdir(&directory, 'p')
  12. set undodir=$XDG_CACHE_HOME/vim/undo | call mkdir(&undodir, 'p')
  13. let s:MRU_File = $XDG_CACHE_HOME."/vim/mru"
  14. if !has('nvim') | set viminfofile=$XDG_CACHE_HOME/vim/viminfo | endif
  15. if has('nvim')
  16. source ~/.config/nvim/plugin/plugins.vim
  17. endif
  18. map <leader>c :w! \| !compiler "<c-r>%"<CR>
  19. " Set leader
  20. let mapleader = ","
  21. " Leader Mappings
  22. map <Leader>w :update<CR>
  23. map <Leader>q :qall<CR>
  24. map <Leader>gs :Gstatus<CR>
  25. " map Q to gq for line formatting cuz Q is useless
  26. nnoremap Q gq
  27. " Recently edited files
  28. map <Leader>h :History<CR>
  29. " CtrlP use FZF (faster!)
  30. nnoremap <C-p> :Files<CR>
  31. nnoremap <leader>b :Buffers<CR>
  32. noremap <leader>u :w<Home>silent <End> !urlview<CR>
  33. " System clipboard copy
  34. nnoremap <Leader>y "+y
  35. nnoremap <Leader>p "+p
  36. vnoremap <Leader>y "+y
  37. vnoremap <Leader>p "+p
  38. nnoremap <Leader>Y "+Y
  39. nnoremap <Leader>P "+P
  40. vnoremap <Leader>d "+d
  41. nnoremap <Leader>D "+D
  42. syntax on
  43. filetype plugin on
  44. set autoread " Auto reload changed files
  45. set wildmenu " Tab autocomplete in command mode
  46. set backspace=indent,eol,start " http://vi.stackexchange.com/a/2163
  47. set laststatus=2 " Show status line on startup
  48. set splitright " Open new splits to the right
  49. set splitbelow " Open new splits to the bottom
  50. set lazyredraw " Reduce the redraw frequency
  51. set ttyfast " Send more characters in fast terminals
  52. set nowrap " Don't wrap long lines
  53. set listchars=extends:→ " Show arrow if line continues rightwards
  54. set listchars+=precedes:← " Show arrow if line continues leftwards
  55. set nobackup nowritebackup noswapfile " Turn off backup files
  56. set noerrorbells novisualbell " Turn off visual and audible bells
  57. set expandtab shiftwidth=2 tabstop=2 " Two spaces for tabs everywhere
  58. set history=500
  59. set hidden " Save buffers automatically
  60. set ignorecase smartcase " Search queries intelligently set case
  61. set incsearch " Show search results as you type
  62. set timeoutlen=1000 ttimeoutlen=0 " Remove timeout when hitting escape
  63. set showcmd " Show size of visual selection
  64. set cmdheight=2
  65. set t_Co=256
  66. noh
  67. " set clipboard=unnamedplus
  68. set shortmess+=c
  69. set updatetime=300
  70. if has("patch-8.1.1564")
  71. " Recently vim can merge signcolumn and number column into one
  72. set signcolumn=number
  73. else
  74. set signcolumn=yes
  75. endif
  76. " Persistent undo
  77. set undodir=~/.local/share/vim/undo/
  78. set undofile
  79. set undolevels=1000
  80. set undoreload=10000
  81. " Ignored files/directories from autocomplete (and CtrlP)
  82. set wildignore+=*/tmp/*
  83. set wildignore+=*.so
  84. set wildignore+=*.zip
  85. set wildignore+=*/vendor/bundle/*
  86. set wildignore+=*/node_modules/
  87. " Enable autocompletion:
  88. set wildmode=longest,list,full
  89. " Disables automatic commenting on newline:
  90. autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
  91. vnoremap . :normal .<CR>
  92. map <leader>f :Goyo \| set linebreak<CR>
  93. map <leader>o :setlocal spell! spelllang=en_us<CR>
  94. set splitbelow splitright
  95. map <leader>s :!clear && shellcheck -x %<CR>
  96. cnoremap w!! execute 'silent! write !sudo tee % >/dev/null' <bar> edit!
  97. "-------------------------------------------------------------------------------
  98. " Interface
  99. "-------------------------------------------------------------------------------
  100. set number " Enable line numbers
  101. set scrolloff=5 " Leave 5 lines of buffer when scrolling
  102. set sidescrolloff=10 " Leave 10 characters of horizontal buffer when scrolling
  103. "-------------------------------------------------------------------------------
  104. " Colors & Formatting
  105. "-------------------------------------------------------------------------------
  106. let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
  107. let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
  108. if (has("termguicolors"))
  109. set termguicolors
  110. endif
  111. let g:material_theme_style='ocean-community'
  112. set background=dark
  113. try
  114. colorscheme material
  115. catch /^Vim\%((\a\+)\)\=:E185/
  116. colorscheme default
  117. endtry
  118. " Showcase comments in italics
  119. highlight Comment cterm=italic gui=italic
  120. " Easy tab navigation
  121. nnoremap <C-Left> :tabprevious<CR>
  122. nnoremap <C-Right> :tabnext<CR>
  123. " Find/replace
  124. vnoremap <C-r> "hy:%s/<C-r>h//g<left><left><left>
  125. " DON'T USE ARROWS NORMIE
  126. nnoremap <C-c> :echoe "Use Esc"<CR>
  127. nnoremap <Left> :echoe "Use h"<CR>
  128. nnoremap <Right> :echoe "Use l"<CR>
  129. nnoremap <Up> :echoe "Use k"<CR>
  130. nnoremap <Down> :echoe "Use j"<CR>
  131. " Split resize
  132. nnoremap <silent> <Leader>+ :exe "resize " . (winheight(0) * 3/2)<CR>
  133. nnoremap <silent> <Leader>- :exe "resize " . (winheight(0) * 2/3)<CR>
  134. " Make vim obey transparency
  135. hi! Normal ctermbg=NONE guibg=NONE
  136. hi! NonText ctermbg=NONE guibg=NONE
  137. "-------------------------------------------------------------------------------
  138. " Neovim-specific configurations
  139. if has('nvim')
  140. let $NVIM_TUI_ENABLE_TRUE_COLOR=1
  141. set termguicolors
  142. " Fix vim-tmux-navigator <C-h> https://git.io/viGRU
  143. nmap <BS> <C-W>h
  144. " Fix vim-tmux-navigator <C-h> https://git.io/vS5QH
  145. nmap <BS> :<C-u>TmuxNavigateLeft<CR>
  146. " The following require plugins to be loaded so they should only be set in neovim
  147. let g:vimtex_view_general_viewer = 'zathura'
  148. " Syntastic max file size for python
  149. let g:syntastic_python_pylint_post_args="--max-line-length=120"
  150. " Widths fot several plugins
  151. let g:goyo_width = 120 " Goyo
  152. let g:Tlist_WinWidth = 40 " Tlist
  153. endif
  154. " Don't clear clipboard on exit
  155. autocmd VimLeave * call system("xsel -ib", getreg('+'))
  156. " Useful for GDB debugging
  157. packadd termdebug
  158. " File Specific Settings
  159. if has("autocmd")
  160. " Use skeleton files
  161. augroup templates
  162. autocmd BufNewFile *.* silent! execute '0r ~/.local/share/vim/templates/skeleton.'.expand("<afile>:e")
  163. autocmd BufNewFile * %substitute#\[:VIM_EVAL:\]\(.\{-\}\)\[:END_EVAL:\]#\=eval(submatch(1))#ge
  164. augroup END
  165. autocmd BufWinLeave *.tex !texclear %:p " Run texclear on exit
  166. autocmd BufRead calcurse-note.* :set filetype=markdown " Use markdown for calcurse notes
  167. " Enable Goyo by default for mutt writing
  168. autocmd BufRead,BufNewFile /tmp/neomutt* let g:goyo_width=80
  169. autocmd BufRead,BufNewFile /tmp/neomutt* :Goyo | set bg=light
  170. autocmd BufRead,BufNewFile /tmp/neomutt* map ZZ :Goyo\|x!<CR>
  171. autocmd BufRead,BufNewFile /tmp/neomutt* map ZQ :Goyo\|q!<CR>
  172. endif