Mercurial > vim
annotate runtime/compiler/powershell.vim @ 35288:e0701cae97d4 default tip
Added tag v9.1.0448 for changeset b68266606e8434409a5b8fd532bc7d801b292737
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 29 May 2024 08:00:05 +0200 |
parents | e75d871c5b91 |
children |
rev | line source |
---|---|
24387 | 1 " Vim compiler file |
2 " Compiler: powershell | |
3 " URL: https://github.com/PProvost/vim-ps1 | |
34702
2c3f939d46bf
runtime(compilers): ensure compiler! sets global options (#14336)
Christian Brabandt <cb@256bit.org>
parents:
24387
diff
changeset
|
4 " Contributors: Enno Nagel |
2c3f939d46bf
runtime(compilers): ensure compiler! sets global options (#14336)
Christian Brabandt <cb@256bit.org>
parents:
24387
diff
changeset
|
5 " Last Change: 2024 Mar 29 |
34778
e1df51f68736
runtime: Remove fallback :CompilerSet definition from compiler plugins
Christian Brabandt <cb@256bit.org>
parents:
34702
diff
changeset
|
6 " 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) |
34785
e75d871c5b91
runtime: fix :compiler leaving behind a g:makeprg variable (#14414)
Christian Brabandt <cb@256bit.org>
parents:
34778
diff
changeset
|
7 " 2024 Apr 05 by The Vim Project (avoid leaving behind g:makeprg) |
24387 | 8 |
9 if exists("current_compiler") | |
10 finish | |
11 endif | |
12 let current_compiler = "powershell" | |
13 | |
14 let s:cpo_save = &cpo | |
15 set cpo-=C | |
16 | |
17 if !exists("g:ps1_makeprg_cmd") | |
18 if executable('pwsh') | |
19 " pwsh is the future | |
20 let g:ps1_makeprg_cmd = 'pwsh' | |
21 elseif executable('pwsh.exe') | |
22 let g:ps1_makeprg_cmd = 'pwsh.exe' | |
23 elseif executable('powershell.exe') | |
24 let g:ps1_makeprg_cmd = 'powershell.exe' | |
25 else | |
26 let g:ps1_makeprg_cmd = '' | |
27 endif | |
28 endif | |
29 | |
30 if !executable(g:ps1_makeprg_cmd) | |
31 echoerr "To use the powershell compiler, please set g:ps1_makeprg_cmd to the powershell executable!" | |
32 endif | |
33 | |
34 " Show CategoryInfo, FullyQualifiedErrorId, etc? | |
35 let g:ps1_efm_show_error_categories = get(g:, 'ps1_efm_show_error_categories', 0) | |
36 | |
37 " Use absolute path because powershell requires explicit relative paths | |
38 " (./file.ps1 is okay, but # expands to file.ps1) | |
34785
e75d871c5b91
runtime: fix :compiler leaving behind a g:makeprg variable (#14414)
Christian Brabandt <cb@256bit.org>
parents:
34778
diff
changeset
|
39 let s:makeprg = g:ps1_makeprg_cmd .. ' %:p:S' |
24387 | 40 |
41 " Parse file, line, char from callstacks: | |
42 " Write-Ouput : The term 'Write-Ouput' is not recognized as the name of a | |
43 " cmdlet, function, script file, or operable program. Check the spelling | |
44 " of the name, or if a path was included, verify that the path is correct | |
45 " and try again. | |
46 " At C:\script.ps1:11 char:5 | |
47 " + Write-Ouput $content | |
48 " + ~~~~~~~~~~~ | |
49 " + CategoryInfo : ObjectNotFound: (Write-Ouput:String) [], CommandNotFoundException | |
50 " + FullyQualifiedErrorId : CommandNotFoundException | |
51 | |
34785
e75d871c5b91
runtime: fix :compiler leaving behind a g:makeprg variable (#14414)
Christian Brabandt <cb@256bit.org>
parents:
34778
diff
changeset
|
52 execute 'CompilerSet makeprg=' .. escape(s:makeprg, ' ') |
34702
2c3f939d46bf
runtime(compilers): ensure compiler! sets global options (#14336)
Christian Brabandt <cb@256bit.org>
parents:
24387
diff
changeset
|
53 |
24387 | 54 " Showing error in context with underlining. |
55 CompilerSet errorformat=%+G+%m | |
56 " Error summary. | |
57 CompilerSet errorformat+=%E%*\\S\ :\ %m | |
58 " Error location. | |
59 CompilerSet errorformat+=%CAt\ %f:%l\ char:%c | |
60 " Errors that span multiple lines (may be wrapped to width of terminal). | |
61 CompilerSet errorformat+=%C%m | |
62 " Ignore blank/whitespace-only lines. | |
63 CompilerSet errorformat+=%Z\\s%# | |
64 | |
65 if g:ps1_efm_show_error_categories | |
66 CompilerSet errorformat^=%+G\ \ \ \ +\ %.%#\\s%#:\ %m | |
67 else | |
68 CompilerSet errorformat^=%-G\ \ \ \ +\ %.%#\\s%#:\ %m | |
69 endif | |
70 | |
71 | |
72 " Parse file, line, char from of parse errors: | |
73 " At C:\script.ps1:22 char:16 | |
74 " + Stop-Process -Name "invalidprocess | |
75 " + ~~~~~~~~~~~~~~~ | |
76 " The string is missing the terminator: ". | |
77 " + CategoryInfo : ParserError: (:) [], ParseException | |
78 " + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString | |
79 CompilerSet errorformat+=At\ %f:%l\ char:%c | |
80 | |
81 | |
82 let &cpo = s:cpo_save | |
83 unlet s:cpo_save | |
84 | |
85 " vim:set sw=2 sts=2: |