From f1080a2bbe701949de16f8b93481375ee5732322 Mon Sep 17 00:00:00 2001 From: toastal Date: Sun, 2 Aug 2020 12:31:06 +0700 Subject: Dhall language support (fixes #2820) --- autoload/ale/dhall.vim | 21 +++++++++++++++++++++ autoload/ale/fix/registry.vim | 15 +++++++++++++++ autoload/ale/fixers/dhall_format.vim | 14 ++++++++++++++ autoload/ale/fixers/dhall_freeze.vim | 18 ++++++++++++++++++ autoload/ale/fixers/dhall_lint.vim | 14 ++++++++++++++ 5 files changed, 82 insertions(+) create mode 100644 autoload/ale/dhall.vim create mode 100644 autoload/ale/fixers/dhall_format.vim create mode 100644 autoload/ale/fixers/dhall_freeze.vim create mode 100644 autoload/ale/fixers/dhall_lint.vim (limited to 'autoload') diff --git a/autoload/ale/dhall.vim b/autoload/ale/dhall.vim new file mode 100644 index 00000000..6e57c4a7 --- /dev/null +++ b/autoload/ale/dhall.vim @@ -0,0 +1,21 @@ +" Author: toastal +" Description: Functions for working with Dhall’s executable + +call ale#Set('dhall_executable', 'dhall') +call ale#Set('dhall_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('dhall_options', '') + +function! ale#dhall#GetExecutable(buffer) abort + return ale#Escape(ale#Var(a:buffer, 'dhall_executable')) +endfunction + +function! ale#dhall#GetExecutableWithOptions(buffer) abort + let l:executable = ale#dhall#GetExecutable(a:buffer) + + return l:executable + \ . ale#Pad(ale#Var(a:buffer, 'dhall_options')) +endfunction + +function! ale#dhall#GetCommand(buffer) abort + return '%e ' . ale#Pad(ale#Var(a:buffer, 'dhall_options')) +endfunction diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index 02b02699..3dc5c774 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -32,6 +32,21 @@ let s:default_registry = { \ 'suggested_filetypes': ['d'], \ 'description': 'Fix D files with dfmt.', \ }, +\ 'dhall-format': { +\ 'function': 'ale#fixers#dhall_format#Fix', +\ 'suggested_filetypes': ['dhall'], +\ 'description': 'Standard code formatter for the Dhall language', +\ }, +\ 'dhall-freeze': { +\ 'function': 'ale#fixers#dhall_freeze#Freeze', +\ 'suggested_filetypes': ['dhall'], +\ 'description': 'Add integrity checks to remote import statements of an expression for the Dhall language', +\ }, +\ 'dhall-lint': { +\ 'function': 'ale#fixers#dhall_lint#Fix', +\ 'suggested_filetypes': ['dhall'], +\ 'description': 'Standard code formatter for the Dhall language and removing dead code', +\ }, \ 'fecs': { \ 'function': 'ale#fixers#fecs#Fix', \ 'suggested_filetypes': ['javascript', 'css', 'html'], diff --git a/autoload/ale/fixers/dhall_format.vim b/autoload/ale/fixers/dhall_format.vim new file mode 100644 index 00000000..214af2c8 --- /dev/null +++ b/autoload/ale/fixers/dhall_format.vim @@ -0,0 +1,14 @@ +" Author: toastal +" Description: Dhall’s built-in formatter + +function! ale#fixers#dhall_format#Fix(buffer) abort + let l:executable = ale#dhall#GetExecutableWithOptions(a:buffer) + let l:command = l:executable + \ . ' format' + \ . ' --inplace %t' + + return { + \ 'command': l:command, + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/autoload/ale/fixers/dhall_freeze.vim b/autoload/ale/fixers/dhall_freeze.vim new file mode 100644 index 00000000..74ae7530 --- /dev/null +++ b/autoload/ale/fixers/dhall_freeze.vim @@ -0,0 +1,18 @@ +" Author: toastal +" Description: Dhall’s package freezing + +call ale#Set('dhall_freeze_options', '') + +function! ale#fixers#dhall_freeze#Freeze(buffer) abort + let l:executable = ale#dhall#GetExecutableWithOptions(a:buffer) + let l:command = l:executable + \ . ' freeze' + \ . ale#Pad(ale#Var(a:buffer, 'dhall_freeze_options')) + \ . ' --inplace %t' + + + return { + \ 'command': l:command, + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/autoload/ale/fixers/dhall_lint.vim b/autoload/ale/fixers/dhall_lint.vim new file mode 100644 index 00000000..2abbe6f7 --- /dev/null +++ b/autoload/ale/fixers/dhall_lint.vim @@ -0,0 +1,14 @@ +" Author: toastal +" Description: Dhall’s built-in linter/formatter + +function! ale#fixers#dhall_lint#Fix(buffer) abort + let l:executable = ale#dhall#GetExecutableWithOptions(a:buffer) + let l:command = l:executable + \ . ' lint' + \ . ' --inplace %t' + + return { + \ 'command': l:command, + \ 'read_temporary_file': 1, + \} +endfunction -- cgit v1.2.3 From ed47008710a2295ff3bf2d2e6372ee29cdbe6c39 Mon Sep 17 00:00:00 2001 From: toastal Date: Mon, 14 Sep 2020 09:20:53 +0700 Subject: addressing missing docs + cleaning up older Dhall files --- autoload/ale/dhall.vim | 7 +++++-- autoload/ale/fix/registry.vim | 5 ----- autoload/ale/fixers/dhall.vim | 23 ----------------------- autoload/ale/fixers/dhall_format.vim | 2 +- 4 files changed, 6 insertions(+), 31 deletions(-) delete mode 100644 autoload/ale/fixers/dhall.vim (limited to 'autoload') diff --git a/autoload/ale/dhall.vim b/autoload/ale/dhall.vim index 6e57c4a7..cc54418f 100644 --- a/autoload/ale/dhall.vim +++ b/autoload/ale/dhall.vim @@ -1,4 +1,4 @@ -" Author: toastal +" Author: Pat Brisbin , toastal " Description: Functions for working with Dhall’s executable call ale#Set('dhall_executable', 'dhall') @@ -6,7 +6,10 @@ call ale#Set('dhall_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('dhall_options', '') function! ale#dhall#GetExecutable(buffer) abort - return ale#Escape(ale#Var(a:buffer, 'dhall_executable')) + let l:executable = ale#Var(a:buffer, 'dhall_executable') + + " Dhall is written in Haskell and commonly installed with Stack + return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'dhall') endfunction function! ale#dhall#GetExecutableWithOptions(buffer) abort diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index 0a729cf9..218a0f95 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -390,11 +390,6 @@ let s:default_registry = { \ 'suggested_filetypes': ['html', 'htmldjango'], \ 'description': 'Fix HTML files with html-beautify.', \ }, -\ 'dhall': { -\ 'function': 'ale#fixers#dhall#Fix', -\ 'suggested_filetypes': ['dhall'], -\ 'description': 'Fix Dhall files with dhall-format.', -\ }, \} " Reset the function registry to the default entries. diff --git a/autoload/ale/fixers/dhall.vim b/autoload/ale/fixers/dhall.vim deleted file mode 100644 index 18f6006c..00000000 --- a/autoload/ale/fixers/dhall.vim +++ /dev/null @@ -1,23 +0,0 @@ -" Author: Pat Brisbin -" Description: Integration of dhall-format with ALE. - -call ale#Set('dhall_format_executable', 'dhall') - -function! ale#fixers#dhall#GetExecutable(buffer) abort - let l:executable = ale#Var(a:buffer, 'dhall_format_executable') - - " Dhall is written in Haskell and commonly installed with Stack - return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'dhall') -endfunction - -function! ale#fixers#dhall#Fix(buffer) abort - let l:executable = ale#fixers#dhall#GetExecutable(a:buffer) - - return { - \ 'command': l:executable - \ . ' format' - \ . ' --inplace' - \ . ' %t', - \ 'read_temporary_file': 1, - \} -endfunction diff --git a/autoload/ale/fixers/dhall_format.vim b/autoload/ale/fixers/dhall_format.vim index 214af2c8..d4021983 100644 --- a/autoload/ale/fixers/dhall_format.vim +++ b/autoload/ale/fixers/dhall_format.vim @@ -1,6 +1,6 @@ " Author: toastal " Description: Dhall’s built-in formatter - +" function! ale#fixers#dhall_format#Fix(buffer) abort let l:executable = ale#dhall#GetExecutableWithOptions(a:buffer) let l:command = l:executable -- cgit v1.2.3 From 48cbf1cb36e6e289be6275e6643504326963c3a4 Mon Sep 17 00:00:00 2001 From: toastal Date: Fri, 25 Sep 2020 08:26:17 +0700 Subject: dhall alias --- autoload/ale/fix/registry.vim | 1 + 1 file changed, 1 insertion(+) (limited to 'autoload') diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index 218a0f95..7b2682bf 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -36,6 +36,7 @@ let s:default_registry = { \ 'function': 'ale#fixers#dhall_format#Fix', \ 'suggested_filetypes': ['dhall'], \ 'description': 'Standard code formatter for the Dhall language', +\ 'aliases': ['dhall'], \ }, \ 'dhall-freeze': { \ 'function': 'ale#fixers#dhall_freeze#Freeze', -- cgit v1.2.3