From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Niels Thykier Newsgroups: gmane.emacs.bugs Subject: bug#72088: eglot: Segregates language servers in a way that hampers polyglot language servers Date: Sun, 14 Jul 2024 14:01:32 +0200 Message-ID: <8febc150-6ed6-430a-afd8-a738d960616e@thykier.net> References: <6e65694c-88d6-4c54-93a8-2ffb843ce6d0@thykier.net> <86bk31lsvd.fsf@gnu.org> <86cyngk2qm.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8039"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird Cc: Eli Zaretskii , 72088@debbugs.gnu.org To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jul 14 14:04:25 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1sSxxp-0001lC-6f for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 14 Jul 2024 14:04:25 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sSxxU-0005O9-Hd; Sun, 14 Jul 2024 08:04:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sSxxT-0005Nw-Go for bug-gnu-emacs@gnu.org; Sun, 14 Jul 2024 08:04:03 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sSxxS-0003Y9-5N for bug-gnu-emacs@gnu.org; Sun, 14 Jul 2024 08:04:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sSxxS-0004MX-Ge for bug-gnu-emacs@gnu.org; Sun, 14 Jul 2024 08:04:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Niels Thykier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 14 Jul 2024 12:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72088 X-GNU-PR-Package: emacs Original-Received: via spool by 72088-submit@debbugs.gnu.org id=B72088.172095859516712 (code B ref 72088); Sun, 14 Jul 2024 12:04:02 +0000 Original-Received: (at 72088) by debbugs.gnu.org; 14 Jul 2024 12:03:15 +0000 Original-Received: from localhost ([127.0.0.1]:57263 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sSxwg-0004LU-Hp for submit@debbugs.gnu.org; Sun, 14 Jul 2024 08:03:15 -0400 Original-Received: from mailrelay1-1.pub.mailoutpod2-cph3.one.com ([46.30.211.176]:37975) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sSxwe-0004LG-D9 for 72088@debbugs.gnu.org; Sun, 14 Jul 2024 08:03:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thykier.net; s=rsa1; h=content-transfer-encoding:content-type:in-reply-to:from:references:cc:to: subject:mime-version:date:message-id:from; bh=ZzLqwkFioOcqbKGB9duGdhtPuKzO87FaXiQ118KBjJo=; b=JU6r7H56AJWp//nGZ/EDM3mFm/69TqJtzRkQsjfxdC7xwiak2ps5d8Hvre0GNlCgCi0k1pPQEMhP6 VMC2mRwCBucJVX3Mvv++H+UOiWpVQM3NJOrM+Ga5dzhqK5TVB9yjrcDri7d8BGk3EwSWA/A+BEHF3i Z7PVydgL7YiP9kR4bWMYo/hl/aOS4qROoeZE7Q5bAb7mBCxm1Iz41QvCGi2XM7urZeuQezEuzcYzbf wwD6ewQcJtdZ1CqQB/MDDe+SyYWEwRvBwkp9usvUlWnYyqn8qSc+Fx0RcROQVMiedjx0H+qS20TrLl P15A9hzaSjKUEZA2DWuSE0MI6kwJ8cg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=thykier.net; s=ed1; h=content-transfer-encoding:content-type:in-reply-to:from:references:cc:to: subject:mime-version:date:message-id:from; bh=ZzLqwkFioOcqbKGB9duGdhtPuKzO87FaXiQ118KBjJo=; b=1AqQ3nDxtOR63zW/KQw50GxTuXnwe6UYjvuTgriYTMzkx0SUsWZGLrT7DxgUaMQi24h/S+v3VRDmP ASX3szIDg== X-HalOne-ID: cfa4c8ef-41d8-11ef-849b-a581d61233e4 Original-Received: from [127.0.0.1] (unknown [185.220.101.150]) by mailrelay1.pub.mailoutpod2-cph3.one.com (Halon) with ESMTPSA id cfa4c8ef-41d8-11ef-849b-a581d61233e4; Sun, 14 Jul 2024 12:01:34 +0000 (UTC) Content-Language: en-US Autocrypt: addr=niels@thykier.net; keydata= xsFNBEoc+tABEAC2hwVc8hIXriemyLerYBq5Q7d0QrYkuvruWGRbDvfegqGJDopZb/Tq2jBm 2QwGIy7ikTxgOqcH2fQH5zJuYq6WC4ST9DdXghhqh6pm1e68dhyJrWmmdmgV42bvb5GvtMGC vfeSCsqJrp1yjJCHyJmBj33ExBhPr4YGLOJc45wol0LB8HfqietRaGKiS5Vsay6D+LUCEPKX EZD72nh+VdKZdy8YNBUF+e27LapLH+6dkH8wR7OJU8SoVwhVOZcpf4mjmw3iiQIvWKJhokhG K1cjZ7huIZEs+x0XlEwA1FWLCMp9Ktnum8NlF7uQfGEpfQ1Oofr50vxx8cnGoVnwUKIRcRx9 uBGRWehTBnbe/7CSXIbvWY7T4KHjbI33k8P6ytVxpVNHrSKK2P4Fb6Dsh7QondikzvMdlWqD h0rhjchpPXAUuqT/3ItSlJhllFkfTDUG26tFq1v3AlPLayPvFjkC9HUAiu5rqSJsNR/bDSxo /JfBerzzbqfw4aQ0iYoT/0zJ3PqaqsAqU8dHdTXHbrryzqM+sD65Q87ZhC9BFIXENplIQ91V JNxjuq0PEHJDZ9lAh3+Paa6LUAEhqGffTpdEo1iyqY6zDT6cBgFY7MWJiM8rWkI8IADj4aiz wBEud1nEjIVYZkk0qF8kFhvn3j88cfTV3/8OgRvL3lWsOoDEdwARAQABzSFOaWVscyBUaHlr aWVyIDxuaWVsc0B0aHlraWVyLm5ldD7CwZMEEwEIAD0CGy8GCwkIBwMCBBUCCAMEFgIDAQIe AQIXgBYhBLMTGkUdv998oFtBlwVLu599gGRCBQJk5 In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:288840 Archived-At: João Távora: > On Sun, Jul 14, 2024, 10:36 Niels Thykier wrote: > >> I read through >> >> https://www.gnu.org/software/emacs/manual/html_node/eglot/Setting-Up-LSP-Servers.html >> and I do not see anything here that decides how to control whether one >> or two instances per project will be spawned. >> > > In that section, did you happen to read this sentence? > > "In addition, major-mode can be a list of several major modes specified in > one of the above forms – this means a running instance of the associated > server is responsible for files of multiple major modes or languages in the > project. " > > If so, how do you comprehend or interpret it? Maybe it could be clarified. > Regardless, the default value of the eglot-server-programs variable that > ships with Emacs has several examples that make use of this feature, so it > may be worth studying those. > > João > I missed it entirely. My recommendations would one or more of the following: 1 Use a more verbose variant of the `major-mode` placeholder, like `(major-mode-or-modes . server)`. This would have prompted me to not assume `major-mode` was just a single major-mode. 2 Provide an example featuring multiple modes in addition the existing examples. This example could also show off the `:language-id` feature. 3 Provide a howto guide for adding a new LSP server configuration that explicitly featured the distinction between single mode vs. multi-mode LSP servers. (Note "howto guide" is specifically the "howto guide" from https://docs.divio.com/documentation-system/) For me, either 1+2 would definitely have worked. The third option is a question of which kind of audience you want to optimize for. Personally, I find it difficult myself to figure out what deserves a howto guide, so I can totally understand if you pass on doing one of those. A bit more on what happened on my end: I think a key aspect of this problem is that I was trying to quickly solve a problem. Namely getting my prototype to work and all I could find was reference documentation, which is tailored for solving a different type of documentation problem than what I ideally needed (Compare problem-oriented vs information-oriented on https://docs.divio.com/documentation-system/). Since I know the documentation has the "wrong focus" for the thing I want to do, I scan much more aggressively for examples and highlighted words that looks like definitions and then retrace from there if relevant. This is a common issue for many projects including some of my own that they only provide one or two types of documentation (with reference documentation being the most common type of documentation), which has made me adopt this reading style. The use of `major-mode` in the documentation had me assume that it was one major mode at the time which works out of the box with no warnings. The moment I saw: "The value of the variable is an alist, whose elements are of the form (major-mode . server)", I was like "Got it, one major mode + a server definition. Where do I find the definition of `server`? Next line talks about the major-mode and I got what is. I need the server part, oh I see the highlighted `(programs args)` below, so skip to that. Oh, there are examples in the bottom. Ok, so 5x the first example that with a bit of replacements" and I had some code that worked and I was back to working on my language server. From there it took me several months until the server reached maturity enough to provide features where this mistake got in the way. As mentioned, an example that might have worked would have been: ``` ;; Polyglot LSP server example. The instance is reused ;; in a given project for all the listed modes. (with-eval-after-load 'eglot (add-to-list 'eglot-server-programs '(( c-mode (cpp-mode :language-id "c++")) . ("custom-c-lsp" "--stdio")))) ``` In fact, it would have been nice to have this example, because I spent 30 minutes fighting with the elisp syntax figuring out the syntax. After that, I spent 15 minutes trying to figure out why my `eglot-ensure` configuration stopped working (as you can probably tell, lisp/elisp is not really not my jam). Hope that helped. Best regards, Niels