From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: Update on tree-sitter structure navigation Date: Thu, 7 Sep 2023 18:04:02 -0700 Message-ID: References: <5E7F2A94-4377-45C0-8541-7F59F3B54BA1@gmail.com> <8a5b3b3e-f091-3f38-09d4-c4e26bec97f9@yandex.ru> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33405"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel , Danny Freeman , Theodor Thornhill , =?utf-8?Q?Jostein_Kj=C3=B8nigsen?= , Randy Taylor , Wilhelm Kirschbaum , Perry Smith To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Sep 08 03:04:34 2023 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 1qePvG-0008SS-GU for ged-emacs-devel@m.gmane-mx.org; Fri, 08 Sep 2023 03:04:34 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qePv5-0006o8-4G; Thu, 07 Sep 2023 21:04:23 -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 1qePv2-0006nT-O3 for emacs-devel@gnu.org; Thu, 07 Sep 2023 21:04:20 -0400 Original-Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qePv0-0005cA-6P for emacs-devel@gnu.org; Thu, 07 Sep 2023 21:04:20 -0400 Original-Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1c328b53aeaso13305605ad.2 for ; Thu, 07 Sep 2023 18:04:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694135056; x=1694739856; darn=gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=2hoCiFLFUZrEQ5BrNxbPcY32A6WrIus/ye4KXax5htM=; b=D6RTaRrD8IxYDUOcNXCk2LI/lcWQ4Dudt5wGN79otsrbq8z3MmAeKefULZfgNcozNH 7yXl8r71uvCAvjF2fxm+BkFQeSYPrx21cNTlWwD/gE5qtefKPtSibrz9c1MyePrl/Q+u 5JwFh9pJKJo/vdH5e+hu7aFweFEXAyhBptPwvgLOkL6zM7xv0jOP/h59Jr8q+uO/j0k8 /Lem30CEVysgwwjf1G/OjvPI1HG89Q/kQMCfAGxXzUe+2tNgKScScY1zHSxYPHsF8fr5 aQwowMdZOYcy1Ob1BbEr/3FNiRALjg/QWChV2kR0pmSqlGBbzYKxrN9zE3hfA9YbnLFN 1tGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694135056; x=1694739856; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2hoCiFLFUZrEQ5BrNxbPcY32A6WrIus/ye4KXax5htM=; b=heyNquHu0BbJ5vYfjx/PVcWBSYDty4/Om9RsZYZIHbRHhsOA4gLpAiZsiIaLn7II6S 2yB4GgO13EBFqgPesR2QCYaK0Pxct1dmC1cm0eZbgfLxwGCPDY8mbzEReueD5zmwIrqb forJkLodJcgh46Wofu/XyWWYYn+ZbMvjF3xM6bowB0FRYp44/bU9E8nFTB2xDfkWNvpE WziM35Bf9gEdXdVL/yGzFMgWhF7HmfOD2CQ95Es0lL3oh27csQSKE21pcktT2EP4MCVh JeJJ1TeSKnNl5lw49zZaPQF1KW9PjMlusmAJQu6YcKKvz7PuMOjfvbmxjRipWyLsWmNu YcYw== X-Gm-Message-State: AOJu0YyKaQkJ9N8TD7yggP4LEZvIrJFykRrLm0rmyeralHktqWMIdS1F H+xsp78zawKvZG/Umhqimd8= X-Google-Smtp-Source: AGHT+IEIzheuI5Ctj5feXVygPHkFeMn92Pwut/gLTx+KpcihJwTsfnwwgLQzYRa49+/bTcqTgH3UMQ== X-Received: by 2002:a17:902:e550:b0:1b8:83a3:7db6 with SMTP id n16-20020a170902e55000b001b883a37db6mr1445795plf.44.1694135056110; Thu, 07 Sep 2023 18:04:16 -0700 (PDT) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id u1-20020a170902e80100b001bc445e2497sm347125plg.79.2023.09.07.18.04.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Sep 2023 18:04:15 -0700 (PDT) In-Reply-To: <8a5b3b3e-f091-3f38-09d4-c4e26bec97f9@yandex.ru> X-Mailer: Apple Mail (2.3731.700.6) Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=casouri@gmail.com; helo=mail-pl1-x62f.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, 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: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:310301 Archived-At: > On Sep 2, 2023, at 5:56 PM, Dmitry Gutov wrote: >=20 > Hi Yuan, >=20 > On 02/09/2023 08:01, Yuan Fu wrote: >> - Solve the grammar versioning/breaking-change problem: tree-sitter = grammar don=E2=80=99t have a version number, so every time the author = changes the grammar, our queries break, and loading the mode only = produces a giant error. >=20 > I don't have a better idea than basically copying NeoVim and others: = to maintain the urls to parser repositories and the ref of the latest = known good revision, for the current version of the major mode. That = info could be filled in by major modes themselves, e.g. in an autoload = block (similarly to how auto-mode-alist is appended to). That=E2=80=99ll probably be ideal for third-party modes. But knowing = Eli, I don=E2=80=99t think builtin major modes can do that. >=20 >> Finally, feel free to send me an email or send to emacs-devel and CC = me, if there are things treesit.c and treesit.el can do better, or when = there are nice things in neovim and other editors and Emacs ought to = have, too. >=20 > Something I mentioned previously, there is notion of scopes in = tree-sitter docs, see the Local Variables section here: = https://tree-sitter.github.io/tree-sitter/syntax-highlighting#local-variab= les >=20 > Basically to know which symbols are defined and for how long, the = parser needs additional help from the major mode author. >=20 > Neovim's definition here: = https://github.com/nvim-treesitter/nvim-treesitter/blob/master/queries/rub= y/locals.scm Good call. I=E2=80=99ll add it to my TODO list, but it=E2=80=99ll have a = lower priority, since I personally aren=E2=80=99t really interested in = coloring variables different colors. If someone is interested, do please = give it a try. Yuan=