adityam / filter

ConTeXt module to process contents of a start-stop environment through an external program
45 stars 10 forks source link

t-vim doesn't appear to set vimrc correctly #45

Closed Semptum closed 3 years ago

Semptum commented 3 years ago

I was trying to make Julia syntax highlighting work. When I started looking in the logs, I saw that vim was called with vim -u NONE so I set

\definevimtyping[julia][
    syntax=julia,
    vimrc=~/.vimrc,
    escape=on
]

However after that the logs showed something weird:

vim -u sujet-temp-vimrc-~/.vimrc.tmp -X -i NONE --noplugin --clean -es -n -c "syntax manual" -c "set syntax=julia" -c "set tabstop=4" -c "let contextstartline=1| let contextstopline=0| let strip=1" -c "let escapecomments=1" -c "let highlight=[]"  -c "source /usr/share/texmf-dist/tex/context/third/vim/2context.vim" -c "qa" sujet-temp-julia-0.tmp sujet-temp-julia-0.vimout

To avoid confusion, my filename is "sujet.tex".

I'm still looking trying to understand the source code but this vimrc is just weird and without setting the correct vimrc the syntax highlighting doesn't work even in interactive mode. Is it normal behaviour?

Thanks for the work on this module btw, it's pretty great for other languages.

Best regards,

Semptum commented 3 years ago

So, I can generate a correct .vimout file with the right syntactic information but I have to do the following:

vim -u NONE -X -i NONE --noplugin --clean -es -n -c "syntax manual" -c "set syntax=julia" -c "set tabstop=4" -c "let contextstartline=1| let contextstopline=0| let strip=1" -c "let escapecomments=1" -c "let highlight=[]"  -c "source /usr/share/texmf-dist/tex/context/third/vim/2context.vim" -c "qa" sujet-temp-julia-0.tmp sujet-temp-julia-0.vimout

to

vim -u ~/.vimrc -X -i NONE --noplugin -N -es -n -c "syntax manual" -c "set syntax=julia" -c "set tabstop=4" -c "let contextstartline=1| let contextstopline=0| let strip=1" -c "let escapecomments=1" -c "let highlight=[]"  -c "source /usr/share/texmf-dist/tex/context/third/vim/2context.vim" -c "qa" sujet-temp-julia-0.tmp sujet-temp-julia-0.vimout

And the output went from

\SYNBOL{}iter=Fibonacci(n)\SYNEOL{}
\SYNBOL{}for i in iter\SYNEOL{}
\SYNBOL{}    #body\SYNEOL{}
\SYNBOL{}end\SYNEOL{}

to

\SYNBOL{}iter\SYN[Operator]{=}\SYN[juliaNone]{Fibonacci}\SYN[juliaNone]{(}\SYN[juliaParBlock]{n}\SYN[juliaNone]{)}\SYNEOL{}
\SYNBOL{}\SYN[Repeat]{for}\SYN[juliaForBlock]{ i }\SYN[Keyword]{in}\SYN[juliaForBlock]{ iter}\SYNEOL{}
\SYNBOL{}\SYN[juliaForBlock]{    }\SYN[Comment]{#}\SYN[Comment]{body}\SYNEOL{}
\SYNBOL{}\SYN[Repeat]{end}\SYNEOL{}

It could be that I misunderstood something basic and there is a reason why it uses --clean and prepends something to the vimrc filename, I'm not fluent in ConTexT yet.

EDIT: Sorry, was using Arch's distributed ConTexT. In the new version there is no --clean but there is still the issue with the prepended filename and the lack of -N. I'm feeling rather stupid, I spent hours on this and once I wrote an issue I immediately started understanding the code a bit more.

adityam commented 3 years ago

Are you using the latest version of the t-vim module? There was a bug which was fixed recently. See e2a606d9964ecc5abdabf885142b5a73fdfccecb

Is there a specific reason why you want to set the non-compatible mode?

adityam commented 3 years ago

The vimrc setting is not a bug. See the section on tuning color schemes to see how it is supposed to be used. The t-vim module has no mechanism for loading a system wide vimrc (which is typically meant for interactive usage and has the potential slow things down)

Semptum commented 3 years ago

Are you using the latest version of the t-vim module? There was a bug which was fixed recently. See e2a606d

Is there a specific reason why you want to set the non-compatible mode?

I am now, yes.

I needed to set the non-compatible mode to load the julia plugin, otherwise the syntax highlighting doesn't work. But I was reading the man for the vim command options too much and forgot it was also possible in the vimrc. I have implemented a vimrc that works thanks to your comment.

Apologies for the issue, a forum might have been more suited. Since the latest version works without issues to produce a syntactically annotated file and it was user error that caused the problems, I'm closing the issue.