From 263bc89ae7767d47b7d65cc970acea98dcc8f6e7 Mon Sep 17 00:00:00 2001 From: Stefan Liebl Date: Thu, 16 Feb 2017 17:12:04 +0100 Subject: [PATCH] some little helpers --- vimfiles.stefan/after/ftplugin/gitcommit.vim | 5 ++ vimfiles.stefan/after/ftplugin/html.vim | 8 +-- vimfiles.stefan/after/ftplugin/python.vim | 2 +- vimfiles.stefan/plugin/toptica.vim | 57 ++++++++++++++++++-- 4 files changed, 62 insertions(+), 10 deletions(-) create mode 100644 vimfiles.stefan/after/ftplugin/gitcommit.vim diff --git a/vimfiles.stefan/after/ftplugin/gitcommit.vim b/vimfiles.stefan/after/ftplugin/gitcommit.vim new file mode 100644 index 0000000..f6bae85 --- /dev/null +++ b/vimfiles.stefan/after/ftplugin/gitcommit.vim @@ -0,0 +1,5 @@ +" Stefans gitcommit-filetype-plugin + +" add branch name to commit message +nnoremap gcc :execute 'normal i'.fugitive#head()A: +nnoremap ccc :Gcommit:execute 'normal i'.fugitive#head()A: diff --git a/vimfiles.stefan/after/ftplugin/html.vim b/vimfiles.stefan/after/ftplugin/html.vim index a511aaf..7b8be0b 100644 --- a/vimfiles.stefan/after/ftplugin/html.vim +++ b/vimfiles.stefan/after/ftplugin/html.vim @@ -23,11 +23,11 @@ endfunction " These mappings and TagSelection function will allow you to place " an XML tag around either the current word, or the current selected " text -"nmap _t viw_t -"vnoremap _t :call TagSelection() +"nmap _t viw_t +"vnoremap _t :call TagSelection() " -"nmap _t viw_t -"vnoremap _t :call TagSelection() +"nmap _t viw_t +"vnoremap _t :call TagSelection() " "function! TagSelection() " let l:tag = input("Tag name? ") diff --git a/vimfiles.stefan/after/ftplugin/python.vim b/vimfiles.stefan/after/ftplugin/python.vim index e168db0..5305679 100644 --- a/vimfiles.stefan/after/ftplugin/python.vim +++ b/vimfiles.stefan/after/ftplugin/python.vim @@ -20,7 +20,7 @@ endpython endfunction call Set_python_tag_files() -nnoremap :YcmCompleter GoTo +nnoremap :YcmCompleter GoTo " commenting let b:commentstring = '#' diff --git a/vimfiles.stefan/plugin/toptica.vim b/vimfiles.stefan/plugin/toptica.vim index fc32f34..626f1bf 100644 --- a/vimfiles.stefan/plugin/toptica.vim +++ b/vimfiles.stefan/plugin/toptica.vim @@ -19,6 +19,7 @@ function s:ProjectDlcproSet(project_type) execute 'cd '.s:ProjectSrcDir execute 'set path-=./**' execute 'set path+=' . s:ProjectBaseDir.'/**' + execute 'set path+=/opt/OSELAS.Toolchain-2012.12.1/arm-cortexa8-linux-gnueabi/gcc-4.7.3-glibc-2.16.0-binutils-2.22-kernel-3.6-sanitized/sysroot-arm-cortexa8-linux-gnueabi/usr/include' " editor settings set spell spelllang=en,de @@ -31,7 +32,7 @@ function s:ProjectDlcproSet(project_type) " compiler compiler gcc - let s:makegoals = ['artifacts', 'device-control', 'user-interface', 'doxygen', 'shg-firmware', 'docu-ul0', 'code-generation', 'dependency-graphs'] + let s:makegoals = ['artifacts', 'device-control', 'user-interface', 'doxygen', 'shg-firmware', 'docu-ul0', 'code-generation', 'dependency-graphs', 'clean', 'distclean', 'help'] let s:makeopts = ['-j4'] let g:Program = g:ProjectBuildDir.s:Program command! -complete=custom,GetAllMakeCompletions -nargs=* Make call s:Make('') @@ -75,8 +76,16 @@ function s:ProjectDlcproSet(project_type) \'~/dlcpro/firmware/.ycm_extra_conf.py', \'!~/tools/vimsuite/vimfiles.YouCompleteMe/*', \] + + " rtags + command! RtagsIncludeTree execute('!rc --dependencies %') + + " little helpers + command! -nargs=? BuildDirStash call s:BuildDirStash('') + command! -nargs=? BuildDirUnStash call s:BuildDirUnStash('') + endfunction - + " ==== " Make " ==== @@ -91,10 +100,13 @@ function s:Make(args) endfunction function s:Cmake(build_type) - if a:build_type == '' - let build_type = 'Debug' - else + if a:build_type != '' let build_type = a:build_type + else + let build_type = 'Debug' + endif + if !isdirectory(g:ProjectBuildDir) + call mkdir(g:ProjectBuildDir) endif call asyncrun#quickfix_toggle(10, 1) let args = "" @@ -150,3 +162,38 @@ function ClangFormat() endif pyf /usr/share/vim/addons/syntax/clang-format.py endfunction + +" =============== +" Stash / Unstash +" =============== +function s:BuildDirStash(suffix) + if a:suffix != '' + let suffix = a:suffix + else + let suffix = fugitive#head() + endif + let target_dir = g:ProjectBuildDir.'.'.suffix + let subverion = 1 + while isdirectory(target_dir) + let target_dir = g:ProjectBuildDir.'.'.suffix.'.'.subsuffix + let subsuffix += 1 + endwhile + call rename(g:ProjectBuildDir, target_dir) +endfunction + +function s:BuildDirUnStash(suffix) + if a:suffix != '' + let suffix = a:suffix + else + let suffix = fugitive#head() + endif + let source_dir = g:ProjectBuildDir.'.'.suffix + if !isdirectory(source_dir) + echoerr 'source directory '.source_dir.' not found' + elseif isdirectory(g:ProjectBuildDir) + echoerr 'target directory '.g:ProjectBuildDir.' exists' + else + call rename(source_dir, g:ProjectBuildDir) + endif +endfunction +