45 lines
1.3 KiB
Text
45 lines
1.3 KiB
Text
/-
|
|
Copyright (c) 2020 Marc Huisinga. All rights reserved.
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
Authors: Marc Huisinga, Wojciech Nawrocki
|
|
-/
|
|
import Lean.Data.JsonRpc
|
|
import Lean.Data.Lsp.TextSync
|
|
|
|
/-! Minimal LSP servers/clients do not have to implement a lot
|
|
of functionality. Most useful additional behaviour is instead
|
|
opted into via capabilities. -/
|
|
|
|
namespace Lean
|
|
namespace Lsp
|
|
|
|
open Json
|
|
|
|
-- TODO: right now we ignore the client's capabilities
|
|
inductive ClientCapabilities where
|
|
| mk
|
|
|
|
instance : FromJson ClientCapabilities :=
|
|
⟨fun j => ClientCapabilities.mk⟩
|
|
|
|
instance ClientCapabilities.hasToJson : ToJson ClientCapabilities :=
|
|
⟨fun o => mkObj []⟩
|
|
|
|
-- TODO largely unimplemented
|
|
structure ServerCapabilities where
|
|
textDocumentSync? : Option TextDocumentSyncOptions := none
|
|
hoverProvider : Bool := false
|
|
|
|
instance : FromJson ServerCapabilities :=
|
|
⟨fun j => do
|
|
let textDocumentSync? := j.getObjValAs? TextDocumentSyncOptions "textDocumentSync"
|
|
let hoverProvider ← j.getObjValAs? Bool "hoverProvider"
|
|
pure ⟨textDocumentSync?, hoverProvider⟩⟩
|
|
|
|
instance : ToJson ServerCapabilities := ⟨fun o => mkObj $
|
|
opt "textDocumentSync" o.textDocumentSync? ++
|
|
[⟨"hoverProvider", o.hoverProvider⟩]⟩
|
|
|
|
end Lsp
|
|
end Lean
|