1" Vim compiler file 2" Compiler: powershell 3" URL: https://github.com/PProvost/vim-ps1 4" Last Change: 2020 Mar 30 5 6if exists("current_compiler") 7 finish 8endif 9let current_compiler = "powershell" 10 11if exists(":CompilerSet") != 2 " older Vim always used :setlocal 12 command -nargs=* CompilerSet setlocal <args> 13endif 14 15let s:cpo_save = &cpo 16set cpo-=C 17 18if !exists("g:ps1_makeprg_cmd") 19 if executable('pwsh') 20 " pwsh is the future 21 let g:ps1_makeprg_cmd = 'pwsh' 22 elseif executable('pwsh.exe') 23 let g:ps1_makeprg_cmd = 'pwsh.exe' 24 elseif executable('powershell.exe') 25 let g:ps1_makeprg_cmd = 'powershell.exe' 26 else 27 let g:ps1_makeprg_cmd = '' 28 endif 29endif 30 31if !executable(g:ps1_makeprg_cmd) 32 echoerr "To use the powershell compiler, please set g:ps1_makeprg_cmd to the powershell executable!" 33endif 34 35" Show CategoryInfo, FullyQualifiedErrorId, etc? 36let g:ps1_efm_show_error_categories = get(g:, 'ps1_efm_show_error_categories', 0) 37 38" Use absolute path because powershell requires explicit relative paths 39" (./file.ps1 is okay, but # expands to file.ps1) 40let &l:makeprg = g:ps1_makeprg_cmd .' %:p:S' 41 42" Parse file, line, char from callstacks: 43" Write-Ouput : The term 'Write-Ouput' is not recognized as the name of a 44" cmdlet, function, script file, or operable program. Check the spelling 45" of the name, or if a path was included, verify that the path is correct 46" and try again. 47" At C:\script.ps1:11 char:5 48" + Write-Ouput $content 49" + ~~~~~~~~~~~ 50" + CategoryInfo : ObjectNotFound: (Write-Ouput:String) [], CommandNotFoundException 51" + FullyQualifiedErrorId : CommandNotFoundException 52 53" Showing error in context with underlining. 54CompilerSet errorformat=%+G+%m 55" Error summary. 56CompilerSet errorformat+=%E%*\\S\ :\ %m 57" Error location. 58CompilerSet errorformat+=%CAt\ %f:%l\ char:%c 59" Errors that span multiple lines (may be wrapped to width of terminal). 60CompilerSet errorformat+=%C%m 61" Ignore blank/whitespace-only lines. 62CompilerSet errorformat+=%Z\\s%# 63 64if g:ps1_efm_show_error_categories 65 CompilerSet errorformat^=%+G\ \ \ \ +\ %.%#\\s%#:\ %m 66else 67 CompilerSet errorformat^=%-G\ \ \ \ +\ %.%#\\s%#:\ %m 68endif 69 70 71" Parse file, line, char from of parse errors: 72" At C:\script.ps1:22 char:16 73" + Stop-Process -Name "invalidprocess 74" + ~~~~~~~~~~~~~~~ 75" The string is missing the terminator: ". 76" + CategoryInfo : ParserError: (:) [], ParseException 77" + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString 78CompilerSet errorformat+=At\ %f:%l\ char:%c 79 80 81let &cpo = s:cpo_save 82unlet s:cpo_save 83 84" vim:set sw=2 sts=2: 85