mirror of
https://github.com/dense-analysis/ale.git
synced 2026-08-20 06:37:58 +08:00
Add support for fatou (#5159)
Add a linter that runs the fatou language server (`fatou lsp`) for Julia diagnostics, and a fixer that formats Julia with `fatou format`.
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
" Author: Johan Larsson <johan@jolars.co>
|
||||
" Description: A language server, formatter, and linter for Julia
|
||||
|
||||
call ale#Set('julia_fatou_executable', 'fatou')
|
||||
|
||||
function! ale_linters#julia#fatou#GetProjectRoot(buffer) abort
|
||||
let l:config = ale#path#FindNearestFile(a:buffer, 'fatou.toml')
|
||||
|
||||
return !empty(l:config) ? fnamemodify(l:config, ':h') : ''
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('julia', {
|
||||
\ 'name': 'fatou',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable': {b -> ale#Var(b, 'julia_fatou_executable')},
|
||||
\ 'command': '%e lsp',
|
||||
\ 'project_root': function('ale_linters#julia#fatou#GetProjectRoot'),
|
||||
\})
|
||||
@@ -124,6 +124,11 @@ let s:default_registry = {
|
||||
\ 'suggested_filetypes': ['erlang'],
|
||||
\ 'description': 'Format Erlang code with erlfmt',
|
||||
\ },
|
||||
\ 'fatou': {
|
||||
\ 'function': 'ale#fixers#fatou#Fix',
|
||||
\ 'suggested_filetypes': ['julia'],
|
||||
\ 'description': 'Format Julia files with fatou.',
|
||||
\ },
|
||||
\ 'fecs': {
|
||||
\ 'function': 'ale#fixers#fecs#Fix',
|
||||
\ 'suggested_filetypes': ['javascript', 'css', 'html'],
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
" Author: Johan Larsson <johan@jolars.co>
|
||||
" Description: Format Julia files with fatou.
|
||||
|
||||
call ale#Set('julia_fatou_executable', 'fatou')
|
||||
call ale#Set('julia_fatou_options', '')
|
||||
|
||||
function! ale#fixers#fatou#Fix(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'julia_fatou_executable')
|
||||
let l:options = ale#Var(a:buffer, 'julia_fatou_options')
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable) . ' format'
|
||||
\ . ale#Pad(l:options),
|
||||
\}
|
||||
endfunction
|
||||
@@ -2,6 +2,39 @@
|
||||
ALE Julia Integration *ale-julia-options*
|
||||
|
||||
|
||||
===============================================================================
|
||||
fatou *ale-julia-fatou*
|
||||
|
||||
fatou is a language server, formatter, and linter for Julia. The `fatou` linter
|
||||
runs the language server (`fatou lsp`) to report diagnostics, and the `fatou`
|
||||
fixer formats Julia with `fatou format`.
|
||||
|
||||
Project-level configuration is read from a `fatou.toml` file discovered by
|
||||
walking up from the file being edited. See https://github.com/jolars/fatou for
|
||||
more information.
|
||||
|
||||
*ale-options.julia_fatou_executable*
|
||||
*g:ale_julia_fatou_executable*
|
||||
*b:ale_julia_fatou_executable*
|
||||
julia_fatou_executable
|
||||
g:ale_julia_fatou_executable
|
||||
Type: |String|
|
||||
Default: `'fatou'`
|
||||
|
||||
This variable can be changed to change the path to fatou.
|
||||
|
||||
*ale-options.julia_fatou_options*
|
||||
*g:ale_julia_fatou_options*
|
||||
*b:ale_julia_fatou_options*
|
||||
julia_fatou_options
|
||||
g:ale_julia_fatou_options
|
||||
Type: |String|
|
||||
Default: `''`
|
||||
|
||||
This variable can be changed to pass additional arguments to the `fatou
|
||||
format` command used by the fixer.
|
||||
|
||||
|
||||
===============================================================================
|
||||
languageserver *ale-julia-languageserver*
|
||||
|
||||
|
||||
@@ -386,6 +386,7 @@ Notes:
|
||||
* `jsonnet-lint`
|
||||
* `jsonnetfmt`
|
||||
* Julia
|
||||
* `fatou`
|
||||
* `languageserver`
|
||||
* Kotlin
|
||||
* `kotlinc`!!
|
||||
|
||||
@@ -3744,6 +3744,7 @@ documented in additional help files.
|
||||
jsonnetfmt............................|ale-jsonnet-jsonnetfmt|
|
||||
jsonnet-lint..........................|ale-jsonnet-jsonnet-lint|
|
||||
julia...................................|ale-julia-options|
|
||||
fatou.................................|ale-julia-fatou|
|
||||
languageserver........................|ale-julia-languageserver|
|
||||
kotlin..................................|ale-kotlin-options|
|
||||
kotlinc...............................|ale-kotlin-kotlinc|
|
||||
|
||||
@@ -396,6 +396,7 @@ formatting.
|
||||
* [jsonnet-lint](https://jsonnet.org/learning/tools.html) :speech_balloon:
|
||||
* [jsonnetfmt](https://jsonnet.org/learning/tools.html) :speech_balloon:
|
||||
* Julia
|
||||
* [fatou](https://github.com/jolars/fatou) :speech_balloon:
|
||||
* [languageserver](https://github.com/JuliaEditorSupport/LanguageServer.jl)
|
||||
* Kotlin
|
||||
* [kotlinc](https://kotlinlang.org) :floppy_disk:
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
Before:
|
||||
call ale#assert#SetUpFixerTest('julia', 'fatou')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownFixerTest()
|
||||
|
||||
Execute(The default command should be correct):
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'command': ale#Escape('fatou') . ' format',
|
||||
\ }
|
||||
|
||||
Execute(The executable and options should be configurable):
|
||||
let g:ale_julia_fatou_executable = 'foobar'
|
||||
let g:ale_julia_fatou_options = '--line-width 80'
|
||||
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'command': ale#Escape('foobar') . ' format --line-width 80',
|
||||
\ }
|
||||
@@ -0,0 +1,23 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('julia', 'fatou')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default executable path should be correct):
|
||||
AssertLinter 'fatou', ale#Escape('fatou') . ' lsp'
|
||||
|
||||
Execute(The executable should be configurable):
|
||||
let g:ale_julia_fatou_executable = '/path/to/fatou'
|
||||
|
||||
AssertLinter '/path/to/fatou', ale#Escape('/path/to/fatou') . ' lsp'
|
||||
|
||||
Execute(The project root should be detected correctly with a configuration file):
|
||||
call ale#test#SetFilename('../test-files/fatou/subdir/file.jl')
|
||||
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/fatou')
|
||||
|
||||
Execute(The project root should be empty when no project files can be detected):
|
||||
call ale#test#SetFilename('../test-files/dummy')
|
||||
|
||||
AssertLSPProject ''
|
||||
Reference in New Issue
Block a user