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: Tree-sitter integration on feature/tree-sitter Date: Sat, 7 May 2022 11:33:21 -0700 Message-ID: <66C72181-D168-4BEE-AB06-FB3CFDCC3D51@gmail.com> References: <9E6D13F6-7E50-44EE-A357-C971A11A3636@gmail.com> <837d6xzpac.fsf@gnu.org> <87a6btelet.fsf@thornhill.no> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.80.82.1.1\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16430"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , emacs-devel@gnu.org To: Theodor Thornhill Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat May 07 20:34:02 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 1nnPFh-00042t-C2 for ged-emacs-devel@m.gmane-mx.org; Sat, 07 May 2022 20:34:01 +0200 Original-Received: from localhost ([::1]:44912 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nnPFf-0003SX-VG for ged-emacs-devel@m.gmane-mx.org; Sat, 07 May 2022 14:33:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51292) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnPF8-0002m6-5m for emacs-devel@gnu.org; Sat, 07 May 2022 14:33:26 -0400 Original-Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]:35408) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nnPF6-0005fd-CN; Sat, 07 May 2022 14:33:25 -0400 Original-Received: by mail-pf1-x431.google.com with SMTP id c14so8903390pfn.2; Sat, 07 May 2022 11:33:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=FrCmGr9Sr15Gqrk6e3U+eYBThSMcoGCCy883ObfFDV4=; b=eN6NJsfFMuYHyR+yUQnfKJjE54MLllOUfUArFBt3L37DZY2/U+IkJce5uxfaks6mBm 7DjBaqaGvLu1k4XU66EwZQrbRycZq2SDkyoA3xIpiiE+Fsc8tiUYY7T2Et6Wni5IPBUU VykmJE3WZWiOpVsCPYTaVBwpwSnmkAcPA8bI04BdsMv7JimyNxnIUHWWhS6YTIQmGH9G 8TbWrzCFazFMViYmA1Q4WvJQoLx1wsnmsh8KCcE6iJGXmW5J8/o5gzRCQBT/FSWXextv FwKq91s160+liHaEuZiEpH+rR4xA1UXVIwjuoUr8DLqFokybiJAGky6CMggFU0dBlGVn di2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=FrCmGr9Sr15Gqrk6e3U+eYBThSMcoGCCy883ObfFDV4=; b=IlOOW+DVJMpI4axFfzvW/pdbla3KGsUmY6K3AsZuOJomQwRRYWtBHm2uBsSz6Stsme traMspoAwdB6JG4Q/Xd6gTpvB2RoQ7fAWYplnmR7d55IaIcLxLl0GRVf0m0idL+vDddi 3ZACyCW/1q88UNBXjlYQmxmyqDXeoFDvwXREOUjFNldPGM5yyw5vro1nfiVFpeMYeKpR cxao6jq1eGqm133c0suQB0PCcPAFxfzttdw/1/e4aT8gZd1giTmMDjk1+w2Zga+NtgaQ DbR1KwbjrsucFZ+8ADrR31fcwQW7dEm1/r1KX20SN+qdL2LmhgtSa+igH3DK6oafd7ic yx7A== X-Gm-Message-State: AOAM531ekFiEzfD6X2S8gIuFSn9B0Ul5JMTW9wgeLcgoFV/C8n1dT073 5DLe8lqJQZLhOGlAbtTcxRTalM+bIGI= X-Google-Smtp-Source: ABdhPJxftnjDKYxSUoH38VZ6SAu01KpC7m5MnBiRCJyyvvJr6VSiCpZgKl//oqWwIBAI4G3dmrF3mg== X-Received: by 2002:a62:a105:0:b0:50d:c97b:3084 with SMTP id b5-20020a62a105000000b0050dc97b3084mr8869845pff.61.1651948402542; Sat, 07 May 2022 11:33:22 -0700 (PDT) Original-Received: from smtpclient.apple ([2600:1700:2ec7:8c90:148:e841:81b0:7360]) by smtp.gmail.com with ESMTPSA id h7-20020aa796c7000000b0050dc76281e3sm5549170pfq.189.2022.05.07.11.33.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 May 2022 11:33:22 -0700 (PDT) In-Reply-To: <87a6btelet.fsf@thornhill.no> X-Mailer: Apple Mail (2.3696.80.82.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=casouri@gmail.com; helo=mail-pf1-x431.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, T_SCC_BODY_TEXT_LINE=-0.01 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" Xref: news.gmane.io gmane.emacs.devel:289424 Archived-At: I forgot to mention the changes I made prior to pushing: - Changed prefix to treesit- - Now language definitions are referred to as 'c and 'python, rather = than 'tree-sitter-c and 'tree-sitter-python (because we changed the = prefix) - New variable treesit-extra-load-path that lets the user use different = load-paths for language definitions These are the changes we agreed on in the old thread. I also added a new = indentation preset parent-bol, as suggested by Theodor. > The easiest way to play with it is to use some provided major mode = that > implements it. I've made one here for golang, for reference: > = https://git.sr.ht/~theo/dotfiles/tree/master/item/emacs/.emacs.d/lisp/go-m= ode.el. >=20 > This can easily be modified to use 'tree-sitter-c instead So now 'tree-sitter-c should be 'c. >=20 > To make this work you need the definition compiled and put on some = path > that emacs can see. The suggested one is LD_LIBRARY_PATH, and I start > emacs using something like this: >=20 > ``` > LD_LIBRARY_PATH=3D/home/theo/src/tree-sitter-module/dist = /path/to/tree-sitter-enabled-emacs/src/emacs > ``` Now you can use tree-sitter-extra-load-path >=20 > This is using the scripts provided by Yuan Fu in the = tree-sitter-modules > repo. When the major mode is enabled, you can start querying the > document by using the provided functions, such as: >=20 > ```elisp > (tree-sitter-node-start > (tree-sitter-node-at (point) (point) 'tree-sitter-go)) > ``` >=20 > `M-x tree-sitter-inspect-mode` shows what node you are on in the mode > line. It helps with debugging. >=20 > By 'play with it', I guess we can implement folding, highlighting, > navigation, simple rename functionality, Imenu etc etc. Now you should use treesit- prefix. Thanks, Yuan=