SetProject unterstützt project.vim
git-svn-id: https://vimsuite.svn.sourceforge.net/svnroot/vimsuite/trunk@140 eb2d0018-73a3-4aeb-bfe9-1def61c9ec69
This commit is contained in:
parent
bcb2bb581f
commit
d97485db30
@ -14,7 +14,11 @@ if exists('nochangelog')
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
function s:ReportRev(Rev)
|
function s:ReportRev(Rev)
|
||||||
if a:Rev >= '129'
|
if a:Rev >= '139'
|
||||||
|
echo 'Neu seit Rev: 129'
|
||||||
|
echo 'Projekt laden über project.vim'
|
||||||
|
echo 'Einstellungen bleiben gespeichert'
|
||||||
|
elseif a:Rev >= '129'
|
||||||
echo 'Neu seit Rev: 129'
|
echo 'Neu seit Rev: 129'
|
||||||
echo 'Tags für BMS-X'
|
echo 'Tags für BMS-X'
|
||||||
echo 'Doxygen Toolkit'
|
echo 'Doxygen Toolkit'
|
||||||
@ -144,7 +148,7 @@ function s:ReportRev(Rev)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" uncomment next line to get changelog for the last version
|
" uncomment next line to get changelog for the last version
|
||||||
"execute 'call s:ReportRev(' . g:VimFilesRevision . ')'
|
execute 'call s:ReportRev(' . g:VimFilesRevision . ')'
|
||||||
|
|
||||||
" comment changelog after first usage
|
" comment changelog after first usage
|
||||||
silent! new <sfile>
|
silent! new <sfile>
|
||||||
|
@ -12,26 +12,27 @@ if !exists("basedir")
|
|||||||
let g:basedir = getcwd()
|
let g:basedir = getcwd()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let s:makefileNames = [
|
let s:projectFileNames = [
|
||||||
\ 'makefile',
|
\ 'makefile',
|
||||||
\ 'Makefile',
|
\ 'Makefile',
|
||||||
\ 'makefile.mak',
|
\ 'makefile.mak',
|
||||||
\ 'Makefile.mak',
|
\ 'Makefile.mak',
|
||||||
\ 'make.bat',
|
\ 'make.bat',
|
||||||
\ 'make_fsw.bat']
|
\ 'make_fsw.bat',
|
||||||
let g:projectFile = fnamemodify($VIMRUNTIME . '/../projects.txt', ':p')
|
\ 'project.vim']
|
||||||
|
let g:projectsFile = fnamemodify($VIMRUNTIME . '/../projects.txt', ':p')
|
||||||
|
|
||||||
" ----------
|
" ----------
|
||||||
" SetProject
|
" SetProject
|
||||||
" ----------
|
" ----------
|
||||||
command -complete=customlist,GetAllMakefiles -nargs=? SetProject call s:SetProject('<args>')
|
command -complete=customlist,GetAllProjectFiles -nargs=? SetProject call s:SetProject('<args>')
|
||||||
" only for backward compatibility
|
" only for backward compatibility
|
||||||
command -nargs=? SetBmskProject
|
command -nargs=? SetBmskProject
|
||||||
\ execute 'source ' . g:vimfiles . '/tools/bmsk.vim'
|
\ execute 'source ' . g:vimfiles . '/tools/bmsk.vim'
|
||||||
\ | SetBmskProject <args>
|
\ | SetBmskProject <args>
|
||||||
|
|
||||||
"function GetAllMakefiles(ArgLead, CmdLine, CursorPos)
|
"function GetAllProjectFiles(ArgLead, CmdLine, CursorPos)
|
||||||
function GetAllMakefiles(...)
|
function GetAllProjectFiles(...)
|
||||||
let makefilePaths = []
|
let makefilePaths = []
|
||||||
|
|
||||||
" Get Makefiles from g:WA or ArgLead
|
" Get Makefiles from g:WA or ArgLead
|
||||||
@ -45,29 +46,29 @@ function GetAllMakefiles(...)
|
|||||||
let path = expand(ArgLead)
|
let path = expand(ArgLead)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
let makefilePaths += s:GetAllMakefilesInPath(path)
|
let makefilePaths += s:GetAllProjectFilesInPath(path)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if makefilePaths == []
|
if makefilePaths == []
|
||||||
" Get Projects from project.txt
|
" Get Projects from project.txt
|
||||||
let projectPaths = s:GetProjectPaths(g:projectFile)
|
let projectPaths = s:GetProjectPaths(g:projectsFile)
|
||||||
for projectPath in projectPaths
|
for projectPath in projectPaths
|
||||||
let makefilePaths += s:GetAllMakefilesInPath(projectPath)
|
let makefilePaths += s:GetAllProjectFilesInPath(projectPath)
|
||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
|
|
||||||
return makefilePaths
|
return makefilePaths
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Get all Makefiles defined in s:makefileNames contained in path
|
" Get all Makefiles defined in s:projectFileNames contained in path
|
||||||
function s:GetAllMakefilesInPath(path)
|
function s:GetAllProjectFilesInPath(path)
|
||||||
let files = []
|
let files = []
|
||||||
if isdirectory(a:path)
|
if isdirectory(a:path)
|
||||||
let path = a:path
|
let path = a:path
|
||||||
else
|
else
|
||||||
let path = a:path . '*'
|
let path = a:path . '*'
|
||||||
endif
|
endif
|
||||||
for makefileName in s:makefileNames
|
for makefileName in s:projectFileNames
|
||||||
let pathlist = path . ',' . path . '/*,' . path . '/*/*'
|
let pathlist = path . ',' . path . '/*,' . path . '/*/*'
|
||||||
let newfiles = split(globpath(pathlist, makefileName))
|
let newfiles = split(globpath(pathlist, makefileName))
|
||||||
let files += newfiles
|
let files += newfiles
|
||||||
@ -77,46 +78,59 @@ function s:GetAllMakefilesInPath(path)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Get Project-Paths from project.txt
|
" Get Project-Paths from project.txt
|
||||||
function s:GetProjectPaths(projectFile)
|
function s:GetProjectPaths(projectsFile)
|
||||||
let paths = []
|
let paths = []
|
||||||
if filereadable(a:projectFile)
|
if filereadable(a:projectsFile)
|
||||||
let paths = split(system('more ' . a:projectFile))
|
let paths = split(system('more ' . a:projectsFile))
|
||||||
endif
|
endif
|
||||||
return paths
|
return paths
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Find makefile and set some options
|
" Find projectfile and set some options
|
||||||
" ----------------------------------
|
" -------------------------------------
|
||||||
function s:SetProject(makefile)
|
function s:SetProject(projectfile)
|
||||||
if ((a:makefile == '') && has('browse'))
|
if ((a:projectfile == '') && has('browse'))
|
||||||
" Browse for makefile
|
" Browse for projectfile
|
||||||
if exists('g:WA')
|
if exists('g:WA')
|
||||||
let l:WA = g:WA
|
let l:WA = g:WA
|
||||||
else
|
else
|
||||||
let l:WA = ''
|
let l:WA = ''
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let makefilePath = fnamemodify(browse(0, 'Select makefile', l:WA, ''), ':p')
|
let b:browsefilter =
|
||||||
|
\ "All Project Files\t" . join(s:projectFileNames, ';') . "\n"
|
||||||
|
\ . "Vim-Files\t*.vim\n"
|
||||||
|
\ . "Batch-Files\t*.bat\n"
|
||||||
|
\ . "Makefiles\tmakefile;*.mak\n"
|
||||||
|
\ . "All\ Files\t*\n"
|
||||||
|
let projectfilePath = fnamemodify(browse(0, 'Select projectfile', l:WA, ''), ':p')
|
||||||
|
if !filereadable(a:projectfile)
|
||||||
|
" Cancel
|
||||||
|
return
|
||||||
|
endif
|
||||||
else
|
else
|
||||||
" set Workarea and basedir
|
" set Workarea and basedir
|
||||||
if filereadable(a:makefile)
|
if filereadable(a:projectfile)
|
||||||
let makefilePath = fnamemodify(a:makefile, ':p')
|
let projectfilePath = fnamemodify(a:projectfile, ':p')
|
||||||
else
|
else
|
||||||
echoerr 'No makefile' a:makefile
|
echoerr 'No projectfile' a:projectfile
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" split file name and path
|
" split file name and path
|
||||||
let g:basedir = fnamemodify(makefilePath, ':p:h')
|
let g:basedir = fnamemodify(projectfilePath, ':p:h')
|
||||||
let makefileName = fnamemodify(makefilePath, ':t')
|
let projectfileName = fnamemodify(projectfilePath, ':t')
|
||||||
|
|
||||||
" test if makefile is a batch-script
|
" test if projectfile is a batch-script
|
||||||
let ext = fnamemodify(makefileName, ':e')
|
let ext = fnamemodify(projectfileName, ':e')
|
||||||
if ext == 'bat'
|
if ext == 'vim'
|
||||||
let g:makeCommand = makefilePath
|
execute 'source ' . projectfilePath
|
||||||
|
return
|
||||||
|
elseif ext == 'bat'
|
||||||
|
let g:makeCommand = projectfilePath
|
||||||
else
|
else
|
||||||
let g:makeCommand = 'make -f ' . makefilePath
|
let g:makeCommand = 'make -f ' . projectfilePath
|
||||||
endif
|
endif
|
||||||
let &makeprg = g:makeCommand . ' $*'
|
let &makeprg = g:makeCommand . ' $*'
|
||||||
|
|
||||||
@ -138,7 +152,7 @@ endfunction
|
|||||||
" Get Project Specific Variables
|
" Get Project Specific Variables
|
||||||
function s:GetProjectVariables()
|
function s:GetProjectVariables()
|
||||||
let varnames = [
|
let varnames = [
|
||||||
\ 'VIM_CONFIGFILE',
|
\ 'VIM_PROJECTFILE',
|
||||||
\]
|
\]
|
||||||
let s:Variables = GetMakeVars(varnames)
|
let s:Variables = GetMakeVars(varnames)
|
||||||
|
|
||||||
@ -155,19 +169,19 @@ endfunction
|
|||||||
function s:EvalProjectVariables()
|
function s:EvalProjectVariables()
|
||||||
try
|
try
|
||||||
" evaluate path variable
|
" evaluate path variable
|
||||||
if s:Variables['VIM_CONFIGFILE'] != ''
|
if s:Variables['VIM_PROJECTFILE'] != ''
|
||||||
if !filereadable(s:Variables['VIM_CONFIGFILE'])
|
if !filereadable(s:Variables['VIM_PROJECTFILE'])
|
||||||
" try to create config-file
|
" try to create config-file
|
||||||
make vim-config
|
make vim-config
|
||||||
endif
|
endif
|
||||||
try
|
try
|
||||||
execute 'source ' . s:Variables['VIM_CONFIGFILE']
|
execute 'source ' . s:Variables['VIM_PROJECTFILE']
|
||||||
catch
|
catch
|
||||||
echoerr 'cant source "' . s:Variables['VIM_CONFIGFILE'] . '"'
|
echoerr 'cant source "' . s:Variables['VIM_PROJECTFILE'] . '"'
|
||||||
echoerr 'check the make variable VIM_CONFIGFILE'
|
echoerr 'check the make variable VIM_PROJECTFILE'
|
||||||
endtry
|
endtry
|
||||||
else
|
else
|
||||||
echomsg 'set the make-variable VIM_CONFIGFILE to the project-config file for vim'
|
echomsg 'set the make-variable VIM_PROJECTFILE to the project-config file for vim'
|
||||||
echomsg 'For old BMSK-Projects try :SetBmskProject'
|
echomsg 'For old BMSK-Projects try :SetBmskProject'
|
||||||
endif
|
endif
|
||||||
catch /E716/ " Schlüssel nicht vorhanden
|
catch /E716/ " Schlüssel nicht vorhanden
|
||||||
@ -240,41 +254,50 @@ endfunction
|
|||||||
let s:VimSuiteMenuLocation = 70
|
let s:VimSuiteMenuLocation = 70
|
||||||
let s:VimSuiteMenuName = '&VimSuite.'
|
let s:VimSuiteMenuName = '&VimSuite.'
|
||||||
|
|
||||||
function s:AddMakefileToProjectMenu(makefilePath)
|
function s:AddFileToProjectMenu(makefilePath, submenu, priority)
|
||||||
exec 'anoremenu '.s:VimSuiteMenuLocation.'.10 '.s:VimSuiteMenuName.'&Project.'
|
exec 'anoremenu '
|
||||||
\ . escape(a:makefilePath, '.\') . '<tab>'.
|
\ . s:VimSuiteMenuLocation
|
||||||
\' :SetProject ' . a:makefilePath . '<CR>'
|
\ . a:priority' '
|
||||||
|
\ . s:VimSuiteMenuName.'&Project'
|
||||||
|
\ . a:submenu . '.'
|
||||||
|
\ . escape(a:makefilePath, '.\') . '<tab>'
|
||||||
|
\ . ' :SetProject ' . a:makefilePath . '<CR>'
|
||||||
endfunction
|
endfunction
|
||||||
"
|
"
|
||||||
function s:AddAllKnownProjectsToMenu()
|
function s:AddAllKnownProjectsToMenu()
|
||||||
" Projects in project.txt
|
" Projects in project.txt
|
||||||
exec 'anoremenu '. s:VimSuiteMenuName.
|
exec 'anoremenu ..50 '. s:VimSuiteMenuName.
|
||||||
\'&Project.-sep2- :'
|
\'&Project.-sep2- :'
|
||||||
let projectPaths = s:GetProjectPaths(g:projectFile)
|
let projectPaths = s:GetProjectPaths(g:projectsFile)
|
||||||
let makefilePaths = []
|
let makefilePaths = []
|
||||||
for projectPath in projectPaths
|
for projectPath in projectPaths
|
||||||
let makefilePaths += s:GetAllMakefilesInPath(projectPath)
|
let makefilePaths += s:GetAllProjectFilesInPath(projectPath)
|
||||||
endfor
|
endfor
|
||||||
for makefilePath in makefilePaths
|
for makefilePath in makefilePaths
|
||||||
call s:AddMakefileToProjectMenu(makefilePath)
|
call s:AddFileToProjectMenu(makefilePath, '.Makefiles\ in\ project\.txt', '..60')
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
" Projects in g:WA
|
" Projects in g:WA
|
||||||
if exists('g:WA')
|
if exists('g:WA')
|
||||||
exec 'anoremenu '. s:VimSuiteMenuName.
|
for makefilePath in s:GetAllProjectFilesInPath(g:WA)
|
||||||
\'&Project.-sep3- :'
|
if fnamemodify(makefilePath, ':e') == 'vim'
|
||||||
for makefilePath in s:GetAllMakefilesInPath(g:WA)
|
let submenu = ''
|
||||||
call s:AddMakefileToProjectMenu(makefilePath)
|
let prio = '..30'
|
||||||
|
else
|
||||||
|
let submenu = '.Makefiles\ in\ WA'
|
||||||
|
let prio = '..70'
|
||||||
|
endif
|
||||||
|
call s:AddFileToProjectMenu(makefilePath, submenu, prio)
|
||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
"
|
"
|
||||||
function s:InitProjectMenu()
|
function s:InitProjectMenu()
|
||||||
exec 'silent! aunmenu '.s:VimSuiteMenuName.'&Project'
|
exec 'silent! aunmenu '.s:VimSuiteMenuName.'&Project'
|
||||||
exec 'anoremenu '.s:VimSuiteMenuLocation.'.10 '.s:VimSuiteMenuName.
|
exec 'anoremenu '.s:VimSuiteMenuLocation.'.10.10 '.s:VimSuiteMenuName.
|
||||||
\'&Project.&Browse\ for\ makefile<tab>:SetProject'.
|
\'&Project.&Browse\ for\ projectfile<tab>:SetProject'.
|
||||||
\' :SetProject<CR>'
|
\' :SetProject<CR>'
|
||||||
exec 'anoremenu ..25 '. s:VimSuiteMenuName.
|
exec 'anoremenu ..20 '. s:VimSuiteMenuName.
|
||||||
\'&Project.-sep1- :'
|
\'&Project.-sep1- :'
|
||||||
endfunction
|
endfunction
|
||||||
"
|
"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user