" Vimball Archiver by Charles E. Campbell, Jr., Ph.D. UseVimball finish compiler/msbuild.vim [[[1 17 " Vim compiler file " Compiler: MSBuild " Maintainer: Heath Stewart " Version: 1.0 if exists("current_compiler") finish endif let current_compiler = "msbuild" if exists(":CompilerSet") != 2 " Older vim always used :setlocal command -nargs=* CompilerSet setlocal endif CompilerSet errorformat=\ %#%f(%l\\\,%c):\ %m CompilerSet makeprg=msbuild\ \"%\"\ /nologo\ /v:q\ /property:GenerateFullPaths=true\ $* doc/msbuild.txt [[[1 81 *msbuild.txt* Vim plugin for MSBuild project support Maintainer: Heath Stewart License: Apache 2.0 Version: 1.0 INTRODUCTION *msbuild-syntax* This Vim plugin enables syntax support for all typical MSBuild project and include files matching the following patterns: *.*proj *.props *.targets You can also build an open project from within Vim using ":make". Any warnings or errors can then be opened directly. You can also pass command line parameters to ":make" like you would to msbuild.exe, like: > :make /t:rebuild > Some items and imported projects or targets can also be opened with |gf|. Any environment variables in the path are expanded automatically if possible. ABOUT *msbuild-about* You can grab the latest version or report and issue on Github: http://github.com/heaths/vim-msbuild *msbuild-files* OPENING FILES *msbuild-opening* You can use commands like |gf| to open files authored into a project, like in the following example: > Here, both "Main.cs" and "$(MSBuildExtensionsPath32)\Example.targets" would be opened into a new buffer. An attempt is made to resolve any properties in a path in the format "$(property)". A number of MSBuild reserved properties are defined and you may define your own specific to your environment. See |msbuild-variables| for more information about customizing path resolution. VARIABLES *msbuild-variables* Most of the MSBuild reserved properties that represent direcories and files are automatically defined and locked to prevent change. You can see which properties are defined along with their values by typing the following: > :let g:msbuild_reserved :let b:msbuild_reserved Machine-wide properties are defined globally, while file-specific properties are defined for the current buffer. These properties are used for commands like |gf| along with any properties you define at either the global or buffer scope in the "msbuild_properties" |Dictionary| variable: > :let g:msbuild_properties = {'TargetFrameworkVersion': 'v4.5'} Any attempt to redefine reserved properties is simply ignored. If a property is not defined, the property name in the format "$(property)" is automatically evaluated as an environment variable. If no environment variable matching the property name is defined, an error is reported along with as much of the path that could be resolved. ------------------------------------------------------------------------------ vim:ft=help: ftdetect/msbuild.vim [[[1 7 " Vim ftdetect plugin file " Language: MSBuild " Maintainer: Heath Stewart " Version: 1.0 " Override the default file type setting. au BufNewFile,BufRead *.*proj,*.props,*.targets set ft=msbuild ftplugin/msbuild.vim [[[1 118 " Vim filetype plugin file " Language: MSBuild " Maintainer: Heath Stewart " Version: 1.0 " Only do this when not done yet for this buffer. if exists("b:did_ftplugin") | finish | endif " Make sure the continuation lines below do not cause problems in compatibility mode. let s:save_cpo = &cpo set cpo-=C " Define some defaults in case the included ftplugins don't set them. let s:undo_ftplugin = "" " Source the XML plugins for this buffer. runtime! ftplugin/xml.vim ftplugin/xml_*.vim ftplugin/xml/*.vim " Don't load another plugin for this buffer. let b:did_ftplugin = 1 " Override our defaults if these were set by an included ftplugin. if exists("b:undo_ftplugin") let s:undo_ftplugin = b:undo_ftplugin endif " Set up global reserved properties. setl isident+=(,) if !exists("g:msbuild_reserved") && exists("$ProgramFiles") let g:msbuild_reserved = {} if !exists("$ProgramFiles(x86)") || expand("$ProgramFiles") == expand("$ProgramFiles(x86)") let g:msbuild_reserved.MSBuildProgramFiles32 = expand("$ProgramFiles") let g:msbuild_reserved.MSBuildProgramFiles = g:msbuild_reserved.MSBuildProgramFiles32 else let g:msbuild_reserved.MSBuildProgramFiles32 = expand("$ProgramFiles(x86)") let g:msbuild_reserved.MSBuildProgramFiles64 = expand("$ProgramFiles") let g:msbuild_reserved.MSBuildProgramFiles = g:msbuild_reserved.MSBuildProgramFiles64 endif let g:msbuild_reserved.MSBuildExtensionsPath32 = g:msbuild_reserved.MSBuildProgramFiles32 . "\\MSBuild" let g:msbuild_reserved.MSBuildExtensionsPath = g:msbuild_reserved.MSBuildProgramFiles . "\\MSBuild" if get(g:msbuild_reserved, "MSBuildProgramFiles64") let g:msbuild_reserved.MSBuildExtensionsPath64 = g:msbuild_reserved.MSBuildProgramFiles64 . "\\MSBuild" endif lockv! g:msbuild_reserved endif " Set up buffer-specific reserved properties. let b:msbuild_reserved = {} let b:msbuild_reserved.MSBuildThisFile = expand("%:t") let b:msbuild_reserved.MSBuildThisFileDirectory = expand("%:p:h") let b:msbuild_reserved.MSBuildThisFileDirectoryNoRoot = substitute(expand("%:p:h"), '\w:', "", "") let b:msbuild_reserved.MSBuildThisFileExtension = expand("%:e") let b:msbuild_reserved.MSBuildThisFileFullPath = expand("%:p") let b:msbuild_reserved.MSBuildThisFileName = expand("%:t:r") if expand(":e") =~ ".*proj$" let b:msbuild_reserved.MSBuildProjectFile = b:msbuild_reserved.MSBuildThisFile let b:msbuild_reserved.MSBuildProjectDirectory = b:msbuild_reserved.MSBuildThisFileDirectory let b:msbuild_reserved.MSBuildProjectDirectoryNoRoot = b:msbuild_reserved.MSBuildThisFileDirectoryNoRoot let b:msbuild_reserved.MSBuildProjectExtension = b:msbuild_reserved.MSBuildThisFileExtension let b:msbuild_reserved.MSBuildProjectFullPath = b:msbuild_reserved.MSBuildThisFileFullPath let b:msbuild_reserved.MSBuildProjectName = b:msbuild_reserved.MSBuildThisFileName endif " Merge global reserved properties and lock. if exists("g:msbuild_reserved") let b:msbuild_reserved = extend(b:msbuild_reserved, g:msbuild_reserved) endif lockv! b:msbuild_reserved " Define the function to resolve path variables. func! MSBuildResolvePath(var) let properties = copy(b:msbuild_reserved) " Merge user-defined global properties, which may have changed. if exists("g:msbuild_properties") && type(g:msbuild_properties) == type({}) let properties = extend(properties, g:msbuild_properties, "keep") endif " Merge user-defined buffer properties, which may have changed. if exists("b:msbuild_properties") && type(b:msbuild_properties) == type({}) let properties = extend(properties, b:msbuild_properties, "keep") endif return get(properties, a:var, expand("$" . a:var)) endf " Enable opening include files. setl isfname+=(,) setl includeexpr=substitute(v:fname,'\\$(\\(\\w\\+\\))','\\=MSBuildResolvePath(submatch(1))','g') " Set compiler options. compiler msbuild " Change the browse dialog on Win32 to show mainly MSBuild files if has("gui_win32") let b:browsefilter = \ "All MSBuild Files (*.*proj, *.props, *.targets)\t*.*proj;*.props;*.targets\n" . \ "MSBuild Project Files (*.*proj)\t*.*proj\n" . \ "MSBuild Import Files (*.props, *.targets)\t*.props;*.targets\n" . \ "All Files (*.*)\t*.*\n" endif " Undo the stuff we changed. let b:undo_ftplugin = \ "unlockv! b:msbuild_reserved | " . \ "unlet! b:browsefilter b:msbuild_reserved | " . \ "setlocal isident< isfname< includeexpr< | " . \ s:undo_ftplugin " Restore the saved compatibility options. let &cpo = s:save_cpo unlet! s:save_cpo syntax/msbuild.vim [[[1 24 " Vim syntax file " Language: MSBuild " Maintainer: Heath Stewart " Version: 1.0 " Quit when a syntax file was already loaded for this buffer. if exists("b:current_syntax") | finish | endif " Make sure the continuation lines below do not cause problems in compatibility mode. let s:save_cpo = &cpo set cpo-=C " Define some defaults in case the included ftplugins don't set them. let s:undo_ftplugin = "" " Source the XML syntax for this buffer. runtime! syntax/xml.vim syntax/xml/*.vim " Make sure the syntax file is not loaded again for this buffer. let b:current_syntax = "msbuild" " Restore the saved compatibility options. let &cpo = s:save_cpo unlet s:save_cpo