-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vscode-languageclient: missing namespace #463
Comments
thanks for filing the issue. I'll look at this together with #367 , as it also handles things at the top level of the library. the effort required for this one is somewhat bigger. I also think it's about the most important issue to handle now. |
So far ST has looked at package.json to determine a subset of typings to include. Going forward *all* files will be translated. This solves #463 There are loads of details for computing shorter module names. These will be solved similar to how `exports` was solved in #486, by injecting "proxy modules" into the AST. Note that some libraries ship typings for multiple hierarchies, typically in folders named `src`, `es`, `es6` and so on. we'll now get all those duplicates as well.
So far ST has looked at package.json to determine a subset of typings to include. Going forward *all* files will be translated. This solves #463 There are loads of details for computing shorter module names. These will be solved similar to how `exports` was solved in #486, by injecting "proxy modules" into the AST. Note that some libraries ship typings for multiple hierarchies, typically in folders named `src`, `es`, `es6` and so on. we'll now get all those duplicates as well.
@oyvindberg thanks again for your offer of a workaround on gitter. Here's a little something to tide us over for now. cc @kubukoz if you're interested - This is connecting to a server assumed to be already running (note this is bypassing the usual backwards implementation where VSCode is actually the server, basically translated from https://github.com/itemis/xtext-languageserver-example/blob/master/vscode-extension/src/extension.ts) //manual facade until https://github.com/ScalablyTyped/Converter/issues/463 is fixed
import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport
import typings.node.NodeJS.{ReadableStream, WritableStream}
import typings.vscodeLanguageclient.configurationMod.*
import typings.vscodeLanguageclient.clientMod.*
type ServerOptions =
js.Function0[
js.Promise[StreamInfo]
] // other stuff as well but this will do for now
trait StreamInfo extends js.Object {
var writer: WritableStream
var reader: ReadableStream
}
object StreamInfo {
def apply(
writer: WritableStream,
reader: ReadableStream
): StreamInfo = js.Dynamic
.literal(writer = writer, reader = reader)
.asInstanceOf[StreamInfo]
}
object Trace extends js.Object {
opaque type Trace <: Int = Int
val Off: Trace = 0
val Messages: Trace = 1
val Compact: Trace = 2
val Verbose: Trace = 3
}
@js.native
@JSImport("vscode-languageclient/node", "LanguageClient")
class LanguageClient(
name: String,
serverOptions: ServerOptions,
clientOptions: LanguageClientOptions
) extends js.Object {
def start(): js.Promise[Unit] = js.native
def setTrace(value: Trace.Trace): js.Promise[Unit] = js.native
} usage (in val lspPort = 5000
val lspHost = "localhost"
val serverOptions = () => {
var socket = netMod.connect(lspPort, lspHost)
var result = StreamInfo(
reader = socket.asInstanceOf[ReadableStream],
writer = socket.asInstanceOf[WritableStream]
)
js.Promise.resolve(result)
}
val clientOptions = LanguageClientOptions(
).setDocumentSelector(js.Array[String]("scala"))
.setSynchronize(
SynchronizeOptions().setFileEvents(
workspace.createFileSystemWatcher("**/*.scala")
)
)
val lc =
new LanguageClient("language-server", serverOptions, clientOptions);
lc.setTrace(Trace.Verbose)
lc.start() |
Hi! First of all, thank you for building this tool - it's been an amazing help as I've been building a VS Code extension. Now I'm trying to move to a LSP architecture, so I gave vscode-languageclient a try.
The examples for typescript all say I should be using this:
and, according to https://scalablytyped.org/docs/encoding, this would look like
import typings.vscodeLanguageclientNode.LanguageClient
. However, that doesn't work - in fact the compiler (and Metals) don't seem to recognizevscodeLanguageclientNode
.I'd appreciate some hints about whether this is a bug or I'm doing something wrong :)
To reproduce:
package.json
LanguageClient
(according to snippets from https://code.visualstudio.com/api/language-extensions/language-server-extension-guide)Reproduction at https://github.com/kubukoz/demos/tree/sjs-vscodenode
The text was updated successfully, but these errors were encountered: