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