nvimrc 11 KB

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