From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: cc-mode fontification feels random Date: Sat, 05 Jun 2021 13:31:33 -0400 Message-ID: References: <831r9iw473.fsf@gnu.org> <87h7ieyma7.fsf@gmail.com> <15be7dd8-e901-e317-5111-e1a34f6f0416@gmail.com> <83k0n9l9pv.fsf@gnu.org> <83eedhl83r.fsf@gnu.org> <8735txfkk7.fsf@fastmail.fm> <837dj8ls7d.fsf@gnu.org> <87y2bo9r42.fsf@telefonica.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12862"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: =?windows-1252?Q?=D3scar?= Fuentes Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jun 05 19:33:22 2021 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 1lpaAj-00037i-Mj for ged-emacs-devel@m.gmane-mx.org; Sat, 05 Jun 2021 19:33:21 +0200 Original-Received: from localhost ([::1]:52118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpaAi-0002cH-44 for ged-emacs-devel@m.gmane-mx.org; Sat, 05 Jun 2021 13:33:20 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57716) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpa9G-0001nk-OS for emacs-devel@gnu.org; Sat, 05 Jun 2021 13:31:50 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:42290) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpa9A-0006Ql-Ap for emacs-devel@gnu.org; Sat, 05 Jun 2021 13:31:49 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 348D880528; Sat, 5 Jun 2021 13:31:40 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 895BB808AB; Sat, 5 Jun 2021 13:31:34 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1622914294; bh=uDRx8Pu+cqT/4xdMVSglcHZLmCxjkDYEz4WM4UZoqxM=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=HSyFnpc4c2aE74ooOOhK5MFcG6Q2/Lrl0mZpx2uELVlBIweg2xXx6kkxYMbFIKejC jpC5f9EkZFD1IaRRAGtxHEGc7xuqyyXxx8GCN69S1Mkj/Oz3LeW6rWUtgEeVUEQ9i9 8AzjqOO48d91CSoGBJxJd694Sdjn8Y/SuA5OSMncsbSKwzSrqokQDdogRjtae0/q8G /IZ3MZksBbapHiKFMRR3LX57JrXMjXm3cWO1S80jOUgbqFxb961UU2ofC1xRrY/UIh aF/kdu6Uyh+Ule19ab0WOKRe/t7B/sMAudHnwY6Eg2BJLOBd+WaI2C70tUoKSmhiP9 HTqFKJxDU7C6Q== Original-Received: from alfajor (69-196-163-239.dsl.teksavvy.com [69.196.163.239]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 4CA53120728; Sat, 5 Jun 2021 13:31:34 -0400 (EDT) In-Reply-To: <87y2bo9r42.fsf@telefonica.net> (=?windows-1252?Q?=22=D3scar?= Fuentes"'s message of "Sat, 05 Jun 2021 19:08:13 +0200") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca 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, RCVD_IN_DNSWL_MED=-2.3, 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.23 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:270442 Archived-At: >> I think that's where tree-sitter shines, because AFAIK it does not rely >> on access to other files. > > I took a look at tree-sitter and, IIUC, it suffers from the same > limitations as CC mode: it gets the information provided by a parser. To a large extent that's unavoidable. AFAIU it should be able to do a slightly better job in some cases by just trying out all possible interpretations and only keeping those that make sense (from a purely syntactic point of view). > But most fundamentally, it is unable to determine what > Foo::bar is even when it is defined on the current file. Indeed it's quite possible that there are also cases where tree-sitter does a worse job than CC-mode, e.g. by not taking into account semantic information that can be extracted from the current file. > If we are going to really modernize Emacs' programming language > support we need to provide more than parser-based syntax highlighting > and indentation. [...] That means we need something like LSP. I believe/hope this is obvious to everyone, yes. > Tree-sitter migth be useful for the languages not yet supported by > LSP, though My impression is that tree-sitter might be useful for syntax-highlighting and indentation. I'm not sure how well those two features are supported/handled by LSP servers and clients currently. > (but, if I got it right, tree-sitter is implemented on Javascript, AFAIK only the source grammars and the grammar-compiler is written in Javascript: the parsing engine is written in C and exposed as a C library. >> I think you'd expect a good LSP server to "degrade gracefully" and still >> provide good info for indentation and syntax highlighting even if you >> only have the one file and all the other files in the project >> are missing. > As already mentioned elsewhere on this thread, an LSP server with access > to just the current file is severely handicapped. Of course. The question is whether it can still provide a good enough behavior in that case compared to tree-sitter. If not, it might be an argument in favor of using both LSP and tree-sitter. Stefan