diff options
author | Jelte Fennema <github-tech@jeltef.nl> | 2021-08-25 08:27:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-25 15:27:04 +0900 |
commit | d53a085096306c890897385692693ee653aaddce (patch) | |
tree | c55044979ba1c480589de22590b4df63bc44a17a /autoload | |
parent | f896744feec260fb196d38bba23308080c04192c (diff) | |
download | ale-d53a085096306c890897385692693ee653aaddce.zip |
Add fixer for "dotnet format" (#3879)
The .NET ecosystem has an official tool for formatting its files: `dotnet format`
This adds support for that tool to ALE.
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/fix/registry.vim | 5 | ||||
-rw-r--r-- | autoload/ale/fixers/dotnet_format.vim | 18 |
2 files changed, 23 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index 15a6632d..975d02f6 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -396,6 +396,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['dart'], \ 'description': 'Fix Dart files with dart format.', \ }, +\ 'dotnet-format': { +\ 'function': 'ale#fixers#dotnet_format#Fix', +\ 'suggested_filetypes': ['cs'], +\ 'description': 'Fix C# files with dotnet format.', +\ }, \ 'xmllint': { \ 'function': 'ale#fixers#xmllint#Fix', \ 'suggested_filetypes': ['xml'], diff --git a/autoload/ale/fixers/dotnet_format.vim b/autoload/ale/fixers/dotnet_format.vim new file mode 100644 index 00000000..b44a28bd --- /dev/null +++ b/autoload/ale/fixers/dotnet_format.vim @@ -0,0 +1,18 @@ +" Author: ghsang <gwonhyuksang@gmail.com> +" Description: Integration of dotnet format with ALE. + +call ale#Set('cs_dotnet_format_executable', 'dotnet') +call ale#Set('cs_dotnet_format_options', '') + +function! ale#fixers#dotnet_format#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'cs_dotnet_format_executable') + let l:options = ale#Var(a:buffer, 'cs_dotnet_format_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' format' + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' --folder --include %t "$(dirname %t)"', + \ 'read_temporary_file': 1, + \} +endfunction |