Add vimrc

Change-Id: I25f3f01fc24ba0d94aa84f7ae5fab22a282460ae
This commit is contained in:
Jakub Fojt
2019-07-09 15:03:20 +02:00
parent 5f25c94fc4
commit 267dbd2ef6
10 changed files with 170 additions and 0 deletions

121
.vimrc Executable file
View File

@@ -0,0 +1,121 @@
cd /repo/efjtjkb/epg/up/
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim' " let Vundle manage Vundle, required
Plugin 'scrooloose/nerdtree'
Plugin 'c.vim'
Plugin 'jeetsukumaran/vim-buffergator'
Plugin 'ericcurtin/CurtineIncSw.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'ctrlpvim/ctrlp.vim'
call vundle#end() " required
filetype plugin indent on " required
set tabstop=4 " show existing tab with 4 spaces width
set shiftwidth=4 " when indenting with '>', use 4 spaces width
set expandtab " On pressing tab, insert 4 spaces
set mouse=a
set nu
" define upper case versions of :w and :q
command! -bang -range=% -complete=file -nargs=* W <line1>,<line2>write<bang> <args>
command! -bang Q quit<bang>
" fugitive.vim looks for tags in .git
" set tags +=~/tags " Recursively move upwards in tree, searching in subfolders for tags file
" Open NERDTree if no file specified
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
" CtrlP
let g:ctrlp_working_path_mode = 'ra'
" Find project root
let git_dir_location=finddir('.git', ';')
let git_root_location=fnamemodify(git_dir_location, ':h')
" Locate cscope file
if has("cscope")
set csto=0 " Search cscope before ctags
set cst " <C-]> searches cscope also
set nocsverb " Not verbose when adding database
set cspc=3 " Display the last 3 components of file path
"add any database in current dir
if filereadable("cscope.out")
cs add cscope.out
"else search cscope.out in git folder
else
let cscope_file=findfile("cscope.out", git_dir_location)
if !empty(cscope_file) && filereadable(cscope_file)
exe "cs add" cscope_file git_root_location
endif
endif
endif
command! Csc cscope find c <cword>
" Regen cscope
" sh ~/bin/gen_cscope.sh . .git/cscope.out
"
" Key binds
"
nmap <F2> :NERDTreeToggle<CR>
nmap <F3> :NERDTreeFind<CR>
map <F5> :call CurtineIncSw()<CR>
nmap <F8> :silent !/home/efjtjkb/bin/comp<enter>
" Remap <F9> (c-vim uses this)
"nmap <F9> :silent !/home/efjtjkb/bin/run<enter>
autocmd VimEnter * noremap <F9> :silent !/home/efjtjkb/bin/run<enter>
nmap <F10> :silent !/home/efjtjkb/bin/run old<enter>
" MINUT to et macros
let @a=':%s/MINUT_ASSERT_EQ/et_asserteq/ge
\:%s/MINUT_ASSERT_NE/et_assertne/ge
\:%s/MINUT_ASSERT_STREQ/et_asserteq_str/ge
\:%s/MINUT_ASSERT_STRNE/et_assertne_str/ge
\:%s/MINUT_ASSERT_PTREQ/et_asserteq_ptr/ge
\:%s/MINUT_ASSERT_PTRNE/et_assertne_ptr/ge
\:%s/MINUT_ASSERT/et_assert/ge
\:%s/MINUT_TEST_EQ/et_asserteq/ge
\:%s/MINUT_TEST_NE/et_assertne/ge
\:%s/MINUT_TEST_STREQ/et_asserteq_str/ge
\:%s/MINUT_TEST_STRNE/et_assertne_str/ge
\:%s/MINUT_TEST_PTREQ/et_asserteq_ptr/ge
\:%s/MINUT_TEST_PTRNE/et_assertne_ptr/ge
\:%s/MINUT_TEST/et_assert/ge
\:%s/\_s\+MINUT_RETURN_SUCCESS();//e
" \_s\+ all preceding whitespace
\:%s/#include "minut.h"/#include "et.h"/ge
'
function! Et(name)
let start = line('.') - 1
call append(start,"ET_FIXTURE(" . a:name . ", setup, teardown) {")
call append(start+1,"")
call append(start+2,"};")
call append(start+3,"")
call append(start+4,"ET_FIXTURE_FN(" . a:name . ", setup)")
call append(start+5,"{")
call append(start+6," " . a:name . "* fixture = et_test_fixture();")
call append(start+7,"")
call append(start+8," (void)fixture;")
call append(start+9,"}")
call append(start+10,"")
call append(start+11,"ET_FIXTURE_FN(" . a:name . ", teardown)")
call append(start+12,"{")
call append(start+13," " . a:name . "* fixture = et_test_fixture();")
call append(start+14,"")
call append(start+15," (void)fixture;")
call append(start+16,"}")
call append(start+17,"")