Dotfiles for different machines on different branches.
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.

247 lines
7.0 KiB

11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
7 months ago
11 months ago
11 months ago
11 months ago
7 months ago
  1. " Begin Plugin section
  2. if ! filereadable(expand('~/.config/nvim/autoload/plug.vim'))
  3. echo "Downloading junegunn/vim-plug to manage plugins..."
  4. silent !mkdir -p ~/.config/nvim/autoload/
  5. silent !curl "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" > ~/.config/nvim/autoload/plug.vim
  6. autocmd VimEnter * PlugInstall
  7. endif
  8. " Read files correctly
  9. autocmd BufRead,BufNewFile *.tex set filetype=tex
  10. autocmd BufRead,BufNewFile *.h set filetype=c
  11. call plug#begin('~/.local/share/nvim/plugged')
  12. Plug 'lervag/vimtex' , {'for' : 'tex'} " Tex library for autocompletion
  13. Plug 'donRaphaco/neotex' , {'for': 'tex'} " Asynchronous pdf rendering
  14. Plug 'scrooloose/nerdtree', {'on': 'NERDTreeToggle'} " Filetree
  15. Plug 'majutsushi/tagbar', {'on': 'TagbarToggle'} " Show tags
  16. Plug 'airblade/vim-gitgutter' " Git Upgrades
  17. Plug 'qpkorr/vim-renamer' " Bulk renamer
  18. Plug 'sirver/ultisnips' " Snippets
  19. Plug 'uiiaoo/java-syntax.vim' , {'for': 'java'} " Better syntax highlight for java than default
  20. Plug 'frazrepo/vim-rainbow' " Colorized matching brackets
  21. Plug 'junegunn/fzf.vim' " Quickly jump files using fzf
  22. Plug 'ryanoasis/vim-devicons' " Enable Icons for vim
  23. Plug 'rrethy/vim-hexokinase' , {'do': 'make hexokinase'} " Color Preview
  24. Plug 'tomasiser/vim-code-dark' " adding colorscheme
  25. Plug 'tpope/vim-surround' " Help for quotes/parantheses
  26. Plug 'alvan/vim-closetag' " Auto close HTML tags
  27. Plug 'neoclide/coc.nvim', {'do': 'yarn install --frozen-lockfile'}
  28. call plug#end()
  29. " Coc
  30. inoremap <silent><expr> <TAB>
  31. \ pumvisible() ? "\<C-n>" :
  32. \ <SID>check_back_space() ? "\<TAB>" :
  33. \ coc#refresh()
  34. inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
  35. function! s:check_back_space() abort
  36. let col = col('.') - 1
  37. return !col || getline('.')[col - 1] =~# '\s'
  38. endfunction
  39. let g:coc_global_extensions = [
  40. \ 'coc-java',
  41. \ 'coc-python',
  42. \ 'coc-vimtex',
  43. \ ]
  44. if has('nvim')
  45. inoremap <silent><expr> <c-space> coc#refresh()
  46. else
  47. inoremap <silent><expr> <c-@> coc#refresh()
  48. endif
  49. inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
  50. \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
  51. nmap <silent> gd <Plug>(coc-definition)
  52. nmap <silent> gy <Plug>(coc-type-definition)
  53. nmap <silent> gi <Plug>(coc-implementation)
  54. nmap <silent> gr <Plug>(coc-references)
  55. nnoremap <silent> K :call <SID>show_documentation()<CR>
  56. function! s:show_documentation()
  57. if (index(['vim','help'], &filetype) >= 0)
  58. execute 'h '.expand('<cword>')
  59. elseif (coc#rpc#ready())
  60. call CocActionAsync('doHover')
  61. else
  62. execute '!' . &keywordprg . " " . expand('<cword>')
  63. endif
  64. endfunction
  65. autocmd CursorHold * silent call CocActionAsync('highlight')
  66. nmap <leader>rn <Plug>(coc-rename)
  67. xmap <leader>f <Plug>(coc-format-selected)
  68. nmap <leader>f <Plug>(coc-format-selected)
  69. augroup mygroup
  70. autocmd!
  71. autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
  72. autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
  73. augroup end
  74. set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
  75. " Colorscheme
  76. colorscheme codedark
  77. " Rainbow
  78. au FileType,BufNewFile,BufRead java,c,cpp,py,h call rainbow#load()
  79. " Ultisnippets
  80. let g:UltiSnipsExpandTrigger="<alt-j>"
  81. " Tagbar
  82. map <F3> :TagbarToggle<CR>
  83. " Nerdtree
  84. map <F2> :NERDTreeToggle<CR>
  85. autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
  86. let g:NERDTreeWinPos = "left"
  87. " Neotex
  88. let g:neotex_enabled = 2
  89. " CoVim
  90. let CoVim_default_name = "TiynGER"
  91. let CoVim_default_port = "7000"
  92. " Hexokinase
  93. let g:Hexokinase_refreshEvents = ['InsertLeave']
  94. let g:Hexokinase_optInPatterns = [
  95. \ 'full_hex',
  96. \ 'triple_hex',
  97. \ 'rgb',
  98. \ 'rgba',
  99. \ 'hsl',
  100. \ 'hsla',
  101. \ 'color_names'
  102. \]
  103. let g:Hexokinase_highlighters = ['backgroundfull']
  104. autocmd VimEnter * HexokinaseTurnOn
  105. " Vim-Closetag
  106. let g:closetag_filenames = '*.html,*.xhtml,*.phtml'
  107. let g:closetag_xhtml_filenames = '*.xhtml,*.jsx'
  108. let g:closetag_filetypes = 'html,xhtml,phtml'
  109. let g:closetag_xhtml_filetypes = 'xhtml,jsx'
  110. let g:closetag_emptyTags_caseSensitive = 1
  111. let g:closetag_regions = {
  112. \ 'typescript.tsx': 'jsxRegion,tsxRegion',
  113. \ 'javascript.jsx': 'jsxRegion',
  114. \ }
  115. let g:closetag_shortcut = '>'
  116. let g:closetag_close_shortcut = '<leader>>'
  117. " End Plugin section
  118. let mapleader =","
  119. set go=a
  120. " Enable mouse for all modes
  121. set mouse=a
  122. set clipboard+=unnamedplus
  123. " Enable command completion
  124. set wildmode=longest,list,full
  125. " Setting Tab-length
  126. set expandtab
  127. set softtabstop=4
  128. set shiftwidth=4
  129. " Splits open at the bottom and right, which is non-retarded, unlike vim defaults.
  130. set splitbelow splitright
  131. " Disable case sensitive matching
  132. set ignorecase
  133. " Enable nocompatible mode
  134. set nocompatible
  135. " Enable Plugins
  136. filetype plugin on
  137. " Enable syntax highlighting
  138. syntax on
  139. " Enable true colors
  140. set termguicolors
  141. " Set utf-8 encoding
  142. set encoding=utf-8
  143. " Show relative numbers on left side
  144. set number relativenumber
  145. " Speedup vim with long lines
  146. set ttyfast
  147. set lazyredraw
  148. " TextEdit might fail without hidden
  149. set hidden
  150. " Disable Backupfiles for Lsp
  151. set nobackup
  152. set nowritebackup
  153. " Dont pass messages to ins-completion-menu
  154. set shortmess+=c
  155. " Always show the signcolumn, otherwise it would shift the text each time
  156. " diagnostics appear/become resolved.
  157. if has("patch-8.1.1564")
  158. " Recently vim can merge signcolumn and number column into one
  159. set signcolumn=number
  160. else
  161. set signcolumn=yes
  162. endif
  163. " enable persistent undo
  164. if has('persistent_undo')
  165. set undofile
  166. set undodir=$XDG_CACHE_HOME/vim/undo
  167. endif
  168. " Delete trailing whitespaces on save
  169. fun! TrimWhitespace()
  170. let l:save = winsaveview()
  171. keeppatterns %s/\s\+$//e
  172. call winrestview(l:save)
  173. endfun
  174. autocmd BufWritePre * :call TrimWhitespace()
  175. " Disables automatic commenting on newline:
  176. autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
  177. " Clean LaTex build files
  178. autocmd VimLeave *.tex !texclear %
  179. " Mapping Dictionaries
  180. map <F5> :setlocal spell! spelllang=de_de<CR>
  181. map <F6> :set spelllang=en_us<CR>
  182. " Compiler for languages
  183. map <leader>c :w! \| !compiler <c-r>%<CR>
  184. " Open corresponding file (pdf/html/...)
  185. map <leader>p :!opout <c-r>%<CR><CR>
  186. " Shortcut for split navigation
  187. map <C-h> <C-w>h
  188. map <C-j> <C-w>j
  189. map <C-k> <C-w>k
  190. map <C-l> <C-w>l
  191. " Copy selected text to system clipboard (requires gvim/nvim/vim-x11 installed):
  192. map <C-p> "+P
  193. vnoremap <C-c> "+y
  194. " Save file as sudo on files that require root permission
  195. cnoremap w!! execute 'silent! write !sudo tee % >/dev/null' <bar> edit!
  196. " Alias for replacing
  197. nnoremap S :%s//gI<Left><Left><Left>
  198. " Start Formatting section
  199. au FileType python setlocal formatprg=autopep8\ -
  200. au FileType java setlocal formatprg=astyle\ --indent=spaces=2\ --style=google
  201. autocmd FileType java setlocal shiftwidth=2 softtabstop=2
  202. au FileType c setlocal formatprg=astyle\ --mode=c
  203. au FileType tex,latex setlocal formatprg=latexindent\ -
  204. autocmd FileType java,python,c,tex,latex noremap <F8> gggqG
  205. au FileType markdown noremap <F8> :silent %!prettier --stdin-filepath % <CR>
  206. " End Formatting section