vim: initial

This commit is contained in:
Robert Kmiec
2019-04-24 17:28:20 +02:00
commit d3e5416414

542
.vimrc Normal file
View File

@@ -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 <F6> :call CurtineIncSw()<CR>
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=<F3>
" 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 <leader><space> :noh<cr>
"nnoremap <tab> %
"vnoremap <tab> %
" 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 <up> <C-w>k
nnoremap <down> <C-w>j
nnoremap <left> <C-w>h
nnoremap <right> <C-w>l
nnoremap <Home> :tabp<CR>
nnoremap <End> :tabn<CR>
nnoremap j gj
nnoremap k gk
" Get Rid of stupid Goddamned help keys
inoremap <F1> <ESC>
nnoremap <F1> <ESC>
vnoremap <F1> <ESC>
" Map : to ; also in command mode.
"nnoremap ; :
" Reselect visual block after incrementing/decrementing
vnoremap <c-a> <c-a>gv
vnoremap <c-x> <c-x>gv
" Set vim to save the file on focus out.
"au FocusLost * :wa
nmap <leader>w :wa<CR>
" 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 <leader>W :%s/\s\+$//<cr>:let @/=''<CR>
" Re-hardwrap Paragraph
nnoremap <leader>q gqip
" ,v Select just pasted text.
"nnoremap <leader>v V`]
" jj For Quicker Escaping between normal and editing mode.
inoremap jj <ESC>
" 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 <C-n> :NERDTreeToggle<cr>
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 <leader>t <ESC>:TagbarToggle<cr>
"imap <leader>t <ESC>:TagbarToggle<cr>i
nmap <leader>t :TlistToggle<cr>
imap <leader>t <ESC>:TagbarToggle<cr>i
nnoremap Y y$
map <Leader>a gg0VG$
nnoremap <leader>2 <esc>:set tabstop=2 softtabstop=2 shiftwidth=2<cr>
nnoremap <leader>4 <esc>:set tabstop=4 softtabstop=4 shiftwidth=4<cr>
nnoremap <leader>8 <esc>:set tabstop=8 softtabstop=8 shiftwidth=8<cr>
"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 <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR>
"" Using 'CTRL-spacebar' then a search type makes the vim window
"" split horizontally, with search result displayed in
"" the new window.
" nmap <C-[>s :scs find s <C-R>=expand("<cword>")<CR><CR>
" nmap <C-[>g :scs find g <C-R>=expand("<cword>")<CR><CR>
" nmap <C-[>c :scs find c <C-R>=expand("<cword>")<CR><CR>
" nmap <C-[>t :scs find t <C-R>=expand("<cword>")<CR><CR>
" nmap <C-[>e :scs find e <C-R>=expand("<cword>")<CR><CR>
" nmap <C-[>f :scs find f <C-R>=expand("<cfile>")<CR><CR>
" nmap <C-[>i :scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
" nmap <C-[>d :scs find d <C-R>=expand("<cword>")<CR><CR>
"" Hitting CTRL-space *twice* before the search type does a vertical
"" split instead of a horizontal one
" nmap <C-[><C-[>s :vert scs find s <C-R>=expand("<cword>")<CR><CR>
" nmap <C-[><C-[>g :vert scs find g <C-R>=expand("<cword>")<CR><CR>
" nmap <C-[><C-[>c :vert scs find c <C-R>=expand("<cword>")<CR><CR>
" nmap <C-[><C-[>t :vert scs find t <C-R>=expand("<cword>")<CR><CR>
" nmap <C-[><C-[>e :vert scs find e <C-R>=expand("<cword>")<CR><CR>
" nmap <C-[><C-[>i :vert scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
" nmap <C-[><C-[>d :vert scs find d <C-R>=expand("<cword>")<CR><CR>
endif
nnoremap yg :YcmCompleter GoTo<CR>
nnoremap yf :YcmCompleter FixIt<CR>
nnoremap yd :YcmCompleter GetDoc<CR>
nnoremap yt :YcmCompleter GetType<CR>
nnoremap yp :YcmCompleter GetParent<CR>
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 <F10> :ConoLineColorDark<CR>
"nnoremap <S-F10> :ConoLineColorLight<CR>
map <F12> :colorscheme random<CR>
set foldenable
set foldlevelstart=5
set foldnestmax=5
nnoremap <space> za
nnoremap <leader>s :mksession!<CR>
"print the register
nmap <leader>q "ap
"save register
nmap <leader>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 <buffer> /* s/*<Space><Space>*/<Left><Left><Left><Esc>p
" additional mapping : complete a classical C multi-line comment:
"inoremap <buffer> /*<CR> /*<CR><CR>/<Esc>kA<Space>
" additional mapping : {<CR> always opens a block
inoremap <buffer> {<CR> {<CR>}<Esc>O
"vnoremap <buffer> {<CR> S{<CR>}<Esc>Pk=iB
inoremap :w<CR> <Esc>:w<CR>i
"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='<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 <F2> :silent ! plantuml %:p && eog -g %:p:r.png &<CR>:redraw!<CR>
" ctrlp configuration
let g:ctrlp_map = '<c-p>'
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 <Esc> <C-W>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 <silent> n n:call HLNext(0.2)<cr>
nnoremap <silent> N N:call HLNext(0.2)<cr>
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<LEFT><LEFT>
xmap S :s//g<LEFT><LEFT>
xmap <BS> x