""""""""""""""""""""""""""""""""""""" " Miguel's .vimrc " " Author: Michal Idziorek " " Last Update: 2018-05-29 " """"""""""""""""""""""""""""""""""""" " {{{ TODO / NOTES " " http://www.alexeyshmalko.com/2014/using-vim-as-c-cpp-ide/ " set exrc " set secure " " https://github.com/spf13/spf13-vim " http://antjanus.com/blog/thoughts-and-opinions/use-vim/ " http://stevelosh.com/blog/2010/09/coming-home-to-vim/ " http://derekingrouville.com/2012/vim-is-my-ide/ " http://www.alexeyshmalko.com/2014/using-vim-as-c-cpp-ide/ " " * check out this plugins! (and many more from vim.org) " " taglist.vim " NerdTree DONE " snipMate " c.vim ? " autocomplpop " pathogen DONE " minibufexpl DONE " fugitive DONE " vim-sensible DONE " surround " perl-support ? " matchit " vimspell " conqueshell " fuzzyfinder " Nerd Commenter " tSkeleton " grep " cppcomplete " colortest ? " colour sampler pack " gundo! " CScope / CCTree " inline reference/ (stlrefvim?) " emmet.io (webdev) " " * jump to definition / list calls " " * spellcheck / translate / thesaurus " " * change mappings to more specific mappings and use noremap! " " * toggle 'cursorline' via hotkey for nicer reading experience. " " * spellcheck " " * ft=c.doxygen etc. " " * include dependancies as git submodules (wherever possible) " (check licenses first) " " * :help complete-functions " " * spellcheck " " * ctags shortcuts? " " * quickfix " " * compiler/debugger invocation " " * implement a plugin for fast-reading (check if one exists first ;)) " " * release vim-colortune plugin " " * dictionary " " * load layout automatically on start " " * ConqueGDB Resize " " * Do something about startup lag (because of YouCompleteMe) " " * Do something about the input problems in ConqueGDB/Term (YouCompl?) " " }}} " {{{ Vundle - Plugin Manager " " Vundle plugin manager (Replaces pathogen)" " https://github.com/VundleVim/Vundle.vim set nocompatible filetype off " set the runtime path to include Vundle and initialize set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() " alternatively, pass a path where Vundle should install plugins " call vundle#begin('~/some/path/here') " let Vundle manage Vundle, required Plugin 'gmarik/Vundle.vim' " github plugins " Plugin 'Valloric/YouCompleteMe' Plugin 'fholgado/minibufexpl.vim' Plugin 'scrooloose/nerdtree' Plugin 'majutsushi/tagbar' Plugin 'tpope/vim-fugitive' Plugin 'tpope/vim-sensible' Plugin 'vim-scripts/Conque-GDB' " My own plugins on github " Plugin 'git://ex40.softwarefools.com/vim-potion.git' " Plugin 'git://ex40.softwarefools.com/vim-colortune.git' """""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " draculatheme.com " Plugin 'dracula/vim' " syntax on " color dracula """""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " All of your Plugins must be added before the following line call vundle#end() filetype plugin indent on " To ignore plugin indent changes, instead use: " filetype plugin on " " 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 " " see :h vundle for more details or wiki for FAQ " Put your non-Plugin stuff after this line " }}} let g:ConqueGdb_Leader = '\' let g:ConqueTerm_CloseOnEnd = 1 set nowrap set invlist " PATH " let $PATH='/home/miguel/opt/gcc-5.1.0/bin:'.$PATH " let $PATH='/home/miguel/opt/gcc-5.2.0/bin:'.$PATH " Basic Settings " {{{ " let there be mapleaders " {{{ " use but remap to _ so it is visible for 'showcmd' nmap _ let mapleader="\_" let maplocalleader="\_" " }}} " filetype stuff " {{{ filetype plugin indent on " }}} " misc! " {{{ let g:potion_command = "/home/miguel/int/dev/potion/bin/potion" set nocompatible set backspace=2 " set ruler set showcmd set number set hidden " set cursorcolumn " set cursorline " save before making etc. set autowrite " some nice candy set laststatus=2 set wildmenu " indent set autoindent set cindent " mouse support in xterm set mouse=a "other set previewheight=25 " http://robots.thoughtbot.com/vim-splits-move-faster-and-more-naturally " set splitbelow " set splitright nnoremap nnoremap nnoremap nnoremap " }}} " set the status line " {{{ set statusline=%f " Path to the file set statusline+=%= " Switch to the right side set statusline+=%l " Current line set statusline+=/ " Separator set statusline+=%L " Total lines set statusline+=, " comma set statusline+=%c " Column set statusline+=\ (%P) " Percentage " }}} " terminal width / colorcolumn " {{{ " http://richarddingwall.name/2008/05/31/is-the-80-character-line-limit-still-relevant/ " " set tw=80 " set tw=72 " set tw=78 (for instance vims :help) set tw=0 set colorcolumn=73 " }}} " wrapping " {{{ "set wrap "set showbreak=>_ " }}} " tabs " {{{ set listchars=tab:>. set tabstop=8 set shiftwidth=4 set softtabstop=4 set shiftround " }}} " folding " {{{ set foldcolumn=5 set foldlevelstart=0 " }}} " colorscheme / syntax highlight " {{{ "colorscheme olgas colorscheme desert syntax enable syntax sync fromstart " }}} " minimize gui " {{{ " set guioptions= set guioptions-=m set guioptions-=T set guioptions-=r set guioptions-=L set guifont=Monospace\ 9 " }}} " searching " {{{ set hlsearch set incsearch " }}} " bracket matching and matchtime in ms. " {{{ set showmatch set matchtime=5 " }}} " }}} " Mappings / Custom Global Keybindings " {{{ " first of all: temporary mappings, to get rid of some bad habits. "inoremap "inoremap "inoremap "inoremap "inoremap " alternative to esc in insert mode! inoremap jk " display help in new tab on map :tab help map :silent make \| copen \| redraw! map :silent make \| redraw! " retab map rt :retab! " toggle tabs visibility noremap t :set invlist " nnoremap :tselect " easy editing and sourcing of vimrc nnoremap sv :source $MYVIMRC nnoremap ev :e $MYVIMRC " turn off search highlight nnoremap h :nohlsearch " toggle visibility of trailing whitespaces nnoremap w :match Error /\v +$/ nnoremap W :match " toggle and navigate quickfix window nnoremap cn :cnext nnoremap cp :cprevious nnoremap cc :cc " grep operator " nnoremap g :silent execute "grep! -R " . shellescape(expand("")) . " .":copen nnoremap g :set operatorfunc=GrepOperatorg@ vnoremap g :call GrepOperator(visualmode()) " buffer navigaion nnoremap bn :MBEbn nnoremap bp :MBEbp nnoremap bd :MBEbd " activate 'very magic' for searches automatically nnoremap / /\v nnoremap ? ?\v " make nnoremap mm :silent make! nnoremap mc :silent make! clean nnoremap mn :silent make! new nnoremap mr :silent make!:call system("make run &") nnoremap md :silent make!:call system("make debug &") nnoremap ms :silent make! stop nnoremap mf :silent make! %:r:redraw! nnoremap mx :silent make! %:r !./%:r " run my new 'ColorTune' plugin " nnoremap cc :call Colortune_fill() " session handling nnoremap ss :call Session_save() nnoremap sl :call Session_load() " }}} " layout nnoremap ln :NERDTreeToggle nnoremap lt :TagbarToggle nnoremap lg :ConqueGdb nnoremap lm :MBEToggle nnoremap lq :copen " File Type Specific Settings " {{{ " Enforce custom syntax hl for some file extensions " {{{ augroup filetype_custom autocmd! au BufRead,BufNewFile *.twig set filetype=htmljinja au BufRead,BufNewFile *.md set filetype=markdown augroup END " }}} " Set foldmethod=marker for vim files " {{{ augroup filetype_vim autocmd! autocmd FileType vim setlocal foldmethod=marker augroup END " }}} " Custom settings for markdown files " {{{ augroup filetype_markdown autocmd! " autocmd FileType markdown setlocal spell " autocmd FileType markdown setlocal list augroup END " }}} " Simple shortcuts for cpp files " {{{ augroup filetype_cpp autocmd! autocmd FileType cpp nnoremap c I// autocmd FileType cpp :iabbrev iff if () {}jkF autocmd FileType cpp nnoremap bo :r ~/_int/dev/misc/c++/template/template.cpp augroup END " }}} " Haskell specifics " {{{ augroup filetype_haskell autocmd! autocmd FileType haskell setlocal foldmethod=marker " autocmd Filetype haskell map :w:term cabal -- exec runghc % autocmd Filetype haskell map :w:term make autocmd FileType haskell setlocal expandtab augroup END " }}} " }}} " Session Handling (that sucks) " {{{ " we always want MBE, NERDTree and Tagbar " let g:miniBufExplBRSplit = 0 " Put new window above function! Session_save() NERDTreeClose TagbarClose MBECloseAll mksession! .lastvimsession NERDTree Tagbar MBEOpen endfunction function! Session_load() NERDTreeClose TagbarClose MBECloseAll " source ~/.lastvimsession NERDTree Tagbar MBEOpen call feedkeys("\\") endfunction if filereadable(".lastvimsession") " " augroup my_vim_leave " autocmd! " autocmd VimLeave * NERDTreeClose " autocmd VimLeave * TagbarClose " autocmd VimLeave * MBECloseAll " autocmd VimLeave * mksession! .lastvimsession " augroup END " " augroup my_vim_enter " autocmd! " autocmd VimEnter * source .lastvimsession " autocmd VimEnter * NERDTree " autocmd VimEnter * MBEOpen " autocmd VimEnter * Tagbar " augroup END " endif " }}} " Custom Functions " {{{ " GrepOperator(type) " {{{ function! s:GrepOperator(type) let saved_unnamed_register = @@ if a:type ==# 'v' normal! `y elseif a:type ==# 'char' normal! `[v`]y else echom "not supported" return endif silent execute "grep! -R " . shellescape(@@) . " ." copen let @@ = saved_unnamed_register endfunction " }}} " }}} " Experimental (Disabled) " {{{ """"""""""""""""""""""""""""""""""""""""""""""""""""" " experimental stuff added during the course of: " " learnvimscriptthehardway.stevelosh.com " """"""""""""""""""""""""""""""""""""""""""""""""""""" " move line under the cursor up and down. " nnoremap - ddp " nnoremap _ kddpk " make word under curstor upper-case " inoremap viwUea " nnoremap viwUe " abbreviations and typo correction " iabbrev @@ miguel@quad " iabbrev ccopy Copyright 2014 M. Idziorek, all rights reserved. " iabbrev teh the " topic handling for markdown files " onoremap ih :execute "normal! ?^==\\+$\r:nohlsearch\rkvg_" " onoremap ah :execute "normal! ?^==\\+$\r:nohlsearch\rg_vk0" " " single and double quoting " nnoremap " viwa"hbi"lel " nnoremap ' viwa"hbi"lel " vnoremap " ``>la"l " open previous buffer in new split-window " nnoremap p :execute "leftabove vsplit ".bufname("#") " }}} " Vim Status Line Color " {{{ function! InsertStatuslineColor(mode) if a:mode == 'i' hi statusline guibg=Cyan ctermfg=6 guifg=Black ctermbg=0 elseif a:mode == 'r' hi statusline guibg=Purple ctermfg=5 guifg=Black ctermbg=0 else hi statusline guibg=DarkRed ctermfg=1 guifg=Black ctermbg=0 endif endfunction " }}} " if has("nvim") " Make escape work in the Neovim terminal. tnoremap " Make navigation into and out of Neovim terminal splits nicer. tnoremap h tnoremap j tnoremap k tnoremap l " I like relative numbering when in normal mode. autocmd TermOpen * setlocal conceallevel=0 colorcolumn=0 relativenumber " Prefer Neovim terminal insert mode to normal mode. autocmd BufEnter term://* startinsert endif