1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-02 21:20:05 +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
" @parentsection supported-filetypes
" 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
" >
" {
" 'exe' : 'Edit-DTWBeautifyScript',
" 'args' : ["-IndentType FourSpaces", "-StandardOutput"],
" 'exe' : 'powershell',
" 'args' : ['-noprofile', '-Command', "Edit-DTWBeautifyScript", "-IndentType", "FourSpaces", "-StandardOutput"],
" 'stdin' : 0,
" }
" <
" @subsection PSScriptAnalyzer
" >
" {
" 'exe' : 'Invoke-Formatter',
" 'args' : ['-ScriptDefinition (Get-Content ' . expand('%') . ' -Raw)'],
" 'exe' : 'powershell',
" 'args' : ['-noprofile', '-Command', 'Invoke-Formatter', '-ScriptDefinition (Get-Content ' . expand('%') . ' -Raw)'],
" 'stdin' : 0,
" 'no_append' : 1,
" }

View File

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

View File

@ -232,13 +232,22 @@ This is a list of default formatters.
POWERSHELL FORMATTERS *neoformat-supported-filetypes-powershell*
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
>
{
'exe' : 'Edit-DTWBeautifyScript',
'args' : ["-IndentType FourSpaces", "-StandardOutput"],
'exe' : 'powershell',
'args' : ['-noprofile', '-Command', "Edit-DTWBeautifyScript",
"-IndentType", "FourSpaces", "-StandardOutput"],
'stdin' : 0,
}
<
@ -246,8 +255,9 @@ PSSCRIPTANALYZER
>
{
'exe' : 'Invoke-Formatter',
'args' : ['-ScriptDefinition (Get-Content ' . expand('%') . ' -Raw)'],
'exe' : 'powershell',
'args' : ['-noprofile', '-Command', 'Invoke-Formatter', '-ScriptDefinition
(Get-Content ' . expand('%') . ' -Raw)'],
'stdin' : 0,
'no_append' : 1,
}