purs-tidy for PureScript (#3863)

* purs-tidy

* update email address for toastal
This commit is contained in:
toastal
2021-08-08 13:09:21 +00:00
committed by GitHub
parent a793db7399
commit 775d121d46
10 changed files with 85 additions and 3 deletions

View File

@@ -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'],

View File

@@ -1,4 +1,4 @@
" Author: toastal <toastal@protonmail.com>
" Author: toastal <toastal@posteo.net>
" Description: Dhalls built-in formatter
"
function! ale#fixers#dhall_format#Fix(buffer) abort

View File

@@ -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', '')

View File

@@ -1,4 +1,4 @@
" Author: toastal <toastal@protonmail.com>
" Author: toastal <toastal@posteo.net>
" Description: Dhalls built-in linter/formatter
function! ale#fixers#dhall_lint#Fix(buffer) abort

View File

@@ -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