From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: Update on tree-sitter structure navigation Date: Sun, 3 Sep 2023 03:56:03 +0300 Message-ID: <8a5b3b3e-f091-3f38-09d4-c4e26bec97f9@yandex.ru> References: <5E7F2A94-4377-45C0-8541-7F59F3B54BA1@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2122"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Cc: Danny Freeman , Theodor Thornhill , =?UTF-8?Q?Jostein_Kj=c3=b8nigsen?= , Randy Taylor , Wilhelm Kirschbaum , Perry Smith To: Yuan Fu , emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Sep 03 02:57:07 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 1qcbQJ-0000NP-Fo for ged-emacs-devel@m.gmane-mx.org; Sun, 03 Sep 2023 02:57:07 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcbPa-00070w-4c; Sat, 02 Sep 2023 20:56: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 1qcbPY-00070b-Kp for emacs-devel@gnu.org; Sat, 02 Sep 2023 20:56:20 -0400 Original-Received: from forward501c.mail.yandex.net ([2a02:6b8:c03:500:1:45:d181:d501]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qcbPT-0005K4-I1 for emacs-devel@gnu.org; Sat, 02 Sep 2023 20:56:19 -0400 Original-Received: from mail-nwsmtp-smtp-production-main-63.sas.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-63.sas.yp-c.yandex.net [IPv6:2a02:6b8:c14:6e01:0:640:627f:0]) by forward501c.mail.yandex.net (Yandex) with ESMTP id 442E45EADC; Sun, 3 Sep 2023 03:56:11 +0300 (MSK) Original-Received: by mail-nwsmtp-smtp-production-main-63.sas.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id 7uIU3XwDYiE0-XSxxZxXI; Sun, 03 Sep 2023 03:56:10 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1693702570; bh=DVWdQXos0j8IaGoJAfrdlwg5QDOv5htz8dAqqf6PrWE=; h=In-Reply-To:From:Subject:Message-ID:Cc:References:Date:To; b=muUDwB5uSIpVGxNpjWaMke7fP5S2Bv4BN6fAprqBrG3lHLB3FnSkxDm6mmljtoOJ9 +DwuIuj6asINXrf3RHHIFNOdRYiB13hTNtb+xNDINmr1rBgqgGpwQXumt1G/OUaTrI rYum4F8HgztoeNpnRNXCt+WEJJlq+TkBukEv7nis= Authentication-Results: mail-nwsmtp-smtp-production-main-63.sas.yp-c.yandex.net; dkim=pass header.i=@yandex.ru Original-Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailauth.nyi.internal (Postfix) with ESMTP id ED13B27C005B; Sat, 2 Sep 2023 20:56:06 -0400 (EDT) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sat, 02 Sep 2023 20:56:06 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudeghedggeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne goufhushhpvggtthffohhmrghinhculdegledmnecujfgurhepkfffgggfuffvvehfhfgj tgfgsehtkeertddtfeejnecuhfhrohhmpeffmhhithhrhicuifhuthhovhcuoegughhuth hovheshigrnhguvgigrdhruheqnecuggftrfgrthhtvghrnhepgeejueeiveduueffudeg ledvhedtleefjeeuudekudehgeeghfdugfdutdefveeinecuffhomhgrihhnpehgihhthh husgdrihhopdhgihhthhhusgdrtghomhenucevlhhushhtvghrufhiiigvpedtnecurfgr rhgrmhepmhgrihhlfhhrohhmpegughhuthhovhdomhgvshhmthhprghuthhhphgvrhhsoh hnrghlihhthidqudeffeefleelheehvddqvdelgeejjeejjeeiqdgughhuthhovheppeih rghnuggvgidrrhhusehfrghsthhmrghilhdrtghomh X-ME-Proxy: Feedback-ID: ib1d9465d:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 2 Sep 2023 20:56:04 -0400 (EDT) Content-Language: en-US In-Reply-To: <5E7F2A94-4377-45C0-8541-7F59F3B54BA1@gmail.com> Received-SPF: pass client-ip=2a02:6b8:c03:500:1:45:d181:d501; envelope-from=dgutov@yandex.ru; helo=forward501c.mail.yandex.net X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 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, NICE_REPLY_A=-1.473, RCVD_IN_DNSWL_LOW=-0.7, 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:309921 Archived-At: Hi Yuan, On 02/09/2023 08:01, Yuan Fu wrote: > - Solve the grammar versioning/breaking-change problem: tree-sitter grammar don’t have a version number, so every time the author changes the grammar, our queries break, and loading the mode only produces a giant error. 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). > 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. 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-variables Basically to know which symbols are defined and for how long, the parser needs additional help from the major mode author. Neovim's definition here: https://github.com/nvim-treesitter/nvim-treesitter/blob/master/queries/ruby/locals.scm