vim support

362 views
Skip to first unread message

Peng Yu

unread,
Aug 21, 2012, 4:52:24 PM8/21/12
to sage-s...@googlegroups.com
Hi,

I followed the following tip to set up vim for sage. But I don't see
syntax highlight nor correctly auto indentation. Has anybody
successfully configured vim for sage?

http://wiki.sagemath.org/Tips

Vim filetypes To get Vim to use Python syntax highlighting,
indentation, and so on for .sage files, put the following in
$VIM/filetype.vim:

augroup filetypedetect
au! BufRead,BufNewFile *.sage,*.spyx,*.pyx setfiletype python
augroup END

--
Regards,
Peng

Dima Pasechnik

unread,
Aug 22, 2012, 9:04:36 AM8/22/12
to sage-s...@googlegroups.com

On Wednesday, 22 August 2012 04:52:24 UTC+8, Peng Yu wrote:
Hi,

I followed the following tip to set up vim for sage. But I don't see
syntax highlight nor correctly auto indentation. Has anybody
successfully configured vim for sage?

Do Python syntax high-lightings work in your vim?

P Purkayastha

unread,
Aug 22, 2012, 12:07:41 PM8/22/12
to sage-s...@googlegroups.com
What I use is:

autocmd BufRead,BufNewFile,BufWritePost *.sage set filetype=python
autocmd BufRead,BufNewFile,BufWritePost *.spyx,*.pyx set filetype=python.c

Ruslan Kiyanchuk

unread,
Aug 23, 2012, 3:16:20 AM8/23/12
to sage-s...@googlegroups.com
Vim filetypes To get Vim to use Python syntax highlighting,
indentation, and so on for .sage files, put the following in
$VIM/filetype.vim:

augroup filetypedetect
   au! BufRead,BufNewFile *.sage,*.spyx,*.pyx setfiletype python
augroup END


What I use is:

autocmd BufRead,BufNewFile,BufWritePost *.sage set filetype=python
autocmd BufRead,BufNewFile,BufWritePost *.spyx,*.pyx set filetype=python.c

I've seen that tip, but it's not really close to a solution, it's just a dirty hack that has nothing to do with Sage (Python syntax != Sage syntax, there's plenty of extra stuff in Sage).

What I did for now is just exporting Sage keywords (there are corresponding built-in functions for that) into Python syntax file, so I at least get highlight for all functions and methods. You can find the file here http://xsnippet.org/359006/

I'd prefer having Sage syntax suger highlighting as well (like z.<x> = ...), but didn't bother to implement it yet.
 

--
Sincerely, Ruslan Kiyanchuk

P Purkayastha

unread,
Aug 23, 2012, 11:00:27 PM8/23/12
to sage-s...@googlegroups.com, ruslan.k...@gmail.com
It's not really a hack. The syntax and functions in Sage are a superset of what is there in python. So, it makes sense to set it to python. Of course, it would be nice to have Sage functions properly highlighted, but as a first step the commands below work. You don't get syntax highlighting for Sage functions, but you do get stuff properly indented.

Ruslan Kiyanchuk

unread,
Aug 24, 2012, 9:52:23 AM8/24/12
to sage-s...@googlegroups.com
By being a hack, I mean that the setting has nothing to do with "Vim support of Sage". It's  just forcing vim to interpret Sage files as Python files, since sage is built upon Python and has similar (though, not identical) syntax. Relatively to vim, it thinks that it just works with Python. So one can't really call it a "Sage support".

--
You received this message because you are subscribed to the Google Groups "sage-support" group.
To post to this group, send email to sage-s...@googlegroups.com.
To unsubscribe from this group, send email to sage-support...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.
 
 



--
Sincerely, Ruslan Kiyanchuk

Keshav Kini

unread,
Aug 24, 2012, 12:55:32 PM8/24/12
to sage-s...@googlegroups.com
Ruslan Kiyanchuk <ruslan.k...@gmail.com> writes:

> By being a hack, I mean that the setting has nothing to do with "Vim
> support of Sage". It's  just forcing vim to interpret Sage files as
> Python files, since sage is built upon Python and has similar
> (though, not identical) syntax. Relatively to vim, it thinks that it
> just works with Python. So one can't really call it a "Sage support".

That's true. But is anyone saying vim supports Sage syntax?

-Keshav

----
Join us in #sagemath on irc.freenode.net !

Ruslan Kiyanchuk

unread,
Aug 24, 2012, 1:59:37 PM8/24/12
to sage-s...@googlegroups.com
That's true. But is anyone saying vim supports Sage syntax?

Nope, but that's the problem :) Would be nice to have full Sage syntax support (and autocompletion — sweet dreams :) since I'm pretty sure many of those who use Sage also use Vim. Unfortunately currently I'm not too good in vimscript to write a good syntax file or completion plugin. But after my vacation is over I might give it some time if no good solution will come up before. 


--
Sincerely, Ruslan Kiyanchuk
Reply all
Reply to author
Forward
0 new messages