🧀 treesit 解析问题导致的treemacs,fingertip bug
问题
treemacs下有可能出现这样的问题
1
[Treemacs] Encountered error while following tag at point: (wrong-type-argument markerp 367)
fingertip-mode下,有可能出现这样的问题
1
treesit-buffer-root-node: No available parser for this buffer: #<buffer QuoteError.vue> [2 times]
本质原因是在该mode下,treesit没有正确解析
如何解决
- 设置treesit source
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
(setq 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"))
(css . ("https://github.com/tree-sitter/tree-sitter-css"))
(cmake . ("https://github.com/uyha/tree-sitter-cmake"))
(csharp . ("https://github.com/tree-sitter/tree-sitter-c-sharp.git"))
(dockerfile . ("https://github.com/camdencheek/tree-sitter-dockerfile"))
(elisp . ("https://github.com/Wilfred/tree-sitter-elisp"))
(elixir "https://github.com/elixir-lang/tree-sitter-elixir" "main" "src" nil nil)
(go . ("https://github.com/tree-sitter/tree-sitter-go"))
(gomod . ("https://github.com/camdencheek/tree-sitter-go-mod.git"))
(haskell "https://github.com/tree-sitter/tree-sitter-haskell" "master" "src" nil nil)
(html . ("https://github.com/tree-sitter/tree-sitter-html"))
(java . ("https://github.com/tree-sitter/tree-sitter-java.git"))
(javascript . ("https://github.com/tree-sitter/tree-sitter-javascript"))
(json . ("https://github.com/tree-sitter/tree-sitter-json"))
(lua . ("https://github.com/Azganoth/tree-sitter-lua"))
(make . ("https://github.com/alemuller/tree-sitter-make"))
(markdown . ("https://github.com/tree-sitter-grammars/tree-sitter-markdown" "split_parser" "tree-sitter-markdown/src"))
(markdown-inline . ("https://github.com/tree-sitter-grammars/tree-sitter-markdown" "split_parser" "tree-sitter-markdown-inline/src"))
(ocaml . ("https://github.com/tree-sitter/tree-sitter-ocaml" nil "ocaml/src"))
(org . ("https://github.com/milisims/tree-sitter-org"))
(python . ("https://github.com/tree-sitter/tree-sitter-python"))
(php . ("https://github.com/tree-sitter/tree-sitter-php"))
(typescript . ("https://github.com/tree-sitter/tree-sitter-typescript" nil "typescript/src"))
(tsx . ("https://github.com/tree-sitter/tree-sitter-typescript" nil "tsx/src"))
(ruby . ("https://github.com/tree-sitter/tree-sitter-ruby"))
(rust . ("https://github.com/tree-sitter/tree-sitter-rust"))
(sql . ("https://github.com/m-novikov/tree-sitter-sql"))
(scala "https://github.com/tree-sitter/tree-sitter-scala" "master" "src" nil nil)
(toml "https://github.com/tree-sitter/tree-sitter-toml" "master" "src" nil nil)
(vue . ("https://github.com/merico-dev/tree-sitter-vue"))
(kotlin . ("https://github.com/fwcd/tree-sitter-kotlin"))
(yaml . ("https://github.com/ikatyang/tree-sitter-yaml"))
(zig . ("https://github.com/GrayJack/tree-sitter-zig"))
(liquid . ("https://github.com/Shopify/tree-sitter-liquid"))
(htmldjango . ("https://github.com/interdependence/tree-sitter-htmldjango"))
(clojure . ("https://github.com/sogaiu/tree-sitter-clojure"))
(nix . ("https://github.com/nix-community/nix-ts-mode"))
(mojo . ("https://github.com/HerringtonDarkholme/tree-sitter-mojo"))))
- 安装
M-x treesit-install-language-grammer
- treesit-parser-create 这一步最关键
1
2
3
4
(add-hook 'markdown-mode-hook #'(lambda () (treesit-parser-create 'markdown)))
(add-hook 'zig-mode-hook #'(lambda () (treesit-parser-create 'zig)))
(add-hook 'mojo-mode-hook #'(lambda () (treesit-parser-create 'mojo)))
(add-hook 'emacs-lisp-mode-hook #'(lambda () (treesit-parser-create 'elisp)))
This post is licensed under CC BY 4.0 by the author.