From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?=C3=93scar_Fuentes?= Newsgroups: gmane.emacs.devel Subject: Re: cc-mode fontification feels random Date: Sat, 05 Jun 2021 19:08:13 +0200 Message-ID: <87y2bo9r42.fsf@telefonica.net> 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> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38561"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) To: emacs-devel@gnu.org Cancel-Lock: sha1:h+yngTSIvanhKkPqsBWWquNqxm4= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jun 05 19:09:18 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 1lpZnS-0009ll-I0 for ged-emacs-devel@m.gmane-mx.org; Sat, 05 Jun 2021 19:09:18 +0200 Original-Received: from localhost ([::1]:47002 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpZnR-0005xG-8o for ged-emacs-devel@m.gmane-mx.org; Sat, 05 Jun 2021 13:09:17 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpZmd-0005FQ-DP for emacs-devel@gnu.org; Sat, 05 Jun 2021 13:08:27 -0400 Original-Received: from ciao.gmane.io ([116.202.254.214]:44924) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpZmb-0004VB-9c for emacs-devel@gnu.org; Sat, 05 Jun 2021 13:08:26 -0400 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1lpZmX-0008Sy-Qm for emacs-devel@gnu.org; Sat, 05 Jun 2021 19:08:21 +0200 X-Injected-Via-Gmane: http://gmane.org/ Received-SPF: pass client-ip=116.202.254.214; envelope-from=ged-emacs-devel@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.249, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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:270441 Archived-At: Stefan Monnier writes: >> not everything is laid out 100% yet. The user will expect that some >> completion cases could be inaccurate when not everything is coded yet, >> but the user will NOT expect to see inaccurate "syntax highlighting" >> or indentation, nor incorrect "show definition" and "show callers" >> results for the code that was already written, and in particular for >> the code in the file being edited. > > 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. For starts, in C++, being limited to the current file means that it is unable to determine if Foo::bar is a type, a value or a function when Foo is defined on a header file. But most fundamentally, it is unable to determine what Foo::bar is even when it is defined on 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. We need smart code completion, code hints, transformations, etc. That means we need something like LSP. Tree-sitter migth be useful for the languages not yet supported by LSP, though (but, if I got it right, tree-sitter is implemented on Javascript, so it requires a JS engine to work, maybe too much of a dependency for something that doesn't add that much over what we have now.) > 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. One thing is to miss the information about some functions yet-to-be-written and another thing entirely is to ignore everything not defined on the current file.