1
0

nvimrc 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. " set the runtime path to include Vundle and initialize
  2. call plug#begin('~/.config/nvim/plugged')
  3. Plug 'neoclide/coc.nvim', { 'branch': 'release' }
  4. Plug 'ludovicchabant/vim-gutentags'
  5. Plug 'scrooloose/nerdtree'
  6. Plug 'Xuyuanp/nerdtree-git-plugin'
  7. Plug 'tpope/vim-fugitive'
  8. Plug 'airblade/vim-gitgutter'
  9. Plug 'whiteinge/diffconflicts'
  10. Plug 'mhinz/vim-startify'
  11. Plug 'altercation/vim-colors-solarized'
  12. Plug 'vim-airline/vim-airline'
  13. Plug 'vim-airline/vim-airline-themes'
  14. Plug 'suan/vim-instant-markdown'
  15. Plug 'tpope/vim-markdown'
  16. Plug 'nvie/vim-flake8'
  17. Plug 'SirVer/ultisnips'
  18. Plug 'octol/vim-cpp-enhanced-highlight'
  19. Plug 'junegunn/goyo.vim'
  20. Plug 'junegunn/limelight.vim'
  21. Plug 'lervag/vimtex'
  22. Plug 'ap/vim-css-color'
  23. Plug 'mattn/emmet-vim'
  24. Plug 'tpope/vim-commentary'
  25. Plug 'pangloss/vim-javascript', { 'for': 'javacript' }
  26. Plug 'tpope/vim-unimpaired'
  27. Plug 'tpope/vim-surround'
  28. Plug 'christoomey/vim-tmux-navigator'
  29. Plug 'roxma/vim-tmux-clipboard'
  30. Plug 'Chiel92/vim-autoformat'
  31. Plug 'keith/swift.vim'
  32. Plug 'snakemake/snakemake', {'rtp': 'misc/vim/'}
  33. Plug 'junegunn/vim-easy-align'
  34. Plug 'glench/vim-jinja2-syntax'
  35. Plug 'fatih/vim-go'
  36. Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
  37. Plug 'junegunn/fzf.vim'
  38. Plug 'KabbAmine/vCoolor.vim'
  39. Plug 'leafOfTree/vim-vue-plugin'
  40. " All of your Plugins must be added before the following line
  41. call plug#end() " required
  42. "
  43. " U S E R S E T U P
  44. "
  45. " Recursive file search
  46. set path+=**
  47. " Ignore some stuff esp. for ctrlP
  48. set wildignore+=*/node_modules/*,*/build*/*,*/InstallArea/*
  49. " Make watchdogs possible
  50. set backupcopy=yes
  51. " jump between split lines
  52. map j gj
  53. map k gk
  54. nnoremap <silent> <BS> :TmuxNavigateLeft<cr>
  55. "map mapleader / to (german layout)
  56. let mapleader = ","
  57. " execute current file
  58. nnoremap <leader>e :!'%:p'<CR>
  59. " Run `make` in current directory
  60. nnoremap <leader>m :!make<CR>
  61. " open build/*.pdf
  62. nnoremap <leader>o :!open build/*.pdf<CR>
  63. " open Nerdtree with CTRL+n
  64. map <C-n> :NERDTreeToggle<CR>
  65. " toggle background with ,i
  66. nnoremap <leader>i :let &background = (&background == "dark" ? "light" : "dark")<CR>
  67. " Open fzf file list
  68. nnoremap <silent> <expr> <Leader><Leader> (expand('%') =~ 'NERD_tree' ? "\<c-w>\<c-w>" : '').":Files\<cr>"
  69. nnoremap <silent> <Leader>b :Buffers<CR>
  70. nnoremap <silent> <Leader>t :Tags<CR>
  71. " :w for :W
  72. command W w
  73. command Wq wq
  74. command Q q
  75. command Qa qa
  76. command WQ wq
  77. " color scheme
  78. colo solarized
  79. set ai " Set auto inline on
  80. set number " Show line numbers
  81. syntax on " Set syntax highlighting on
  82. set tabstop=4 " width of tab
  83. " should be redundant after tabstop and expandtab,
  84. " but vim-snipmate is messing up (?)
  85. set softtabstop=4
  86. set shiftwidth=4
  87. set expandtab " use 'tabstop' spaces instead of tab
  88. set colorcolumn=80 " Bar hinting for 80 chars
  89. set breakindent "baby, yeah!
  90. set mouse=a " activate mouse support
  91. set relativenumber " aka :set rnu
  92. " searching
  93. set ignorecase " ignore case while searching
  94. nnoremap <C-s> :set hlsearch!<CR>
  95. " python
  96. let g:python3_host_prog = '~/.pyenv/versions/3.9.5/bin/python'
  97. " autoformatting
  98. let g:formatter_python = ['yapf']
  99. let g:formatter_yapf_style = 'pep8'
  100. " handling backupfiles
  101. set backupdir=~/.config/nvim/backup//
  102. set directory=~/.config/nvim/swap//
  103. set undodir=~/.config/nvim/undo//
  104. " NERDTree Configuration
  105. " hide some fileextenxions
  106. let NERDTreeIgnore = ['\.pyc$']
  107. " vim-fugitive
  108. " gdiff vertical instead of horizontal
  109. set diffopt+=vertical
  110. " Airline stuff
  111. let g:airline_powerline_fonts = 1
  112. let g:airline#extensions#tabline#enabled = 1
  113. let g:airline#extensions#tabline#buffer_nr_show = 1
  114. " multiple-cursors mapping
  115. let g:multi_cursor_use_default_mapping=0
  116. let g:multi_cursor_next_key='<C-d>'
  117. let g:multi_cursor_quit_key='<Esc>'
  118. " configure UltiSnips
  119. let g:UltiSnipsExpandTrigger='<C-j>'
  120. let g:UltiSnipsJumpForwardTrigger='<C-j>'
  121. let g:UltiSnipsJumpBackwardTrigger='<C-k>'
  122. " vCoolor config
  123. let g:vcoolor_map = '<C-c>'
  124. let g:vcool_ins_rgb_map = '' " Insert rgb color.
  125. let g:vcool_ins_hsl_map = '' " Insert hsl color.
  126. let g:vcool_ins_rgba_map = '' " Insert rgba color.
  127. " startify
  128. let g:startify_change_to_dir = 0
  129. let g:startify_change_to_vcs_root = 1
  130. let g:startify_fortune_use_unicode = 1
  131. " vim-javascript config
  132. let g:javascript_enable_domhtmlcss = 1
  133. " limelight+goyo settings, automatically fire up limelight with goyo
  134. let g:limelight_conceal_ctermfg = 'gray'
  135. let g:goyo_width = 85
  136. autocmd! User GoyoEnter Limelight
  137. autocmd! User GoyoLeave Limelight!
  138. " map `,g` to start goyo
  139. nnoremap <leader>g :Goyo<CR>
  140. " Enable emmet-vim just for html/css
  141. let g:user_emmet_isntall_global = 0
  142. autocmd FileType html,css,md EmmetInstall
  143. " configure flake8
  144. " bind `,f` to Flake8
  145. nnoremap <leader>f :call Flake8()<CR>
  146. let g:flake8_show_quickfix=1
  147. let g:flake8_show_in_gutter=1
  148. " instant markdown
  149. let g:instant_markdown_autostart = 0
  150. " activate mouse support
  151. set mouse=a
  152. set scrolloff=5
  153. " add some cpp-keywords
  154. syn keyword cppExceptions noexcept using
  155. " allow mouse clicks to change cursor position
  156. set noequalalways
  157. " list whitespaces and some other characters
  158. set listchars=tab:>-,trail:~
  159. set list
  160. " use latex flavour for plaintex files
  161. let g:tex_flavor = "latex"
  162. " set some default options for my personal latexmk
  163. let g:vimtex_compiler_progname="nvr"
  164. let g:vimtex_view_method = 'skim'
  165. " let g:vimtex_view_general_viewer = 'open'
  166. " let g:vimtex_view_general_options = '-a Skim'
  167. let g:vimtex_compiler_latexmk={
  168. \ 'options' : [
  169. \ '-lualatex',
  170. \ '-silent',
  171. \ '-synctex=1',
  172. \ '-interaction=nonstopmode',
  173. \ '-shell-escape',
  174. \ ],
  175. \ 'build_dir' : 'livepreview',
  176. \}
  177. let g:vimtex_quickfix_ignore_filters = [
  178. \ 'Marginpar on page',
  179. \]
  180. let g:vimtex_quickfix_autoclose_after_keystrokes = 5
  181. let g:vimtex_matchparen_enabled=0 " turn off folding to speed up things
  182. "
  183. " coc.nvim
  184. "
  185. " TextEdit might fail if hidden is not set.
  186. set hidden
  187. " Some servers have issues with backup files, see #649.
  188. " use them anyway
  189. " set nobackup
  190. " set nowritebackup
  191. " Give more space for displaying messages.
  192. " set cmdheight=2
  193. " Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
  194. " delays and poor user experience.
  195. set updatetime=300
  196. " Don't pass messages to |ins-completion-menu|.
  197. set shortmess+=c
  198. " Always show the signcolumn, otherwise it would shift the text each time
  199. " diagnostics appear/become resolved.
  200. if has("patch-8.1.1564")
  201. " Recently vim can merge signcolumn and number column into one
  202. set signcolumn=number
  203. else
  204. set signcolumn=yes
  205. endif
  206. " Use tab for trigger completion with characters ahead and navigate.
  207. " NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
  208. " other plugin before putting this into your config.
  209. inoremap <silent><expr> <TAB>
  210. \ pumvisible() ? "\<C-n>" :
  211. \ <SID>check_back_space() ? "\<TAB>" :
  212. \ coc#refresh()
  213. inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
  214. function! s:check_back_space() abort
  215. let col = col('.') - 1
  216. return !col || getline('.')[col - 1] =~# '\s'
  217. endfunction
  218. " Use <c-space> to trigger completion.
  219. if has('nvim')
  220. inoremap <silent><expr> <c-space> coc#refresh()
  221. else
  222. inoremap <silent><expr> <c-@> coc#refresh()
  223. endif
  224. " Use <cr> to confirm completion, `<C-g>u` means break undo chain at current
  225. " position. Coc only does snippet and additional edit on confirm.
  226. " <cr> could be remapped by other vim plugin, try `:verbose imap <CR>`.
  227. if exists('*complete_info')
  228. inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
  229. else
  230. inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
  231. endif
  232. " Use `[g` and `]g` to navigate diagnostics
  233. " Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
  234. nmap <silent> [g <Plug>(coc-diagnostic-prev)
  235. nmap <silent> ]g <Plug>(coc-diagnostic-next)
  236. " GoTo code navigation.
  237. nmap <silent> gd <Plug>(coc-definition)
  238. nmap <silent> gy <Plug>(coc-type-definition)
  239. nmap <silent> gi <Plug>(coc-implementation)
  240. nmap <silent> gr <Plug>(coc-references)
  241. " Use K to show documentation in preview window.
  242. nnoremap <silent> K :call <SID>show_documentation()<CR>
  243. function! s:show_documentation()
  244. if (index(['vim','help'], &filetype) >= 0)
  245. execute 'h '.expand('<cword>')
  246. else
  247. call CocAction('doHover')
  248. endif
  249. endfunction
  250. " Highlight the symbol and its references when holding the cursor.
  251. autocmd CursorHold * silent call CocActionAsync('highlight')
  252. " Symbol renaming.
  253. nmap <leader>rn <Plug>(coc-rename)
  254. " Formatting selected code.
  255. xmap <leader>f <Plug>(coc-format-selected)
  256. nmap <leader>f <Plug>(coc-format-selected)
  257. augroup mygroup
  258. autocmd!
  259. " Setup formatexpr specified filetype(s).
  260. autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
  261. " Update signature help on jump placeholder.
  262. autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
  263. augroup end
  264. " Applying codeAction to the selected region.
  265. " Example: `<leader>aap` for current paragraph
  266. xmap <leader>a <Plug>(coc-codeaction-selected)
  267. nmap <leader>a <Plug>(coc-codeaction-selected)
  268. " Remap keys for applying codeAction to the current buffer.
  269. nmap <leader>ac <Plug>(coc-codeaction)
  270. " Apply AutoFix to problem on the current line.
  271. nmap <leader>qf <Plug>(coc-fix-current)
  272. " Map function and class text objects
  273. " NOTE: Requires 'textDocument.documentSymbol' support from the language server.
  274. xmap if <Plug>(coc-funcobj-i)
  275. omap if <Plug>(coc-funcobj-i)
  276. xmap af <Plug>(coc-funcobj-a)
  277. omap af <Plug>(coc-funcobj-a)
  278. xmap ic <Plug>(coc-classobj-i)
  279. omap ic <Plug>(coc-classobj-i)
  280. xmap ac <Plug>(coc-classobj-a)
  281. omap ac <Plug>(coc-classobj-a)
  282. " Use CTRL-S for selections ranges.
  283. " Requires 'textDocument/selectionRange' support of LS, ex: coc-tsserver
  284. nmap <silent> <C-s> <Plug>(coc-range-select)
  285. xmap <silent> <C-s> <Plug>(coc-range-select)
  286. " Add `:Format` command to format current buffer.
  287. command! -nargs=0 Format :call CocAction('format')
  288. " Add `:Fold` command to fold current buffer.
  289. command! -nargs=? Fold :call CocAction('fold', <f-args>)
  290. " Add `:OR` command for organize imports of the current buffer.
  291. command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
  292. " Add (Neo)Vim's native statusline support.
  293. " NOTE: Please see `:h coc-status` for integrations with external plugins that
  294. " provide custom statusline: lightline.vim, vim-airline.
  295. set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
  296. " Mappings for CoCList
  297. " Show all diagnostics.
  298. nnoremap <silent><nowait> <space>a :<C-u>CocList diagnostics<cr>
  299. " Manage extensions.
  300. nnoremap <silent><nowait> <space>e :<C-u>CocList extensions<cr>
  301. " Show commands.
  302. nnoremap <silent><nowait> <space>c :<C-u>CocList commands<cr>
  303. " Find symbol of current document.
  304. nnoremap <silent><nowait> <space>o :<C-u>CocList outline<cr>
  305. " Search workspace symbols.
  306. nnoremap <silent><nowait> <space>s :<C-u>CocList -I symbols<cr>
  307. " Do default action for next item.
  308. nnoremap <silent><nowait> <space>j :<C-u>CocNext<CR>
  309. " Do default action for previous item.
  310. nnoremap <silent><nowait> <space>k :<C-u>CocPrev<CR>
  311. " Resume latest coc list.
  312. nnoremap <silent><nowait> <space>p :<C-u>CocListResume<CR>
  313. "
  314. " End COC
  315. "
  316. " Snakemake syntax
  317. au BufNewFile,BufRead Snakefile set syntax=snakemake
  318. au BufNewFile,BufRead *.rules set syntax=snakemake
  319. au BufNewFile,BufRead *.snakefile set syntax=snakemake
  320. au BufNewFile,BufRead *.snake set syntax=snakemake
  321. " golang
  322. let g:go_fmt_command = "goimports"
  323. " only for the e5 interactive machines
  324. let g:go_version_warning = 0
  325. " easy align
  326. vmap <Enter> <Plug>(EasyAlign)
  327. source $HOME/.config/nvim/local.vimrc