Skip to content

Latest commit

 

History

History
 
 

scijava-lsp-ty

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

SciJava LSP ty

A language server for python, backed by ty, for use with scijava-lsp.

ty runs as a process per environment scripts run in, in a small environment of its own, which Appose builds the first time it is needed (see TyLauncher).

Example

Context context = new Context(LanguageServerService.class);
// (a) Start the server: the plugin offering "python", for scripts run by the
// server's own Python (or, e.g., new Environment().withInterpreter(python)).
LanguageServer server = context.service(LanguageServerService.class)
	.launch("python", new Environment());
server.initialize(new InitializeParams()).get();
server.initialized(new InitializedParams());

// (b) Ask it about a script: open it, then ask, e.g. for completions.
String script = "import json\njson.du";
server.getTextDocumentService().didOpen(new DidOpenTextDocumentParams(
	new TextDocumentItem("untitled:/example.py", "python", 1, script)));
server.getTextDocumentService().completion(new CompletionParams(
	new TextDocumentIdentifier("untitled:/example.py"),
	Positions.position(script, script.length()))).get(); // dump, dumps

context.dispose(); // Stops the server, too.