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: cc-mode fontification feels random Date: Fri, 04 Jun 2021 09:10:33 +0200 Message-ID: References: <831r9iw473.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="35221"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org, ubolonton@gmail.com, joaotavora@gmail.com To: Eli Zaretskii , Daniel Colascione Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jun 04 09:17:12 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 1lp44t-000910-0T for ged-emacs-devel@m.gmane-mx.org; Fri, 04 Jun 2021 09:17:11 +0200 Original-Received: from localhost ([::1]:60220 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lp44s-0007Xm-0J for ged-emacs-devel@m.gmane-mx.org; Fri, 04 Jun 2021 03:17:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45838) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lp3yi-0001it-ER for emacs-devel@gnu.org; Fri, 04 Jun 2021 03:10:48 -0400 Original-Received: from out0.migadu.com ([2001:41d0:2:267::]:36309) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lp3yd-0001nb-8B; Fri, 04 Jun 2021 03:10:48 -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=1622790635; 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=lBdEUfv6SuVhvDWQ3hfXPfgfl+jj8wrNe4FKQJa5weE=; b=uqqCjmB2JIMPvoGux9/yohnr30t1DchBFVEMIrMr4wq1Y35cryyCg+tplfPStxdNGvflN+ YHv4hen2R5t1DkojR/jNhExYYM3ZFWlaibMMDSzKWl4Bt0b16CcDF9ZlJ4vMu6RbX1C2GR GEVDz6qBl/z+DtHxEKP7tgQXWflImt7iqSGiQ56yDkwyDe3z/4a7giVMj2i2Ikh1AjmJz3 6k/xuOMfRDA6KQadyH/XNDjQxTgnTEwh5vhJMTI/9bDtZNrR5dD6Xu5huVUWJtan/uCTB5 lxdaWbdgZsc3mHR801XDsTMhLHvNTOWgfEQdsGslnsxoSSZ2L3rea4tDXLnB1g== In-Reply-To: <831r9iw473.fsf@gnu.org> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: theo@thornhill.no Received-SPF: pass client-ip=2001:41d0:2:267::; envelope-from=theo@thornhill.no; helo=out0.migadu.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, 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:270362 Archived-At: >> As long as I can remember, cc-mode fontification has felt totally >> random, with actual faces depending on happenstance of previously-parsed >> types, luck of the draw in jit-lock chunking, and so on. Is there any >> *general* way that we can make fontification more robust and consistent? Yes, tree-sitter. Ubolonton has made a tremendous package implementing this for emacs. It is used in csharp-mode already, with success. At least for the fontification. There are still some kinks to work out in the indentation part of the mode. In C#-mode we use tree sitter for: - Fontification - Indentation There is also a normal CC mode version, which is enabled by default. So you need to install the third party packages as well as enabling csharp-tree-sitter-mode. You can try it out and see if it has some benefits. Performance wise the tree-sitter mode is leagues above the CC mode one. Also one benefit is that it is extremely easy to define these grammars. > See also Eglot and LSP. LSP-mode supports the semantic fontification from lsp servers, which usually uses tree-sitter. Examples for this is Rust, F# and others. Eglot does not yet support this, though I believe there is an issue somewhere for it. > > Patches more than welcome, I think having this (whether tree-sitter or > some other similar technology) in core is long overdue. Pinging @Ubolonton and Joao, as they probably know way more than me about this. -- Theodor Thornhill