Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Letting VIM spell check strings #53

Merged
merged 1 commit into from

6 participants

@camilo

As of now the syntax file only spell checks comments, adding @Spell to the rubyString regions.

@AndrewRadev
Collaborator

This looks like a useful feature, although I'm worried about false positives. Considering the language's string interpolation and metaprogramming, a lot of spelling errors might be generated where they're not wanted. Personally, I use spell checking on demand, so I can't say how much of an issue this could be to someone who has it on at all times.

Still, I'm leaning towards accepting it, so if there are no objections, I'll merge it in some time tomorrow.

@AndrewRadev AndrewRadev merged commit d1cd15d into vim-ruby:master
@jfelchner

@AndrewRadev I'm not a fan of this. The false positives thing is extremely annoying when you're trying to embed ruby in another language like Markdown using GH code fencing or HEREDOCs.

Take this for example:

image

Obviously this is a contrived example, but initializable should not be flagged. But I don't want to disable spell checking completely, because I'm in a Markdown document. And I can't even set the region to @NoSpell because the inner syntax is more specific. So it's @Spell takes priority over the @NoSpell in the outer region.

I'd really like to get this either taken out or an option added to opt into spell checking strings.

@tpope
Owner

I lean slightly against highlighting strings as well.

@AndrewRadev AndrewRadev referenced this pull request from a commit
@AndrewRadev AndrewRadev Revert "Letting VIM spell check regular strings"
This reverts commit c27c526.

False positives can be annoying, and embedding ruby in a different
language makes it impossible to disable selectively.

For a discussion, see #53
4661bf7
@AndrewRadev
Collaborator

In that case, I'll revert the commit. Spellchecking can be kind of annoying to juggle, the fact that it's impossible to override when embedded is kind of a dealbreaker.

Maybe an option could work, though we're not very fond of adding too many options in vim-ruby. @camilo, I think you could add this as an extension in your own vimfiles, for personal usage. Do you feel strongly about adding it in vim-ruby with an option?

@aminfara

Hi, I loved this feature as it helped me prevent misspelled words being published to our production website. Personally I believe spell checking is the most important for string literals as they normally tell something to the end user.

Could we at least have this feature as an option? It was very useful.

Personally I changed vim-ruby manually to add this feature. but in case of update I will loose that.

@AndrewRadev
Collaborator

@aminfara, you could put this in your .vimrc, outside of vim-ruby:

augroup ruby_syntax
  autocmd!

  autocmd Syntax ruby syn region rubyString matchgroup=rubyStringDelimiter start="\"" end="\"" skip="\\\\\|\\\"" contains=@rubyStringSpecial,@Spell fold
  autocmd Syntax ruby syn region rubyString matchgroup=rubyStringDelimiter start="'"  end="'"  skip="\\\\\|\\'"  contains=rubyQuoteEscape,@Spell fold
augroup END

This overrides the setup in vim-ruby to add spell checking. The other way around would be impossible (if you enable it, it can't be disabled from outside the syntax file), but you could do this yourself, without changing vim-ruby. Theoretically, if we were to change those lines, you may run into trouble, but vim-ruby doesn't change particularly often, the odds of it happening are pretty low.

If you still feel strongly about having it as an option instead, I'll consider it, though I'd also need to hear from @tpope on the matter.

@dkearns
Owner

I just went with my personal preference (comments only) when initially adding the spell checking as it was a new feature and there wasn't any trend amongst the other syntax files.

That was a dozen years ago though and it seems that both strings and comments are generally checked now.

@jfelchner

I'd personally be fine with an option, but having string checking globally enabled and not being able to disable it is bad IMO.

The snippet above seems like a perfectly reasonable thing to have in a vimrc though.

@aminfara

@AndrewRadev I patched my .vimrc and it did the trick. Thanks.

I suggest you add the snippet to readme file so everybody likes the feature can enable it manually. Without having to search google for hours first ;).

Thanks.

@AndrewRadev
Collaborator

@dkearns, @jfelchner has a point. Having it enabled by default means you can't disable it in some cases.

@aminfara Glad it works, but you make a great point -- this is not particularly discoverable. Considering it's just two lines that are reasonably isolated and that there's already a documentation section for syntax highlighting options, I think it'll be better to just make it an option.

I've pushed a commit that adds the setting ruby_spellcheck_strings. Set it to 1 in your vimrc with let ruby_spellcheck_strings = 1 and you should get spellchecking.

If anybody has issues with the variable name, documentation, or something, please let me know.

@aminfara

@AndrewRadev Fantastic! really appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 19, 2011
  1. @camilo
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 2 deletions.
  1. +2 −2 syntax/ruby.vim
View
4 syntax/ruby.vim
@@ -135,8 +135,8 @@ syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\[" end="\][io
syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r(" end=")[iomxneus]*" skip="\\\\\|\\)" contains=@rubyRegexpSpecial fold
" Normal String and Shell Command Output
-syn region rubyString matchgroup=rubyStringDelimiter start="\"" end="\"" skip="\\\\\|\\\"" contains=@rubyStringSpecial fold
-syn region rubyString matchgroup=rubyStringDelimiter start="'" end="'" skip="\\\\\|\\'" contains=rubyQuoteEscape fold
+syn region rubyString matchgroup=rubyStringDelimiter start="\"" end="\"" skip="\\\\\|\\\"" contains=@rubyStringSpecial,@Spell fold
+syn region rubyString matchgroup=rubyStringDelimiter start="'" end="'" skip="\\\\\|\\'" contains=rubyQuoteEscape,@Spell fold
syn region rubyString matchgroup=rubyStringDelimiter start="`" end="`" skip="\\\\\|\\`" contains=@rubyStringSpecial fold
" Generalized Single Quoted String, Symbol and Array of Strings
Something went wrong with that request. Please try again.