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?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Newsgroups: gmane.emacs.bugs Subject: bug#62795: 29.0.90; eglot: gdscript default port is 6005 Date: Sun, 16 Apr 2023 12:08:50 +0100 Message-ID: <87zg78yth9.fsf@gmail.com> References: <87zg7dido0.fsf@aliyun.com> <83cz45efgq.fsf@gnu.org> <87pm8548pb.fsf@aliyun.com> <87ttxg4hd9.fsf@aliyun.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21686"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Eli Zaretskii , 62795@debbugs.gnu.org, xiliuya To: Ruijie Yu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Apr 16 13:07:16 2023 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 1po0E0-0005Qr-4G for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 16 Apr 2023 13:07:16 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1po0Do-0003ry-4Q; Sun, 16 Apr 2023 07:07: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 1po0Dm-0003rq-N1 for bug-gnu-emacs@gnu.org; Sun, 16 Apr 2023 07:07:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1po0Dm-00061I-6Q for bug-gnu-emacs@gnu.org; Sun, 16 Apr 2023 07:07:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1po0Dl-0001Ve-Lw for bug-gnu-emacs@gnu.org; Sun, 16 Apr 2023 07:07:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 16 Apr 2023 11:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62795 X-GNU-PR-Package: emacs Original-Received: via spool by 62795-submit@debbugs.gnu.org id=B62795.16816432135787 (code B ref 62795); Sun, 16 Apr 2023 11:07:01 +0000 Original-Received: (at 62795) by debbugs.gnu.org; 16 Apr 2023 11:06:53 +0000 Original-Received: from localhost ([127.0.0.1]:50664 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1po0Dc-0001VH-Fh for submit@debbugs.gnu.org; Sun, 16 Apr 2023 07:06:52 -0400 Original-Received: from mail-wm1-f46.google.com ([209.85.128.46]:33531) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1po0Db-0001V4-7t for 62795@debbugs.gnu.org; Sun, 16 Apr 2023 07:06:51 -0400 Original-Received: by mail-wm1-f46.google.com with SMTP id v20-20020a05600c471400b003ed8826253aso6426790wmo.0 for <62795@debbugs.gnu.org>; Sun, 16 Apr 2023 04:06:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681643205; x=1684235205; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7Q3GFwYXdySG0OSrBmfbUa+P73At5p5ZDMs/+4upnOU=; b=ZLky5uHDVK8WSiVN665BuB3ZM5xOSBMJV5E35sdSRzLe8zLXd+HUbt/iFqfDWm+4YZ +ARzJBTn8tiz0stJAbEoEmJaHbG038AFSbZKvqf4O3x+f2qj6ba4y4u9KVrbj7qtEnkw lfsIexVoIfvJDd6urn4qFPBHPnji1wGN4rUMTpX7PZG+mA+/Zg8MHNPMxVvWner8AOWi 3W2mmrQQURuluEv82U0zkQyECvvgdt2bV7kGDQ5+DnwZBlDVGN+UIHedJzKLy5pJ8BGb XncLSAT+lGPndp7QKKpIBCUD8so4vHEmCII59jiXHfG7RYP/TzjZOns1C7eidthD4nKG NMzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681643205; x=1684235205; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=7Q3GFwYXdySG0OSrBmfbUa+P73At5p5ZDMs/+4upnOU=; b=XDKPWzAaCwkraMXoc9OoOwOWw5s4kfZyfZPdfrO2O9TlmOAekuguV1OiYz6dd3cbNq IrGfevXPYTdCFoMAESeQAL0bdrqWk8AhgeMGnPw4wJ02MjYr5drlSOEJ06cJG9Mmn8+8 rLpickdoErQJEfbt4p1c2jSlcCkaiVrTN3FoOClmI2lMmM7x4L1sbbkcXAJhjwo096qz JCXYDTn/BHppC3hGDQHBEQbjOGvb13orVrSO2ByBgb1/DZ3/DMoh4X1A1PI6EZy7nCRl GYc9stYpdO1gK2cqpr0sJFi+DxthllfM7EoHzMhnpu+C7XD1Er+E7P4yAFpVJROqMYC5 bZmg== X-Gm-Message-State: AAQBX9ddzDLTd1uJJd2wmUN0wDLLKCMjlXWNJvTAkWHsGnKsXEj4Z5VQ cyI0V2jeXXvCuYpPn1sshXL9SqX8QXI= X-Google-Smtp-Source: AKy350boxyVq9k/DoDxWHDQlgfVjd4s3wQvhm7fi4+2+/2KyUxYI4ksRRijzm/SY0dLyMrkrI2K4oA== X-Received: by 2002:a7b:cb88:0:b0:3f1:6faa:d94c with SMTP id m8-20020a7bcb88000000b003f16faad94cmr1899528wmi.16.1681643205081; Sun, 16 Apr 2023 04:06:45 -0700 (PDT) Original-Received: from krug ([87.196.73.56]) by smtp.gmail.com with ESMTPSA id y24-20020a7bcd98000000b003ee44b2effasm8928756wmj.12.2023.04.16.04.06.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Apr 2023 04:06:44 -0700 (PDT) In-Reply-To: (Ruijie Yu's message of "Sun, 16 Apr 2023 13:49:27 +0800") 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:260109 Archived-At: Ruijie Yu writes: > TLDR: I think the Melpa package "gdscript-mode" needs to define a > function `gdscript-mode-find-lsp', and eglot needs decide how to use > this function to get the port number. Elaborations below. > > xiliuya via "Bug reports for GNU Emacs, the Swiss army knife of text edit= ors" writes: > >> Jo=C3=A3o T=C3=A1vora writes: >> >>> I see. So it's not an inferior process to Emacs. Then >>> maybe a function can be crafted in Elisp -- and housed >>> in gdscript-mode -- that somehow discovers if the Godot >>> Engine is running and finds the correct port. Then >>> gdscript-mode can add that function to eglot-server-programs. >> >> I wrote this function to add gdscript-mode: >> ----- >> (defun eglot-add-gdscript-lsp () >> (let* ((lsp-port (string-to-number >> (shell-command-to-string >> "awk -F'=3D' '/network\\/language_server\\/remote_p= ort/ {print $2;}' $HOME/.config/godot/editor_settings-4.tres"))) >> (lsp-list (cons 'gdscript-mode (list "localhost" lsp-port >> )))) >> (push lsp-list >> eglot-server-programs))) >> ----- We're getting closer, but this is not what I meant at all. It's much simpler. (defun gdscript-eglot-contact (&optional _interactive) "Produce a suitable value for LSP contact in `eglot-server-programs'." (list "localhost" (string-to-number (shell-command-to-string "awk -F'=3D' '/network\\/language_server\\/remote_port/ {print = $2;}' $HOME/.config/godot/editor_settings-4.tres")))) In your configuration, or in gdscript-mode.el directly (add-to-list 'eglot-server-programs '(gdscript-mode . gdscript-eglot-contact)) Do you follow the idea? You can add a function object to eglot-server-programs _instead_ of the host/port list. The docstring of eglot-server-programs should be clear on the matter. [...] CONTACT can be: =20=20=20=20 [...] =20=20=20=20 * A list (HOST PORT [TCP-ARGS...]) where HOST is a string and PORT is a positive integer for connecting to a server via TCP. =20=20=20=20 [...] =20=20=20=20 * A function of a single argument producing any of the above values for CONTACT. The argument's value is non-nil if the connection was requested interactively (e.g. from the `eglot' command), and nil if it wasn't (e.g. from `eglot-ensure'). If the call is interactive, the function can ask the user for hints on finding the required programs, etc. Otherwise, it should not ask the user for any input, and return nil or signal an error if it can't produce a valid CONTACT. [...] If it's not clear, let us know. Another detail: I think the use of `awk` can probably be be optimized away Elisp code for processing text. Same for the shell use of $HOME which is also has an Elisp abstraction (see docstring of `expand-file-name`). In theory, you don't need shell-command-to-string at all. If the function is made simple enough and portable across operating systems where the Godot engine runs, then a lambda version of it can be added to eglot.el IMO. But it's really better to add it to gdscript-mode.el, wherever it is maintained. Jo=C3=A3o