diff --git a/.gvimrc b/.gvimrc new file mode 100644 index 0000000..b5b7037 --- /dev/null +++ b/.gvimrc @@ -0,0 +1 @@ +colorscheme evening diff --git a/.vim/CurtinIncSw.vim b/.vim/CurtinIncSw.vim new file mode 100644 index 0000000..63b4e35 --- /dev/null +++ b/.vim/CurtinIncSw.vim @@ -0,0 +1,41 @@ +function! CurtineIncSw() + if match(expand("%"), '\.c') > 0 + let l:next_file = substitute(".*\\\/" . expand("%:t"), '\.c\(.*\)', '.h[a-z]*', "") + elseif match(expand("%"), "\\.h") > 0 + let l:next_file = substitute(".*\\\/" . expand("%:t"), '\.h\(.*\)', '.c[a-z]*', "") + endif + + if exists("b:previous_file") && b:previous_file == l:next_file + e# + else + let l:directory_name = fnamemodify(expand("%:p"), ":h") + " At this point cmd might evaluate to something of the format: + " /Users/person/ . -type f -iregex ".*\/test_class.h[a-z]*" -print -quit + let l:cmd="find " . l:directory_name . " . -type f -iregex \"" . l:next_file . "\" -print -quit" + + " The substitute gets rid of the new line at the end of the result. The + " function `filereadable` does not like the newline that `find` puts at + " the end of the result and will not acknowledge that the file exists. + let l:result = substitute(system(l:cmd), '\n', '', '') + + if filereadable(l:result) + exe "e " l:result + endif + endif +endfun + +function! GetCurrentFile() + if exists("b:current_file") + let b:previous_file = b:current_file + endif + + if match(expand("%"), '\.c') > 0 + let b:current_file = substitute(".*\\\/" . expand("%:t"), '\.c\(.*\)', '.c[a-z]*', "") + elseif match(expand("%"), "\\.h") > 0 + let b:current_file = substitute(".*\\\/" . expand("%:t"), '\.h\(.*\)', '.h[a-z]*', "") + endif +endfun + +augroup CurtineIncSwCurrentFile + autocmd BufWinEnter * call GetCurrentFile() +augroup END diff --git a/.vim/bundle/CurtineIncSw.vim b/.vim/bundle/CurtineIncSw.vim new file mode 160000 index 0000000..6b32ef6 --- /dev/null +++ b/.vim/bundle/CurtineIncSw.vim @@ -0,0 +1 @@ +Subproject commit 6b32ef621cd96442e726fab1a815429dd9e0f991 diff --git a/.vim/bundle/Vundle.vim b/.vim/bundle/Vundle.vim new file mode 160000 index 0000000..9a38216 --- /dev/null +++ b/.vim/bundle/Vundle.vim @@ -0,0 +1 @@ +Subproject commit 9a38216a1c0c597f978d73547d37681fc689c90d diff --git a/.vim/bundle/c.vim b/.vim/bundle/c.vim new file mode 160000 index 0000000..69f0368 --- /dev/null +++ b/.vim/bundle/c.vim @@ -0,0 +1 @@ +Subproject commit 69f0368c7d8dac196bd94ddfa80d98b1cedc7eb0 diff --git a/.vim/bundle/ctrlp.vim b/.vim/bundle/ctrlp.vim new file mode 160000 index 0000000..2e773fd --- /dev/null +++ b/.vim/bundle/ctrlp.vim @@ -0,0 +1 @@ +Subproject commit 2e773fd8c7548526853fff6ee2e642eafbbe3d04 diff --git a/.vim/bundle/nerdtree b/.vim/bundle/nerdtree new file mode 160000 index 0000000..33fe2fd --- /dev/null +++ b/.vim/bundle/nerdtree @@ -0,0 +1 @@ +Subproject commit 33fe2fdf16a95c12e8284364c780ed405dbaad17 diff --git a/.vim/bundle/vim-buffergator b/.vim/bundle/vim-buffergator new file mode 160000 index 0000000..947b60d --- /dev/null +++ b/.vim/bundle/vim-buffergator @@ -0,0 +1 @@ +Subproject commit 947b60dca4d4fc6a041a6ec84b17ca6736d1b916 diff --git a/.vim/bundle/vim-fugitive b/.vim/bundle/vim-fugitive new file mode 160000 index 0000000..aff3359 --- /dev/null +++ b/.vim/bundle/vim-fugitive @@ -0,0 +1 @@ +Subproject commit aff3359699559231faee7d645678f71190700ec6 diff --git a/.vim/bundle/vim-gutentags b/.vim/bundle/vim-gutentags new file mode 160000 index 0000000..eecb136 --- /dev/null +++ b/.vim/bundle/vim-gutentags @@ -0,0 +1 @@ +Subproject commit eecb136fae97e30d5f01e71f0d3b775c8b017385 diff --git a/.vimrc b/.vimrc new file mode 100755 index 0000000..a040c3a --- /dev/null +++ b/.vimrc @@ -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 ,write +command! -bang Q quit + +" 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 " 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 +" Regen cscope +" sh ~/bin/gen_cscope.sh . .git/cscope.out +" +" Key binds +" + +nmap :NERDTreeToggle +nmap :NERDTreeFind +map :call CurtineIncSw() +nmap :silent !/home/efjtjkb/bin/comp +" Remap (c-vim uses this) +"nmap :silent !/home/efjtjkb/bin/run +autocmd VimEnter * noremap :silent !/home/efjtjkb/bin/run +nmap :silent !/home/efjtjkb/bin/run old + +" 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,"") + call append(start+18,"ET_TEST_F(" . a:name . ", )") +endfunction