Skip to content

Commit

Permalink
render more info from completions
Browse files Browse the repository at this point in the history
  • Loading branch information
Nimaoth committed Mar 13, 2024
1 parent eb7dec9 commit 2009177
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 10 deletions.
29 changes: 28 additions & 1 deletion src/text/language/language_server_base.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 17 additions & 9 deletions src/text/language/language_server_lsp.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 2009177

Please sign in to comment.