atom-community / atom-languageclient

Provide integration support for adding Language Server Protocol servers to Atom.
https://www.npmjs.com/package/atom-languageclient
MIT License
44 stars 13 forks source link

make the languageId of didOpen notifications configurable #178

Closed ayame113 closed 3 years ago

ayame113 commented 3 years ago

According to the spec, the recommended markdown languageId for textDocument/didOpen requests is "markdown". Currently, the markdown languageId is "github markdown", can you change it?

image

(The specifications say "If a document refers to one of the programming languages listed below it is recommended that clients use those ids.".)

UziTech commented 3 years ago

the languageId is set by the grammar name. If you want the languageid to be markdown you can use language-markdown instead of language-gfm

UziTech commented 3 years ago

I feel like we should leave this between the grammars and the servers. GFM should be processed differently than CommonMark (markdown). I think the servers might want to know which one they are receiving.

ayame113 commented 3 years ago

I think the servers might want to know which one they are receiving.

It makes sense. How about allowing users of this package to configure languageId through the AutoLanguageClient?

example:

class FooBarLanguageClient extends AutoLanguageClient {
  getLanguageIdFromGrammarScope(scopeName: string): string|undefined {
    // If return undefined, the default value will be used
    if (scopeName==='source.gfm') {
      return 'markdown'
    }
  }
}
UziTech commented 3 years ago

I think some sort of override would be ok. @ayame113 wanna create a PR?

ayame113 commented 3 years ago

wanna create a PR?

OK, I will do it.