From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Theodor Thornhill Newsgroups: gmane.emacs.devel Subject: Re: Tree-sitter integration on feature/tree-sitter Date: Sat, 07 May 2022 11:34:18 +0200 Message-ID: <87a6btelet.fsf@thornhill.no> References: <9E6D13F6-7E50-44EE-A357-C971A11A3636@gmail.com> <837d6xzpac.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24430"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Eli Zaretskii , Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat May 07 11:35:46 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 1nnGqm-00064r-VB for ged-emacs-devel@m.gmane-mx.org; Sat, 07 May 2022 11:35:46 +0200 Original-Received: from localhost ([::1]:36614 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nnGql-0000vF-Ly for ged-emacs-devel@m.gmane-mx.org; Sat, 07 May 2022 05:35:43 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45490) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnGpY-00009J-5Q for emacs-devel@gnu.org; Sat, 07 May 2022 05:34:28 -0400 Original-Received: from out0.migadu.com ([94.23.1.103]:30658) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnGpU-0002GC-2w; Sat, 07 May 2022 05:34:27 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1651916060; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=E33swYQ3fvcJoEhTjDoWT0ZJn/TdIw8RIz8ddxjgbEg=; b=oUsrbSqEgXouKE5Q8XziW9ZQrdvI/7IR7y3D2nTugx9uJk014KW1AjYY5CwK2kmAJd3xPm EufOQkBahDdiKs88QjA2PI4qOgEC8iYXHLNQvOTHOa83TtEO5KmXtKb1CVUItkYEkts/Ee kY8N0F/6GZLG7yfYeP6N5mk/A3kC4ltczFoFBckwHyBXbyK8pNViXID3tXXbi+CqsEnES1 E6YuNexYRaB2CDHLEyVFGzzoHQKkB/K+9lSCvaLjRpu4iUyr+HmSrArhizw4uwZxP++1XO nu0ldjEkL0tcY84d7+fgCBBu1WHuOQgF69eMoP6e6FfVv/gM6eq8QQZUh6qVBg== In-Reply-To: <837d6xzpac.fsf@gnu.org> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: thornhill.no Received-SPF: pass client-ip=94.23.1.103; envelope-from=theo@thornhill.no; helo=out0.migadu.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, 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:289381 Archived-At: > Thanks! > >> - play with it > > Would you please suggest how to "play with it"? What features to turn > on and how, what commands and displays to try, etc. Posting such > instructions should allow all of us get to testing this branch much > sooner and easier. 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-mode.el. This can easily be modified to use 'tree-sitter-c instead 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: ``` LD_LIBRARY_PATH=/home/theo/src/tree-sitter-module/dist /path/to/tree-sitter-enabled-emacs/src/emacs ``` 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: ```elisp (tree-sitter-node-start (tree-sitter-node-at (point) (point) 'tree-sitter-go)) ``` `M-x tree-sitter-inspect-mode` shows what node you are on in the mode line. It helps with debugging. By 'play with it', I guess we can implement folding, highlighting, navigation, simple rename functionality, Imenu etc etc. Hope this helps a little! Theodor Thornhill