diff --git a/src/zathura_language_server/assets/json/zathurarc.json b/src/zathura_language_server/assets/json/zathurarc.json index 42725b5..814464d 100644 --- a/src/zathura_language_server/assets/json/zathurarc.json +++ b/src/zathura_language_server/assets/json/zathurarc.json @@ -509,18 +509,121 @@ "type": "array", "items": { "type": "object", - "patternProperties": { - ".*": { - "type": "object", - "additionalProperties": false, - "properties": { - "shortcut": { - "type": "string" + "additionalProperties": false, + "properties": { + "key": { + "anyOf": [ + { + "type": "string", + "enum": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ] }, - "argument": { - "type": "string" + { + "type": "string", + "pattern": "<[ACS]-.*>|.|[a-zA-Z]+" } - } + ] + }, + "shortcut": { + "type": "string", + "enum": [ + "abort", + "adjust_window", + "change_mode", + "display_link", + "exec", + "focus_inputbar", + "follow", + "goto", + "jumplist", + "navigate", + "navigate_index", + "print", + "quit", + "recolor", + "reload", + "rotate", + "scroll", + "search", + "set", + "snap_to_page", + "toggle_fullscreen", + "toggle_index", + "toggle_inputbar", + "toggle_page_mode", + "toggle_statusbar", + "zoom", + "mark_add", + "mark_evaluate", + "feedkeys" + ] + }, + "argument": { + "type": "string", + "enum": [ + "best-fit", + "bottom", + "backward", + "collapse", + "collapse-all", + "default", + "down", + "expand", + "expand-all", + "forward", + "full-down", + "full-up", + "half-down", + "half-up", + "in", + "left", + "next", + "out", + "page-bottom", + "page-top", + "previous", + "right", + "rotate-ccw", + "rotate-cw", + "select", + "specific", + "toggle", + "top", + "up", + "width", + null + ] } }, "uniqueItems": true @@ -530,18 +633,121 @@ "type": "array", "items": { "type": "object", - "patternProperties": { - ".*": { - "type": "object", - "additionalProperties": false, - "properties": { - "shortcut": { - "type": "string" + "additionalProperties": false, + "properties": { + "key": { + "anyOf": [ + { + "type": "string", + "enum": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ] }, - "argument": { - "type": "string" + { + "type": "string", + "pattern": "<[ACS]-.*>|.|[a-zA-Z]+" } - } + ] + }, + "shortcut": { + "type": "string", + "enum": [ + "abort", + "adjust_window", + "change_mode", + "display_link", + "exec", + "focus_inputbar", + "follow", + "goto", + "jumplist", + "navigate", + "navigate_index", + "print", + "quit", + "recolor", + "reload", + "rotate", + "scroll", + "search", + "set", + "snap_to_page", + "toggle_fullscreen", + "toggle_index", + "toggle_inputbar", + "toggle_page_mode", + "toggle_statusbar", + "zoom", + "mark_add", + "mark_evaluate", + "feedkeys" + ] + }, + "argument": { + "type": "string", + "enum": [ + "best-fit", + "bottom", + "backward", + "collapse", + "collapse-all", + "default", + "down", + "expand", + "expand-all", + "forward", + "full-down", + "full-up", + "half-down", + "half-up", + "in", + "left", + "next", + "out", + "page-bottom", + "page-top", + "previous", + "right", + "rotate-ccw", + "rotate-cw", + "select", + "specific", + "toggle", + "top", + "up", + "width", + null + ] } }, "uniqueItems": true @@ -551,18 +757,121 @@ "type": "array", "items": { "type": "object", - "patternProperties": { - ".*": { - "type": "object", - "additionalProperties": false, - "properties": { - "shortcut": { - "type": "string" + "additionalProperties": false, + "properties": { + "key": { + "anyOf": [ + { + "type": "string", + "enum": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ] }, - "argument": { - "type": "string" + { + "type": "string", + "pattern": "<[ACS]-.*>|.|[a-zA-Z]+" } - } + ] + }, + "shortcut": { + "type": "string", + "enum": [ + "abort", + "adjust_window", + "change_mode", + "display_link", + "exec", + "focus_inputbar", + "follow", + "goto", + "jumplist", + "navigate", + "navigate_index", + "print", + "quit", + "recolor", + "reload", + "rotate", + "scroll", + "search", + "set", + "snap_to_page", + "toggle_fullscreen", + "toggle_index", + "toggle_inputbar", + "toggle_page_mode", + "toggle_statusbar", + "zoom", + "mark_add", + "mark_evaluate", + "feedkeys" + ] + }, + "argument": { + "type": "string", + "enum": [ + "best-fit", + "bottom", + "backward", + "collapse", + "collapse-all", + "default", + "down", + "expand", + "expand-all", + "forward", + "full-down", + "full-up", + "half-down", + "half-up", + "in", + "left", + "next", + "out", + "page-bottom", + "page-top", + "previous", + "right", + "rotate-ccw", + "rotate-cw", + "select", + "specific", + "toggle", + "top", + "up", + "width", + null + ] } }, "uniqueItems": true @@ -572,18 +881,121 @@ "type": "array", "items": { "type": "object", - "patternProperties": { - ".*": { - "type": "object", - "additionalProperties": false, - "properties": { - "shortcut": { - "type": "string" + "additionalProperties": false, + "properties": { + "key": { + "anyOf": [ + { + "type": "string", + "enum": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ] }, - "argument": { - "type": "string" + { + "type": "string", + "pattern": "<[ACS]-.*>|.|[a-zA-Z]+" } - } + ] + }, + "shortcut": { + "type": "string", + "enum": [ + "abort", + "adjust_window", + "change_mode", + "display_link", + "exec", + "focus_inputbar", + "follow", + "goto", + "jumplist", + "navigate", + "navigate_index", + "print", + "quit", + "recolor", + "reload", + "rotate", + "scroll", + "search", + "set", + "snap_to_page", + "toggle_fullscreen", + "toggle_index", + "toggle_inputbar", + "toggle_page_mode", + "toggle_statusbar", + "zoom", + "mark_add", + "mark_evaluate", + "feedkeys" + ] + }, + "argument": { + "type": "string", + "enum": [ + "best-fit", + "bottom", + "backward", + "collapse", + "collapse-all", + "default", + "down", + "expand", + "expand-all", + "forward", + "full-down", + "full-up", + "half-down", + "half-up", + "in", + "left", + "next", + "out", + "page-bottom", + "page-top", + "previous", + "right", + "rotate-ccw", + "rotate-cw", + "select", + "specific", + "toggle", + "top", + "up", + "width", + null + ] } }, "uniqueItems": true @@ -599,29 +1011,193 @@ "normal": { "type": "array", "items": { - "type": "string", - "uniqueItems": true + "uniqueItems": true, + "anyOf": [ + { + "type": "string", + "enum": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ] + }, + { + "type": "string", + "pattern": "<[ACS]-.*>|.|[a-zA-Z]+" + } + ] } }, "fullscreen": { "type": "array", "items": { - "type": "string", - "uniqueItems": true + "uniqueItems": true, + "anyOf": [ + { + "type": "string", + "enum": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ] + }, + { + "type": "string", + "pattern": "<[ACS]-.*>|.|[a-zA-Z]+" + } + ] } }, "presentation": { "type": "array", "items": { - "type": "string", - "uniqueItems": true + "uniqueItems": true, + "anyOf": [ + { + "type": "string", + "enum": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ] + }, + { + "type": "string", + "pattern": "<[ACS]-.*>|.|[a-zA-Z]+" + } + ] } }, "index": { "type": "array", "items": { - "type": "string", - "uniqueItems": true + "uniqueItems": true, + "anyOf": [ + { + "type": "string", + "enum": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ] + }, + { + "type": "string", + "pattern": "<[ACS]-.*>|.|[a-zA-Z]+" + } + ] } } } diff --git a/src/zathura_language_server/misc/zathurarc.py b/src/zathura_language_server/misc/zathurarc.py index bd7d6b6..bdcbb85 100644 --- a/src/zathura_language_server/misc/zathurarc.py +++ b/src/zathura_language_server/misc/zathurarc.py @@ -1,7 +1,6 @@ r"""Zathurarc ============= """ -import re from typing import Any from tree_sitter_lsp.misc import get_md_tokens @@ -31,6 +30,9 @@ def init_schema() -> dict[str, Any]: tokens = get_md_tokens("zathurarc") indices = [] end_index = len(tokens) + keys = [] + shortcuts = [] + arguments = [] for i, token in enumerate(tokens): if token.content == "OPTIONS": end_index = i @@ -53,10 +55,31 @@ def init_schema() -> dict[str, Any]: if token.content == "" or token.content.startswith("