Skip to content

Instantly share code, notes, and snippets.

@ZacLN
Created November 7, 2017 16:57
Show Gist options
  • Save ZacLN/287109d3f4682d6706c4acdc7c7db2ea to your computer and use it in GitHub Desktop.
Save ZacLN/287109d3f4682d6706c4acdc7c7db2ea to your computer and use it in GitHub Desktop.
using LanguageServer
using CSTParser
for n in names(LanguageServer, true, true)
eval(:(import LanguageServer.$n))
end
import LanguageServer.JSONRPC:Request, parse
import LanguageServer: process, lint
Range = LanguageServer.Range
root = "nope"
# run from here to setup server
server = LanguageServerInstance(IOBuffer(), IOBuffer(), true)
process(LanguageServer.parse(Request, """{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":6547,"rootPath":"$root","rootUri":"$root","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true},"didChangeConfiguration":{"dynamicRegistration":false},"didChangeWatchedFiles":{"dynamicRegistration":false},"symbol":{"dynamicRegistration":true},"executeCommand":{"dynamicRegistration":true}},"textDocument":{"synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"completionItem":{"snippetSupport":true}},"hover":{"dynamicRegistration":true},"signatureHelp":{"dynamicRegistration":true},"references":{"dynamicRegistration":true},"documentHighlight":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"definition":{"dynamicRegistration":true},"codeAction":{"dynamicRegistration":true},"codeLens":{"dynamicRegistration":true},"documentLink":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true}}},"trace":"off"}}"""), server);
@time process(LanguageServer.parse(Request, """{"jsonrpc":"2.0","method":"initialized","params":{}}"""), server)
uri = "none"
text = """
module A
struct Bob{T}
end
Bob{T}(x) where T = Bob{T}()
end
"""
r = parse(Request, """{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"$uri","languageId":"julia","version":1,"text":""}}}""")
r.params.textDocument.text = text
process(r, server)
doc = server.documents[URI2(uri)];
L = lint(doc, server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment