win11,emacs30,想开启treesit试试效果,按照网上的例子做了一下配置:
(use-package treesit
:when (and (fboundp 'treesit-available-p)
(treesit-available-p))
:custom (major-mode-remap-alist
'((c-mode . c-ts-mode)
(c++-mode . c++-ts-mode)
(cmake-mode . cmake-ts-mode)
(conf-toml-mode . toml-ts-mode)
(css-mode . css-ts-mode)
(js-mode . js-ts-mode)
(js-json-mode . json-ts-mode)
(python-mode . python-ts-mode)
(sh-mode . bash-ts-mode)
(typescript-mode . typescript-ts-mode))))
可是打开啥文件,都会提示我grammar不存在。我的dll也按照网上说明存放在.emacs.d/tree-sitter里,为啥找不到呢?
我还遗漏了啥配置吗?
多谢;
treesit 和 tree-sitter 有点不同.
你要添加 treesit 语言列表并下载它:
(use-package treesit
:hook
(c-mode . c-ts-mode)
(c++-mode . c++-ts-mode)
(rust-mode . rust-ts-mode)
:custom
(treesit-font-lock-level 4) ;; 高亮等级
;; 有关更多语言链接到 treesit-auto.el 实现, 查看 :url :revision :source-dir
;; https://github.com/renzmann/treesit-auto/blob/main/treesit-auto.el
;; :url "https://github.com/tree-sitter/tree-sitter-typescript"
;; :revision "master"
;; :source-dir "tsx/src"
(treesit-language-source-alist
'((bash "https://github.com/tree-sitter/tree-sitter-bash")
(c "https://github.com/tree-sitter/tree-sitter-c")
(cpp "https://github.com/tree-sitter/tree-sitter-cpp")
(cmake "https://github.com/uyha/tree-sitter-cmake")
(elisp "https://github.com/Wilfred/tree-sitter-elisp")
(html "https://github.com/tree-sitter/tree-sitter-html")
(javascript "https://github.com/tree-sitter/tree-sitter-javascript" "master" "src")
(json "https://github.com/tree-sitter/tree-sitter-json")
(make "https://github.com/alemuller/tree-sitter-make")
(markdown "https://github.com/ikatyang/tree-sitter-markdown")
(python "https://github.com/tree-sitter/tree-sitter-python")
(toml "https://github.com/tree-sitter/tree-sitter-toml")
(rust "https://github.com/ISouthRain/tree-sitter-rust" "v0.23.3")
(lua "https://github.com/tree-sitter-grammars/tree-sitter-lua")
(yaml "https://github.com/ikatyang/tree-sitter-yaml")))
)
下载命令: M-x treesit-install-language-grammar
Windows 完全支持 treesit。
你需要 M-x treesit-install-language-grammar
这是我个人使用的 treesit 配置:
1 个赞