From 0c7dbfc4be3eac7437bd24a258663f03330be216 Mon Sep 17 00:00:00 2001 From: qx13468 Date: Fri, 13 Apr 2007 09:08:13 +0000 Subject: [PATCH] Angleichen bmsk - bmsx: Bmsk benutzt GetVars, ... git-svn-id: https://vimsuite.svn.sourceforge.net/svnroot/vimsuite/trunk@134 eb2d0018-73a3-4aeb-bfe9-1def61c9ec69 --- vimfiles.stefan/compiler/bmsk.vim | 54 ------------------------------- vimfiles.stefan/ftplugin/vim.vim | 4 ++- vimfiles.stefan/plugin/bmsk.vim | 11 +++++-- vimfiles.stefan/plugin/tools.vim | 49 ++++++++++++++++++---------- 4 files changed, 43 insertions(+), 75 deletions(-) diff --git a/vimfiles.stefan/compiler/bmsk.vim b/vimfiles.stefan/compiler/bmsk.vim index 6ccf800..c7494ba 100644 --- a/vimfiles.stefan/compiler/bmsk.vim +++ b/vimfiles.stefan/compiler/bmsk.vim @@ -14,9 +14,6 @@ let b:forceRedoTexCompiler = 'yes' let g:Tex_ShowallLines = 1 "execute 'source ' . expand(g:vimfiles . '/compiler/tex.vim') -let g:makeprg = simplify(GetBmskDir() . '/make_fsw.bat') -let &makeprg = g:makeprg . ' $*' - if exists('g:make_log') let &shellpipe = '| ' . g:tee . PathNormpath(make_log) . ' | ' . g:tee else @@ -133,22 +130,6 @@ if (g:SW_Stand != '') let g:makeopts = g:makeopts . ' Stand=' . g:SW_Stand endif -" user commands -command! -nargs=* Make execute(':make! ' . g:makeopts) -command! -nargs=0 Clean call Clean() -command! -nargs=0 CleanAll call CleanAll() -command! Compile call Compile_File() -command! PreCompile call PreCompile_File() - -" Clean function -function! Clean() - Make clean -endfunction -function! CleanAll() - cscope kill -1 - Make cleanall -endfunction - " reformat i-file command! ReformatIFile call Reformat_IFile() function! Reformat_IFile() abort @@ -168,38 +149,3 @@ function! Reformat_IFile() abort endwhile endfunction -function! GetMakeVar(varName) - let var = GetMakeVars([a:varName]) - if has_key(var, a:varName) - let varValue = var[a:varName] - else - let varValue = '' - endif - return varValue -endfunction - -function! GetMakeVars(varNameList) - let varlist = {} - try - let vars = join(a:varNameList, ' ') - let command = g:makeprg . g:makeopts . ' getvar name="' . vars . '"' - let output = system(command) - let lines = split(output, "\n") - if len(lines) == 1 - " make < make-43 (Antwort nur VALUE) - let RE = '\(.*\)' - let SU = "let varlist['" . vars . "']='\\1'" - else - " make >= make-43 (Antwort: NAME=VALUE - let RE = '^\(\w\+\)=\(.*\)\s*' - let SU = "let varlist['\\1']='\\2'" - endif - for line in lines - if match(line, RE) >= 0 - execute substitute(line, RE, SU, '') - endif - endfor - endtry - return varlist -endfunction - diff --git a/vimfiles.stefan/ftplugin/vim.vim b/vimfiles.stefan/ftplugin/vim.vim index 1cd0a40..05786e4 100644 --- a/vimfiles.stefan/ftplugin/vim.vim +++ b/vimfiles.stefan/ftplugin/vim.vim @@ -10,7 +10,9 @@ setlocal softtabstop=4 setlocal formatoptions=croq " vimfiles sollen immer im unix-Format gespeichert werden -setlocal fileformat=unix +if filereadable('%') + setlocal fileformat=unix +endif " commenting let b:commentstring = '"' diff --git a/vimfiles.stefan/plugin/bmsk.vim b/vimfiles.stefan/plugin/bmsk.vim index ba5e5f3..a41493a 100644 --- a/vimfiles.stefan/plugin/bmsk.vim +++ b/vimfiles.stefan/plugin/bmsk.vim @@ -45,6 +45,8 @@ function s:SetBmskProject(basedir) let basedir = fnamemodify(makefile, ':p:h') let makefile = fnamemodify(makefile, ':t') if ((makefile == 'make_fsw.bat') || (makefile == 'makefile.mak') || (makefile == 'makefile')) + let g:makeCommand = makefile + let &makeprg = g:makeCommand . ' $*' call s:SetBmskDirs(basedir) else echo 'No makefile:' makefile @@ -59,6 +61,8 @@ function s:SetBmskProject(basedir) let basedir = fnamemodify(makefile, ':p:h') endif if (filereadable(makefile)) + let g:makeCommand = makefile + let &makeprg = g:makeCommand . ' $*' call s:SetBmskDirs(basedir) else echo 'No makefile' makefile @@ -755,7 +759,8 @@ command -nargs=? GrepBmsk call GrepFull(GetBmskSwDir(), '*.c *.h *.kgs', ' " ---------------- " Make and compile " ---------------- -command -complete=custom,GetAllBmskTargets -nargs=* Bmsk call s:Bmsk('') +"command -complete=custom,GetAllBmskTargets -nargs=* Make call s:Make('') +command -complete=custom,GetAllBmskTargets -nargs=* Bmsk call s:Make('') command -complete=custom,GetAllBmskTargets -nargs=* BmskDoku call s:BmskDoku('') command -nargs=* Clean compiler bmsk | Clean command -nargs=* CleanAll compiler bmsk | CleanAll @@ -764,11 +769,11 @@ command -nargs=* Lint Bmsk %:t:r.lint command -complete=customlist,GetAllBmskSWStand -nargs=1 BmskAll call s:BmskAll('') " Programmstand compilieren -function s:Bmsk(args) +function s:Make(args) echo a:args cscope kill -1 compiler bmsk - execute 'Make ' . a:args + execute 'make!' a:args g:makeopts CscopeConnect clist endfunction diff --git a/vimfiles.stefan/plugin/tools.vim b/vimfiles.stefan/plugin/tools.vim index a1522a6..ae0d73b 100644 --- a/vimfiles.stefan/plugin/tools.vim +++ b/vimfiles.stefan/plugin/tools.vim @@ -25,7 +25,7 @@ let g:projectFile = fnamemodify($VIMRUNTIME . '/../projects.txt', ':p') " SetProject " ---------- if (v:version > 602) - command -complete=customlist,GetAllMakefiles -nargs=? SetProject call s:SetProject('') + command -complete=customlist,GetAllMakefiles -nargs=? SetProject call SetProject('') else command -nargs=1 SetProject call SetProject('') endif @@ -84,7 +84,7 @@ endfunction " Find makefile and set some options " ---------------------------------- -function s:SetProject(makefile) +function SetProject(makefile) if ((a:makefile == '') && has('browse')) " Browse for makefile if exists('g:WA') @@ -106,13 +106,16 @@ function s:SetProject(makefile) " split file name and path let g:basedir = fnamemodify(makefilePath, ':p:h') - let g:makefileName = fnamemodify(makefilePath, ':t') + let makefileName = fnamemodify(makefilePath, ':t') " test if makefile is a batch-script - let ext = fnamemodify(g:makefileName, ':e') + let ext = fnamemodify(makefileName, ':e') if ext == 'bat' - let &makeprg = makefilePath . ' $*' + let g:makeCommand = makefilePath + else + let g:makeCommand = 'make -f ' . makefilePath endif + let &makeprg = g:makeCommand . ' $*' " set directories execute 'cd ' . g:basedir @@ -138,7 +141,7 @@ function s:SetProjectVariables() \ 'VIM_CSCOPEFILE', \ 'GOALS', \] - let s:Variables = s:GetMakeVars(varnames) + let s:Variables = GetMakeVars(varnames) echo 'Reading variables from makefile' echo '-------------------------------' @@ -154,7 +157,7 @@ function s:SetProjectVariables() try execute 'set path=' . s:Variables['VIM_PATH'] catch - echoerr 'cant set path to ' . s:Variables['VIM_PATH'] + echoerr 'cant set path to "' . s:Variables['VIM_PATH'] . '"' echoerr 'check the make variable VIM_PATH' endtry else @@ -166,7 +169,7 @@ function s:SetProjectVariables() try execute 'set tags=' . s:Variables['VIM_TAGS'] catch - echoerr 'cant set tags to ' . s:Variables['VIM_TAGS'] + echoerr 'cant set tags to "' . s:Variables['VIM_TAGS'] . '"' echoerr 'check the make variable VIM_TAGS' endtry else @@ -178,7 +181,7 @@ function s:SetProjectVariables() try execute 'set cscopeprg=' . s:Variables['VIM_CSCOPEPRG'] catch - echoerr 'cant set cscopeprg to ' . s:Variables['VIM_CSCOPEPRG'] + echoerr 'cant set cscopeprg to "' . s:Variables['VIM_CSCOPEPRG'] . '"' echoerr 'check the make variable VIM_CSCOPEPRG' endtry else @@ -189,7 +192,7 @@ function s:SetProjectVariables() cscope kill -1 execute 'cscope add ' . s:Variables['VIM_CSCOPEFILE'] catch - echomsg 'cant add cscope-file ' . s:Variables['VIM_CSCOPEFILE'] + echomsg 'cant add cscope-file "' . s:Variables['VIM_CSCOPEFILE'] . '"' echomsg 'check the make variable VIM_CSCOPEFILE and if file exists' endtry else @@ -201,7 +204,7 @@ function s:SetProjectVariables() try execute 'compiler ' . s:Variables['VIM_COMPILER'] catch - echoerr 'cant set compiler to ' . s:Variables['VIM_COMPILER'] + echoerr 'cant set compiler to "' . s:Variables['VIM_COMPILER'] . '"' echoerr 'check the make variable VIM_COMPILER' endtry else @@ -209,29 +212,30 @@ function s:SetProjectVariables() endif catch - echoerr 'Could not read variables from makefile (vim-script-error)' + echoerr 'Error while reading make-variables: ' . v:exception endtry endfunction " Get values for a list of variables as dictionary -function! s:GetMakeVars(varNameList) +function GetMakeVars(varNameList) let varlist = {} try let vars = join(a:varNameList, ' ') - let command = g:makefileName . ' getvar name="' . vars . '"' + let command = g:makeCommand . ' getvar name="' . vars . '"' + "echomsg command let output = system(command) let lines = split(output, "\n") let RE = '^\(\w\+\)=\(.*\)\s*' let SU = "let varlist['\\1']='\\2'" - "echo 'getvars:' + "echomsg 'getvars:' for line in lines - " echo line + "echomsg line if match(line, RE) >= 0 execute substitute(line, RE, SU, '') endif endfor - "echo '' + "echomsg '' catch echoerr 'Could not read make variables' endtry @@ -248,6 +252,17 @@ function! s:GetMakeVars(varNameList) return varlist endfunction +function GetMakeVar(varName) + let var = GetMakeVars([a:varName]) + try + varValue = var[a:varName] + catch + varValue = '' + echoerr 'Could not read make-variable "' . varName . '"' + endtry + return varValue +endfunction + " ------------------------------------------ " special make-command for target-completion " ------------------------------------------