Set Syntax Highlighting to new textEditor (SOLVED)


#1

I am building a package which, at some point, inserts text into a .feature file.
Is there any option when creating the new text editor in which I can specify which syntax I would like to use (if available, since gherkin syntax doesn’t come built in Atom)?

This is how I am generating the editor:

    gsText = document.createElement 'atom-text-editor';
    gsText.setAttribute 'mini',''
    gsText.setAttribute 'gutter-hidden',''
    gfText.dataset.grammar = "source feature"

I would like to avoid taking those textEditor later and using textEditor.setGrammar('language') since it doesn’t work as expected.

EDIT: I am doing things right. It’s just the syntax highlighting package for gherking language which is not behaving as I wanted to.

thank you for your clues!


#2

I don’t really understand the question, but you should be able to use textEditor.setGrammar(atom.grammars.grammarForScopeName('source.feature)) to set the grammar of a text editor


#3

I am. I was about to edit.
The issue is about the syntax highlighter which isn’t behaving as I expected in my specific situation.