Update language grammar without restart


#1

Hello, I am very new to modifying or creating packages for atom.
My goal was to add some extra grammar to language-pfm package (for now without creating my own one).
As the patterns are always quite tricky it would be great when I could see the changes immediately when I save the pfm.cson file where the grammar is defined.
However I cannot figure out how to do so. I have tested two packages which promise to do this but they seem not to work in this case. Is it possible at all?

How do other people who develop new grammars act on this? Restart the editor or the window takes way to long.

Thanks


#2

I agree that it is a painful process.
No there is not a way to avoid the dreaded restart AFAIK.

You can however have two sessions open and restart only the one session.

Use Ctril+Shift+F5 for the software driven restart. And consider blocking web access to Atom while you are playing around - Else Atom phones home on each restart.

Cheers.


#3

Can you think on an other tool for testing the grammar before adding it to atom at all?

Thanks for the quick reply.


#4

I am but 2 months young on this… so my ‘NO’ answer does not mean much.
If you are willing to wait a little for an answer, someone else might answer.
Is there any particular thing that is a challenge for you making the grammar?


#5

Try adding this to your init.coffee:

atom.commands.add 'atom-text-editor', 'custom:load-active-editor-as-grammar', ->
    editor = atom.workspace.getActiveTextEditor()
    atom.grammars.loadGrammarSync(editor.getPath())

Make a keybinding for it and use it when you make a change to a grammar file but don’t want to reload, or to write a grammar file without bothering to make a proper package folder for it.


#6

@DamnedScholar: Thanks, that works like a charm. I was able to change the grammar in a much shorter time with this hint.


#7

Thank you for a helpful tip. I’d give you x2 likes if I could.

I especially like this bit… that can be handy.
C-ya.