summaryrefslogtreecommitdiff
path: root/ale_linters/robot
diff options
context:
space:
mode:
authorSamuel Branisa <branisa.samuel@windowslive.com>2021-09-11 02:19:17 +0200
committerGitHub <noreply@github.com>2021-09-11 09:19:17 +0900
commit19437e25d05950ab83dce285b4b8ec5166e06dba (patch)
treef961d8ddc232dbd0123021b770f3aebe39b472e2 /ale_linters/robot
parentbf29f6ea92ff993d5d96bc4e760f315e95e332a5 (diff)
downloadale-19437e25d05950ab83dce285b4b8ec5166e06dba.zip
Robot framework rflint support (#3715)
* Create rflint.vim support for robot framework by creating ale definition for rflint syntax linter * robot framework - rflint support
Diffstat (limited to 'ale_linters/robot')
-rw-r--r--ale_linters/robot/rflint.vim46
1 files changed, 46 insertions, 0 deletions
diff --git a/ale_linters/robot/rflint.vim b/ale_linters/robot/rflint.vim
new file mode 100644
index 00000000..8fe2d797
--- /dev/null
+++ b/ale_linters/robot/rflint.vim
@@ -0,0 +1,46 @@
+" Author: Samuel Branisa <branisa.samuel@icloud.com>
+" Description: rflint linting for robot framework files
+
+call ale#Set('robot_rflint_executable', 'rflint')
+
+function! ale_linters#robot#rflint#GetExecutable(buffer) abort
+ return ale#Var(a:buffer, 'robot_rflint_executable')
+endfunction
+
+function! ale_linters#robot#rflint#GetCommand(buffer) abort
+ let l:executable = ale_linters#robot#rflint#GetExecutable(a:buffer)
+ let l:flags = '--format'
+ \ . ' "{filename}:{severity}:{linenumber}:{char}:{rulename}:{message}"'
+
+ return l:executable
+ \ . ' '
+ \ . l:flags
+ \ . ' %s'
+endfunction
+
+function! ale_linters#robot#rflint#Handle(buffer, lines) abort
+ let l:pattern = '\v^([[:alnum:][:punct:]]+):(W|E):([[:digit:]]+):([[:digit:]]+):([[:alnum:]]+):(.*)$'
+ let l:output = []
+
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
+ call add(l:output, {
+ \ 'bufnr': a:buffer,
+ \ 'filename': l:match[1],
+ \ 'type': l:match[2],
+ \ 'lnum': str2nr(l:match[3]),
+ \ 'col': str2nr(l:match[4]),
+ \ 'text': l:match[5],
+ \ 'detail': l:match[6],
+ \})
+ endfor
+
+ return l:output
+endfunction
+
+call ale#linter#Define('robot', {
+\ 'name': 'rflint',
+\ 'executable': function('ale_linters#robot#rflint#GetExecutable'),
+\ 'command': function('ale_linters#robot#rflint#GetCommand'),
+\ 'callback': 'ale_linters#robot#rflint#Handle',
+\})
+