diff options
author | MD <0xhyoga@cygnusdao.finance> | 2023-12-08 19:13:37 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-08 22:13:37 +0000 |
commit | 71718722b2a5626b91422a8560bfc90c1d3903a4 (patch) | |
tree | 4eddaf885e4bd93b38cf03e8e93591914b416956 /ale_linters/cairo | |
parent | 32ee7039d0ee7afcc134756cfac78678cffc7017 (diff) | |
download | ale-71718722b2a5626b91422a8560bfc90c1d3903a4.zip |
Add support for Scarb in `cairo` files (#4669)
* Add support for Scarb in `cairo` files
* specify if linter should run on saved
Diffstat (limited to 'ale_linters/cairo')
-rw-r--r-- | ale_linters/cairo/scarb.vim | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/ale_linters/cairo/scarb.vim b/ale_linters/cairo/scarb.vim new file mode 100644 index 00000000..48212f0b --- /dev/null +++ b/ale_linters/cairo/scarb.vim @@ -0,0 +1,31 @@ +" Author: 0xhyoga <0xhyoga@gmx.com>, +" Description: scarb for cairo files + +function! ale_linters#cairo#scarb#GetScarbExecutable(bufnr) abort + if ale#path#FindNearestFile(a:bufnr, 'Scarb.toml') isnot# '' + return 'scarb' + else + " if there is no Scarb.toml file, we don't use scarb even if it exists, + " so we return '', because executable('') apparently always fails + return '' + endif +endfunction + +function! ale_linters#cairo#scarb#GetCommand(buffer, version) abort + return 'scarb build' +endfunction + +call ale#linter#Define('cairo', { +\ 'name': 'scarb', +\ 'executable': function('ale_linters#cairo#scarb#GetScarbExecutable'), +\ 'command': {buffer -> ale#semver#RunWithVersionCheck( +\ buffer, +\ ale_linters#cairo#scarb#GetScarbExecutable(buffer), +\ '%e --version', +\ function('ale_linters#cairo#scarb#GetCommand'), +\ )}, +\ 'callback': 'ale#handlers#cairo#HandleCairoErrors', +\ 'output_stream': 'both', +\ 'lint_file': 1, +\}) + |