branch: elpa/typst-ts-mode commit 545bd677be523bbd366400d3919a40b4c58869ad Author: Meow King <mr.meowk...@anche.no> Commit: Meow King <mr.meowk...@anche.no>
feat: add transient menu --- typst-ts-misc-commands.el | 11 ++++++++++- typst-ts-mode.el | 7 +------ typst-ts-transient.el | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 7 deletions(-) diff --git a/typst-ts-misc-commands.el b/typst-ts-misc-commands.el index bb2e5ec964..1031675999 100644 --- a/typst-ts-misc-commands.el +++ b/typst-ts-misc-commands.el @@ -1,4 +1,4 @@ -;;; typst-ts-misc-commands.el --- core functions for typst-ts-mode -*- lexical-binding: t; -*- +;;; typst-ts-misc-commands.el --- Miscellaneous commands for typst-ts-mode -*- lexical-binding: t; -*- ;; Copyright (C) 2023-2024 The typst-ts-mode Project Contributors ;; This file is NOT part of Emacs. @@ -21,11 +21,20 @@ ;;; Code: +(require 'treesit) + ;; (defgroup typst-ts-mc nil ;; "Typst ts miscellaneous commands." ;; :prefix "typst-ts-misc-commands" ;; :group 'typst-ts) +(defun typst-ts-mc-install-grammar () + (interactive) + (let ((treesit-language-source-alist treesit-language-source-alist)) + (add-to-list 'treesit-language-source-alist + '(typst "https://github.com/Ziqi-Yang/tree-sitter-typst")) + (treesit-install-language-grammar 'typst))) + (defun typst-ts-mc-export-to-markdown () (interactive) diff --git a/typst-ts-mode.el b/typst-ts-mode.el index bc2a873902..084c977e52 100644 --- a/typst-ts-mode.el +++ b/typst-ts-mode.el @@ -42,6 +42,7 @@ (require 'typst-ts-editing) (require 'typst-ts-lsp) (require 'typst-ts-misc-commands) +(require 'typst-ts-transient) (defgroup typst-ts nil "Tree Sitter enabled Typst Writing." @@ -756,12 +757,6 @@ typst tree sitter grammar (at least %s)!" (current-time-string min-time)) ;;;###autoload (add-to-list 'auto-mode-alist '("\\.typ\\'" . typst-ts-mode)) -(defun typst-ts-mode-install-grammar () - (interactive) - (let ((treesit-language-source-alist treesit-language-source-alist)) - (add-to-list 'treesit-language-source-alist - '(typst "https://github.com/Ziqi-Yang/tree-sitter-typst")) - (treesit-install-language-grammar 'typst))) (provide 'typst-ts-mode) diff --git a/typst-ts-transient.el b/typst-ts-transient.el new file mode 100644 index 0000000000..1db16983c9 --- /dev/null +++ b/typst-ts-transient.el @@ -0,0 +1,47 @@ +;;; typst-ts-transient.el --- Transient menu for typst-ts-mode -*- lexical-binding: t; -*- +;; Copyright (C) 2023-2024 The typst-ts-mode Project Contributors + +;; This file is NOT part of Emacs. +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see <http://www.gnu.org/licenses/>. + +;;; Commentary: + +;; Miscellaneous commands + +;;; Code: + +(require 'transient) +(require 'typst-ts-compile) +(require 'typst-ts-misc-commands) + +(transient-define-prefix typst-ts-tmenu () + "Typst-ts-mode transient menu." + [["Compile" + ("c" "compile & preview" typst-ts-compile-and-preview) + ("C" "compile" typst-ts-compile) + ("w" "watch" typst-ts-watch-mode) + ("p" "preview" typst-ts-mode-preview)] + + ["Export" + ("em" "markdown" typst-ts-mc-export-to-markdown)] + + ["Search" + ("ss" "symbol" typst-ts-mc-search-typst-symbol) + ("sr" "recognize symbol" typst-ts-mc-recognize-typst-symbol) + ("sp" "package" typst-ts-mc-search-package)]]) + + +(provide 'typst-ts-transient) + +;;; typst-ts-transient.el ends here