dotfiles/vimrc

222 lines
9 KiB
VimL
Raw Normal View History

2017-11-03 07:09:33 +00:00
set nocompatible " be iMproved, required
filetype off " required
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
2020-03-13 17:29:52 +00:00
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'airblade/vim-gitgutter'
Plugin 'altercation/vim-colors-solarized'
Plugin 'scrooloose/nerdtree'
Plugin 'vim-syntastic/syntastic'
Plugin 'farmergreg/vim-lastplace.git'
Plugin 'yggdroot/indentline'
2017-11-03 07:09:33 +00:00
call vundle#end() " required
filetype plugin indent on " required
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
syntax enable
set background=dark
"" Default Tab Setup
2019-08-02 05:43:13 +00:00
set tabstop=2
2017-11-03 07:09:33 +00:00
set softtabstop=0
2020-05-20 15:25:22 +00:00
set shiftwidth=2
2017-11-03 07:09:33 +00:00
set expandtab
set smarttab
"set cindent " Interferes with filetype based intentation, automatic for
set cinoptions=(0,u0,U0
"set smartindent " No effect with cindent enabled
set autoindent " Retains intentation from previous line
set copyindent
set preserveindent " Might interfere with smarttab ?
set paste
set wildmenu " Tab Completion Menu
set smartindent " Puppet Manifests Tab Setup
"" Status Bar Setup
set laststatus=2
set noshowmode
set showcmd
"" Needed for proper tabline display of anonymous buffers
set hidden
set mouse=r
" Search options
set ignorecase "ignore case when searching
set smartcase "first search casesensivtive, then
set incsearch "Just to searchresult while typing
set hlsearch " Highlight search results
hi Search guibg=lightRed
" Press Space to turn off highlighting and clear any message already displayed.
:nnoremap <silent> <Space> :nohlsearch<Bar>:echo<CR>
" ------------------------------------ Colors / Theme -------------------------------------------
let g:solarized_visibility = "high"
let g:solarized_contrast = "high"
"let g:solarized_termcolors = 256
2017-11-03 07:09:33 +00:00
colorscheme solarized
augroup CursorLine
au!
au VimEnter,WinEnter,BufWinEnter * setlocal cursorline
au WinLeave * setlocal nocursorline
augroup END
" ------------------------------------ Keybindings -------------------------------------------
" toggle numbers
noremap <C-l> :set invnumber<CR>
inoremap <C-l> <C-O>:set invnumber<CR>
map <C-n> :NERDTreeToggle<CR>
" splits
nnoremap <C-V> <C-W><C-V>
" ------------------------------------ AirLine -------------------------------------------
let g:airline_theme='solarized'
2020-03-13 17:29:52 +00:00
let g:airline#extensions#tabline#enabled = 1
"let g:airline#extensions#tabline#left_sep = ' '
"let g:airline#extensions#tabline#left_alt_sep = '|'
"let g:airline#extensions#tabline#formatter = 'default'
2017-11-03 07:09:33 +00:00
" powerline symbols
let g:airline_symbols = {}
let g:airline_left_sep = ''
let g:airline_left_alt_sep = ''
let g:airline_right_sep = ''
let g:airline_right_alt_sep = ''
let g:airline_symbols.branch = ''
let g:airline_symbols.readonly = ''
let g:airline_symbols.linenr = '☰'
let g:airline_symbols.maxlinenr = ''
2017-11-03 07:09:33 +00:00
" ------------------------------------ SynTastic-------------------------------------------
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
2019-06-11 19:26:36 +00:00
let g:syntastic_mode_map = { 'passive_filetypes': ['cpp', 'c'] }
2017-11-03 07:09:33 +00:00
" ------------------------------------ NERDTree -------------------------------------------
"" NERDTree Setup
let g:NERDTreeDirArrowExpandable = '>'
let g:NERDTreeDirArrowCollapsible = 'v'
" close vim if only in nerdtree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" ------------------------------------ GitGutter -------------------------------------------
"" GitGutter Setup
set updatetime=250
let g:gitgutter_enabled = 1
let g:gitgutter_signs = 1
let g:gitgutter_highlight_lines = 0
if executable('/usr/bin/git') == 0
let g:gitgutter_git_executable = "/bin/true"
let g:gitgutter_enabled = 1
endif
let g:gitgutter_max_signs = 500 " default value
let g:gitgutter_realtime = 1
let g:gitgutter_eager = 1
" ------------------------------------ Indent Line -------------------------------------------
let g:indentLine_color_term = 0
"let g:indentLine_char_list = ['|', '¦', '┆', '┊']
2017-11-03 07:09:33 +00:00
" ------------------------------------ Whitespace Highlighting -------------------------------------------
autocmd ColorScheme * highlight ExtraWhitespaces ctermbg=red guibg=red
"" Extra Whitespace Highlighting
highlight ExtraWhitespaces ctermbg=red guibg=red
"Show tabs and spaces after the inital (tabs and) spaces
"Show trailing whitespace only after some text (ignores blank lines)
"Show tabs that are not at the start of a line (and all spaces after too)
function! <SID>MatchExtraWhitespacesNow()
if exists("b:sew")
if b:sew == 1
match ExtraWhitespaces /^\t* \+\zs\(\t\+ *\)\+\|\S\zs\(\s\+$\| *\zs\(\t\+ *\)\+\)/
else
if exists("b:sewb")
if b:sewb == 1
match ExtraWhitespaces /\S\zs\s\+$/
else
:call clearmatches()
endif
endif
endif
endif
endfunction
function! <SID>MatchExtraWhitespacesNowInsert()
if exists("b:sew")
if b:sew == 1
match ExtraWhitespaces /^\t* \+\zs\(\t\+ *\)\+\|\S\zs\(\s\+\%#\@<!$\| *\zs\(\t\+ *\)\+\)/
else
if exists("b:sewb")
if b:sewb == 1
match ExtraWhitespaces /\S\zs\s\+\%#\@<!$/
else
:call clearmatches()
endif
endif
endif
endif
endfunction
"" Extra Whitespace Stripping
function! <SID>StripExtraWhitespaces()
if exists("b:sewb")
if b:sewb == 1
let l = line(".")
let c = col(".")
"Remove trailing whitespace only after some text (ignores blank lines)
%s/\S\zs\s\+$//ge
if exists("b:sew")
if b:sew == 1
"Remove tabs and spaces after the inital (tabs and) spaces
%s/^\t* \+\zs\(\t\+ *\)\+//ge
"Replace tabs that are not at the start of a line
"(and all spaces after too) with a single space to keep
"tokens apart
%s/\S *\zs\(\t\+ *\)\+/ /ge
endif
endif
call cursor(l, c)
endif
endif
endfunction
autocmd BufWinEnter * :call <SID>MatchExtraWhitespacesNow()
autocmd InsertEnter * :call <SID>MatchExtraWhitespacesNowInsert()
autocmd InsertLeave * :call <SID>MatchExtraWhitespacesNow()
autocmd BufWinLeave * :call clearmatches()
autocmd FileType c,changelog,conf,config,cpp,csh,diff,dosini,eruby,fstab,git,gitcommit,gitconfig,gitrebase,haskell,make,pamconf,puppet,ruby,sh,spec,sshconfig,sudoers,tex,vim,yaml,zsh let b:sewb=1 | let b:sew=0 | :call <SID>MatchExtraWhitespacesNow()
autocmd BufWritePre <buffer> :call <SID>StripExtraWhitespaces()
command Sewb let b:sewb=1 | let b:sew=0 | :call <SID>MatchExtraWhitespacesNow()
command Sew let b:sewb=1 | let b:sew=1 | :call <SID>MatchExtraWhitespacesNow()
command Sewbnow let b:sewb=1 | let b:sew=0 | :call <SID>StripExtraWhitespaces() | :call <SID>MatchExtraWhitespacesNow()
command Sewnow let b:sewb=1 | let b:sew=1 | :call <SID>StripExtraWhitespaces() | :call <SID>MatchExtraWhitespacesNow()
command Nosewb let b:sewb=0 | let b:sew=0 | :call <SID>MatchExtraWhitespacesNow()
command Nosew let b:sew=0 | :call <SID>MatchExtraWhitespacesNow()
""------------------------------------ Vimdiff Setup ----------------------------------------------------
highlight DiffAdd cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red
highlight DiffDelete cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red
highlight DiffChange cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red
highlight DiffText cterm=bold ctermfg=10 ctermbg=88 gui=none guifg=bg guibg=Red
"" Disable syntax highlighting in diff mode only
if &diff
syntax off
endif
" ------------------------------------ More Cool Stuff -------------------------------------------
"" UTF-8 Setup
if has("multi_byte")
if &termencoding == ""
let &termencoding = &encoding
endif
set encoding=utf-8
setglobal fileencoding=utf-8
"setglobal bomb
set fileencodings=ucs-bom,utf-8,latin1
endif