Dhall language support (fixes #2820)

This commit is contained in:
toastal 2020-08-02 12:31:06 +07:00
parent ed69b074ba
commit f1080a2bbe
No known key found for this signature in database
GPG Key ID: A1CAFFE4DB109A47
8 changed files with 142 additions and 0 deletions

21
autoload/ale/dhall.vim Normal file
View File

@ -0,0 +1,21 @@
" Author: toastal <toastal@protonmail.com>
" Description: Functions for working with Dhalls 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

View File

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

View File

@ -0,0 +1,14 @@
" Author: toastal <toastal@protonmail.com>
" Description: Dhalls 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

View File

@ -0,0 +1,18 @@
" Author: toastal <toastal@protonmail.com>
" Description: Dhalls 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

View File

@ -0,0 +1,14 @@
" Author: toastal <toastal@protonmail.com>
" Description: Dhalls 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

52
doc/ale-dhall.txt Normal file
View File

@ -0,0 +1,52 @@
===============================================================================
ALE Dhall Integration *ale-dhall-options*
g:ale_dhall_executable *g:ale_dhall_executable*
*b:ale_dhall_executable*
Type: |String|
Default: `'dhall'`
g:ale_dhall_options g:ale_dhall_options
b:ale_dhall_options
Type: |String|
Default: `''`
This variable can be set to pass additional options to the 'dhall` executable.
This is shared with `dhall-freeze` and `dhall-lint`.
>
let g:dhall_options = '--ascii'
<
===============================================================================
dhall-format *ale-dhall-format*
Dhall
(https://dhall-lang.org/)
===============================================================================
dhall-freeze *ale-dhall-freeze*
Dhall
(https://dhall-lang.org/)
g:ale_dhall_freeze_options g:ale_dhall_freeze_options
b:ale_dhall_freeze_options
Type: |String|
Default: `''`
This variable can be set to pass additional options to the 'dhall freeze`
executable.
>
let g:dhall_freeze_options = '--all'
<
===============================================================================
dhall-lint *ale-dhall-lint*
Dhall
(https://dhall-lang.org/)
===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:

View File

@ -2374,6 +2374,10 @@ documented in additional help files.
dart....................................|ale-dart-options|
dartanalyzer..........................|ale-dart-dartanalyzer|
dartfmt...............................|ale-dart-dartfmt|
dhall...................................|ale-dhall-options|
dhall-format..........................|ale-dhall-format|
dhall-freeze..........................|ale-dhall-freeze|
dhall-lint............................|ale-dhall-lint|
dockerfile..............................|ale-dockerfile-options|
dockerfile_lint.......................|ale-dockerfile-dockerfile_lint|
hadolint..............................|ale-dockerfile-hadolint|

View File

@ -127,6 +127,10 @@ formatting.
* [dartanalyzer](https://github.com/dart-lang/sdk/tree/master/pkg/analyzer_cli) :floppy_disk:
* [dartfmt](https://github.com/dart-lang/sdk/tree/master/utils/dartfmt)
* [language_server](https://github.com/natebosch/dart_language_server)
* Dhall
* [dhall-format](https://github.com/dhall-lang)
* [dhall-freeze](https://github.com/dhall-lang)
* [dhall-lint](https://github.com/dhall-lang)
* Dockerfile
* [dockerfile_lint](https://github.com/projectatomic/dockerfile_lint)
* [hadolint](https://github.com/hadolint/hadolint)