wingyplus / language-robot-framework

Robot Framework grammar for Atom Text Editor.
https://atom.io/packages/language-robot-framework
26 stars 17 forks source link

Improved Syntax Highlights #39

Closed goatshen closed 6 years ago

goatshen commented 6 years ago

To improve the syntax highlighting of keywords. I hope this will resolve the following feature request: https://github.com/wingyplus/language-robot-framework/issues/37

How: I added two regex in robottxt.cson and gave them 'keyword.control.robot' scope.

image

wingyplus commented 6 years ago

@goatshen Cool. And will be good if you add test case and fix test to pass.

And thanks for your contribution.

goatshen commented 6 years ago

Hi @wingyplus .

The 'bdd style' test suite assumes that the first BDD word (e.g. Give, When, Then, And, But) will be tokenized. For the example, we expect that 'Given' will be tokenised with the scope ['text.robot', 'keyword.control.robot'].

expectedScopes = ['text.robot', 'keyword.control.robot']

it 'tokenizes Given', ->
  {tokens} = grammar.tokenizeLine '    Given Do Something'

  expect(tokens[1].scopes).toEqual expectedScopes
  expect(tokens[1].value).toEqual 'Given'

With my additional changes to the grammar, 'Given Do Something' will now have the scope ['text.robot', 'keyword.control.robot'].

I was wondering if we should add an additional scope to the BDD words so it stands out from the keywords?

Also, I am able to use Travis to run the test cases but it takes a while. How do you locally run the test cases?

Cheers

goatshen commented 6 years ago

Hi @wingyplus I fixed the test cases. Also made some adjustments to the Grammar since some variables were not being highlighted. Appreciate any feedback!

wingyplus commented 6 years ago

Sorry for late reply. I think BDD style keyword should have additional syntax. Maybe it will used underline hightlight. But it can do it later. :)

For running test on local you can do with apm test.

wingyplus commented 6 years ago

@goatshen Thanks for your PR. I published this PR as a version 2.4.0. :)

fardy316 commented 5 years ago

Thanks for this enhancement. Is there any way to have different colors for the Keywords and the Keywords Definition like I would get in an IDE like PyCharm ?

As you can see in my screenshot, I have an orange font color for the Keywords and a light yellow color for the Keywords Definitions.

keywordscolors

Thanks

wingyplus commented 5 years ago

Possible to do that. It's needs to modify regexp for keyword definitions because I re-use keyword syntax for both test case (or keyword) and keyword definitions.

I also have plan to revamp for new parser api (https://github.com/tree-sitter/tree-sitter). It'll be a good place to do this. :)

fardy316 commented 5 years ago

Thanks for the quick response.

If you're planning to revamp the regex, maybe it'll be a good idea to split everything up so it'll be easier to customize for everybody's needs.

But that would only be nice to have. You already did a fantastic work on your plugin.

Thanks.