.dotfiles/vim/vimrc

284 lines
6.6 KiB
VimL
Raw Normal View History

2018-08-18 13:15:18 +02:00
set nocompatible " required
" set the runtime path to include Vundle and initialize
call plug#begin('~/.vim/bundle')
2018-08-18 13:15:18 +02:00
2019-01-19 00:15:06 +01:00
" USEFUL
" comment plugin
Plug 'tpope/vim-commentary'
2019-01-19 00:15:06 +01:00
2019-04-17 23:31:52 +02:00
" brackets management
Plug 'machakann/vim-sandwich'
2019-04-17 23:31:52 +02:00
2019-04-19 18:09:33 +02:00
" snippets
Plug 'SirVer/ultisnips'
2019-04-19 18:09:33 +02:00
" WINDOW MANAGEMENT
2018-12-22 15:28:44 +01:00
" tmux navigator
Plug 'christoomey/vim-tmux-navigator'
2018-12-22 15:28:44 +01:00
2018-11-21 15:44:26 +01:00
" winresizer
Plug 'simeji/winresizer'
2018-08-18 13:15:18 +02:00
" FILE MANAGEMENT
2018-08-18 13:15:18 +02:00
" nert-tree
Plug 'scrooloose/nerdtree'
2018-08-18 13:15:18 +02:00
2019-01-18 22:29:22 +01:00
" fzf plugin
Plug 'junegunn/fzf.vim'
2019-01-18 22:29:22 +01:00
" GIT STUFF
2018-08-18 13:15:18 +02:00
" git
Plug 'tpope/vim-fugitive'
2018-08-18 13:15:18 +02:00
2019-01-18 22:29:22 +01:00
" vim gitgutter
Plug 'airblade/vim-gitgutter'
2019-01-18 22:29:22 +01:00
" COLORS
2019-11-26 23:53:20 +01:00
" Plastic colorscheme
Plug 'aonemd/kuroi.vim'
2019-01-18 22:29:22 +01:00
2018-08-18 13:15:18 +02:00
" powerline
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
2018-08-18 13:15:18 +02:00
" LANGUAGE SUPPORT
" vim ale for interaction with language servers
Plug 'w0rp/ale'
2019-08-12 00:15:00 +02:00
" editorconfig plugin
Plug 'editorconfig/editorconfig-vim'
2019-08-12 00:15:00 +02:00
2019-01-19 00:05:19 +01:00
" language packs
Plug 'sheerun/vim-polyglot'
2019-01-19 00:05:19 +01:00
" latex
Plug 'lervag/vimtex'
call plug#end() " required
2018-08-18 13:15:18 +02:00
filetype plugin indent on " required
" syntax
syntax on
2019-11-26 23:53:20 +01:00
colorscheme kuroi
set background=dark
let mapleader=" "
2019-11-26 23:53:20 +01:00
hi MatchParen cterm=bold ctermbg=NONE ctermfg=red
2018-08-18 13:15:18 +02:00
2018-11-18 22:14:48 +01:00
" random settings
2018-08-18 13:15:18 +02:00
set number
set clipboard=unnamed
2018-11-18 22:14:48 +01:00
set mouse=nvi
set smarttab
set visualbell
set virtualedit=block
set scrolloff=1
set wildmenu
2018-11-30 13:36:35 +01:00
set term=screen-256color
2019-01-18 18:34:26 +01:00
set autoread
2019-03-31 20:00:43 +02:00
set lazyredraw
2019-05-10 00:41:01 +02:00
set history=250
2018-11-18 22:14:48 +01:00
" tabs and line wrap
2018-08-18 13:15:18 +02:00
set tabstop=4
set wrapmargin=8
set softtabstop=0 noexpandtab
set shiftwidth=4
set backspace=2
set backspace=indent,eol,start
set encoding=utf-8
2018-11-18 22:14:48 +01:00
set autoindent
" search
set incsearch
set hlsearch
set smartcase
2018-08-18 13:15:18 +02:00
2019-01-09 23:41:35 +01:00
" Disable Backup and Swap files
set noswapfile
set nobackup
set nowritebackup
2018-08-18 13:15:18 +02:00
" setup split
set splitbelow
set splitright
2018-11-21 16:01:41 +01:00
" tabs
nnoremap <leader>t :tabnew<CR>
2019-01-18 18:49:35 +01:00
nnoremap <C-n> gT
nnoremap <C-p> gt
2018-11-21 16:01:41 +01:00
" search for visual selection
vnoremap // y/<C-R>"<CR>
2018-08-18 13:15:18 +02:00
" Enable folding
set foldmethod=indent
set foldlevel=99
" remap code folding
2019-01-18 22:29:22 +01:00
nnoremap <leader>g za
2018-08-18 13:15:18 +02:00
2019-04-03 14:25:35 +02:00
" auto reload .vimrc on write
autocmd BufWritePost .vimrc source %
2019-05-10 00:41:01 +02:00
" ex command
cnoremap <C-p> <Up>
cnoremap <C-n> <Down>
2019-01-27 00:23:56 +01:00
" toggle hybrid number mode
nnoremap <leader>h :set rnu!<CR>
:augroup numbertoggle
: autocmd!
: autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
: autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
:augroup END
2019-01-23 17:33:12 +01:00
" disable arrow keys
noremap <Up> <Nop>
noremap <Down> <Nop>
noremap <Left> <Nop>
noremap <Right> <Nop>
2019-08-23 12:54:21 +02:00
" auto expand brackets
inoremap (; (<CR>)<C-c>O
inoremap (, (<CR>),<C-c>O
inoremap {; {<CR>}<C-c>O
inoremap {, {<CR>},<C-c>O
inoremap [; [<CR>]<C-c>O
inoremap [, [<CR>],<C-c>O
2019-03-31 20:00:43 +02:00
" Delete buffer while keeping window layout (don't close buffer's windows).
" Version 2008-11-18 from http://vim.wikia.com/wiki/VimTip165
if v:version < 700 || exists('loaded_bclose') || &cp
finish
endif
let loaded_bclose = 1
if !exists('bclose_multiple')
let bclose_multiple = 1
endif
" Display an error message.
function! s:Warn(msg)
echohl ErrorMsg
echomsg a:msg
echohl NONE
endfunction
" Command ':Bclose' executes ':bd' to delete buffer in current window.
" The window will show the alternate buffer (Ctrl-^) if it exists,
" or the previous buffer (:bp), or a blank buffer if no previous.
" Command ':Bclose!' is the same, but executes ':bd!' (discard changes).
" An optional argument can specify which buffer to close (name or number).
function! s:Bclose(bang, buffer)
if empty(a:buffer)
let btarget = bufnr('%')
elseif a:buffer =~ '^\d\+$'
let btarget = bufnr(str2nr(a:buffer))
else
let btarget = bufnr(a:buffer)
endif
if btarget < 0
call s:Warn('No matching buffer for '.a:buffer)
return
endif
if empty(a:bang) && getbufvar(btarget, '&modified')
call s:Warn('No write since last change for buffer '.btarget.' (use :Bclose!)')
return
endif
" Numbers of windows that view target buffer which we will delete.
let wnums = filter(range(1, winnr('$')), 'winbufnr(v:val) == btarget')
if !g:bclose_multiple && len(wnums) > 1
call s:Warn('Buffer is in multiple windows (use ":let bclose_multiple=1")')
return
endif
let wcurrent = winnr()
for w in wnums
execute w.'wincmd w'
let prevbuf = bufnr('#')
if prevbuf > 0 && buflisted(prevbuf) && prevbuf != btarget
buffer #
else
bprevious
endif
if btarget == bufnr('%')
" Numbers of listed buffers which are not the target to be deleted.
let blisted = filter(range(1, bufnr('$')), 'buflisted(v:val) && v:val != btarget')
" Listed, not target, and not displayed.
let bhidden = filter(copy(blisted), 'bufwinnr(v:val) < 0')
" Take the first buffer, if any (could be more intelligent).
let bjump = (bhidden + blisted + [-1])[0]
if bjump > 0
execute 'buffer '.bjump
else
execute 'enew'.a:bang
endif
endif
endfor
execute 'bdelete'.a:bang.' '.btarget
execute wcurrent.'wincmd w'
endfunction
command! -bang -complete=buffer -nargs=? Bclose call <SID>Bclose(<q-bang>, <q-args>)
nnoremap <silent> <Leader>bd :Bclose<CR>
2018-11-21 15:44:26 +01:00
" PLUGIN SETTINGS
2019-01-23 17:31:52 +01:00
" polyglot setup
let g:polyglot_disabled = ["latex"]
2018-08-18 13:15:18 +02:00
" nerd tree setup
let NERDTreeIgnore=['\.pyc$', '\~$'] "ignore files in NERDTree
2019-01-09 23:41:35 +01:00
map <leader>e :NERDTreeToggle<CR>
2018-08-18 13:15:18 +02:00
2019-04-03 14:15:12 +02:00
" AIRLINE SETUP
" sections
let g:airline_section_y = ""
let g:airline_section_z = "%l/%L:%c"
let g:airline_section_b = "%{airline#util#wrap(airline#extensions#branch#get_head(),0)}"
" other stuff
2019-11-26 23:53:20 +01:00
let g:airline_theme='luna'
2019-01-19 12:03:22 +01:00
let g:airline_solarized_bg='dark'
let g:airline_powerline_fonts = 1
2019-04-03 14:15:12 +02:00
let g:airline_inactive_collapse=1
let g:airline_skip_empty_sections = 1
let g:airline#extensions#whitespace#enabled = 0
let g:airline#extensions#wordcount#enabled = 0
let g:airline#extensions#keymap#enabled = 0
set ttimeoutlen=50
2019-01-18 19:07:40 +01:00
" gitgutter setup
let g:gitgutter_sign_added = '∙'
let g:gitgutter_sign_modified = '∙'
let g:gitgutter_sign_removed = '∙'
let g:gitgutter_sign_modified_removed = '∙'
augroup VimDiff
autocmd!
autocmd VimEnter,FilterWritePre * if &diff | GitGutterDisable | endif
augroup END
2019-01-18 22:29:22 +01:00
" fzf setup
2019-08-12 00:15:00 +02:00
nmap <C-y> :Buffers<CR>
nmap <Leader>f :GFiles<CR>
2019-01-18 22:29:22 +01:00
let g:fzf_buffers_jump = 1
2019-01-19 12:03:22 +01:00
" vim-ale setup
let g:ale_completion_enabled = 1
let g:ale_lint_on_text_changed = 'never'
let g:ale_fixers = {
\ '*': ['trim_whitespace'],
\ 'python': ['autopep8']
\ }
nmap <Leader>d :ALEGoToDefinition<CR>
nmap <Leader>r :ALEFindReferences<CR>
nmap <Leader>b :ALEFix<CR>
nnoremap <space>l :lnext<CR>
nnoremap <space>p :lprevious<CR>
2019-04-03 12:50:18 +02:00
2019-04-19 18:09:33 +02:00
" UltiSnip setup
" Trigger configuration
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
2019-05-10 00:41:01 +02:00
let g:UltiSnipsJumpBackwardTrigger="<C-tab>"
2019-04-19 18:09:33 +02:00
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"
let g:UltiSnipsSnippetDirectories=[$HOME."/.vim/snipps"]