From d3e541641452bf50ff28f19038d271778f0a5b2c Mon Sep 17 00:00:00 2001 From: Robert Kmiec Date: Wed, 24 Apr 2019 17:28:20 +0200 Subject: [PATCH] vim: initial --- .vimrc | 542 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 542 insertions(+) create mode 100644 .vimrc diff --git a/.vimrc b/.vimrc new file mode 100644 index 0000000..f2b2af7 --- /dev/null +++ b/.vimrc @@ -0,0 +1,542 @@ +if &compatible + set nocompatible " Be iMproved +endif + +filetype plugin off +filetype off " required + +" 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 + +" let Vundle manage Vundle, required +Plugin 'VundleVim/Vundle.vim' + +" Completion engines: +Plugin 'Valloric/YouCompleteMe' +"Plugin 'zxqfl/tabnine-vim' +"Plugin 'lifepillar/vim-mucomplete' +"Plugin 'Shougo/neocomplete.vim' +"Plugin 'lyuts/vim-rtags' +"Plugin 'JBakamovic/cxxd-vim' + +"Plugin 'KabbAmine/zeavim.vim' +"Plugin 'Shougo/neosnippet-snippets' +"Plugin 'Shougo/neosnippet.vim' +"Plugin 'Shougo/vimproc.vim' +"Plugin 'andymass/vim-matchup' " Improve if-else matches +"Plugin 'apalmer1377/factorus' doesn't work witch c++ +"Plugin 'easymotion/vim-easymotion' +"Plugin 'fholgado/minibufexpl.vim' ctrl-p ctrl-f +"Plugin 'gabrielelana/vim-markdown' +"Plugin 'idanarye/vim-vebugger' :Termdebug +"Plugin 'jeaye/color_coded' +"Plugin 'jez/vim-superman' "vman application +"Plugin 'metakirby5/codi.vim' +"Plugin 'milkypostman/vim-togglelist' " Map of quickfix toggles +"Plugin 'mnpk/vim-jira-complete' +"Plugin 'pelodelfuego/vim-swoop' +"Plugin 'quark-zju/vim-cpp-auto-include' +"Plugin 'rhysd/vim-clang-format' +"Plugin 'scrooloose/nerdtree' +"Plugin 'tpope/vim-commentary' " Toggle C style comments with gc +"Plugin 'tpope/vim-fugitive' " Git integration +"Plugin 'vim-airline/vim-airline' +"Plugin 'vim-scripts/CycleColor' +"Plugin 'vim-scripts/DoxygenToolkit.vim' " Doxygen support +"Plugin 'vim-scripts/a.vim' Curtine is the new a.vim +"Plugin 'vim-scripts/taglist.vim' +Plugin 'airblade/vim-gitgutter' " Mark edited lines +Plugin 'ctrlpvim/ctrlp.vim' +Plugin 'ericcurtin/CurtineIncSw.vim' "Toggle .c .h files +Plugin 'flazz/vim-colorschemes' " lots of colorschemes +Plugin 'justinmk/vim-sneak' +Plugin 'kergoth/vim-bitbake' " Bitbake templates and syntax +Plugin 'ludovicchabant/vim-gutentags' "Auto generate tags +Plugin 'mileszs/ack.vim' " Ack integration + +call vundle#end() " required + +map :call CurtineIncSw() + +packadd termdebug +"let g:termdebugger="/opt/glibc-oecore-x86_64/sysroots/x86_64-oesdk-linux/usr/bin/mips-oe-linux/mips-oe-linux-gdb" + +" ========== Vim Basic Settings =============" + +filetype plugin indent on + +" Make vim incompatbile to vi. +set nocompatible +set modelines=0 + +"TAB settings. +set tabstop=4 +set shiftwidth=4 +set softtabstop=4 + +" More Common Settings. +set encoding=utf-8 +set scrolloff=8 +set autoindent +set cino=l1,:0 +set showmode +set showcmd +set hidden +"set visualbell + +"set cursorline +set ttyfast +set ruler +set backspace=eol,indent,start +"set statusline=%<%f%h%m%r%=%b\ 0x%B\ \ %l,%c%V\ %P +set laststatus=2 + +"set relativenumber +set number +set norelativenumber + +set shell=/usr/local/bin/fish +set lazyredraw + +if exists("+undofile") + if isdirectory($HOME . '/.vim/undo') == 0 + :silent !mkdir -p ~/.vim/undo > /dev/null 2>&1 + endif + set undodir=~/.vim/undo/ + set undofile +endif + +if isdirectory($HOME . '/.vim/tags') == 0 + :silent !mkdir -p ~/.vim/tags > /dev/null 2>&1 +endif +let g:gutentags_cache_dir='~/.vim/tags' +let g:gutentags_ctags_extra_args=['--fields=+l'] + +"Changing Leader Key +let mapleader = "\\" + +" Set title to window +set title +" Dictionary path, from which the words are being looked up. +"set dictionary=/usr/share/dict/words + +" Make pasting done without any indentation break +set pastetoggle= + +" Make Vim able to edit crontab fields again. +"set backupskip=/tmp/*,/private/tmp/*" + +" Enable Mouse +"set mouse=a + +syntax on + +"Settings for Searching and Moving +"nnoremap / /\v +"vnoremap / /\v +"Control it with %/s///i - ignore and I - sens +"set ignorecase +set smartcase +" %s///g not needed +set gdefault +set incsearch +set showmatch +set matchtime=3 +set hlsearch +nnoremap :noh +"nnoremap % +"vnoremap % + +" Make Vim to handle long lines nicely. +set wrap +set textwidth=79 +"set formatoptions=cqran1j +set formatoptions=cqrnb1j + +" Naviagations using keys up/down/left/right +" Disabling default keys to learn the hjkl +nnoremap k +nnoremap j +nnoremap h +nnoremap l +nnoremap :tabp +nnoremap :tabn + +nnoremap j gj +nnoremap k gk + +" Get Rid of stupid Goddamned help keys +inoremap +nnoremap +vnoremap + +" Map : to ; also in command mode. +"nnoremap ; : + +" Reselect visual block after incrementing/decrementing +vnoremap gv +vnoremap gv + +" Set vim to save the file on focus out. +"au FocusLost * :wa +nmap w :wa + +" Adding More Shorcuts keys using leader key. +" Leader Key provide separate namespace for specific commands. +",W Command to remove white space from a file. +""nnoremap W :%s/\s\+$//:let @/='' + +" Re-hardwrap Paragraph +nnoremap q gqip + +" ,v Select just pasted text. +"nnoremap v V`] + +" jj For Quicker Escaping between normal and editing mode. +inoremap jj + +" Working with split screen nicely +" Resize Split When the window is resized" +au VimResized * :wincmd = + +" Wildmenu completion " +set wildmenu +set wildmode=list:longest +set wildignore+=.hg,.git,.svn " Version Controls" +set wildignore+=*.aux,*.out,*.toc "Latex Indermediate files" +set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg "Binary Imgs" +set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest "Compiled Object files" +set wildignore+=*.spl "Compiled speolling world list" +set wildignore+=*.sw? "Vim swap files" +set wildignore+=*.DS_Store "OSX SHIT" +set wildignore+=*.luac "Lua byte code" +set wildignore+=migrations "Django migrations" +set wildignore+=*.pyc "Python Object codes" +set wildignore+=*.orig "Merge resolution files" + +"Make Sure that Vim returns to the same line when we reopen a file" +augroup line_return + au! + au BufReadPost * + \ if line("'\"") > 0 && line("'\"") <= line("$") | + \ execute 'normal! g`"zvzz' | + \ endif +augroup END + +match Error /\s\+$\|DUPA\c/ + +" Removing scrollbars +if has("gui_running") + set guitablabel=%-0.12t%M + set guioptions-=T + set guioptions-=r + set guioptions-=L + set guioptions+=a + set guioptions-=m + colorscheme molokai + set listchars=tab:▸\ ,eol:¬ " Invisibles using the Textmate style +else + set t_Co=256 + colorscheme badwolf + set background=dark + " To show special characters in Vim + set listchars=tab:▸\ ,trail:¬ + set list + hi clear SpellBad + hi SpellBad cterm=underline +endif + +" ========== Plugin Settings ==========" + +" Mapping to NERDTree +nnoremap :NERDTreeToggle +let NERDTreeIgnore=['\.vim$', '\~$', '\.pyc$'] + +" Mini Buffer some settigns." +let g:miniBufExplMapWindowNavVim = 1 +let g:miniBufExplMapWindowNavArrows = 1 +let g:miniBufExplMapCTabSwitchBufs = 1 +let g:miniBufExplModSelTarget = 1 +let g:miniBufExplStatusLineText = '' + +" Tab color settings to make it more visible. +hi MBEChanged ctermfg=white +hi MBENormal ctermfg=white + +" Tagbar key bindings." +"nmap t :TagbarToggle +"imap t :TagbarTogglei +nmap t :TlistToggle +imap t :TagbarTogglei + +nnoremap Y y$ +map a gg0VG$ + +nnoremap 2 :set tabstop=2 softtabstop=2 shiftwidth=2 +nnoremap 4 :set tabstop=4 softtabstop=4 shiftwidth=4 +nnoremap 8 :set tabstop=8 softtabstop=8 shiftwidth=8 + +"Full line: +"set colorcolumn=120 +"call matchadd('ColorColumn', '\%80v', 100) + +if has("autocmd") + "restore cursor position + autocmd BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif + autocmd FileType helpfile set nonumber + + autocmd WinLeave * set nocursorline + autocmd WinEnter * set cursorline + + autocmd FileType tex set textwidth=79 +endif + +if has("cscope") + "use both cscope and ctags + set cscopetag + + " change this to 1 to search ctags DBs first + set csto=0 + set cst + set nocsverb + " add any database in current directory + if filereadable("cscope.out") + cs add cscope.out + " else add database pointed to by environment + elseif $CSCOPE_DB != "" + cs add $CSCOPE_DB + endif + +" 's' symbol: find all references to the token under cursor +" 'g' global: find global definition(s) of the token under cursor +" 'c' calls: find all calls to the function name under cursor +" 't' text: find all instances of the text under cursor +" 'e' egrep: egrep search for the word under cursor +" 'f' file: open the filename under cursor +" 'i' includes: find files that include the filename under cursor +" 'd' called: find functions that function under cursor calls + + " Using 'CTRL-\' then a search type makes the vim window + " "shell-out", with search results displayed on the bottom + + nmap s :cs find s =expand("") + nmap g :cs find g =expand("") + nmap c :cs find c =expand("") + nmap t :cs find t =expand("") + nmap e :cs find e =expand("") + nmap f :cs find f =expand("") + nmap i :cs find i ^=expand("")$ + nmap d :cs find d =expand("") + + "" Using 'CTRL-spacebar' then a search type makes the vim window + "" split horizontally, with search result displayed in + "" the new window. + + " nmap s :scs find s =expand("") + " nmap g :scs find g =expand("") + " nmap c :scs find c =expand("") + " nmap t :scs find t =expand("") + " nmap e :scs find e =expand("") + " nmap f :scs find f =expand("") + " nmap i :scs find i ^=expand("")$ + " nmap d :scs find d =expand("") + + "" Hitting CTRL-space *twice* before the search type does a vertical + "" split instead of a horizontal one + + " nmap s :vert scs find s =expand("") + " nmap g :vert scs find g =expand("") + " nmap c :vert scs find c =expand("") + " nmap t :vert scs find t =expand("") + " nmap e :vert scs find e =expand("") + " nmap i :vert scs find i ^=expand("")$ + " nmap d :vert scs find d =expand("") +endif + +nnoremap yg :YcmCompleter GoTo +nnoremap yf :YcmCompleter FixIt +nnoremap yd :YcmCompleter GetDoc +nnoremap yt :YcmCompleter GetType +nnoremap yp :YcmCompleter GetParent +let g:ycm_confirm_extra_conf = 0 +let g:ycm_warning_symbol = '>' +let g:ycm_complete_in_strings = 0 +"let g:ycm_server_log_level = 'debug' +"let g:ycm_server_use_vim_stdout = 1 +let g:ycm_collect_identifiers_from_tags_files = 1 +let g:ycm_enable_diagnostic_highlighting = 0 +let g:ycm_autoclose_preview_window_after_completion = 0 +let g:ycm_autoclose_preview_window_after_insertion = 1 +let g:ycm_min_num_of_chars_for_completion = 99 + +"nnoremap :ConoLineColorDark +"nnoremap :ConoLineColorLight +map :colorscheme random + +set foldenable +set foldlevelstart=5 +set foldnestmax=5 +nnoremap za + +nnoremap s :mksession! + +"print the register +nmap q "ap +"save register +nmap Q "ayydd + +" Increment also letters +"set nrformats=alpha,octal,hex + +" Jira config +let b:jiracomplete_url = 'http://192.168.1.49:8080/jira' +let b:jiracomplete_username = 'r.kmiec' +let b:jiracomplete_password = 'password' +" We can also use v:val.menu +let b:jiracomplete_format = '"[". v:val.abbr. "]"' + +set updatetime=4000 + +" From C.vim: +" ADDITIONAL MAPPING : complete a classical C comment: '/*' => '/* | */' +"vnoremap /* s/**/p +" additional mapping : complete a classical C multi-line comment: +"inoremap /* /*/kA +" additional mapping : { always opens a block +inoremap { {}O +"vnoremap { S{}Pk=iB + +inoremap :w :wi + +"let g:clang_format#code_style = "WebKit" +let g:clang_format#command = "clang-format-3.9" +"let g:clang_format#auto_format_on_insert_leave = 1 +"let g:clang_format#auto_format = 1 + +let g:clang_format#style_options = { + \ "AccessModifierOffset" : -4, + \ "AlignAfterOpenBracket" : "false", + \ "AlignConsecutiveAssignments" : "false", + \ "AlignEscapedNewlinesLeft" : "false", + \ "AlignOperands" : "false", + \ "AlignTrailingComments" : "false", + \ "AllowAllParametersOfDeclarationOnNextLine" : "true", + \ "AllowShortBlocksOnASingleLine" : "false", + \ "AllowShortCaseLabelsOnASingleLine" : "false", + \ "AllowShortFunctionsOnASingleLine" : "All", + \ "AllowShortIfStatementsOnASingleLine" : "false", + \ "AllowShortLoopsOnASingleLine" : "false", + \ "AlwaysBreakAfterDefinitionReturnType" : "None", + \ "AlwaysBreakBeforeMultilineStrings" : "false", + \ "AlwaysBreakTemplateDeclarations" : "false", + \ "BinPackArguments" : "true", + \ "BinPackParameters" : "true", + \ "BreakBeforeBinaryOperators" : "All", + \ "BreakBeforeBraces" : "Stroustrup", + \ "BreakBeforeTernaryOperators" : "true", + \ "BreakConstructorInitializersBeforeComma" : "true", + \ "ColumnLimit" : 0, + \ "ConstructorInitializerAllOnOneLineOrOnePerLine" : "false", + \ "ConstructorInitializerIndentWidth" : 4, + \ "ContinuationIndentWidth" : 4, + \ "Cpp11BracedListStyle" : "false", + \ "DerivePointerAlignment" : "false", + \ "DisableFormat" : "false", + \ "ExperimentalAutoDetectBinPacking" : "false", + \ "IndentCaseLabels" : "false", + \ "IndentWidth" : "4", + \ "IndentWrappedFunctionNames" : "false", + \ "KeepEmptyLinesAtTheStartOfBlocks" : "true", + \ "MaxEmptyLinesToKeep" : "1", + \ "NamespaceIndentation" : "Inner", + \ "ObjCBlockIndentWidth" : "4", + \ "ObjCSpaceAfterProperty" : "true", + \ "ObjCSpaceBeforeProtocolList" : "true", + \ "PenaltyBreakBeforeFirstCallParameter" : "19", + \ "PenaltyBreakComment" : "300", + \ "PenaltyBreakFirstLessLess" : "120", + \ "PenaltyBreakString" : "1000", + \ "PenaltyExcessCharacter" : "1000000", + \ "PenaltyReturnTypeOnItsOwnLine" : "60", + \ "PointerAlignment" : "Left", + \ "SpaceAfterCStyleCast" : "false", + \ "SpaceBeforeAssignmentOperators" : "true", + \ "SpaceBeforeParens" : "ControlStatements", + \ "SpaceInEmptyParentheses" : "false", + \ "SpacesBeforeTrailingComments" : 1, + \ "SpacesInAngles" : "false", + \ "SpacesInContainerLiterals" : "true", + \ "SpacesInCStyleCastParentheses" : "false", + \ "SpacesInParentheses" : "false", + \ "SpacesInSquareBrackets" : "false", + \ "Standard" : "Cpp03", + \ "TabWidth" : 8, + \ "UseTab" : "Never"} + + +"let g:vebugger_leader='d' +"let g:vebugger_path_gdb='/home/kmir/ARM-TOOLCHAIN/cross/bin/arm-none-eabi-gdb' + +set foldtext=getline(v:foldstart) +set fillchars=fold:\ +set foldmethod=syntax +set expandtab + +"nnoremap :silent ! plantuml %:p && eog -g %:p:r.png &:redraw! + +" ctrlp configuration +let g:ctrlp_map = '' +let g:ctrlp_cmd = 'CtrlPLastMode' +let g:ctrlp_user_command = 'ack --cpp --cc -f %s' +let g:ctrlp_working_path_mode = 'rw' + +if &term =~ '256color' + " Disable Background Color Erase (BCE) so that color schemes + " work properly when Vim is used inside tmux and GNU screen. + set t_ut= +endif + +let g:alternateSearchPath="sfr:../source,sfr:../src,sfr:../include,sfr:../inc,sfr:./Source,sfr:.." + +set nowrapscan + +tnoremap N +"set notimeout ttimeout timeoutlen=100 + +set spelllang=en,pl + +" from vimconfig.com +"set showbreak=++ + +"let g:rtagsRcCmd='rtags-rc' +set timeoutlen=1000 +set ttimeoutlen=0 +let g:matchparen_timeout = 2 +let g:matchparen_insert_timeout = 2 + + +" taken from Damian Conway + +nnoremap n n:call HLNext(0.2) +nnoremap N N:call HLNext(0.2) + +function! HLNext(blinktime) + let [bufnum, lnum, col, off] = getpos('.') + let matchlen = strlen(matchstr(strpart(getline('.'), col - 1), @/)) + let target_pat = '\c\%#'.@/ + let blinks = 1 + for n in range(1, blinks) + let red = matchadd('WarningMsg', target_pat, 101) + redraw + exec 'sleep ' . float2nr(a:blinktime / (2*blinks) * 1000) . 'm' + call matchdelete(red) + redraw + exec 'sleep ' . float2nr(a:blinktime / (2*blinks) * 1000) . 'm' + endfor +endfunction + +nmap S [Shortcut for :s///g] :%s//g +xmap S :s//g +xmap x