From cf80d3802528ba66266377b112910b19baa23155 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 13 Mar 2024 21:17:50 +0800 Subject: [PATCH] perf(powershell): fix powershell formatters --- .../neoformat/formatters/powershell.vim | 45 +++++++++++++++++++ bundle/neoformat/doc/neoformat.txt | 28 +++++++++++- 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 bundle/neoformat/autoload/neoformat/formatters/powershell.vim diff --git a/bundle/neoformat/autoload/neoformat/formatters/powershell.vim b/bundle/neoformat/autoload/neoformat/formatters/powershell.vim new file mode 100644 index 000000000..53df0d9e5 --- /dev/null +++ b/bundle/neoformat/autoload/neoformat/formatters/powershell.vim @@ -0,0 +1,45 @@ +"============================================================================= +" neoformat.vim --- A Neovim plugin for formatting +" Copyright (c) 2016-2021 Steve Dignam +" Copyright (c) 2022 Eric Wong +" Author: Eric Wong < wsdjeg@outlook.com > +" URL: https://spacevim.org +" License: GPLv3 +"============================================================================= + + +"" +" @section PowerShell formatters, supported-filetypes-powershell +" @parentsection supported-filetypes +" For PowerShell script, there are two default formatters. +" +" @subsection PowerShellBeautifier +" > +" { +" 'exe' : 'Edit-DTWBeautifyScript', +" 'args' : ["-IndentType FourSpaces", "-StandardOutput"], +" 'stdin' : 0, +" } +" < +" @subsection PSScriptAnalyzer +" > +" { +" 'exe' : 'Invoke-Formatter', +" 'args' : ['-ScriptDefinition (Get-Content ' . expand('%') . ' -Raw)'], +" 'stdin' : 0, +" 'no_append' : 1, +" } +" < + +function! neoformat#formatters#powershell#enabled() abort + return neoformat#formatters#ps1#enabled() +endfunction + +function! neoformat#formatters#powershell#PowerShellBeautifier() abort + return neoformat#formatters#ps1#PowerShellBeautifier() +endfunction + +function! neoformat#formatters#powershell#PSScriptAnalyzer() abort + return neoformat#formatters#ps1#PSScriptAnalyzer() +endfunction + diff --git a/bundle/neoformat/doc/neoformat.txt b/bundle/neoformat/doc/neoformat.txt index ad50abf92..3eb9d2cad 100644 --- a/bundle/neoformat/doc/neoformat.txt +++ b/bundle/neoformat/doc/neoformat.txt @@ -9,7 +9,8 @@ CONTENTS *neoformat-contents* 4. ADDING A NEW FORMATTER...................|neoformat-adding-new-formatter| 5. MANAGING UNDO HISTORY...................|neoformat-managing-undo-history| 6. Supported filetypes.......................|neoformat-supported-filetypes| - 1. SQL formatters....................|neoformat-supported-filetypes-sql| + 1. PowerShell formatters......|neoformat-supported-filetypes-powershell| + 2. SQL formatters....................|neoformat-supported-filetypes-sql| ============================================================================== INTRODUCTION *neoformat-intro* @@ -227,6 +228,31 @@ SUPPORTED FILETYPES *neoformat-supported-filetypes* This is a list of default formatters. +============================================================================== +POWERSHELL FORMATTERS *neoformat-supported-filetypes-powershell* + +For PowerShell script, there are two default formatters. + +POWERSHELLBEAUTIFIER + +> + { + 'exe' : 'Edit-DTWBeautifyScript', + 'args' : ["-IndentType FourSpaces", "-StandardOutput"], + 'stdin' : 0, + } +< +PSSCRIPTANALYZER + +> + { + 'exe' : 'Invoke-Formatter', + 'args' : ['-ScriptDefinition (Get-Content ' . expand('%') . ' -Raw)'], + 'stdin' : 0, + 'no_append' : 1, + } +< + ============================================================================== SQL FORMATTERS *neoformat-supported-filetypes-sql*