util/vim/vimrc

507 lines
14 KiB
VimL

" All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just
" /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime
" you can find below. If you wish to change any of those settings, you should
" do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten
" everytime an upgrade of the vim packages is performed. It is recommended to
" make changes after sourcing debian.vim since it alters the value of the
" 'compatible' option.
" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
runtime! debian.vim
" Uncomment the next line to make Vim more Vi-compatible
" NOTE: debian.vim sets 'nocompatible'. Setting 'compatible' changes numerous
" options, so any other options should be set AFTER setting 'compatible'.
if &compatible
set nocompatible
endif
" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
if has("syntax")
syntax on
endif
" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
set background=dark
" Uncomment the following to have Vim jump to the last position when
" reopening a file
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
" Uncomment the following to have Vim load indentation rules and plugins
" according to the detected filetype.
filetype plugin indent on
" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
set ignorecase " Do case insensitive matching
set smartcase " Do smart case matching
set incsearch " Incremental search
set autowrite " Automatically save before commands like :next and :make
set hidden " Hide buffers when they are abandoned
set autoread
set number
set fileencodings=utf-8
set encoding=utf-8
" Fast saving
nmap <leader>w :w!<cr>
" Configure backspace so it acts as it should act
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
" Show matching brackets when text indicator is over them
set showmatch
" Enable syntax highlighting
syntax enable
"Highlight all search results
set hlsearch
" For paste text
set pastetoggle=<F2>
" Wrap lines
set wrap
" And treat log lones as break lines
map j gj
map k gk
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Files, backups and undo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Turn backup off, since most stuff is in SVN, git et.c anyway...
set nobackup
set nowb
set noswapfile
" Set to auto read when a file is changed from the outside
set autoread
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text, tab and indent related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use spaces instead of tabs
set expandtab
" Be smart when using tabs ;)
set smarttab
set nofoldenable
" 1 tab == 4 spaces
set shiftwidth=2
set tabstop=2
set softtabstop=2
" Use 4 in python
""""""""""""""""""""""""""""""""
" => Map
""""""""""""""""""""""""
"Disable arrows"
map <up> <nop>
map <down> <nop>
map <left> <nop>
map <right> <nop>
"" Map space to \
let mapleader = "\<Space>"
"move between splits"
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" Switch to alternate file
map <Leader><Tab> :bnext<cr>
map <Leader><S-Tab> :bprevious<cr>
" This replaces :tabnew which I used to bind to this mapping
nmap <leader>T :enew<cr>
"
" " Move to the next buffer
nmap <leader>l :bnext<CR>
"
" " Move to the previous buffer
nmap <leader>h :bprevious<CR>
"
" " Close the current buffer and move to the previous one
" " This replicates the idea of closing a tab
nmap <leader>bq :bp <BAR> bd #<CR>
"
" " Show all open buffers and their status
nmap <leader>bl :ls<CR>
"Copy with mouse visual"
":noremap <LeftRelease> "+y<LeftRelease>"
"" OPen file
nnoremap <Leader>o :CtrlP<CR>
"" Savefile
nnoremap <Leader>w :w<CR>
"" Duplicate line
nnoremap <Leader>t :t.<CR>
"" quit
nnoremap <Leader>q :q<CR>
"" Save and quit
nnoremap <Leader>wq :wq<CR>
map <F4> I#<Esc><Esc>
nmap <C-V> "+gP
imap <C-V> <ESC><C-V>i
vmap <C-C> "+y
" Find trailing whitspace
match ErrorMsg '\s\+$'
"Remove trailing spaces with \rt
nmap <leader>rt :%s/\s\+$//<CR>
" CTRL-T and CTRL-D indent and unindent blocks
inoremap <C-D> <C-O><LT><LT>
nnoremap <C-D> <LT><LT>
vnoremap <C-T> >
vnoremap <C-D> <LT>
" To save, ctrl-s.
nmap <c-s> :w<CR>
imap <c-s> <Esc>:w<CR>a
" Remove ctrl q"
nnoremap <silent> Q ZZ
" source $MYVIMRC reloads the saved $MYVIMRC
nmap <Leader>s :source $MYVIMRC <CR>
" opens $MYVIMRC for editing, or use :tabedit $MYVIMRC
nmap <Leader>v :e $MYVIMRC <CR>
set clipboard=unnamedplus
" -------------------------------------------------
" Start Dein scripts
" https://github.com/Shougo/dein.vim
"--------------------------------------------------
"
" Add the dein installation directory into runtimepath
set runtimepath+=~/.cache/dein/repos/github.com/Shougo/dein.vim
if dein#load_state('~/.cache/dein')
call dein#begin('~/.cache/dein')
call dein#add('~/.cache/dein/repos/github.com/Shougo/dein.vim')
call dein#add('Shougo/deoplete.nvim')
if !has('nvim')
call dein#add('roxma/nvim-yarp')
call dein#add('roxma/vim-hug-neovim-rpc')
endif
call dein#end()
call dein#save_state()
endif
" My Bundles here:
call dein#add('terryma/vim-expand-region')
vmap v <Plug>(expand_region_expand)
vmap <C-v> <Plug>(expand_region_shrink)
call dein#add('Shougo/neosnippet.vim')
call dein#add('Shougo/neosnippet-snippets')
call dein#add('tpope/vim-git')
call dein#add('tpope/vim-fugitive')
call dein#add('kien/ctrlp.vim')
call dein#add('flazz/vim-colorschemes')
call dein#add('nathanaelkane/vim-indent-guides') " color indentation
call dein#add('preservim/nerdtree')
"call dein#add('Valloric/YouCompleteMe'), {
"" \ 'build' : {
"" \ 'mac' : './install.sh --clang-completer --system-libclang --omnisharp-completer',
"" \ 'unix' : './install.sh --clang-completer --system-libclang --omnisharp-completer',
"" \ 'windows' : './install.sh --clang-completer --system-libclang --omnisharp-completer',
"" \ 'cygwin' : './install.sh --clang-completer --system-libclang --omnisharp-completer'
"" \ }
"" \ }
"call dein#add('Valloric/YouCompleteMe'), {
" \ 'build' : {
" \ 'mac' : './install.sh',
" \ },
" \ }
" Syntax checker
call dein#add('scrooloose/syntastic')
call dein#add('vim-ruby/vim-ruby' ,{ 'on_ft': 'ruby'}) "Ruby
call dein#add('tpope/vim-endwise') "Add endif, end and other stuff
""NeoBundleLazy 'masudaK/vim-python'
call dein#add('klen/python-mode' ,{'on_ft': 'python'})
" Show gitdiff
call dein#add('airblade/vim-gitgutter')
" Disable plugins for LargeFile
call dein#add('vim-scripts/LargeFile')
call dein#add('vim-scripts/DoxygenToolkit.vim') "Generate doxygen
call dein#add('davidhalter/jedi-vim', {
\ 'if': has('pythonx'),
\ 'on_cmd': 'JediClearCache',
\ 'on_ft': 'python',
\ })
call dein#add('ervandew/supertab') "SuperTab
call dein#add('sukima/xmledit.git' ,{'on_ft': 'xml'}) "xmledit
call dein#add('yuroyoro/vim-autoclose')
call dein#add('tpope/vim-endwise')
call dein#add('scrooloose/nerdcommenter') "Comment out lines or blocks
call dein#add('nathanaelkane/vim-indent-guides') "Shows indents
call dein#add('nelstrom/vim-visual-star-search') "Search for visual with *
call dein#add('vim-airline/vim-airline') "For the status line
call dein#add('vim-airline/vim-airline-themes') "For the status line
call dein#add('bling/vim-bufferline')
"call dein#add('fholgado/minibufexpl.vim')
call dein#add('altercation/vim-colors-solarized')
call dein#add('ujihisa/unite-colorscheme')
call dein#add('docunext/closetag.vim.git')
call dein#add('skammer/vim-css-color' ,{'on_ft': 'css'})
call dein#add('StanAngeloff/php.vim' ,{'on_ft': 'php'})
call dein#add('mattn/emmet-vim/')
call dein#add('vim-scripts/keepcase.vim')
" Javascript
call dein#add('othree/yajs.vim' ,{'on_ft': 'js'})
call dein#add('othree/javascript-libraries-syntax.vim' ,{'on_ft': 'js'})
call dein#add('bigfish/vim-js-context-coloring' ,{'on_ft': 'js'})
call dein#add('vim-scripts/SyntaxComplete')
" Arduino
call dein#add('sudar/vim-arduino-syntax' ,{'on_ft': 'ino'})
""call dein#add('Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/')} " For the line in the bottom
" You can specify revision/branch/tag.
call dein#add('Shougo/vimshell')
" Ctags"
if system("command -v ctags") != '' || system("command -v global") != ''
call dein#add('xolox/vim-easytags' ,{'on_ft': ['c', 'cpp', 'h']})
call dein#add('majutsushi/tagbar')
call dein#add('xolox/vim-misc')
""""""""""""""""""""""""""""""""
" => Easytags
""""""""""""""""""""""""
set tags=./tags;,tags;
let g:easytags_file = '~/.vim/tags'
let g:easytags_dynamic_files = 0
let g:easytags_always_enabled = 0
""""""""""""""""""""""""""""""""
" => Tagbar
""""""""""""""""""""""""
nmap <F7> :TagbarToggle<CR>
endif
call dein#add('mrk21/yaml-vim') " Yaml support"
" Required:
filetype plugin indent on
" If there are uninstalled bundles found on startup,
" this will conveniently prompt you to install them.
"End NeoBundle Scripts-------------------------
"let g:pydiction_location = '~/.vim/bundle/pydiction/complete-dict'
nnoremap <buffer> <F9> :exec '!python' shellescape(@%, 1)<cr>
""""""""""""""""""""""""""""""""
" => Javascript
""""""""""""""""""""""""
let g:used_javascript_libs = 'angularjs,angularui,underscore'
""""""""""""""""""""""""""""""""
" => GitGutter
""""""""""""""""""""""""
""" IF SLOW """
"let g:gitgutter_realtime = 0
"let g:gitgutter_eager = 0
""""""""""""""""""""""""""""""""
" => Emmet
""""""""""""""""""""""""
let g:user_emmet_install_global = 0
autocmd FileType html,css EmmetInstall
""""""""""""""""""""""""""""""""
" => php.vim
""""""""""""""""""""""""
function! PhpSyntaxOverride()
hi! def link phpDocTags phpDefine
hi! def link phpDocParam phpType
endfunction
augroup phpSyntaxOverride
autocmd!
autocmd FileType php call PhpSyntaxOverride()
augroup END
""""""""""""""""""""""""""""""""
" => closetag
""""""""""""""""""""""""
autocmd FileType html,htmldjango,jinjahtml,eruby,mako let b:closetag_html_style=1
autocmd FileType html,htmldjango,jinjahtml,eruby,mako source ~/.vim/bundle/closetag.vim/plugin/closetag.vim
""""""""""""""""""""""""""""""""
" => xmledit
""""""""""""""""""""""""
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags noci
""""""""""""""""""""""""""""""""
" => vim-airline
""""""""""""""""""""""""
let g:airline_theme='wombat'
let g:airline#extensions#tabline#enabled = 1
" Show just the filename
let g:airline#extensions#tabline#fnamemod = ':t'
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
let g:airline#extensions#syntastic#enabled = 1
""""""""""""""""""""""""""""""""
" => vim-indent_guides
""""""""""""""""""""""""
colorscheme railscasts
set t_Co=256
let g:indent_guides_enable_on_vim_startup = 1
let g:indent_guides_guide_size = 1
let g:indent_guides_start_level = 2
""""""""""""""""""""""""""""""""
" => ctrl-p
""""""""""""""""""""""""
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlPMixed'
let g:ctrlp_working_path_mode = 'c'
noremap <C-a> :CtrlP /yourdir/<CR>
set wildignore+=*/tmp/*,*.so,*.swp,*.zip
" Try to ignore virtualenv, maybe to much :)
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/](lib|htmlcov|bin|include|local|share|test|unittest)|(\.(git|hg|svn))$',
\ 'file': '\v\.(exe|so|dll)$',
\ 'link': 'some_bad_symbolic_links',
\ }
""""""""""""""""""""""""""""""""
" => LatexBox
""""""""""""""""""""""""
"let g:LatexBox_latexmk_options = "-pvc -pdfps"
""""""""""""""""""""""""""""""""
" => Vim-Ruby
""""""""""""""""""""""""
imap <S-CR> <CR><CR>end<Esc>-cc
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1
autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1
autocmd FileType ruby,eruby let g:rubycomplete_rails = 1
""""""""""""""""""""""""""""""""
" => Jedi-vim
""""""""""""""""""""""""
let g:jedi#goto_assignments_command = "<leader>g"
let g:jedi#goto_definitions_command = "<leader>d"
let g:jedi#documentation_command = "K"
let g:jedi#usages_command = "<leader>n"
let g:jedi#completions_command = "<C-Space>"
let g:jedi#rename_command = "<leader>r"
let g:jedi#show_call_signatures = "1"
let g:jedi#popup_on_dot = 0
""""""""""""""""""""""""""""""""
" => Syntatstic
""""""""""""""""""""""""
"E111 = Indention is not a mulitple of four
let g:syntastic_sh_checkers = ['shellcheck', 'sh']
let g:syntastic_python_checkers = ['flake8']
let g:syntastic_python_flake8_args = '--ignore="E501,E302,E261,E701,E241,E126,E127,E128,W801,E111,E206"'
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
""""""""""""""""""""""""""""""""
" => NERDTree
""""""""""""""""""""""""
"Autostart Nerdtree
"autocmd vimenter * NERDTree
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
map <silent><F8> :NERDTree<CR>
""""""""""""""""""""""""""""""""
" => YouComplteMe
""""""""""""""""""""""""
let g:ycm_autoclose_preview_window_after_completion=1
let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/arduino/.ycm_extra_conf.py'
nnoremap <leader>g :YcmCompleter GoToDefinitionElseDeclaration<CR>
""""""""""""""""""""""""""""""""
" => easymotion
""""""""""""""""""""""""
let g:EasyMotion_do_mapping = 0 " Disable default mappings
" Bi-directional find motion
" Jump to anywhere you want with minimal keystrokes, with just one key binding.
" `s{char}{label}`
nmap s <Plug>(easymotion-s)
" or
" `s{char}{char}{label}`
" Need one more keystroke, but on average, it may be more comfortable.
nmap s <Plug>(easymotion-s2)
" Turn on case sensitive feature
let g:EasyMotion_smartcase = 1
" JK motions: Line motions
map <Leader>j <Plug>(easymotion-j)
map <Leader>k <Plug>(easymotion-k)
""""""""""""""""""""""""""""""
" => Status line
""""""""""""""""""""""""""""""
" Always show the status line
set laststatus=2
" Format the status line
"set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l
if has('gui_running')
set guioptions-=T " no toolbar
colorscheme elflord
endif
" Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local")
source /etc/vim/vimrc.local
endif