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