aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorDanielGavin <danielgavin5@hotmail.com>2024-07-29 12:58:35 +0200
committerGitHub <noreply@github.com>2024-07-29 12:58:35 +0200
commit78456eaf8152201cb9cf1acf42b1b1d32affece1 (patch)
treec436919eb77f0c8e5aa034e7ec5793191ca0239d /src/server
parent9a33cc2fbe7e2dbc82a281af60f56e8232fe03d5 (diff)
parent31d1e4797f78123010f046746a092c0c82ce1320 (diff)
Merge pull request #442 from thetarnav/more-directive-completions
Add missing directives to the completions list
Diffstat (limited to 'src/server')
-rw-r--r--src/server/completion.odin106
1 files changed, 70 insertions, 36 deletions
diff --git a/src/server/completion.odin b/src/server/completion.odin
index 42bec3e..be8b9ab 100644
--- a/src/server/completion.odin
+++ b/src/server/completion.odin
@@ -190,6 +190,75 @@ get_attribute_completion :: proc(
}
+DIRECTIVE_NAME_LIST :: []string {
+ /* basic directives */
+ "file",
+ "directory",
+ "line",
+ "procedure",
+ "caller_location",
+ /* call directives */
+ "location",
+ "exists",
+ "load",
+ "load_directory",
+ "load_hash",
+ "hash",
+ "assert",
+ "panic",
+ "defined",
+ "config",
+ /* type helper */
+ "type",
+ /* struct type */
+ "packed",
+ "raw_union",
+ "align",
+ /* union type */
+ "no_nil",
+ "shared_nil",
+ /* array type */
+ "simd",
+ "soa",
+ "sparse",
+ /* ptr type */
+ "relative",
+ /* field flags */
+ "no_alias",
+ "c_vararg",
+ "const",
+ "any_int",
+ "subtype",
+ "by_ptr",
+ "no_broadcast",
+ "no_capture",
+ /* swich flags */
+ "partial",
+ /* block flags */
+ "bounds_check",
+ "no_bounds_check",
+ "type_assert",
+ "no_type_assert",
+ /* proc inlining */
+ "force_inline",
+ "force_no_inline",
+ /* return values flags */
+ "optional_ok",
+ "optional_allocator_error",
+}
+
+completion_items_directives: []CompletionItem
+
+@init _init_completion_items_directives :: proc () {
+ completion_items_directives = slice.mapper(DIRECTIVE_NAME_LIST, proc (name: string) -> CompletionItem {
+ return {
+ detail = strings.concatenate({"#", name}) or_else name,
+ label = name,
+ kind = .Constant,
+ }
+ })
+}
+
get_directive_completion :: proc(
ast_context: ^AstContext,
position_context: ^DocumentPositionContext,
@@ -198,46 +267,11 @@ get_directive_completion :: proc(
list.isIncomplete = false
- items := make([dynamic]CompletionItem, context.temp_allocator)
-
/*
Right now just return all the possible completions, but later on I should give the context specific ones
*/
- directive_list := []string {
- "file",
- "line",
- "packed",
- "raw_union",
- "align",
- "no_nil",
- "shared_nil",
- "complete",
- "no_alias",
- "caller_location",
- "require_results",
- "type",
- "bounds_check",
- "no_bounds_check",
- "assert",
- "defined",
- "procedure",
- "load",
- "partial",
- "force_inline",
- }
-
- for elem in directive_list {
- item := CompletionItem {
- detail = elem,
- label = elem,
- kind = .Constant,
- }
-
- append(&items, item)
- }
-
- list.items = items[:]
+ list.items = completion_items_directives[:]
}
get_comp_lit_completion :: proc(