use syntastic (or any vim checker) on a sagemath

223 Views Asked by At

I'm using vim for .sage files and I try to have a checker for these files. syntastic can handle python verification (with flake8) so I wanted to try this.

The first idea I had is to put something like this in my .vim/filetype.vim :

au BufNewFile,BufRead *.sage    setfiletype sage

But, I have some "useful" things in my .vim/ftplugin/sage.vim so I don't want to assimilate .sage files and .vim files.

So, my question is: is it possible for example to just tell syntastic to treat .sage files as a .py file?

The other problem I may have is that flake8 won't be happy with the sagemath functions that don't exist in python. Is there something I can do with that?

Thanks for your help.

2

There are 2 best solutions below

3
romainl On
autocmd BufNewFile,BufRead *.sage set filetype=sage

should be in ~/.vim/ftdetect/sage.vim.

0
user8622655 On

In fact, I was, I hope, just to tired to understand well enough the faq of syntastic..

I put

let g:syntastic_sage_checkers = ['python/flake8']
et g:syntastic_sage_flake8_args = '--ignore=F821

in my .vimrc

the first line, as explained in the syntastic page, tells that "even if the type is sage, I will use flake8, usually used for python files.

the second disable the error F821 of flake8, it is the error for "undefined name". It is usefull because of the sagemath functions that differs from python..

`