language-ruby icon indicating copy to clipboard operation
language-ruby copied to clipboard

Safe Navigation operator (&.) should be an operator

Open JustinAiken opened this issue 9 years ago • 3 comments

Support for this operator was added in https://github.com/atom/language-ruby/pull/125, but I think it should be classified different:

  • punctuation.separator.method.ruby
    • (what it is now)
      puncuation
  • keyword.operator.logical.ruby

If there's an agreement, I'd be happy to open a PR that changes it along with the test

JustinAiken avatar Sep 20 '16 16:09 JustinAiken

I think "logical" is a bad scope name for &.:

  • although author&.posts is sort of used as a shorthand of author && author.posts, they're different in that it only skips the invocations on nil but not false
  • "logical" is shaky even for && for that it's essentially a flow control operator in Ruby (so as &.)
  • there's also a . part in it

hediyi avatar Sep 23 '16 02:09 hediyi

Is there any way to make progress with this? I don't have syntax highlighting for safe navigation operators in VSCode which uses this language server. Considering this is a few years old, it would be nice!

bbugh avatar Jul 11 '19 18:07 bbugh

This issue was addressed for the vscode-ruby library, but it still has not been addressed for the atom/language-ruby library.

Here was the vscode-ruby solution, which I believe is still using TextMate:

{
	"comment": "Safe navigation operator",
	"match": "(&\\.)\\s*(?![A-Z])",
	"captures": {
		"1": {
			"name": "keyword.operator.logical.ruby"
		}
	}
},

Can we get this applied to the Tree-sitter version for Atom, so that Safe Nav operators can be highlighted as operators, rather than as methods?

jmoglesby avatar Apr 04 '21 08:04 jmoglesby