Closed cassepipe closed 3 years ago
On simple inspection this looks like should work. What problem do you see or what is not working?
Well, it does work, I get a >>
at the top of the file and I see no error message.
I suspect I don't understand very well how the matching function work and/or I get my indexing wrong.
I am pretty sure about my pattern though as I tested it on the output thanks to the set incsearch
option in Vim.
I just don't know how to debug it
You can run the same commands used in the script inside vim to test the regexp. For example I ran these commands:
:let pattern='\(^\(\h\+\.[ch]\): \(\w\+\)!$\|^Error: \h\+\s\+(line:\s\+\(\d\+\),\s\+col:\s\+\(\d\+\)):\s\+\(.*\)\)'
:echo ale#util#GetMatches(['ft_lstsize.c: Error!'], pattern)
And this was the output:
[['ft_lstsize.c: Error!', 'ft_lstsize.c: Error!', 'ft_lstsize.c', 'Error', '', '', '', '', '', '']]
The regexp works but you are checking l:match[2] == 'OK'
or l:match[2] == 'Error'
when that value is in l:match[3]
. The filename would be in l:match[2]
instead of l:match[1]
. You can test the other error messages to figure out the correct match index.
Also since we get errors for different files is better to add the filename
to the list of errors:
call add(l:output, {
\ 'filename': l:curr_file,
\ 'lnum': str2nr(l:match[1]),
\ 'col': str2nr(l:match[2]),
\ 'type': 'E',
\ 'text': l:match[3],
\})
Hope this helps you implement the linter. I recommend you submit a PR to make the discussion easier. Do not forget to add documentation, tests, and update the list of supported tools. See :h ale-development
for details.
Thanks for the debugging tip ! And thanks for pointing out to where the error is and giving advice for betterment. I will try that out ASAP. If I mange to make it work, I'll do the work of documenting it and submit a PR. I don't think I have the level needed to write tests but I will look into that too.
Name: norminette URL: https://github.com/42School/norminette
The tuition-free 42 network of schools is using a program to check whether the C code written for the school projects and submitted to peer-review follows a certain style. Its purpose is to enforce a common style that is easily readable by others.
It is easily installed with :
Here is an example of what the
norminette
outputs in the terminal:Writing a linter for it should be trivial for someone well versed in Vimscript but alas this not my case.
I have not been able to find help to make it work so far so I am asking here in the hope that someone can show me the way forward. Here is my (non-functional) attempt at it :
Any help or hint would be much appreciated. Thanks for making ALE, I could write code that fast without it.