ruby syntax is not compatiable with embed ruby syntax in vim script. #112

Closed
stardiviner opened this Issue Nov 9, 2012 · 8 comments

Comments

Projects
None yet
4 participants

Here are two screenshots:
enable vim-ruby
disable vim-ruby

Owner

tpope commented Nov 9, 2012

It's working for me. Can anyone else reproduce?

On Fri, Nov 9, 2012 at 1:34 AM, stardiviner notifications@github.comwrote:

Here are two screenshots:
enable vim-ruby http://ompldr.org/vZzc5NA
disable vim-ruby http://ompldr.org/vZzc5NQ


Reply to this email directly or view it on GitHubhttps://github.com/vim-ruby/vim-ruby/issues/112.

Member

AndrewRadev commented Nov 9, 2012

I can't reproduce it either. @NAGATOPain, could you try running

:echo synIDattr(synID(line("."), col("."), 1), "name")

with the cursor on the line = "hello" line and let us know what the result is in both cases? It should be vimRubyRegion.

@AndrewRadev I got output vimEmbedError from your command. Sorry for this, I can not reproduce that correct syntax now.

Member

AndrewRadev commented Nov 10, 2012

Interesting. I grepped a bit at my system files for vimEmbedError and found this:

let s:rubypath= fnameescape(expand("<sfile>:p:h")."/ruby.vim")
if !filereadable(s:rubypath)
 let s:rubypath= fnameescape(globpath(&rtp,"syntax/ruby.vim"))
endif
if (g:vimsyn_embed =~ 'r' && has("ruby")) && filereadable(s:rubypath)
 " ... omitted for brevity
else
 syn region vimEmbedError start=+rub[y]\s*<<\s*\z(.*\)$+ end=+^\z1$+
 syn region vimEmbedError start=+rub[y]\s*<<\s*$+ end=+\.$+
endif
unlet s:rubypath

A vimEmbedError is matched if the expression (g:vimsyn_embed =~ 'r' && has("ruby")) && filereadable(s:rubypath) evaluates to false. Now, has("ruby") should not evaluate to false in one case and true in another. g:vimsyn_embed is probably the same, so it might be a problem with s:rubypath. Debugging this would be difficult on our side, since we can't replicate it, but here's what you could do:

First, find Vim's built-in vimscript syntax file on your system. If you're on Linux, you should be able to find it with:

$ find /usr/share -wholename '*syntax/vim.vim'

If you're on a Mac, I've no idea where the shared files are installed. You could look for it by inspecting your runtimepath with :echo &rtp.

After you find it, edit it (you'll probably need to be a superuser) and locate the above code by searching for s:rubypath. Change the top part from this:

let s:rubypath= fnameescape(expand("<sfile>:p:h")."/ruby.vim")
if !filereadable(s:rubypath)
 let s:rubypath= fnameescape(globpath(&rtp,"syntax/ruby.vim"))
endif

To this:

let s:rubypath= fnameescape(expand("<sfile>:p:h")."/ruby.vim")
echomsg s:rubypath
if !filereadable(s:rubypath)
 let s:rubypath= fnameescape(globpath(&rtp,"syntax/ruby.vim"))
endif
echomsg s:rubypath
echomsg g:vimsyn_embed
echomsg has("ruby")
echomsg filereadable(s:rubypath)

Then, edit a vimscript file and execute :messages and report back the last 5 lines of the output. Interestingly enough, on my machine, the s:rubypath file is the system-wide ruby syntax file, which means that the vim-ruby one is not used at all. This may mean that you don't have a built-in ruby syntax file? I don't know, it's kind of weird.

I have a newer version vim.vim syntax file under .vim/syntax/. And I append your lines into /usr/share/vim/vim73/syntax/vim.vim and .vim/syntax/vim.vim.
Got this output:

/home/chris/Git/dotfiles/.vim/syntax/ruby.vim
/home/chris/.vim/bundle/vim-ruby/syntax/ruby.vim\^@/usr/share/vim/vim73/syntax/ruby.vim
mpPr
1
0

Actually this message only when I append echomsg lines to .vim/syntax/vim.vim can be displayer. not work in /usr/share/vim/vim73/syntax/vim.vim.

Seems that the s:rubypath is not filereadable(). Because I do not have ruby.vim under .vim/syntax/ ?

Owner

tpope commented Nov 11, 2012

I don't have time to dive into this now, but now that you mention it, I
seem to recall that vim.vim sources the ruby.vim in the same directory
rather than walking the runtime path.

On Sat, Nov 10, 2012 at 4:03 PM, stardiviner notifications@github.comwrote:

I have a newer version vim.vim syntax file under .vim/syntax/. And I
append your lines into /usr/share/vim/vim73/syntax/vim.vim and
.vim/syntax/vim.vim.
Got this output:

/home/chris/Git/dotfiles/.vim/syntax/ruby.vim
/home/chris/.vim/bundle/vim-ruby/syntax/ruby.vim^@/usr/share/vim/vim73/syntax/ruby.vim
mpPr
1
0


Reply to this email directly or view it on GitHubhttps://github.com/vim-ruby/vim-ruby/issues/112#issuecomment-10261553.

Member

AndrewRadev commented Nov 13, 2012

The problem seems to be that /home/chris/.vim/bundle/vim-ruby/syntax/ruby.vim\^@/usr/share/vim/vim73/syntax/ruby.vim is being fed to filereadable() directly, while it should have been split by newlines. I wrote to Dr. Chip about it and he seems to have fixed it in his latest alpha version here: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_VIM.

@NAGATOPain, could you download and try that version of syntax/vim.vim and let us know if everything is alright?

@AndrewRadev fixed now. Thanks very much.

dkearns added the syntax label Sep 18, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment