From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_Paulo_Labegalini_de_Carvalho?= Newsgroups: gmane.emacs.devel Subject: Re: Call for volunteers: add tree-sitter support to major modes Date: Fri, 21 Oct 2022 10:47:33 -0600 Message-ID: References: <83sfjtd2bg.fsf@gnu.org> <83o7uhawb9.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000008de9d005eb8e3332" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28670"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Oct 22 00:59:17 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1om0yy-0007Dn-Us for ged-emacs-devel@m.gmane-mx.org; Sat, 22 Oct 2022 00:59:17 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1om0Bi-00042G-93; Fri, 21 Oct 2022 18:08:22 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olvBX-0001x4-JH for emacs-devel@gnu.org; Fri, 21 Oct 2022 12:47:51 -0400 Original-Received: from mail-oi1-x232.google.com ([2607:f8b0:4864:20::232]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1olvBV-0006X7-KZ; Fri, 21 Oct 2022 12:47:51 -0400 Original-Received: by mail-oi1-x232.google.com with SMTP id o64so3790983oib.12; Fri, 21 Oct 2022 09:47:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=FpMo1IhiI27ZJY8XTObDyr+a92lZqEUPjE6kZ034mN4=; b=HBfd0LHk24OJvwyUtw+VCSNibo7XhiGjDtz4JzHWMYsxklBxapCFluBO6nGrRXs57U 24O2fENK2yEp4DSK/l2tbgy5TUfFKwS0yXVoQzE88XgNCn0hmacP8dPHTD9T16zwZC45 gi8XZcSb3AGxRCKDaP29gW3zDHA/dACvGlJY4K/ybhpNSbZ8OwA1YPeFBXz91qy/Y8rD xtP8D587yFgE7FkXDORI/B1bG6DAPWbBzC1KctofHt9E0nrowA0yyf7aP9MZM2VcIY3Z MPNhz1168xIn8Ei5ENel03O+7tYb80qazanM2mXeSZl1KXZxaKLF0O4B8gDh8RAcALpH wB7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FpMo1IhiI27ZJY8XTObDyr+a92lZqEUPjE6kZ034mN4=; b=m2XCXsrfWq6BPzFso15i1LaVrIVaDas+dQNbEF1dChupS92cKEn3VqwHUBVLvkQdZX b8SMaosLlwfE3RRzN//GOtVySNFnQKG8FYyBGadiE1gBcZu0DOUhzhzYagEPmhajWPSb U1/WXSXlYtccI5oA22L5MID3xoeZsrG8xla/cg2yx3FsBbxaEq8TSjEXkHZbQizVhA8S 5T3SEGEtJBScXfkdjZtPKHgTf+6jVrI0RbC4+vIfMktbRjc/X7mrTBXWWtyLiWRYwvnE nqh+xCrU2AbjIu4fe0Ln8VCXVZaq2GyDe6NoDbhiZmDBnQiABBYVtr5uMIlECpVNCmJB uYNQ== X-Gm-Message-State: ACrzQf1ZLw2nJT5VvS+esQpjQQumU7VBf5A8T07wM8WiMqZwambDfzbD ynIb8jwafGG5amTRLmllHHv/7wSZajc60nP7p2GyQToslig= X-Google-Smtp-Source: AMsMyM4LFvVR5pSmgi2Pee14it3xXRAt6iSq8xfLgxfU/Q2bsfjwCrVHhkL+mydIrnmKrkA5b5R6MFZITxOu5LDGAng= X-Received: by 2002:a05:6808:e88:b0:351:2725:ed84 with SMTP id k8-20020a0568080e8800b003512725ed84mr23794884oil.17.1666370866373; Fri, 21 Oct 2022 09:47:46 -0700 (PDT) In-Reply-To: <83o7uhawb9.fsf@gnu.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::232; envelope-from=jaopaulolc@gmail.com; helo=mail-oi1-x232.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: "Emacs-devel" Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:298236 Archived-At: --0000000000008de9d005eb8e3332 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I have finally got some time to work on this. >From my initial understanding of `sh-script-mode' is that it supports many shell scripting languages via an elegant "inheritance" structured code. As part of the tree-sitter project, I only found a repo to generate the parser for bash. So it is my impression that other shell languages might not be correctly parsed by tree-sitter-bash from here: https://github.com/tree-sitter/tree-sitter-bash. My idea to incrementally add support for shell languages is to start with bash and setup three `tree-sitter-font-lock-rules' for it, like so: (defvar sh-script--treesit-settings (treesit-font-lock-rules :language 'bash :feature 'basic ;; queries for 'basic feature here :language 'bash :feature 'moderate ;; queries for 'moderate feature here :language 'bash :feature 'full ;; queries for 'full feature here)) Would that be acceptable? Or should I use a function in the `language:' field that returns a shell language symbol? On Wed, Oct 12, 2022 at 9:36 AM Eli Zaretskii wrote: > > From: Jo=C3=A3o Paulo Labegalini de Carvalho > > Date: Wed, 12 Oct 2022 09:09:26 -0600 > > Cc: emacs-devel@gnu.org > > > > On Tue, Oct 11, 2022 at 11:43 PM Eli Zaretskii wrote: > > > > What and how we should handle the C and derived modes is currently > > under discussion. So if you could start with shell-script-mode, > > that'd be ideal, I think. > > > > For sure. I will start working on shell-script-mode. > > Thanks! > --=20 Jo=C3=A3o Paulo L. de Carvalho Ph.D Computer Science | IC-UNICAMP | Campinas , SP - Brazil Postdoctoral Research Fellow | University of Alberta | Edmonton, AB - Canad= a joao.carvalho@ic.unicamp.br joao.carvalho@ualberta.ca --0000000000008de9d005eb8e3332 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I have finally=C2=A0got some time to work on this.

= >From my initial understanding of `sh-script-mode' is that it supports m= any shell scripting languages via an elegant "inheritance" struct= ured code.

As part of the tree-sitter project, I only found a repo t= o generate the parser for bash. So it is my impression that other shell lan= guages might not be correctly parsed by tree-sitter-bash from here: https://github.com/tre= e-sitter/tree-sitter-bash.

My idea to incrementally=C2=A0add sup= port for shell languages is to start with bash and setup three `tree-sitter= -font-lock-rules' for it, like so:

(def= var sh-script--treesit-settings
=C2=A0 = =C2=A0 (treesit-font-lock-rules
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 :language 'bash
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 :feature 'basic
=C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; queries for '= basic feature here
=C2=A0 =C2=A0 =C2=A0 =C2=A0 :language 'bash
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 :feature 'moderate
=C2=A0 =C2=A0 =C2=A0 =C2=A0 ;= ; queries for 'moderate feature here
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 :language 'bash
=C2=A0 =C2=A0 =C2=A0 =C2=A0 :feature &#= 39;full
=C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; queries for 'full feature h= ere))

Would that be acceptabl= e? Or should I use a function in the `language:' field that returns a s= hell language symbol?

On Wed, Oct 12, 2022 at 9:36 AM Eli Zaretski= i <eliz@gnu.org> wrote:
=
> From: Jo=C3=A3o Paul= o Labegalini de Carvalho <jaopaulolc@gmail.com>
> Date: Wed, 12 Oct 2022 09:09:26 -0600
> Cc: emacs-dev= el@gnu.org
>
> On Tue, Oct 11, 2022 at 11:43 PM Eli Zaretskii <eliz@gnu.org> wrote:
>
>=C2=A0 What and how we should handle the C and derived modes is current= ly
>=C2=A0 under discussion.=C2=A0 So if you could start with shell-script-= mode,
>=C2=A0 that'd be ideal, I think.
>
> For sure. I will start working on shell-script-mode.

Thanks!


--
Jo= =C3=A3o Paulo L. de Carvalho
Ph.D Computer Science | =C2=A0IC-UNICAMP | = Campinas , SP - Brazil
Postdoctoral Research Fellow | University of Albe= rta | Edmonton, AB - Canada
--0000000000008de9d005eb8e3332--