fix(language/go): ensure tree-sitter grammar correctly

This commit is contained in:
2024-11-05 00:18:45 +00:00
parent 509c6ef8a5
commit 0c124709b9
2 changed files with 15 additions and 5 deletions

View File

@@ -151,7 +151,7 @@
(auto-highlight-symbol-mode -1)))
:config
(siren-treesit-auto-ensure-grammar 'go)
(siren-treesit-auto-ensure-grammars 'go 'gomod)
(siren-define-golines-format-mode)
@@ -181,7 +181,7 @@
'(((module_path) @font-lock-constant-face))))
:config
(siren-treesit-auto-ensure-grammar 'gomod)))
(siren-treesit-auto-ensure-grammars 'go 'gomod)))
(use-package lsp-go
:straight lsp-mode

View File

@@ -139,13 +139,23 @@ will be appended."
(not (treesit-ready-p grammar t)))
(siren-treesit-auto-install-grammar grammar)))
(defun siren-treesit-auto-install-grammar (grammar)
(defun siren-treesit-auto-ensure-grammars (&rest grammars)
"Ensure treesit GRAMMARS are installed and ready for use."
(dolist (grammar grammars)
(siren-treesit-auto-ensure-grammar grammar)))
(defun siren-treesit-auto-install-grammar (lang &optional out-dir)
"Install treesit GRAMMAR."
(interactive (list (intern
(completing-read
"Language: "
(mapcar #'car treesit-language-source-alist)))
'interactive))
(when (fboundp 'treesit-ready-p)
(let ((treesit-language-source-alist
(treesit-auto--build-treesit-source-alist)))
(treesit-install-language-grammar grammar
siren-treesit-grammar-dir))))
(treesit-install-language-grammar lang siren-treesit-grammar-dir))))
(defvar siren-treesit-auto--source-alist-populated-p 'nil
"Internal flag to track if `treesit-auto--build-treesit-source-alist'