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.

288 lines
6.4 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
  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 'catppuccin/vim'
  41. Plug 'lifepillar/vim-solarized8'
  42. Plug 'morhetz/gruvbox'
  43. Plug 'arcticicestudio/nord-vim'
  44. Plug 'junegunn/seoul256.vim'
  45. Plug 'junegunn/fzf'
  46. Plug 'junegunn/fzf.vim'
  47. Plug 'prabirshrestha/vim-lsp'
  48. Plug 'mattn/vim-lsp-settings'
  49. Plug 'prabirshrestha/asyncomplete.vim'
  50. Plug 'prabirshrestha/asyncomplete-lsp.vim'
  51. Plug 'Townk/vim-autoclose'
  52. Plug 'tpope/vim-fugitive'
  53. Plug 'vim-airline/vim-airline'
  54. Plug 'vim-airline/vim-airline-themes'
  55. Plug 'junegunn/goyo.vim'
  56. Plug 'junegunn/limelight.vim'
  57. call plug#end()
  58. " options
  59. set nu
  60. set rnu
  61. set mouse+=a
  62. set linebreak
  63. set shiftwidth=2
  64. set tabstop=2
  65. set softtabstop=2
  66. set expandtab
  67. set smarttab
  68. set shiftround
  69. set autoindent
  70. set textwidth=80
  71. set colorcolumn=80
  72. set nowrap
  73. set undodir=~/.vim/undofiles
  74. set undofile nohlsearch incsearch
  75. set scrolloff=7
  76. set wildmode=longest,list,full
  77. set wildmenu
  78. autocmd FileType tex,text set nosmarttab autoindent
  79. autocmd Filetype python set textwidth=0 formatprg=autopep8 shiftwidth=4 tabstop=4 softtabstop=4
  80. autocmd FileType c,cpp,slang set nosmarttab autoindent
  81. autocmd Filetype markdown set nosmarttab shiftwidth=4 tabstop=4 softtabstop=4 autoindent
  82. autocmd BufReadPost *
  83. \ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit'
  84. \ | exe "normal! g`\""
  85. \ | endif
  86. " Remaps
  87. nnoremap j gj
  88. nnoremap k gk
  89. nnoremap <C-h> <C-w>h
  90. nnoremap <C-j> <C-w>j
  91. nnoremap <C-k> <C-w>k
  92. nnoremap <C-l> <C-w>l
  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. inoremap <A-a> ā
  98. inoremap <A-e> ē
  99. inoremap <A-i> ī
  100. inoremap <A-o> ō
  101. inoremap <A-u> ū
  102. nnoremap <F12> :w<BAR>:!texbld run compile<CR>
  103. nnoremap <F5> :w<BAR>:!./test.sh<CR>
  104. vnoremap J :m '>+1<CR>gv=gv
  105. vnoremap K :m '<-2<CR>gv=gv
  106. nnoremap J mzJ`z
  107. nnoremap <C-d> <C-d>zz
  108. nnoremap <C-u> <C-u>zz
  109. nnoremap n nzzzv
  110. nnoremap N Nzzzv
  111. xnoremap <leader>p _dP
  112. vnoremap <leader>y +y
  113. nnoremap <leader>y +y
  114. nnoremap <leader>Y +Y
  115. nnoremap <leader>x :!chmod +x %:p<CR>
  116. nnoremap <leader>X :!chmod -x %<CR>
  117. nnoremap <leader>e :! %:p<CR>
  118. nnoremap <leader>1 1gt
  119. nnoremap <leader>2 2gt
  120. nnoremap <leader>3 3gt
  121. nnoremap <leader>4 4gt
  122. nnoremap <leader>5 5gt
  123. nnoremap <leader>6 6gt
  124. nnoremap <leader>7 7gt
  125. nnoremap <leader>8 8gt
  126. nnoremap <leader>9 9gt
  127. nnoremap <leader>c :tabclose<CR>
  128. nnoremap <leader>b :wprev<CR>
  129. nnoremap <leader>n :wnext<CR>
  130. " netrw
  131. nnoremap <C-n> :20Lexplore<CR>
  132. nnoremap <leader>pv :Explore<CR>
  133. " disable ex mode
  134. map q: <Nop>
  135. nnoremap Q <nop>
  136. " Plugin options must go at the bottom of the file.
  137. " install plugins
  138. if g:just_installed == 1
  139. echom 'Installing Plugins...'
  140. PlugInstall
  141. endif
  142. " Goyo and themes
  143. function! Catppuccin()
  144. set background=dark
  145. colorscheme catppuccin_frappe
  146. let g:airline_theme = "catppuccin_frappe"
  147. endfu
  148. function! SolarizedLight()
  149. colorscheme solarized8
  150. set background=light
  151. let g:airline_theme = "solarized"
  152. endfu
  153. function! SolarizedDark()
  154. colorscheme solarized8
  155. set background=dark
  156. let g:airline_theme = "solarized"
  157. let g:airline_solarized_bg='dark'
  158. endfu
  159. function! Gruvbox()
  160. set background=dark
  161. colorscheme gruvbox
  162. let g:airline_theme = "gruvbox"
  163. endfu
  164. function! Nord()
  165. set background=dark
  166. colorscheme nord
  167. let g:airline_theme = "nord"
  168. endfu
  169. function! Seoul256()
  170. let g:seoul256_background = 234
  171. let g:airline_theme = "seoul256"
  172. set background=dark
  173. colorscheme seoul256
  174. endfu
  175. if has('termguicolors')
  176. set termguicolors
  177. let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
  178. let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
  179. call Catppuccin()
  180. else
  181. call Seoul256()
  182. endif
  183. autocmd! User GoyoEnter Limelight
  184. autocmd! User GoyoLeave Limelight!
  185. let g:airline_powerline_fonts = 1
  186. let g:airline#extensions#tabline#enabled = 1
  187. nnoremap <leader>z :Goyo <CR>
  188. nnoremap <leader>gs :Git <CR>
  189. nnoremap <leader>ff :Files<CR>
  190. nnoremap <C-p> :GFiles<CR>
  191. " lsp
  192. set cot+=preview
  193. function! s:on_lsp_buffer_enabled() abort
  194. setlocal omnifunc=lsp#complete
  195. setlocal signcolumn=yes
  196. if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif
  197. nmap <buffer> gd <plug>(lsp-definition)
  198. nmap <buffer> gs <plug>(lsp-document-symbol-search)
  199. nmap <buffer> gS <plug>(lsp-workspace-symbol-search)
  200. nmap <buffer> gr <plug>(lsp-references)
  201. nmap <buffer> gi <plug>(lsp-implementation)
  202. nmap <buffer> gt <plug>(lsp-type-definition)
  203. nmap <buffer> <leader>rn <plug>(lsp-rename)
  204. nmap <buffer> [g <plug>(lsp-previous-diagnostic)
  205. nmap <buffer> ]g <plug>(lsp-next-diagnostic)
  206. nmap <buffer> K <plug>(lsp-hover)
  207. nnoremap <leader>ft :LspDocumentFormat<CR>
  208. let g:lsp_format_sync_timeout = 1000
  209. endfunction
  210. if exists('*prop_add') && has('patch-9.0.0178')
  211. let g:lsp_diagnostics_virtual_text_enabled = 1
  212. let g:lsp_diagnostics_virtual_text_align = "after"
  213. let g:lsp_diagnostics_virtual_text_padding_left = 5
  214. else
  215. let g:lsp_diagnostics_float_cursor = 1
  216. let g:lsp_diagnostics_float_delay = 200
  217. endif
  218. augroup lsp_install
  219. au!
  220. autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
  221. augroup END
  222. imap <c-space> <Plug>(asyncomplete_force_refresh)
  223. inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
  224. inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
  225. inoremap <expr> <cr> pumvisible() ? "\<C-y>\<cr>" : "\<cr>"
  226. autocmd! CompleteDone * if pumvisible() == 0 | pclose | endif