Letting VIM spell check strings #53

Merged
merged 1 commit into from Sep 21, 2011

Conversation

Projects
None yet
6 participants
@camilo
Contributor

camilo commented Sep 19, 2011

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

@AndrewRadev

This comment has been minimized.

Show comment
Hide comment
@AndrewRadev

AndrewRadev Sep 20, 2011

Member

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.

Member

AndrewRadev commented Sep 20, 2011

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 added a commit that referenced this pull request Sep 21, 2011

Merge pull request #53 from camilo/master
Letting VIM spell check strings

@AndrewRadev AndrewRadev merged commit d1cd15d into vim-ruby:master Sep 21, 2011

@jfelchner

This comment has been minimized.

Show comment
Hide comment
@jfelchner

jfelchner Dec 15, 2014

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

@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

This comment has been minimized.

Show comment
Hide comment
@tpope

tpope Dec 17, 2014

Member

I lean slightly against highlighting strings as well.

Member

tpope commented Dec 17, 2014

I lean slightly against highlighting strings as well.

AndrewRadev added a commit that referenced this pull request Dec 18, 2014

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
@AndrewRadev

This comment has been minimized.

Show comment
Hide comment
@AndrewRadev

AndrewRadev Dec 18, 2014

Member

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?

Member

AndrewRadev commented Dec 18, 2014

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?

@jfelchner

This comment has been minimized.

Show comment
Hide comment

@AndrewRadev thank you! 😄

@aminfara

This comment has been minimized.

Show comment
Hide comment
@aminfara

aminfara Jan 29, 2015

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.

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

This comment has been minimized.

Show comment
Hide comment
@AndrewRadev

AndrewRadev Feb 3, 2015

Member

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

Member

AndrewRadev commented Feb 3, 2015

@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

This comment has been minimized.

Show comment
Hide comment
@dkearns

dkearns Feb 3, 2015

Member

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.

Member

dkearns commented Feb 3, 2015

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

This comment has been minimized.

Show comment
Hide comment
@jfelchner

jfelchner Feb 3, 2015

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.

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

This comment has been minimized.

Show comment
Hide comment
@aminfara

aminfara Feb 8, 2015

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

aminfara commented Feb 8, 2015

@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

This comment has been minimized.

Show comment
Hide comment
@AndrewRadev

AndrewRadev Feb 8, 2015

Member

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

Member

AndrewRadev commented Feb 8, 2015

@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

This comment has been minimized.

Show comment
Hide comment
@aminfara

aminfara Feb 11, 2015

@AndrewRadev Fantastic! really appreciate it.

@AndrewRadev Fantastic! really appreciate it.

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