self-bootstrapping vimrc's
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.

306 lines
6.9 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. filetype plugin indent on
  2. filetype on
  3. syntax on
  4. set nocompatible hidden laststatus=2
  5. set backspace=indent,eol,start
  6. let g:mapleader=" "
  7. let g:just_installed = 0
  8. function! InstallPlug()
  9. if !filereadable(expand("~/.vim/autoload/plug.vim"))
  10. " try to install plug using curl and wget
  11. " If installation succeeds, we should source vim plug.
  12. if !executable('git')
  13. echom 'git not found.'
  14. finish
  15. endif
  16. if executable('curl')
  17. let result = system('curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim')
  18. if v:shell_error == 0
  19. let g:just_installed = 1
  20. return
  21. endif
  22. endif
  23. echom 'curl failed, trying wget. ' . result
  24. if executable('wget') && executable('mkdir')
  25. let result = system('mkdir -p ~/.vim/autoload && wget -O ~/.vim/autoload/plug.vim https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim')
  26. if v:shell_error == 0
  27. let g:just_installed = 1
  28. return
  29. endif
  30. endif
  31. echom 'wget failed too. ' . result
  32. finish
  33. endif
  34. endfu
  35. call InstallPlug()
  36. if g:just_installed == 1
  37. source ~/.vim/autoload/plug.vim
  38. endif
  39. call plug#begin()
  40. Plug 'sheerun/vim-polyglot'
  41. Plug 'ap/vim-css-color'
  42. Plug 'bagrat/vim-buffet'
  43. Plug 'catppuccin/vim'
  44. Plug 'phanviet/vim-monokai-pro'
  45. Plug 'lifepillar/vim-solarized8'
  46. Plug 'morhetz/gruvbox'
  47. Plug 'arcticicestudio/nord-vim'
  48. Plug 'junegunn/seoul256.vim'
  49. Plug 'junegunn/fzf'
  50. Plug 'junegunn/fzf.vim'
  51. Plug 'prabirshrestha/vim-lsp'
  52. Plug 'mattn/vim-lsp-settings'
  53. Plug 'prabirshrestha/asyncomplete.vim'
  54. Plug 'prabirshrestha/asyncomplete-lsp.vim'
  55. Plug 'Townk/vim-autoclose'
  56. Plug 'tpope/vim-fugitive'
  57. Plug 'vim-airline/vim-airline'
  58. Plug 'vim-airline/vim-airline-themes'
  59. Plug 'junegunn/goyo.vim'
  60. Plug 'junegunn/limelight.vim'
  61. call plug#end()
  62. " options
  63. set nu
  64. set rnu
  65. set mouse+=a
  66. set linebreak
  67. set shiftwidth=2
  68. set tabstop=2
  69. set softtabstop=2
  70. set expandtab
  71. set smarttab
  72. set shiftround
  73. set autoindent
  74. set textwidth=80
  75. set colorcolumn=80
  76. set nowrap
  77. set undodir=~/.vim/undofiles
  78. set undofile nohlsearch incsearch
  79. set scrolloff=7
  80. set wildmode=longest,list,full
  81. set wildmenu
  82. autocmd FileType tex,text set nosmarttab autoindent
  83. autocmd Filetype python set textwidth=0 formatprg=autopep8 shiftwidth=4 tabstop=4 softtabstop=4
  84. autocmd FileType c,cpp,slang set nosmarttab autoindent
  85. autocmd Filetype markdown set nosmarttab shiftwidth=4 tabstop=4 softtabstop=4 autoindent
  86. autocmd BufReadPost *
  87. \ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit'
  88. \ | exe "normal! g`\""
  89. \ | endif
  90. " Remaps
  91. nnoremap j gj
  92. nnoremap k gk
  93. nnoremap <C-h> <C-w>h
  94. nnoremap <C-j> <C-w>j
  95. nnoremap <C-k> <C-w>k
  96. nnoremap <C-l> <C-w>l
  97. nnoremap <C-h> <C-w>h
  98. nnoremap <C-j> <C-w>j
  99. nnoremap <C-k> <C-w>k
  100. nnoremap <C-l> <C-w>l
  101. inoremap <A-a> ā
  102. inoremap <A-e> ē
  103. inoremap <A-i> ī
  104. inoremap <A-o> ō
  105. inoremap <A-u> ū
  106. nnoremap <F12> :w<BAR>:!texbld run compile<CR>
  107. nnoremap <F5> :w<BAR>:!./test.sh<CR>
  108. vnoremap J :m '>+1<CR>gv=gv
  109. vnoremap K :m '<-2<CR>gv=gv
  110. nnoremap J mzJ`z
  111. nnoremap <C-d> <C-d>zz
  112. nnoremap <C-u> <C-u>zz
  113. nnoremap n nzzzv
  114. nnoremap N Nzzzv
  115. xnoremap <leader>p _dP
  116. vnoremap <leader>y +y
  117. nnoremap <leader>y +y
  118. nnoremap <leader>Y +Y
  119. nnoremap <leader>x :!chmod +x %:p<CR>
  120. nnoremap <leader>X :!chmod -x %<CR>
  121. nnoremap <leader>e :! %:p<CR>
  122. nmap <leader>1 <Plug>BuffetSwitch(1)
  123. nmap <leader>2 <Plug>BuffetSwitch(2)
  124. nmap <leader>3 <Plug>BuffetSwitch(3)
  125. nmap <leader>4 <Plug>BuffetSwitch(4)
  126. nmap <leader>5 <Plug>BuffetSwitch(5)
  127. nmap <leader>6 <Plug>BuffetSwitch(6)
  128. nmap <leader>7 <Plug>BuffetSwitch(7)
  129. nmap <leader>8 <Plug>BuffetSwitch(8)
  130. nmap <leader>9 <Plug>BuffetSwitch(9)
  131. nmap <leader>0 <Plug>BuffetSwitch(10)
  132. nnoremap <leader>c :Bw<CR>
  133. nnoremap <leader>C :Bw!<CR>
  134. nnoremap <leader>b :wprev<CR>
  135. nnoremap <leader>n :wnext<CR>
  136. " netrw
  137. nnoremap <C-n> :20Lexplore<CR>
  138. nnoremap <leader>pv :Explore<CR>
  139. " tmux
  140. let s:tmux=$TMUX
  141. if s:tmux != ''
  142. nnoremap <C-f> <cmd>!tmuxs<CR>
  143. endif
  144. " disable accidental ex mode
  145. nnoremap Q <nop>
  146. " Plugin options must go at the bottom of the file.
  147. " install plugins
  148. if g:just_installed == 1
  149. echom 'Installing Plugins...'
  150. PlugInstall
  151. endif
  152. " Goyo and themes
  153. function! Catppuccin()
  154. set background=dark
  155. colorscheme catppuccin_mocha
  156. let g:airline_theme = "catppuccin_mocha"
  157. endfu
  158. function! SolarizedLight()
  159. colorscheme solarized8
  160. set background=light
  161. let g:airline_theme = "solarized"
  162. endfu
  163. function! SolarizedDark()
  164. colorscheme solarized8
  165. set background=dark
  166. let g:airline_theme = "solarized"
  167. let g:airline_solarized_bg='dark'
  168. endfu
  169. function! Gruvbox()
  170. set background=dark
  171. colorscheme gruvbox
  172. let g:airline_theme = "gruvbox"
  173. endfu
  174. function! MonokaiPro()
  175. set background=dark
  176. colorscheme monokai_pro
  177. let g:airline_theme = "base16_monokai"
  178. endfu
  179. function! Nord()
  180. set background=dark
  181. colorscheme nord
  182. let g:airline_theme = "nord"
  183. endfu
  184. function! Seoul256()
  185. let g:seoul256_background = 234
  186. let g:airline_theme = "seoul256"
  187. set background=dark
  188. colorscheme seoul256
  189. endfu
  190. if has('termguicolors')
  191. set termguicolors
  192. let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
  193. let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
  194. call Catppuccin()
  195. else
  196. call Seoul256()
  197. endif
  198. autocmd! User GoyoEnter Limelight
  199. autocmd! User GoyoLeave Limelight!
  200. let g:airline_powerline_fonts = 1
  201. "let g:airline#extensions#tabline#enabled = 1
  202. nnoremap <leader>z :Goyo <CR>
  203. nnoremap <leader>gs :Git <CR>
  204. nnoremap <leader>ff :Files<CR>
  205. nnoremap <C-p> :GFiles<CR>
  206. " lsp
  207. set cot+=preview
  208. function! s:on_lsp_buffer_enabled() abort
  209. setlocal omnifunc=lsp#complete
  210. setlocal signcolumn=yes
  211. if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif
  212. nmap <buffer> gd <plug>(lsp-definition)
  213. nmap <buffer> gs <plug>(lsp-document-symbol-search)
  214. nmap <buffer> gS <plug>(lsp-workspace-symbol-search)
  215. nmap <buffer> gr <plug>(lsp-references)
  216. nmap <buffer> gi <plug>(lsp-implementation)
  217. nmap <buffer> gt <plug>(lsp-type-definition)
  218. nmap <buffer> <leader>rn <plug>(lsp-rename)
  219. nmap <buffer> [g <plug>(lsp-previous-diagnostic)
  220. nmap <buffer> ]g <plug>(lsp-next-diagnostic)
  221. nmap <buffer> K <plug>(lsp-hover)
  222. nnoremap <leader>ft :LspDocumentFormat<CR>
  223. let g:lsp_format_sync_timeout = 1000
  224. endfunction
  225. if exists('*prop_add') && has('patch-9.0.0178')
  226. let g:lsp_diagnostics_virtual_text_enabled = 1
  227. let g:lsp_diagnostics_virtual_text_align = "after"
  228. let g:lsp_diagnostics_virtual_text_padding_left = 5
  229. else
  230. let g:lsp_diagnostics_float_cursor = 1
  231. let g:lsp_diagnostics_float_delay = 200
  232. endif
  233. augroup lsp_install
  234. au!
  235. autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
  236. augroup END
  237. imap <c-space> <Plug>(asyncomplete_force_refresh)
  238. inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
  239. inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
  240. inoremap <expr> <cr> pumvisible() ? "\<C-y>\<cr>" : "\<cr>"
  241. autocmd! CompleteDone * if pumvisible() == 0 | pclose | endif