From 633e5a37649fc9bfd6dc3b17ba035a65eca8e448 Mon Sep 17 00:00:00 2001 From: TiynGER Date: Mon, 18 May 2020 02:07:06 +0200 Subject: [PATCH] formatter for specific filetypes only --- .config/nvim/init.vim | 134 +++++++++++++++++++++++++----------------- 1 file changed, 80 insertions(+), 54 deletions(-) diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index 1494d15..8e74f52 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -1,59 +1,76 @@ " Begin Plugin section -if ! filereadable(expand('~/.local/share/nvim/autoload/plug.vim')) echo - "Downloading junegunn/vim-plug to manage plugins..." silent !mkdir -p - ~/.local/share/nvim/autoload/ silent !curl - "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" > - ~/.local/share/nvim/autoload/plug.vim autocmd VimEnter * PlugInstall endif - -call plug#begin('~/.local/share/nvim/plugged') Plug 'lervag/vimtex' , {'for' : -'tex'} " Tex library for autocompletion Plug 'donRaphaco/neotex' , {'for': -'tex'} " Asynchronous pdf rendering Plug 'scrooloose/nerdtree' " Filetree Plug -'majutsushi/tagbar' " Show tags Plug 'airblade/vim-gitgutter' " Git Upgrades +if ! filereadable(expand('~/.local/share/nvim/autoload/plug.vim')) + echo "Downloading junegunn/vim-plug to manage plugins..." + silent !mkdir -p ~/.local/share/nvim/autoload/ + silent !curl "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" > ~/.local/share/nvim/autoload/plug.vim + autocmd VimEnter * PlugInstall +endif + +call plug#begin('~/.local/share/nvim/plugged') +Plug 'lervag/vimtex' , {'for' : 'tex'} " Tex library for autocompletion +Plug 'donRaphaco/neotex' , {'for': 'tex'} " Asynchronous pdf rendering +Plug 'scrooloose/nerdtree' " Filetree +Plug 'majutsushi/tagbar' " Show tags +Plug 'airblade/vim-gitgutter' " Git Upgrades "Plug 'FredKSchott/CoVim' "Use vim together -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 'frazrepo/vim-rainbow' " Colorized matching brackets -Plug 'junegunn/fzf.vim' " Quickly jump files using fzf Plug -'ryanoasis/vim-devicons' " Enable Icons for vim Plug 'rrethy/vim-hexokinase' , -{'do': 'make hexokinase'} " Color Preview Plug 'tomasiser/vim-code-dark' " -adding colorscheme Plug 'godlygeek/tabular' " Tabularizing things Plug -'plasticboy/vim-markdown' , {'for': 'md'} " Helps for markdown call plug#end() +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 'frazrepo/vim-rainbow' " Colorized matching brackets +Plug 'junegunn/fzf.vim' " Quickly jump files using fzf +Plug 'ryanoasis/vim-devicons' " Enable Icons for vim +Plug 'rrethy/vim-hexokinase' , {'do': 'make hexokinase'} " Color Preview +Plug 'tomasiser/vim-code-dark' " adding colorscheme +Plug 'godlygeek/tabular' " Tabularizing things +Plug 'plasticboy/vim-markdown' , {'for': 'md'} " Helps for markdown +call plug#end() " Rainbow au FileType java,c,cpp,py,h call rainbow#load() " You complete me -let g:ycm_global_ycm_extra_conf = -'/home/tiynger/.config/nvim/ycm_extra_conf.py' let g:ycm_semantic_triggers = { - \ 'tex' : ['{'] \} if !exists('g:ycm_semantic_triggers') let -g:ycm_semantic_triggers = {} endif let g:ycm_semantic_triggers.tex = -g:vimtex#re#youcompleteme +let g:ycm_global_ycm_extra_conf = '/home/tiynger/.config/nvim/ycm_extra_conf.py' +let g:ycm_semantic_triggers = { + \ 'tex' : ['{'] + \} +if !exists('g:ycm_semantic_triggers') + let g:ycm_semantic_triggers = {} +endif +let g:ycm_semantic_triggers.tex = g:vimtex#re#youcompleteme " Tagbar map :TagbarToggle " Nerdtree -map :NERDTreeToggle autocmd bufenter * if (winnr("$") == 1 && -exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif let -g:NERDTreeWinPos = "left" +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" +let CoVim_default_name = "TiynGER" +let CoVim_default_port = "7000" " 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 +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 " Vim-Mardown -let g:vim_markdown_folding_disabled=1 let -g:vim_markdown_no_default_key_mappings=1 +let g:vim_markdown_folding_disabled=1 +let g:vim_markdown_no_default_key_mappings=1 " End Plugin section @@ -61,13 +78,15 @@ let mapleader ="," set go=a " Enable mouse for all modes -set mouse=a set clipboard+=unnamedplus +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 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 @@ -84,15 +103,19 @@ set encoding=utf-8 " Show relative numbers on left side set number relativenumber " Speedup vim with long lines -set ttyfast set lazyredraw +set ttyfast +set lazyredraw " enable persistent undo -if has('persistent_undo') set undofile set undodir=$XDG_CACHE_HOME/vim/undo +if has('persistent_undo') + set undofile + set undodir=$XDG_CACHE_HOME/vim/undo endif " Colorscheme -colorscheme codedark highlight CursorLine ctermbg=Yellow cterm=bold -guibg=#1b1b1b highlight CursorColumn ctermbg=Yellow cterm=bold guibg=#1b1b1b +colorscheme codedark +highlight CursorLine ctermbg=Yellow cterm=bold guibg=#1b1b1b +highlight CursorColumn ctermbg=Yellow cterm=bold guibg=#1b1b1b " Center screen on Insertion autocmd InsertEnter * norm zz @@ -103,21 +126,24 @@ autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o " Clean LaTex build files autocmd VimLeave *.tex !texclear % " Read files correctly -autocmd BufRead,BufNewFile *.tex set filetype=tex autocmd BufRead,BufNewFile -*.h set filetype=c +autocmd BufRead,BufNewFile *.tex set filetype=tex +autocmd BufRead,BufNewFile *.h set filetype=c " Mapping Dictionaries -map :setlocal spell! spelllang=de_de map :set -spelllang=en_us +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 +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 @@ -125,12 +151,12 @@ nnoremap S :%s//gI " Start Formatting section -noremap gggqG +autocmd FileType java,python,c,tex,latex noremap gggqG au FileType python setlocal formatprg=autopep8\ - -au FileType java setlocal formatprg=google-java-format\ - autocmd FileType -java setlocal shiftwidth=2 softtabstop=2 +au FileType java setlocal formatprg=google-java-format\ - +autocmd FileType java setlocal shiftwidth=2 softtabstop=2 au FileType c setlocal formatprg=astyle\ --mode=c