[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Initial fontification in sh-mode with tree-sittter

From: João Paulo Labegalini de Carvalho
Subject: Re: Initial fontification in sh-mode with tree-sittter
Date: Sat, 12 Nov 2022 15:04:26 -0700

I see. This is tree-sitter-bash’s problem. When there are only newlines between two EOF’s, the parser erroneously marks everything that follows as heredoc_body. I tried tree-sitter’s online demo and it gives the same result[1]. We should report this to tree-sitter-bash’s author.

Sorry for the delay. I confirmed the problem was in the tree-sitter-bash side and submitted a PR to fix it: https://github.com/tree-sitter/tree-sitter-bash/pull/137
Once my fixes are pulled in, there is no change required to my patch.
Also, when defining sh-mode--treesit-settings, instead of using the value sh-shell as the language, it’s better to just use ‘bash. Here is what happened to me: my default value for sh-shell is fish, so sh-mode--treesit-settings was defined with language = fish. When I open heredoc-issue.sh, sh-mode parses the shebang and sets sh-shell to bash. Since bash does have a parser, (treesit-ready-p ’sh-mode sh-shell) returns t, and tree-sitter is activated. However when font-lock tries to use the query, it errors because query tries to load a parser for fish.

I see. I thought that because sh-mode--treesit-settings is executed after the local variable sh-shell is defined, it would always be equal to the detected/file shell type. I am still getting my head around scope in elisp.

I did the change and I think it is good to go, unless there is anything else to improve for now.

I hope to soon get time to work on imenu, navigation, and indentation for sh-mode & bash with tree-sitter.

Please find the corrected patch attached.

João Paulo L. de Carvalho
Ph.D Computer Science |  IC-UNICAMP | Campinas , SP - Brazil
Postdoctoral Research Fellow | University of Alberta | Edmonton, AB - Canada

Attachment: 0001-Initial-fontification-in-sh-mode-with-tree-sitter.patch
Description: Text Data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]