diff --git a/src/text/language/language_server_base.nim b/src/text/language/language_server_base.nim index f35be604..9790d21b 100644 --- a/src/text/language/language_server_base.nim +++ b/src/text/language/language_server_base.nim @@ -11,7 +11,34 @@ type LanguageServer* = ref object of RootObj onRequestSave: Table[OnRequestSaveHandle, proc(targetFilename: string): Future[void]] onRequestSaveIndex: Table[string, seq[OnRequestSaveHandle]] -type SymbolType* = enum Unknown, Procedure, Function, MutableVariable, ImmutableVariable, Constant, Parameter, Type +type SymbolType* {.pure.} = enum + Unknown = 0 + Text = 1 + Method = 2 + Function = 3 + Constructor = 4 + Field = 5 + Variable = 6 + Class = 7 + Interface = 8 + Module = 9 + Property = 10 + Unit = 11 + Value = 12 + Enum = 13 + Keyword = 14 + Snippet = 15 + Color = 16 + File = 17 + Reference = 18 + Folder = 19 + EnumMember = 20 + Constant = 21 + Struct = 22 + Event = 23 + Operator = 24 + TypeParameter = 25 + type InlayHintKind* = enum Type, Parameter type TextEdit* = object diff --git a/src/text/language/language_server_lsp.nim b/src/text/language/language_server_lsp.nim index 76777478..f284dbe8 100644 --- a/src/text/language/language_server_lsp.nim +++ b/src/text/language/language_server_lsp.nim @@ -194,14 +194,15 @@ method getHover*(self: LanguageServerLSP, filename: string, location: Cursor): F if parsedResponse.contents.asMarkedStringVariant().getSome(markedString): debugf"marked string variant: {markedString}" - if markedString.asMarkedStringObject().getSome(str): - debugf"string object lang: {str.language}, value: {str.value}" - return str.value.some if markedString.asString().getSome(str): debugf"string: {str}" return str.some + if markedString.asMarkedStringObject().getSome(str): + debugf"string object lang: {str.language}, value: {str.value}" + return str.value.some + return string.none return string.none @@ -257,14 +258,14 @@ method getSymbols*(self: LanguageServerLSP, filename: string): Future[seq[Symbol # of Namespace: 3 # of Package: 4 # of Class: 5 - of Method: SymbolType.Procedure + of Method: SymbolType.Method # of Property: 7 # of Field: 8 # of Constructor: 9 # of Enum: 10 # of Interface: 11 - of Function: Procedure - of Variable: MutableVariable + of Function: Function + of Variable: Variable # of Constant: 14 # of String: 15 # of Number: 16 @@ -302,14 +303,21 @@ method getCompletions*(self: LanguageServerLSP, languageId: string, filename: st # debugf"getCompletions: {completions.items.len}" for c in completions.items: # echo c + let docs = if c.documentation.asString().getSome(doc): + doc + elif c.documentation.asMarkupContent().getSome(doc): + doc.value + else: + "" + completionsResult.add(TextCompletion( name: c.label, scope: "lsp", location: location, filename: "", - kind: SymbolType.Function, - typ: "", - doc: "" + kind: SymbolType(c.kind.ord), + typ: c.detail.get(""), + doc: docs, )) # if completionsResult.len == 10: