0

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.

1
  • :h 'syntastic_filetype_map'
    – lcd047
    Sep 24, 2018 at 21:30

2 Answers 2

1

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..

`

0
autocmd BufNewFile,BufRead *.sage set filetype=sage

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

3
  • why? It's working fine with filetype.vim and all the declaraction of this kind are placed here, whithout any problem. I don't remenber now when I had find this, but it's working. Sep 24, 2018 at 20:55
  • 1
    1) because a sentence like "so I don't want to assimilate .sage files and .vim files." shows that you don't understand how it all works. 2) because it is cleaner in many ways than filetype.vim.
    – romainl
    Sep 25, 2018 at 5:47
  • According to :help new-filetype, both ~/.vim/filetype.vim and ~/.vim/ftdetect/*.vim are fine. The latter has the benefit of being composable, but that is only important for plugins, not for a custom configuration. There, it can be nice to have everything in one single file. Sep 25, 2018 at 7:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.