let mapleader ="," """ Begin Plugin section if ! filereadable(expand('~/.config/nvim/autoload/plug.vim')) echo "Downloading junegunn/vim-plug to manage plugins..." silent !mkdir -p ~/.config/nvim/autoload/ silent !curl "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" > ~/.config/nvim/autoload/plug.vim autocmd VimEnter * PlugInstall endif call plug#begin('~/.local/share/nvim/plugged') Plug 'airblade/vim-gitgutter' " git upgrades Plug 'alvan/vim-closetag' " auto close HTML tags Plug 'donRaphaco/neotex' , {'for': 'tex'} " asynchronous pdf rendering for pdf Plug 'fatih/vim-go' , {'for': 'go'} " better support for golang Plug 'hrsh7th/cmp-buffer' " autocompletion bridge for buffer Plug 'hrsh7th/cmp-path' " autocompletion bridge for filesystem Plug 'hrsh7th/nvim-cmp' " autocompletion Plug 'hrsh7th/cmp-nvim-lsp' " autocompletion bridge to lsp Plug 'itchyny/lightline.vim' " fancy statusline Plug 'junegunn/fzf.vim' " quickly jump files using fzf Plug 'luochen1990/rainbow' " colorized matching brackets Plug 'majutsushi/tagbar', {'on': 'TagbarToggle'} " show tags Plug 'mattesgroeger/vim-bookmarks' " Set Bookmarks Plug 'neovim/nvim-lspconfig' " Language server client Plug 'qpkorr/vim-renamer' " bulk renamer Plug 'raimondi/delimitmate' " automatic closing of brackets Plug 'rrethy/vim-hexokinase' , {'do': 'make hexokinase'} " color Preview Plug 'ryanoasis/vim-devicons' " enable icons for vim Plug 'scrooloose/nerdtree', {'on': 'NERDTreeToggle'} " filetree Plug 'tiyn/vim-tccs' " custom colorscheme Plug 'tpope/vim-fugitive' " git wrapper Plug 'tpope/vim-surround' " help for quotes/parantheses Plug 'uiiaoo/java-syntax.vim' , {'for': 'java'} " better syntax highlight for java than default Plug 'zah/nim.vim' , {'for': 'nim'} " Highlighting for nim call plug#end() " alvan/vim-closetag let g:closetag_filenames = '*.html,*.xhtml,*.phtml' let g:closetag_xhtml_filenames = '*.xhtml,*.jsx' let g:closetag_filetypes = 'html,xhtml,phtml' let g:closetag_xhtml_filetypes = 'xhtml,jsx' let g:closetag_emptyTags_caseSensitive = 1 let g:closetag_regions = { \ 'typescript.tsx': 'jsxRegion,tsxRegion', \ 'javascript.jsx': 'jsxRegion', \ } let g:closetag_shortcut = '>' let g:closetag_close_shortcut = '>' " donRaphaco/neotex let g:neotex_enabled = 2 " fatih/vim-go let g:go_def_mapping_enabled = 0 " itchyny/lightline.vim let g:lightline = { 'colorscheme': 'tccs'} " junegunn/fzf.vim let $FZF_DEFAULT_COMMAND = 'find . ~ -type f' nmap :FZF " luochen1990/rainbow let g:rainbow_active = 1 let g:rainbow_conf = { \ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick'], \ 'ctermfgs': ['lightblue', 'lightyellow', 'lightcyan', 'lightmagenta'], \ 'guis': [''], \ 'cterms': [''], \ 'operators': '_,_', \ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'], \ 'separately': { \ '*': {}, \ 'markdown': { \ 'parentheses_options': 'containedin=markdownCode contained', \ }, \ 'lisp': { \ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick', 'darkorchid3'], \ }, \ 'haskell': { \ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/\v\{\ze[^-]/ end=/}/ fold'], \ }, \ 'vim': { \ 'parentheses_options': 'containedin=vimFuncBody', \ }, \ 'perl': { \ 'syn_name_prefix': 'perlBlockFoldRainbow', \ }, \ 'stylus': { \ 'parentheses': ['start=/{/ end=/}/ fold contains=@colorableGroup'], \ }, \ 'css': 0, \ } \} " majutsushi/tagbar map :TagbarToggle " mattesgroeger/vim-bookmarks let g:bookmark_no_default_key_mappings = 1 nmap mm BookmarkToggle nmap ma BookmarkAnnotate nmap ms BookmarkShowAll nmap mn BookmarkNext nmap mp BookmarkPrev nmap mc BookmarkClear highlight BookmarkSign ctermbg=NONE ctermfg=160 highlight BookmarkLine ctermbg=194 ctermfg=NONE let g:bookmark_sign = 'B' let g:bookmark_highlight_lines = 1 " hrsh7th/nvim-cmp lua << EOF -- Add additional capabilities supported by nvim-cmp local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities) -- Set completeopt to have a better completion experience vim.o.completeopt = 'menuone,noselect' -- nvim-cmp setup local cmp = require 'cmp' cmp.setup { mapping = { [''] = cmp.mapping.select_prev_item(), [''] = cmp.mapping.select_next_item(), [''] = cmp.mapping.close(), [''] = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, select = true, }}, sources = { { name = 'nvim_lsp' }, { name = 'path'}, { name = 'buffer' }, }, } EOF " neovim/nvim-lspconfig lua << EOF local nvim_lsp = require('lspconfig') -- Use an on_attach function to only map the following keys -- after the language server attaches to the current buffer local on_attach = function(client, bufnr) local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end -- Mappings. local opts = { noremap=true, silent=true } -- See `:help vim.lsp.*` for documentation on any of the below functions buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) buf_set_keymap('n', 'gy', 'lua vim.lsp.buf.type_definition()', opts) buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) buf_set_keymap('n', 'K', 'lua vim.lsp.buf.hover()', opts) buf_set_keymap('n', '', 'lua vim.lsp.buf.rename()', opts) end -- Use a loop to conveniently call 'setup' on multiple servers and -- map buffer local keybindings when the language server attaches local servers = { "pyright", "bashls", "tsserver", "texlab", "ccls", "gopls", "hls", "nimls", "marksman" } for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup { on_attach=on_attach, capabilities=capabilities, flags = { debounce_text_changes = 150 } } end require'lspconfig'.jdtls.setup{ on_attach=on_attach, flags = { debounce_text_changes = 150 }, cmd = { 'jdtls' } } EOF " rrethy/vim-hexokinase let g:Hexokinase_refreshEvents = ['InsertLeave'] let g:Hexokinase_optInPatterns = [ \ 'full_hex', \ 'triple_hex', \ 'rgb', \ 'rgba', \ 'hsl', \ 'hsla', \ 'color_names' \] let g:Hexokinase_highlighters = ['backgroundfull'] autocmd VimEnter * HexokinaseTurnOn " scrooloose/nerdtree map :NERDTreeToggle autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif let g:NERDTreeWinPos = "left" " tpope/vim-fugitive nnoremap ga :Git add %:p nnoremap gd :Git diff nnoremap gc :Gcommit nnoremap go :Git checkout nnoremap gh :diffget //3 nnoremap gr :Gread nnoremap gu :diffget //2 nnoremap gs :G """ end plugin section set go=a set noshowmode " enable mouse for all modes set mouse=a set clipboard+=unnamedplus " setting Tab-length set expandtab set softtabstop=4 set shiftwidth=4 " splits open at the bottom and right, which is non-retarded, unlike vim defaults. set splitbelow splitright " disable case sensitive matching set ignorecase " enable nocompatible mode set nocompatible " enable Plugins filetype plugin on " enable syntax highlighting syntax on " enable true colors set termguicolors " set utf-8 encoding set encoding=utf-8 " show relative numbers on left side set number relativenumber " speedup vim with long lines set ttyfast set lazyredraw " textEdit might fail without hidden set hidden " disable Backupfiles for Lsp set nobackup set nowritebackup " always show the signcolumn, otherwise it would shift the text each time " diagnostics appear/become resolved. if has("patch-8.1.1564") " Recently vim can merge signcolumn and number column into one set signcolumn=number else set signcolumn=yes endif " enable persistent undo if has('persistent_undo') set undofile set undodir=$XDG_CACHE_HOME/vim/undo endif " unmap unwanted commands nnoremap nnoremap nnoremap nnoremap nnoremap inoremap inoremap inoremap inoremap inoremap inoremap inoremap inoremap inoremap inoremap inoremap " mapping Dictionaries nnoremap :setlocal spell! spelllang=de_de nnoremap :setlocal spell! spelllang=en_us " compiler for languages nnoremap c :w! \| !compiler % " open corresponding file (pdf/html/...) nnoremap p :!opout % " shortcut for split navigation nnoremap h nnoremap j nnoremap k nnoremap l " save file as sudo on files that require root permission cnoremap w!! execute 'silent! write !sudo tee % >/dev/null' edit! " alias for replacing nnoremap ss :%s//gI " delete trailing whitespaces on save fun! TrimWhitespace() let l:save = winsaveview() keeppatterns %s/\s\+$//e call winrestview(l:save) endfun autocmd BufWritePre * :call TrimWhitespace() " read files correctly autocmd BufRead,BufNewFile *.tex set filetype=tex autocmd BufRead,BufNewFile *.html set filetype=html autocmd BufRead,BufNewFile *.h set filetype=c autocmd BufRead,BufNewFile *.nim set filetype=nim " formatting options autocmd FileType java setlocal shiftwidth=2 softtabstop=2 autocmd FileType javascript setlocal shiftwidth=2 softtabstop=2 autocmd FileType markdown setlocal shiftwidth=2 softtabstop=2 " formatting programs autocmd FileType c setlocal formatprg=astyle\ --mode=c\ --style=ansi autocmd FileType c noremap gggqG autocmd FileType html noremap :silent %!tidy -q -i --show-errors 0 autocmd FileType java setlocal formatprg=astyle\ --indent=spaces=2\ --style=google autocmd FileType java noremap gggqG autocmd FileType markdown noremap :silent %!prettier --stdin-filepath % autocmd FileType nim noremap :silent !nimpretty % autocmd FileType python setlocal formatprg=autopep8\ - autocmd FileType python noremap gggqG autocmd FileType tex,latex setlocal formatprg=latexindent\ - autocmd FileType tex,latex noremap gggqG " cleanup certain files after leaving the editor autocmd VimLeave *.tex !texclear % autocmd VimLeave *.c !cclear " highlighting break line autocmd BufEnter,FileType c set colorcolumn=80 autocmd BufEnter,FileType java set colorcolumn=100 autocmd BufEnter,FileType markdown set colorcolumn=80 autocmd BufEnter,FileType tex set colorcolumn=80 autocmd BufEnter,FileType nim set colorcolumn=80 autocmd BufEnter,FileType python set colorcolumn=80 "" colorscheme set background=dark colorscheme tccs highlight colorcolumn guibg=#772222 " python let g:python_host_prog = "/usr/bin/python2" let g:python3_host_prog = "/usr/bin/python3" " irc compatibility to interactive nnoremap is :.w >> indd