diff options
author | Simon Van Casteren <simon.van.casteren@gmail.com> | 2019-12-13 14:44:20 +0100 |
---|---|---|
committer | Simon Van Casteren <simon.van.casteren@gmail.com> | 2019-12-13 14:44:20 +0100 |
commit | e74d203806efea612ef2ab33da1e561c077d6c16 (patch) | |
tree | 05e7faeaaee52d3dce13693ec0cd6a10d16457e8 | |
parent | be644b0be6acd3cdeb957d46e9477ea3e16599ba (diff) |
Added initializationOption to specify project if multiple urp files
-rw-r--r-- | src/lsp.sml | 11 | ||||
-rw-r--r-- | src/lspspec.sml | 4 |
2 files changed, 11 insertions, 4 deletions
diff --git a/src/lsp.sml b/src/lsp.sml index d902fed4..34137a4f 100644 --- a/src/lsp.sml +++ b/src/lsp.sml @@ -47,12 +47,17 @@ fun initState (initParams: LspSpec.initializeParams): state = val rootPath = case #rootUri initParams of NONE => raise Fail "No rootdir found" | SOME a => #path a + val optsUrpFile = + (SOME (FromJson.asString (FromJson.get "urpfile" (FromJson.get "project" (FromJson.get "urweb" (#initializationOptions initParams)))))) + handle ex => NONE val foundUrps = scanDir (fn fname => OS.Path.ext fname = SOME "urp") rootPath in { urpPath = case foundUrps of [] => raise Fail ("No .urp files found in path " ^ rootPath) | one :: [] => OS.Path.base (OS.Path.file one) - | many => raise Fail ("Found multiple .urp files in path " ^ rootPath) + | many => case List.find (fn m => SOME (OS.Path.base (OS.Path.file m)) = optsUrpFile) many of + NONE => raise Fail ("Found multiple .urp files in path " ^ rootPath) + | SOME f => OS.Path.base (OS.Path.file f) , fileStates = SM.empty } end @@ -531,8 +536,8 @@ fun serverLoop () = LspSpec.RequestMessage m => LspSpec.handleMessage m - { initialize = fn _ => - (let val st = initState (LspSpec.parseInitializeParams (#params m)) + { initialize = fn p => + (let val st = initState p in stateRef := SOME st; LspSpec.Success diff --git a/src/lspspec.sml b/src/lspspec.sml index 7993038e..fe1711f0 100644 --- a/src/lspspec.sml +++ b/src/lspspec.sml @@ -195,12 +195,14 @@ structure LspSpec = struct { textDocument = parseTextDocumentIdentifier (FromJson.get "textDocument" params) } type initializeParams = - { rootUri: documentUri option } + { rootUri: documentUri option + , initializationOptions: Json.json } fun parseInitializeParams (j: Json.json) = { rootUri = Option.map parseDocumentUri (FromJson.asOptionalString (FromJson.get "rootUri" j)) + , initializationOptions = FromJson.get "initializationOptions" j } type diagnostic = { range: range (* code?: number | string *) |