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.

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