From e1ae009bac98d4c2a80ed8f70f68b75dab3bc478 Mon Sep 17 00:00:00 2001 From: Nathan Henrie Date: Tue, 7 Feb 2023 01:24:52 -0700 Subject: Add alejandra for nix (#4435) - Fixes https://github.com/dense-analysis/ale/issues/4434 --- autoload/ale/fix/registry.vim | 5 +++++ autoload/ale/fixers/alejandra.vim | 13 +++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 autoload/ale/fixers/alejandra.vim (limited to 'autoload') diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index 7040c4cc..b3275a32 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -7,6 +7,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['python'], \ 'description': 'Add blank lines before control statements.', \ }, +\ 'alejandra': { +\ 'function': 'ale#fixers#alejandra#Fix', +\ 'suggested_filetypes': ['nix'], +\ 'description': 'The Uncompromising Nix Code Formatter', +\ }, \ 'align_help_tags': { \ 'function': 'ale#fixers#help#AlignTags', \ 'suggested_filetypes': ['help'], diff --git a/autoload/ale/fixers/alejandra.vim b/autoload/ale/fixers/alejandra.vim new file mode 100644 index 00000000..3844e8c0 --- /dev/null +++ b/autoload/ale/fixers/alejandra.vim @@ -0,0 +1,13 @@ +call ale#Set('nix_alejandra_executable', 'alejandra') +call ale#Set('nix_alejandra_options', '') + +function! ale#fixers#alejandra#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'nix_alejandra_executable') + let l:options = ale#Var(a:buffer, 'nix_alejandra_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' -- -' + \} +endfunction -- cgit v1.2.3