Help porting Vscode language server extension


#1

Hi all,

I’m in the process of converting my own vscode extension over to atom and am having some difficulty. I’ve implemented a language server for language called kerboscript. It’s used to generate autopiloting scripts for the popular indie game kerbal space program. Check out main project documentation here if your interested.

The main repo is in this repo but the atom client is specifically located here

My first step was port over the syntax highlighting from vscode. I have a textmate grammar which works as I would like in vscode but I can’t seem to get it to activate in atom. So far I’ve simply copied my grammer into the grammars folder renamed .json to .cson and add the filetypes for “ks” which is the file extension. I’ve open the atom client in atom at the level of the package.json and reload which to my understanding should activate the package in a develop mode. I have one sample file in the samples folder which I would expect to be highlighted but it only identifies it as a plain text file.

Any help would be greatly appreciated. I know this is fairly vague but I’m not sure were else to find resources for these sorts of questions.

Thanks!


#2

You’re missing a comma after fileTypes.


#3

Thank you! it still not loading but I’m sure that would have caused me issues later on.


#4

Open up the Atom dev tools (ctrl-shift-i), move to the Console, and run the following code:

atom.workspace.grammarRegistry.grammarForScopeName("source.kos")

That will tell us if the grammar has been picked up by Atom.


#5

You don’t need to rename JSON to CSON; it should accept either.


#8

Sorry for the deleted post, trying to figure out how to edit an old post so I don’t spam

Open up the Atom dev tools (ctrl-shift-i), move to the Console , and run the following code:

I plugged this into the console and it returned undefined. I found another call

atom.workspace.grammarRegistry.getGrammars()

which didn’t show my grammar in the list of loaded grammars

You don’t need to rename JSON to CSON; it should accept either.

I went ahead and just copied my vscode textmate grammar into my atom client just to reduce the possibility of some mistake I made converting it. This doesn’t seem to have fixed the issue either.


#9

further update calling

atom.workspace.grammarRegistry.loadGrammarSync('path/to/my/grammar')

loads the grammar and correctly scopes my sample file. So it appears the issue is the package isn’t loading the grammar at all.


#10

It might be that your activation hook isn’t being triggered because the grammar it’s looking for doesn’t exist until the package has been activated. You should not have any activation requirements for a language package.


#11

I went ahead and removed the activation hooks, it still doesn’t activate. I may have to try some other approach.


#12

It activates just fine for me with no changes (the grammar is detected as expected).

If you are referring to the file lib/main.js not activating, you need to specify it as the entry point in your package.json.


#13

I’ll check on the lib/main.js but mostly I was just referring to the grammar. Well clearly if you can get it to work there is something up with my local environment. I’ll try cloning my own repo and see if that works.

Thanks for the help!


#14

Still not definitively sure why it wasn’t activating, but I blew the folder and scaffold the project again and it properly picked up the textmate grammar.

Thanks DamnedScholar and Aerijo for the help!