summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authortoastal <561087+toastal@users.noreply.github.com>2021-08-08 13:09:21 +0000
committerGitHub <noreply@github.com>2021-08-08 22:09:21 +0900
commit775d121d46b2b2cf61997598e4dc664476fd470d (patch)
treed4f7a63dfd500a511e43b8c20402e4d36ef392e4 /autoload
parenta793db7399e786b8c882b10e6a8540718d5cdbf1 (diff)
downloadale-775d121d46b2b2cf61997598e4dc664476fd470d.zip
`purs-tidy` for PureScript (#3863)
* purs-tidy * update email address for toastal
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/dhall_format.vim2
-rw-r--r--autoload/ale/fixers/dhall_freeze.vim2
-rw-r--r--autoload/ale/fixers/dhall_lint.vim2
-rw-r--r--autoload/ale/fixers/purs_tidy.vim26
5 files changed, 34 insertions, 3 deletions
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 <toastal@protonmail.com>
+" Author: toastal <toastal@posteo.net>
" 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 <toastal@protonmail.com>
+" Author: toastal <toastal@posteo.net>
" 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 <toastal@protonmail.com>
+" Author: toastal <toastal@posteo.net>
" 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 <toastal@posteo.net>
+" 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
+