aboutsummaryrefslogtreecommitdiff
path: root/src/server/hover.odin
diff options
context:
space:
mode:
authorDaniel Gavin <danielgavin5@hotmail.com>2022-06-12 02:00:31 +0200
committerDaniel Gavin <danielgavin5@hotmail.com>2022-06-12 02:00:31 +0200
commita2f3b5ddb1bb77b2736150d57ec6eee2bcfd0e55 (patch)
tree020399d3bb094cf10191b062f0c4bd6b568db895 /src/server/hover.odin
parent12a1db1e284e4ce2af9a51bb60f9817e76c1a481 (diff)
Add custom hover map
Diffstat (limited to 'src/server/hover.odin')
-rw-r--r--src/server/hover.odin20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/server/hover.odin b/src/server/hover.odin
index 25975c0..39b9a33 100644
--- a/src/server/hover.odin
+++ b/src/server/hover.odin
@@ -43,6 +43,10 @@ write_hover_content :: proc(ast_context: ^AstContext, symbol: Symbol) -> MarkupC
return content
}
+builtin_identifier_hover: map[string]string = {
+ "context" = fmt.aprintf("```odin\n %v\n```\n%v", "runtime.context: Context", "This context variable is local to each scope and is implicitly passed by pointer to any procedure call in that scope (if the procedure has the Odin calling convention)."),
+}
+
get_hover_information :: proc(document: ^common.Document, position: common.Position) -> (Hover, bool) {
hover := Hover {
@@ -68,6 +72,22 @@ get_hover_information :: proc(document: ^common.Document, position: common.Posit
hover.range = common.get_token_range(position_context.identifier^, ast_context.file.src)
return hover, true
}
+
+ if str, ok := builtin_identifier_hover[ident.name]; ok {
+ hover.contents.kind = "markdown"
+ hover.contents.value = str
+ hover.range = common.get_token_range(position_context.identifier^, ast_context.file.src)
+ return hover, true
+ }
+ }
+ }
+
+ if position_context.implicit_context != nil {
+ if str, ok := builtin_identifier_hover[position_context.implicit_context.tok.text]; ok {
+ hover.contents.kind = "markdown"
+ hover.contents.value = str
+ hover.range = common.get_token_range(position_context.implicit_context^, ast_context.file.src)
+ return hover, true
}
}