aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Lewis <22850972+BradLewis@users.noreply.github.com>2026-02-10 21:17:53 +1100
committerBrad Lewis <22850972+BradLewis@users.noreply.github.com>2026-02-10 21:18:56 +1100
commit12264e54a18c9b73708cdd11a54ecc06e64e5229 (patch)
tree4ddf77cef5d5310f53e42d6f28d1a25bd3d4a405
parent1efe81498d2fbb91ecac80b57b6009a6399f2ba3 (diff)
Add documentation to package completions
-rw-r--r--src/server/completion.odin6
-rw-r--r--tests/completions_test.odin28
2 files changed, 34 insertions, 0 deletions
diff --git a/src/server/completion.odin b/src/server/completion.odin
index 5bbbcf8..072d21b 100644
--- a/src/server/completion.odin
+++ b/src/server/completion.odin
@@ -1812,6 +1812,12 @@ get_identifier_completion :: proc(
symbol := Symbol {
name = pkg.base,
type = .Package,
+ pkg = pkg.name,
+ value = SymbolPackageValue{},
+ }
+ try_build_package(symbol.pkg)
+ if resolved, ok := resolve_symbol_return(ast_context, symbol); ok {
+ symbol = resolved
}
if score, ok := common.fuzzy_match(matcher, symbol.name); ok == 1 {
diff --git a/tests/completions_test.odin b/tests/completions_test.odin
index 56553c3..bf05f6a 100644
--- a/tests/completions_test.odin
+++ b/tests/completions_test.odin
@@ -5500,3 +5500,31 @@ ast_completion_fake_method_proc_group_single_arg_cursor_position :: proc(t: ^tes
// The proc group 'negate' should have cursor AFTER parentheses since no additional args
test.expect_completion_edit_text(t, &source, ".", "negate", "methods.negate(n)$0")
}
+
+@(test)
+ast_completion_package_docs :: proc(t: ^testing.T) {
+ packages := make([dynamic]test.Package, context.temp_allocator)
+
+ append(
+ &packages,
+ test.Package {
+ pkg = "my_package",
+ source = `// Package docs
+ package my_package
+ Foo :: struct{}
+ `,
+ },
+ )
+
+ source := test.Source {
+ main = `package test
+ import "my_package"
+ main :: proc() {
+ my_pack{*}
+ }
+ `,
+ packages = packages[:],
+ }
+
+ test.expect_completion_docs(t, &source, "", {"my_package: package\n---\nPackage docs"})
+}