From 775d121d46b2b2cf61997598e4dc664476fd470d Mon Sep 17 00:00:00 2001 From: toastal <561087+toastal@users.noreply.github.com> Date: Sun, 8 Aug 2021 13:09:21 +0000 Subject: `purs-tidy` for PureScript (#3863) * purs-tidy * update email address for toastal --- autoload/ale/fix/registry.vim | 5 +++++ autoload/ale/fixers/dhall_format.vim | 2 +- autoload/ale/fixers/dhall_freeze.vim | 2 +- autoload/ale/fixers/dhall_lint.vim | 2 +- autoload/ale/fixers/purs_tidy.vim | 26 ++++++++++++++++++++++++++ 5 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 autoload/ale/fixers/purs_tidy.vim (limited to 'autoload') diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index 7a4d964e..597dfe6c 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -301,6 +301,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['haskell'], \ 'description': 'Refactor Haskell files with stylish-haskell.', \ }, +\ 'purs-tidy': { +\ 'function': 'ale#fixers#purs_tidy#Fix', +\ 'suggested_filetypes': ['purescript'], +\ 'description': 'Format PureScript files with purs-tidy.', +\ }, \ 'purty': { \ 'function': 'ale#fixers#purty#Fix', \ 'suggested_filetypes': ['purescript'], diff --git a/autoload/ale/fixers/dhall_format.vim b/autoload/ale/fixers/dhall_format.vim index d4021983..0812a186 100644 --- a/autoload/ale/fixers/dhall_format.vim +++ b/autoload/ale/fixers/dhall_format.vim @@ -1,4 +1,4 @@ -" Author: toastal +" Author: toastal " Description: Dhall’s built-in formatter " function! ale#fixers#dhall_format#Fix(buffer) abort diff --git a/autoload/ale/fixers/dhall_freeze.vim b/autoload/ale/fixers/dhall_freeze.vim index d1447b31..e029a83d 100644 --- a/autoload/ale/fixers/dhall_freeze.vim +++ b/autoload/ale/fixers/dhall_freeze.vim @@ -1,4 +1,4 @@ -" Author: toastal +" Author: toastal " Description: Dhall's package freezing call ale#Set('dhall_freeze_options', '') diff --git a/autoload/ale/fixers/dhall_lint.vim b/autoload/ale/fixers/dhall_lint.vim index 2abbe6f7..18fe9788 100644 --- a/autoload/ale/fixers/dhall_lint.vim +++ b/autoload/ale/fixers/dhall_lint.vim @@ -1,4 +1,4 @@ -" Author: toastal +" Author: toastal " Description: Dhall’s built-in linter/formatter function! ale#fixers#dhall_lint#Fix(buffer) abort diff --git a/autoload/ale/fixers/purs_tidy.vim b/autoload/ale/fixers/purs_tidy.vim new file mode 100644 index 00000000..0183fd73 --- /dev/null +++ b/autoload/ale/fixers/purs_tidy.vim @@ -0,0 +1,26 @@ +" Author: toastal +" Description: Integration of purs-tidy with ALE. + +call ale#Set('purescript_tidy_executable', 'purs-tidy') +call ale#Set('purescript_tidy_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('purescript_tidy_options', '') + +function! ale#fixers#purs_tidy#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'purescript_tidy', [ + \ 'node_modules/purescript-tidy/bin/index.js', + \ 'node_modules/.bin/purs-tidy', + \]) +endfunction + +function! ale#fixers#purs_tidy#Fix(buffer) abort + let l:executable = ale#fixers#purs_tidy#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'purescript_tidy_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ale#Pad(l:options) + \ . ' %s', + \ 'read_temporary_file': 0, + \} +endfunction + -- cgit v1.2.3