aboutsummaryrefslogtreecommitdiff
path: root/src/server/hover.odin
diff options
context:
space:
mode:
authorBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-08-24 11:17:18 -0400
committerBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-08-24 16:59:25 -0400
commitf4b044d228f18856fa0ae3fbfc9513aaf26d0db6 (patch)
tree7c155e8fcea164a2ebb93825cb367dcc3dd2d9da /src/server/hover.odin
parent7e9d53239f6e8ebff7cf8444d7b97458020317d5 (diff)
Add completion and hover information for builtin types
Diffstat (limited to 'src/server/hover.odin')
-rw-r--r--src/server/hover.odin24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/server/hover.odin b/src/server/hover.odin
index 86fd6a8..d0eb0f3 100644
--- a/src/server/hover.odin
+++ b/src/server/hover.odin
@@ -47,11 +47,6 @@ write_hover_content :: proc(ast_context: ^AstContext, symbol: Symbol) -> MarkupC
return content
}
-builtin_identifier_hover: map[string]string = {
- "context" = "```odin\nruntime.context: Context\n```\nThis 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: ^Document, position: common.Position) -> (Hover, bool, bool) {
hover := Hover {
contents = {kind = "plaintext"},
@@ -83,15 +78,18 @@ get_hover_information :: proc(document: ^Document, position: common.Position) ->
return {}, false, true
}
+ if position_context.type_cast != nil {
+ if str, ok := keywords_docs[position_context.type_cast.tok.text]; ok {
+ hover.contents.kind = "markdown"
+ hover.contents.value = str
+ hover.range = common.get_token_range(position_context.type_cast, ast_context.file.src)
+ return hover, true, true
+ }
+ }
+
if position_context.identifier != nil {
if ident, ok := position_context.identifier.derived.(^ast.Ident); ok {
- if _, ok := keyword_map[ident.name]; ok {
- hover.contents.kind = "plaintext"
- hover.range = common.get_token_range(position_context.identifier^, ast_context.file.src)
- return hover, true, true
- }
-
- if str, ok := builtin_identifier_hover[ident.name]; ok {
+ if str, ok := keywords_docs[ident.name]; ok {
hover.contents.kind = "markdown"
hover.contents.value = str
hover.range = common.get_token_range(position_context.identifier^, ast_context.file.src)
@@ -101,7 +99,7 @@ get_hover_information :: proc(document: ^Document, position: common.Position) ->
}
if position_context.implicit_context != nil {
- if str, ok := builtin_identifier_hover[position_context.implicit_context.tok.text]; ok {
+ if str, ok := keywords_docs[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)