mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-07 21:24:33 +08:00
Add the typstyle formatter as a fixer for Typst (#4927)
Some checks are pending
CI / build_image (push) Waiting to run
CI / test_ale (--linters-only) (push) Blocked by required conditions
CI / test_ale (--neovim-07-only) (push) Blocked by required conditions
CI / test_ale (--neovim-08-only) (push) Blocked by required conditions
CI / test_ale (--vim-80-only) (push) Blocked by required conditions
CI / test_ale (--vim-90-only) (push) Blocked by required conditions
Some checks are pending
CI / build_image (push) Waiting to run
CI / test_ale (--linters-only) (push) Blocked by required conditions
CI / test_ale (--neovim-07-only) (push) Blocked by required conditions
CI / test_ale (--neovim-08-only) (push) Blocked by required conditions
CI / test_ale (--vim-80-only) (push) Blocked by required conditions
CI / test_ale (--vim-90-only) (push) Blocked by required conditions
Co-authored-by: Adrian Vollmer <computerfluesterer@protonmail.com>
This commit is contained in:
@@ -707,6 +707,11 @@ let s:default_registry = {
|
|||||||
\ 'suggested_filetypes': ['clojure'],
|
\ 'suggested_filetypes': ['clojure'],
|
||||||
\ 'description': 'formatter and linter for clojure files',
|
\ 'description': 'formatter and linter for clojure files',
|
||||||
\ },
|
\ },
|
||||||
|
\ 'typstyle': {
|
||||||
|
\ 'function': 'ale#fixers#typstyle#Fix',
|
||||||
|
\ 'suggested_filetypes': ['typst'],
|
||||||
|
\ 'description': 'A formatter for Typst files',
|
||||||
|
\ },
|
||||||
\}
|
\}
|
||||||
|
|
||||||
" Reset the function registry to the default entries.
|
" Reset the function registry to the default entries.
|
||||||
|
|||||||
20
autoload/ale/fixers/typstyle.vim
Normal file
20
autoload/ale/fixers/typstyle.vim
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
" Author: Adrian Vollmer (computerfluesterer@protonmail.com)
|
||||||
|
" Description: Typst formatter using typstyle
|
||||||
|
|
||||||
|
call ale#Set('typst_typstyle_executable', 'typstyle')
|
||||||
|
call ale#Set('typst_typstyle_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||||
|
call ale#Set('typst_typstyle_options', '')
|
||||||
|
|
||||||
|
function! ale#fixers#typstyle#Fix(buffer) abort
|
||||||
|
let l:executable = ale#path#FindExecutable(
|
||||||
|
\ a:buffer,
|
||||||
|
\ 'typst_typstyle',
|
||||||
|
\ ['typstyle']
|
||||||
|
\)
|
||||||
|
|
||||||
|
let l:options = ale#Var(a:buffer, 'typst_typstyle_options')
|
||||||
|
|
||||||
|
return {
|
||||||
|
\ 'command': ale#Escape(l:executable) . ' ' . l:options,
|
||||||
|
\}
|
||||||
|
endfunction
|
||||||
@@ -686,6 +686,8 @@ Notes:
|
|||||||
* `tslint`
|
* `tslint`
|
||||||
* `tsserver`
|
* `tsserver`
|
||||||
* `typecheck`
|
* `typecheck`
|
||||||
|
* Typst
|
||||||
|
* `typstyle`
|
||||||
* V
|
* V
|
||||||
* `v`!!
|
* `v`!!
|
||||||
* `vfmt`
|
* `vfmt`
|
||||||
|
|||||||
24
doc/ale-typst.html
Normal file
24
doc/ale-typst.html
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
===============================================================================
|
||||||
|
ALE Typst Integration *ale-typst-options*
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
typstyle *ale-typst-typstyle*
|
||||||
|
|
||||||
|
g:ale_typst_typstyle_executable *g:ale_typst_typstyle_executable*
|
||||||
|
*b:ale_typst_typstyle_executable*
|
||||||
|
Type: |String|
|
||||||
|
Default: `'typstyle'`
|
||||||
|
|
||||||
|
See |ale-integrations-local-executables|
|
||||||
|
|
||||||
|
|
||||||
|
g:ale_typst_typstyle_options *g:ale_typst_typstyle_options*
|
||||||
|
*b:ale_typst_typstyle_options*
|
||||||
|
Type: |String|
|
||||||
|
Default: `''`
|
||||||
|
|
||||||
|
This variable can be changed to modify flags given to typstyle.
|
||||||
|
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||||
@@ -3478,6 +3478,8 @@ documented in additional help files.
|
|||||||
tslint................................|ale-typescript-tslint|
|
tslint................................|ale-typescript-tslint|
|
||||||
tsserver..............................|ale-typescript-tsserver|
|
tsserver..............................|ale-typescript-tsserver|
|
||||||
xo....................................|ale-typescript-xo|
|
xo....................................|ale-typescript-xo|
|
||||||
|
typst...................................|ale-typst-options|
|
||||||
|
typstyle..............................|ale-typst-typstyle|
|
||||||
v.......................................|ale-v-options|
|
v.......................................|ale-v-options|
|
||||||
v.....................................|ale-v-v|
|
v.....................................|ale-v-v|
|
||||||
vfmt..................................|ale-v-vfmt|
|
vfmt..................................|ale-v-vfmt|
|
||||||
|
|||||||
@@ -695,6 +695,8 @@ formatting.
|
|||||||
* [tslint](https://github.com/palantir/tslint)
|
* [tslint](https://github.com/palantir/tslint)
|
||||||
* [tsserver](https://github.com/Microsoft/TypeScript/wiki/Standalone-Server-%28tsserver%29)
|
* [tsserver](https://github.com/Microsoft/TypeScript/wiki/Standalone-Server-%28tsserver%29)
|
||||||
* typecheck
|
* typecheck
|
||||||
|
* Typst
|
||||||
|
* [typstyle](https://github.com/Enter-tainer/typstyle)
|
||||||
* V
|
* V
|
||||||
* [v](https://github.com/vlang/v/) :floppy_disk:
|
* [v](https://github.com/vlang/v/) :floppy_disk:
|
||||||
* [vfmt](https://github.com/vlang/v/)
|
* [vfmt](https://github.com/vlang/v/)
|
||||||
|
|||||||
21
test/fixers/test_typstyle_fixer_callback.vader
Normal file
21
test/fixers/test_typstyle_fixer_callback.vader
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
Before:
|
||||||
|
call ale#assert#SetUpFixerTest('typst', 'typstyle', 'typstyle')
|
||||||
|
|
||||||
|
After:
|
||||||
|
Restore
|
||||||
|
|
||||||
|
call ale#assert#TearDownFixerTest()
|
||||||
|
|
||||||
|
Execute(The typstyle callback should return the correct default command):
|
||||||
|
AssertEqual
|
||||||
|
\ {'command': ale#Escape('typstyle') . ' '},
|
||||||
|
\ ale#fixers#typstyle#Fix(bufnr(''))
|
||||||
|
|
||||||
|
Execute(The typstyle options should be considered):
|
||||||
|
call ale#test#SetFilename('../test-files/typstyle/testfile.typ')
|
||||||
|
let g:ale_typst_typstyle_options = '-c 100'
|
||||||
|
|
||||||
|
AssertFixer
|
||||||
|
\ { 'command': ale#Escape(g:ale_typst_typstyle_executable)
|
||||||
|
\ . ' -c 100',
|
||||||
|
\ }
|
||||||
Reference in New Issue
Block a user