Mac OS + Treesit + csharp配置求教

Mac系统下,这几天在emacs(自用spacemacs)中配置Treesit + csharp mode;各种尝试,依然出错,无所适从;最新的错误等会贴下面;想问问有没有哪位大神在同样的环境下配置成功的案例可以参考一下;

错误:

Error during redisplay: (jit-lock-function 1) signaled (treesit-query-error "Node type error at" 461 "[\"using\" \"namespace\" \"class\" \"if\" \"else\" \"throw\" \"new\" \"for\" \"return\" \"await\" \"struct\" \"enum\" \"switch\" \"case\" \"default\" \"typeof\" \"try\" \"catch\" \"finally\" \"break\" \"foreach\" \"in\" \"yield\" \"get\" \"set\" \"when\" \"as\" \"out\" \"is\" \"while\" \"continue\" \"this\" \"ref\" \"goto\" \"interface\" \"from\" \"where\" \"select\" \"lock\" \"base\" \"record\" \"init\" \"with\" \"let\" \"static\" \"var\" \"do\" \"public\" \"private\" \"readonly\" \"unmanaged\"] @font-lock-keyword-face (modifier) @font-lock-keyword-face (this_expression) @font-lock-keyword-face" "Debug the query with treesit-query-validate'")

新版本的 csharp treesit parser 和 Emacs 29 不兼容了,要么你自行编译 Emacs 30,要么你自行改 csharp-ts-mode

csharp-ts-mode is broken with the latest version of the parser. You can define this function and run it as part of your config.

https://www.reddit.com/r/emacs/comments/1ezifus/csharptsmode_syntax_highlighting_does_not_work/

1 个赞

症结: emacs 的 ts mode 是直接在 source tree 里以源码更新的形式进行维护的,不会以类似发布插件的形式进行 backport 更新。因此任何 grammar 的 breaking change 只有 master commit 才可以修复。

TLDR: treesit grammar 在设定那个 alist 变量的时候建议锁版本。可以考虑一个 shell script 根据你当前使用的 emacs 版本的 release date,自动选择 该 grammar 在 release date 之前的发布的最新的 tag。

感谢解答

已解决,谢谢