Skip to content

Commit

Permalink
✨ Support completing values
Browse files Browse the repository at this point in the history
  • Loading branch information
Freed-Wu committed Dec 22, 2023
1 parent 8f77922 commit be626b7
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/zathura_language_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,28 @@ def completions(params: CompletionParams) -> CompletionList:
if x.startswith(text)
],
)
elif uni.node.type == "string":
node = uni.node.prev_sibling
if node is None:
return CompletionList(False, [])
property = get_schema()["properties"]["set"]["properties"].get(
uni.node2text(node), {}
)
enum = property.get("enum", {})
if property.get("type", "") == "boolean":
enum = {"true", "false"}
return CompletionList(
False,
[
CompletionItem(
x,
kind=CompletionItemKind.Constant,
insert_text=x,
)
for x in enum
if x.startswith(text)
],
)
elif uni.node.type == "mode_name":
return get_completion_list_by_enum(
text,
Expand Down

0 comments on commit be626b7

Please sign in to comment.