summaryrefslogtreecommitdiff
path: root/ale_linters/cairo
diff options
context:
space:
mode:
author0xHyoga <0xhyoga@cygnusdao.finance>2022-07-22 06:05:08 +0200
committerGitHub <noreply@github.com>2022-07-22 13:05:08 +0900
commit0ea53870b6b93eb3b20dbd8317291cfe06dc38bd (patch)
tree402a3f9c591f1c6c3883d2bda825d8118ba66126 /ale_linters/cairo
parent5ef26c32da4407ca820afe359f6b957dd514a656 (diff)
downloadale-0ea53870b6b93eb3b20dbd8317291cfe06dc38bd.zip
cairo support (#4256)
* cairo support * supported languages txt * add cairo to ale.txt
Diffstat (limited to 'ale_linters/cairo')
-rw-r--r--ale_linters/cairo/starknet.vim37
1 files changed, 37 insertions, 0 deletions
diff --git a/ale_linters/cairo/starknet.vim b/ale_linters/cairo/starknet.vim
new file mode 100644
index 00000000..990bda6d
--- /dev/null
+++ b/ale_linters/cairo/starknet.vim
@@ -0,0 +1,37 @@
+" Author: 0xHyoga <0xHyoga@gmx.com>
+" Description: Report starknet-compile errors in cairo code
+
+call ale#Set('cairo_starknet_executable', 'starknet-compile')
+call ale#Set('cairo_starknet_options', '')
+
+function! ale_linters#cairo#starknet#Handle(buffer, lines) abort
+ " Error always on the first line
+ " e.g ex01.cairo:20:6: Could not find module 'contracts.utils.ex00_base'. Searched in the following paths:
+ let l:pattern = '\v\.cairo:(\d+):(\d+):+ (.*)'
+ let l:output = []
+
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
+ call add(l:output, {
+ \ 'lnum': str2nr(l:match[1]),
+ \ 'col': str2nr(l:match[2]),
+ \ 'type': 'E',
+ \ 'text': l:match[3],
+ \})
+ endfor
+
+ return l:output
+endfunction
+
+function! ale_linters#cairo#starknet#GetCommand(buffer) abort
+ let l:executable = ale#Var(a:buffer, 'cairo_starknet_executable')
+
+ return l:executable . ale#Pad(ale#Var(a:buffer, 'cairo_starknet_options')) . ' %s'
+endfunction
+
+call ale#linter#Define('cairo', {
+\ 'name': 'starknet',
+\ 'executable': {b -> ale#Var(b, 'cairo_starknet_executable')},
+\ 'command': function('ale_linters#cairo#starknet#GetCommand'),
+\ 'callback': 'ale_linters#cairo#starknet#Handle',
+\ 'output_stream': 'stderr',
+\})