-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Textidote #3066
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
" Author: Jordi Altayo <[email protected]>, Juan Pablo Stumpf | ||
" <[email protected]> | ||
" Description: support for textidote grammar and syntax checker | ||
|
||
call ale#Set('tex_textidote_executable', 'textidote') | ||
call ale#Set('tex_textidote_options', '--no-color --output singleline') | ||
" TODO get language from spell spelllang | ||
call ale#Set('tex_textidote_check_lang', '') | ||
|
||
|
||
function! ale_linters#tex#textidote#GetExecutable(buffer) abort | ||
let l:exe = ale#Var(a:buffer, 'tex_textidote_executable') | ||
let l:exe .= ' ' . ale#Var(a:buffer, 'tex_textidote_options') | ||
|
||
let l:check_lang = ale#Var(a:buffer, 'tex_textidote_check_lang') | ||
|
||
if !empty(l:check_lang) | ||
let l:exe .= ' --check ' . l:check_lang | ||
endif | ||
|
||
return l:exe . ' ' . expand('#' . a:buffer . ':t') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does not work when editing files in sub-foders. For example:
Removing the ':t' would properly show the textidote reported errors on both the main.tex and the chapter1/section01.tex files. |
||
endfunction | ||
|
||
function! ale_linters#tex#textidote#Handle(buffer, lines) abort | ||
let l:pattern = '.*' . expand('#' . a:buffer . ':t:r') . '\.tex(L\(\d\+\)C\(\d\+\)-L\d\+C\d\+): \(.*\)".*"' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as previous comment this breaks for subfolder files. Remove the |
||
let l:output = [] | ||
|
||
for l:match in ale#util#GetMatches(a:lines, l:pattern) | ||
call add(l:output, { | ||
\ 'lnum': l:match[1] + 0, | ||
\ 'col' : l:match[2] + 0, | ||
\ 'text': l:match[3], | ||
\ 'type': 'E', | ||
\}) | ||
endfor | ||
|
||
return l:output | ||
endfunction | ||
|
||
call ale#linter#Define('tex', { | ||
\ 'name': 'textidote', | ||
\ 'output_stream': 'stdout', | ||
\ 'executable': {b -> ale#Var(b, 'tex_textidote_executable')}, | ||
\ 'command': function('ale_linters#tex#textidote#GetExecutable'), | ||
\ 'callback': 'ale_linters#tex#textidote#Handle', | ||
\}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small attempt to get language from spelllang configuration, may be worth considering: