dotfiles/vimrc
surtur 8ae8783963
vimrc: refactorized, showing trailing whitespace
* vim-airline, vim-gitgutter, vim-NERDTree,
 vim-fugitive plugins have been added
 system-wide, so removed from the config
* trailing whitespace is from now on
 shown and nicely highlighted using "•"
* when empty vim is open, NERDTree is shown
2019-12-16 00:53:36 +01:00

221 lines
7.1 KiB
VimL

set nocompatible
filetype off "required
"filetype plugin on " required
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
" Enable omni completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
" Enable heavy omni completion.
if !exists('g:neocomplete#sources#omni#input_patterns')
let g:neocomplete#sources#omni#input_patterns = {}
endif
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin()
Plug 'drewtempelmeyer/palenight.vim'
Plug 'https://github.com/suan/vim-instant-markdown', { 'for': 'markdown' }
Plug 'lervag/vimtex', { 'for': 'tex' }
Plug 'xuhdev/vim-latex-live-preview', { 'for': 'tex' }
Plug 'https://tpope.io/vim/surround.git'
Plug 'https://github.com/tpope/vim-repeat.git'
"Plug 'https://github.com/tpope/vim-fugitive.git'
"Plug 'voldikss/vim-mma'
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
call plug#end()
let g:airline_powerline_fonts = 1
let g:Powerline_symbols = "fancy" " sth like this probably set as a default but won't hurt here
let g:airline_highlighting_cache = 1
let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'
let g:gitgutter_terminal_reports_focus=0
"let g:gitgutter_async = 0
let g:gitgutter_sign_allow_clobber=0
let g:deoplete#enable_at_startup = 1
let g:livepreview_cursorhold_recompile = 0
" vim-instant-markdown options
""let g:instant_markdown_allow_unsafe_content = 1
""let g:instant_markdown_mathjax = 1
""let g:instant_markdown_browser = "chromium-browser --incognito"
""let g:instant_markdown_autoscroll = 1
""let g:instant_markdown_autostart = 1
" change cursor shape for different editing modes, neovim does this by default
if !has('nvim')
if exists('$TMUX')
let &t_SI = "\<Esc>Ptmux;\<Esc>\e[5 q\<Esc>\\"
let &t_SR = "\<Esc>Ptmux;\<Esc>\e[4 q\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\e[2 q\<Esc>\\"
else
let &t_SI = "\e[6 q"
let &t_SR = "\e[4 q"
let &t_EI = "\e[2 q"
endif
endif
command! W execute 'silent w !sudo tee % >/dev/null' | edit!
" open a terminal in $PWD
nnoremap <silent> <Leader>tt :terminal<CR>
" toggle showing whitespace
noremap <F5> :set list!<CR>
vmap gb :<C-U>!git blame % -L<C-R>=line("'<") <CR>,<C-R>=line("'>") <CR><CR>
nmap gb :!git blame %<CR>
" ------ autocmd ------
" automatically open NERDTree if vim is open on it's own (argc() ==0 )
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
" Reload changes if file changed outside of vim requires autoread
augroup load_changed_file
autocmd!
autocmd FocusGained,BufEnter * if mode() !=? 'c' | checktime | endif
autocmd FileChangedShellPost * echo "Changes loaded from source file"
augroup END
" when quitting a file, save the cursor position
augroup save_cursor_position
autocmd!
autocmd BufReadPost * call setpos(".", getpos("'\""))
augroup END
" when not running in a console or a terminal that doesn't support 256 colors
" enable cursorline in the currently active window and disable it in inactive ones
if $DISPLAY !=? '' && &t_Co == 256
augroup cursorline
autocmd!
autocmd VimEnter,WinEnter,BufWinEnter * setlocal cursorline
autocmd WinLeave * setlocal nocursorline
augroup END
endif
" when entering insert mode, relative line
" numbers are turned off, leaving absolute line numbers turned on
augroup numbertoggle
autocmd!
autocmd BufEnter,FocusGained,InsertLeave * set number relativenumber
autocmd BufLeave,FocusLost,InsertEnter * set number norelativenumber
augroup END
hi clear CursorLine
augroup CLClear
autocmd! ColorScheme * hi clear CursorLine
augroup END
hi CursorLineNR cterm=bold
augroup CLNRSet
set cursorline
autocmd! ColorScheme * hi CursorLineNR cterm=bold
augroup END
" define indent-based folding, after loading a file switch to manual folding
augroup vimrc
au BufReadPre * setlocal foldmethod=indent
au BufWinEnter * if &fdm == 'indent' | setlocal foldmethod=manual | endif
augroup END
""" autosave and load views
au BufWinLeave ?* mkview
au BufWinEnter ?* silent loadview
au FileType xml setlocal shiftwidth=2 tabstop=2
au FileType c setl ofu=ccomplete#CompleteCpp
au BufNewFile,BufRead *.py,*.pyw,*.pyx,?akefil*
\ setlocal tabstop=4 shiftwidth=4 noexpandtab autoindent
\ textwidth=79 fileformat=unix
" Linux kernel style tabs
au BufNewFile,BufRead *.c,*.h,*.cpp
\ setlocal tabstop=8 shiftwidth=8 softtabstop=8 noexpandtab autoindent
\ textwidth=79 fileformat=unix
" ------ adv maps ------
" strip trailing whitespace, ss (strip space)
nnoremap <silent> <Leader>ss
\ :let b:_p = getpos(".") <Bar>
\ let b:_s = (@/ != '') ? @/ : '' <Bar>
\ %s/\s\+$//e <Bar>
\ let @/ = b:_s <Bar>
\ nohlsearch <Bar>
\ unlet b:_s <Bar>
\ call setpos('.', b:_p) <Bar>
\ unlet b:_p <CR>
match Todo /\s\+$/
set softtabstop=4
set tabstop=4
set shiftwidth=4
set expandtab
set smarttab
set errorformat+=%.%#PHP:\ %m\ \(in\ %f\ on\ line\ %l\)%.%#,
\%E%[0-9]%#.%m:%f?rev=%.%##L%l\ %.%#,%C%.%#
autocmd BufNewFile,BufRead svn-commit.*tmp :0r $SVN_COMMIT_TEMPLATE
set tags=tags;/
set incsearch " incrimental search
set hlsearch " highlighting when searching
filetype indent plugin off
set autoindent
set backspace=2
set listchars=trail:•
set list " show/hide tabs and EOL chars (hidden characters)
set confirm " ask confirmation like save before quit.
set wildmenu " Tab completion menu when using command mode
set scrolloff=5 " scroll offset, min lines above/below cursor
"set scrolljump=5 " jump 5 lines when running out of the screen - NO
set sidescroll=10 " minimum columns to scroll horizontally
set showcmd " show command status
set showmatch " flashes matching parenthese when cursor over the other one
set noshowmode " show editing mode in status (-- INSERT --)
set ruler " show cursor position
set errorbells " bells in terminal
set undolevels=1000 " number of undos stored
set viminfo='50,"50 " '=marks for x files, "=registers for x files
set nofoldenable
"set foldmethod=indent " indent based folding
set encoding=utf-8 " important for powerline besides others
set smartcase " override 'ignorecase' when pattern has upper case characters
set noscrollbind
set updatetime=1000
syntax enable
colo palenight " new fav highlighting
set mouse=a " enable mouse in n,v,i,c,h modes
set laststatus=2 " show powerline status bar
set t_Co=256