From 9622c5c6dd90e49786d8445c0d6de49b8880f4fe Mon Sep 17 00:00:00 2001 From: TiynGER Date: Fri, 30 Oct 2020 17:45:39 +0100 Subject: [PATCH] nvim structure: plug section moved to the bottom and increased readability --- .config/nvim/init.vim | 327 ++++++++++++++++++++++-------------------- 1 file changed, 169 insertions(+), 158 deletions(-) diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index da91e0b..1794c77 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -1,4 +1,128 @@ -" Begin Plugin section +let mapleader ="," + +set go=a + +" enable mouse for all modes +set mouse=a +set clipboard+=unnamedplus + +" enable command completion +set wildmode=longest,list,full + +" 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 + +" dont pass messages to ins-completion-menu +set shortmess+=c + +" 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 + +" delete trailing whitespaces on save +fun! TrimWhitespace() + let l:save = winsaveview() + keeppatterns %s/\s\+$//e + call winrestview(l:save) +endfun +autocmd BufWritePre * :call TrimWhitespace() + +" disables automatic commenting on newline: +autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o + +" clean LaTex build files +autocmd VimLeave *.tex !texclear % + +" mapping Dictionaries +map :setlocal spell! spelllang=de_de +map :set spelllang=en_us + +" compiler for languages +map c :w! \| !compiler % + +" open corresponding file (pdf/html/...) +map p :!opout % + +" shortcut for split navigation +map h +map j +map k +map l + +" copy selected text to system clipboard (requires gvim/nvim/vim-x11 installed): +map "+P +vnoremap "+y + +" save file as sudo on files that require root permission +cnoremap w!! execute 'silent! write !sudo tee % >/dev/null' edit! + +" alias for replacing +nnoremap S :%s//gI + +" read files correctly +autocmd BufRead,BufNewFile *.tex set filetype=tex +autocmd BufRead,BufNewFile *.h set filetype=c + +" formatting +au FileType python setlocal formatprg=autopep8\ - +au FileType java setlocal formatprg=astyle\ --indent=spaces=2\ --style=google +autocmd FileType java setlocal shiftwidth=2 softtabstop=2 +au FileType c setlocal formatprg=astyle\ --mode=c +au FileType tex,latex setlocal formatprg=latexindent\ - +autocmd FileType java,python,c,tex,latex noremap gggqG +au FileType markdown noremap :silent %!prettier --stdin-filepath % + + +""" 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/ @@ -6,31 +130,49 @@ if ! filereadable(expand('~/.config/nvim/autoload/plug.vim')) autocmd VimEnter * PlugInstall endif -" Read files correctly -autocmd BufRead,BufNewFile *.tex set filetype=tex -autocmd BufRead,BufNewFile *.h set filetype=c - call plug#begin('~/.local/share/nvim/plugged') -Plug 'raimondi/delimitmate' " Automatic closing of brackets -Plug 'lervag/vimtex' , {'for' : 'tex'} " Tex library for autocompletion -Plug 'donRaphaco/neotex' , {'for': 'tex'} " Asynchronous pdf rendering -Plug 'scrooloose/nerdtree', {'on': 'NERDTreeToggle'} " Filetree -Plug 'majutsushi/tagbar', {'on': 'TagbarToggle'} " Show tags Plug 'airblade/vim-gitgutter' " Git Upgrades -Plug 'qpkorr/vim-renamer' " Bulk renamer -Plug 'sirver/ultisnips' " Snippets -Plug 'uiiaoo/java-syntax.vim' , {'for': 'java'} " Better syntax highlight for java than default +Plug 'alvan/vim-closetag' " Auto close HTML tags +Plug 'donRaphaco/neotex' , {'for': 'tex'} " Asynchronous pdf rendering Plug 'frazrepo/vim-rainbow' " Colorized matching brackets Plug 'junegunn/fzf.vim' " Quickly jump files using fzf -Plug 'ryanoasis/vim-devicons' " Enable Icons for vim +Plug 'lervag/vimtex' , {'for' : 'tex'} " Tex library for autocompletion +Plug 'majutsushi/tagbar', {'on': 'TagbarToggle'} " Show tags +Plug 'neoclide/coc.nvim', {'do': 'yarn install --frozen-lockfile'} +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 'sirver/ultisnips' " Snippets Plug 'tomasiser/vim-code-dark' " adding colorscheme Plug 'tpope/vim-surround' " Help for quotes/parantheses -Plug 'alvan/vim-closetag' " Auto close HTML tags -Plug 'neoclide/coc.nvim', {'do': 'yarn install --frozen-lockfile'} +Plug 'uiiaoo/java-syntax.vim' , {'for': 'java'} " Better syntax highlight for java than default call plug#end() -" Coc +" 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 + +" frazrepo/vim-rainbow +au FileType,BufNewFile,BufRead java,c,cpp,py,h call rainbow#load() + +" majutsushi/tagbar +map :TagbarToggle + +" neoclide/coc.nvim inoremap \ pumvisible() ? "\" : \ check_back_space() ? "\" : @@ -88,31 +230,7 @@ augroup mygroup autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') augroup end -" Colorscheme -colorscheme codedark - -" Rainbow -au FileType,BufNewFile,BufRead java,c,cpp,py,h call rainbow#load() - -" Ultisnippets -let g:UltiSnipsExpandTrigger="" - -" Tagbar -map :TagbarToggle - -" Nerdtree -map :NERDTreeToggle -autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif -let g:NERDTreeWinPos = "left" - -" Neotex -let g:neotex_enabled = 2 - -" CoVim -let CoVim_default_name = "TiynGER" -let CoVim_default_port = "7000" - -" Hexokinase +" rrethy/vim-hexokinase let g:Hexokinase_refreshEvents = ['InsertLeave'] let g:Hexokinase_optInPatterns = [ \ 'full_hex', @@ -127,122 +245,15 @@ let g:Hexokinase_optInPatterns = [ let g:Hexokinase_highlighters = ['backgroundfull'] autocmd VimEnter * HexokinaseTurnOn -" 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 = '>' - -" End Plugin section - -let mapleader ="," - -set go=a -" Enable mouse for all modes -set mouse=a -set clipboard+=unnamedplus -" Enable command completion -set wildmode=longest,list,full -" 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 -" Dont pass messages to ins-completion-menu -set shortmess+=c -" 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 - -" Delete trailing whitespaces on save -fun! TrimWhitespace() - let l:save = winsaveview() - keeppatterns %s/\s\+$//e - call winrestview(l:save) -endfun -autocmd BufWritePre * :call TrimWhitespace() -" Disables automatic commenting on newline: -autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o -" Clean LaTex build files -autocmd VimLeave *.tex !texclear % - -" Mapping Dictionaries -map :setlocal spell! spelllang=de_de -map :set spelllang=en_us -" Compiler for languages -map c :w! \| !compiler % -" Open corresponding file (pdf/html/...) -map p :!opout % -" Shortcut for split navigation -map h -map j -map k -map l -" Copy selected text to system clipboard (requires gvim/nvim/vim-x11 installed): -map "+P -vnoremap "+y -" Save file as sudo on files that require root permission -cnoremap w!! execute 'silent! write !sudo tee % >/dev/null' edit! -" Alias for replacing -nnoremap S :%s//gI - -" Start Formatting section - -au FileType python setlocal formatprg=autopep8\ - - -au FileType java setlocal formatprg=astyle\ --indent=spaces=2\ --style=google - -autocmd FileType java setlocal shiftwidth=2 softtabstop=2 - -au FileType c setlocal formatprg=astyle\ --mode=c - -au FileType tex,latex setlocal formatprg=latexindent\ - - -autocmd FileType java,python,c,tex,latex noremap gggqG +" scrooloose/nerdtree +map :NERDTreeToggle +autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif +let g:NERDTreeWinPos = "left" -au FileType markdown noremap :silent %!prettier --stdin-filepath % +" sirver/ultisnips +let g:UltiSnipsExpandTrigger="" -" End Formatting section +" tomasiser/vim-code-dark +colorscheme codedark +""" end plugin section