From a2f3b5ddb1bb77b2736150d57ec6eee2bcfd0e55 Mon Sep 17 00:00:00 2001 From: Daniel Gavin Date: Sun, 12 Jun 2022 02:00:31 +0200 Subject: Add custom hover map --- src/server/hover.odin | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/server/hover.odin') 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 } } -- cgit v1.2.3