1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-03-23 01:09:56 +08:00

fix(powershell): fix default powershell formatters

This commit is contained in:
Eric Wong 2024-03-13 22:50:36 +08:00
parent cf80d38025
commit 468322ca4f
3 changed files with 30 additions and 12 deletions

View File

@ -12,20 +12,28 @@
" @section PowerShell formatters, supported-filetypes-powershell " @section PowerShell formatters, supported-filetypes-powershell
" @parentsection supported-filetypes " @parentsection supported-filetypes
" For PowerShell script, there are two default formatters. " For PowerShell script, there are two default formatters.
" `Edit-DTWBeautifyScript` and `Invoke-Formatter`.
"
" Before using these default formatters, you need to install the PowerShell
" modules.
" >
" Install-Module -Name PowerShell-Beautifier -Scope CurrentUser
" Install-Module -Name PSScriptAnalyzer -Scope CurrentUser
" <
" "
" @subsection PowerShellBeautifier " @subsection PowerShellBeautifier
" > " >
" { " {
" 'exe' : 'Edit-DTWBeautifyScript', " 'exe' : 'powershell',
" 'args' : ["-IndentType FourSpaces", "-StandardOutput"], " 'args' : ['-noprofile', '-Command', "Edit-DTWBeautifyScript", "-IndentType", "FourSpaces", "-StandardOutput"],
" 'stdin' : 0, " 'stdin' : 0,
" } " }
" < " <
" @subsection PSScriptAnalyzer " @subsection PSScriptAnalyzer
" > " >
" { " {
" 'exe' : 'Invoke-Formatter', " 'exe' : 'powershell',
" 'args' : ['-ScriptDefinition (Get-Content ' . expand('%') . ' -Raw)'], " 'args' : ['-noprofile', '-Command', 'Invoke-Formatter', '-ScriptDefinition (Get-Content ' . expand('%') . ' -Raw)'],
" 'stdin' : 0, " 'stdin' : 0,
" 'no_append' : 1, " 'no_append' : 1,
" } " }

View File

@ -4,16 +4,16 @@ endfunction
function! neoformat#formatters#ps1#PowerShellBeautifier() abort function! neoformat#formatters#ps1#PowerShellBeautifier() abort
return { return {
\ 'exe' : 'Edit-DTWBeautifyScript', \ 'exe' : 'powershell',
\ 'args' : ["-IndentType FourSpaces", "-StandardOutput"], \ 'args' : ['-noprofile', '-Command', "Edit-DTWBeautifyScript", "-IndentType", "FourSpaces", "-StandardOutput"],
\ 'stdin' : 0, \ 'stdin' : 0,
\ } \ }
endfunction endfunction
function! neoformat#formatters#ps1#PSScriptAnalyzer() abort function! neoformat#formatters#ps1#PSScriptAnalyzer() abort
return { return {
\ 'exe' : 'Invoke-Formatter', \ 'exe' : 'powershell',
\ 'args' : ['-ScriptDefinition (Get-Content ' . expand('%') . ' -Raw)'], \ 'args' : ['-noprofile', '-Command', 'Invoke-Formatter', '-ScriptDefinition (Get-Content ' . expand('%') . ' -Raw)'],
\ 'stdin' : 0, \ 'stdin' : 0,
\ 'no_append' : 1, \ 'no_append' : 1,
\ } \ }

View File

@ -232,13 +232,22 @@ This is a list of default formatters.
POWERSHELL FORMATTERS *neoformat-supported-filetypes-powershell* POWERSHELL FORMATTERS *neoformat-supported-filetypes-powershell*
For PowerShell script, there are two default formatters. For PowerShell script, there are two default formatters.
`Edit-DTWBeautifyScript` and `Invoke-Formatter`.
Before using these default formatters, you need to install the PowerShell
modules.
>
Install-Module -Name PowerShell-Beautifier -Scope CurrentUser
Install-Module -Name PSScriptAnalyzer -Scope CurrentUser
<
POWERSHELLBEAUTIFIER POWERSHELLBEAUTIFIER
> >
{ {
'exe' : 'Edit-DTWBeautifyScript', 'exe' : 'powershell',
'args' : ["-IndentType FourSpaces", "-StandardOutput"], 'args' : ['-noprofile', '-Command', "Edit-DTWBeautifyScript",
"-IndentType", "FourSpaces", "-StandardOutput"],
'stdin' : 0, 'stdin' : 0,
} }
< <
@ -246,8 +255,9 @@ PSSCRIPTANALYZER
> >
{ {
'exe' : 'Invoke-Formatter', 'exe' : 'powershell',
'args' : ['-ScriptDefinition (Get-Content ' . expand('%') . ' -Raw)'], 'args' : ['-noprofile', '-Command', 'Invoke-Formatter', '-ScriptDefinition
(Get-Content ' . expand('%') . ' -Raw)'],
'stdin' : 0, 'stdin' : 0,
'no_append' : 1, 'no_append' : 1,
} }