emacs-devel
[Top][All Lists]
Advanced

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

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


From: Yuan Fu
Subject: Re: Initial fontification in sh-mode with tree-sittter
Date: Sat, 12 Nov 2022 11:45:53 -0800


> On Nov 12, 2022, at 4:47 AM, Eli Zaretskii <eliz@gnu.org> wrote:
> 
>> From: João Paulo Labegalini de Carvalho <jaopaulolc@gmail.com>
>> Date: Wed, 2 Nov 2022 12:55:31 -0600
>> 
>> I missed the update that adds override as the last argument of the capture 
>> function. Fixed now.
>> 
>> On Wed, Nov 2, 2022 at 12:22 PM João Paulo Labegalini de Carvalho 
>> <jaopaulolc@gmail.com> wrote:
>> 
>> Here is another version of the path. This has the queries separated into 
>> language related terms and
>> groups them into lists of features.
>> 
>> Looking forward to your feedback.
>> 
>> Thanks.
>> 
>> On Thu, Oct 27, 2022 at 4:01 PM João Paulo Labegalini de Carvalho 
>> <jaopaulolc@gmail.com> wrote:
>> 
>> Hi everyone,
>> 
>> Please find the patch for enabling fontification in sh-mode (currently only 
>> for bash) using
>> tree-sitter.
>> 
>> I welcome all comments and suggestions to improve the patch.
>> 
>> I noticed a weird behavior with heredocs. Take the code below:
>> 
>> echo <<EOF
>> This is a here document.
>> EOF
>> echo "Done."
>> 
>> My patch correctly fontifies the code above, but if I kill the whole line 
>> with the "This is a here
>> document." text, then the sh-heredoc face bleeds out and all the subsequent 
>> comments get
>> fontified as part of the heredoc.
>> 
>> A similar behavior happens if tree-sitter is not enabled, if the heredoc is 
>> empty then all
>> subsequent commands are fontified as heredoc. However, as soon as anything 
>> is added to the
>> heredoc, then everything goes back to the correct fontification. 
>> 
>> Such "refreshing" does not happen with tree-sitter enabled, but if I execute 
>> M-x sh-mode then the
>> buffer gets refreshed and everything looks good.
>> 
>> What am I doing wrong?
> 
> Yuan, any comments?  If you think this is OK for the tree-sitter
> branch, please install there.

I think there are still some details need to be addressed, eg, 

> 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 can make the change myself though)

Yuan


reply via email to

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