From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ruijie Yu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#62795: 29.0.90; eglot: gdscript default port is 6005 Date: Sun, 16 Apr 2023 13:49:27 +0800 Message-ID: References: <87zg7dido0.fsf@aliyun.com> <83cz45efgq.fsf@gnu.org> <87pm8548pb.fsf@aliyun.com> <87ttxg4hd9.fsf@aliyun.com> Reply-To: Ruijie Yu 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="22527"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.9.22; emacs 30.0.50 Cc: Eli Zaretskii , =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= , 62795@debbugs.gnu.org To: xiliuya Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Apr 16 07:51:24 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 1pnvII-0005bo-6g for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 16 Apr 2023 07:51:22 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pnvI3-0001D5-Sf; Sun, 16 Apr 2023 01:51:08 -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 1pnvI1-0001Cj-EH for bug-gnu-emacs@gnu.org; Sun, 16 Apr 2023 01:51:06 -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 1pnvHy-0004r2-Qf for bug-gnu-emacs@gnu.org; Sun, 16 Apr 2023 01:51:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pnvHy-0004Am-5e for bug-gnu-emacs@gnu.org; Sun, 16 Apr 2023 01:51:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ruijie Yu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 16 Apr 2023 05:51:02 +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.168162422314993 (code B ref 62795); Sun, 16 Apr 2023 05:51:02 +0000 Original-Received: (at 62795) by debbugs.gnu.org; 16 Apr 2023 05:50:23 +0000 Original-Received: from localhost ([127.0.0.1]:50474 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pnvHL-0003tj-1K for submit@debbugs.gnu.org; Sun, 16 Apr 2023 01:50:23 -0400 Original-Received: from netyu.xyz ([152.44.41.246]:46100 helo=mail.netyu.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pnvHI-0003tW-Rw for 62795@debbugs.gnu.org; Sun, 16 Apr 2023 01:50:21 -0400 Original-Received: from fw.net.yu.netyu.xyz ( [222.248.4.98]) by netyu.xyz (OpenSMTPD) with ESMTPSA id 9e93e8ff (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sun, 16 Apr 2023 05:50:18 +0000 (UTC) In-reply-to: <87ttxg4hd9.fsf@aliyun.com> 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:260091 Archived-At: 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 editor= s" 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_po= rt/ {print $2;}' $HOME/.config/godot/editor_settings-4.tres"))) > (lsp-list (cons 'gdscript-mode (list "localhost" lsp-port > )))) > (push lsp-list > eglot-server-programs))) > ----- This is a user-local config file, with an interesting "_4" in its name. Is it possible to have other numbers attached to the file name? Does it have a global default port for which we can search? Something like "/usr/share/godot/..." or "/etc/godot/..."? Also, from your original report, there seems to be a default value compiled into its C/C++ source. Is there any chance to retrieve that value from a distributed package? I am looking at the last bullet point of `eglot-server-programs', at which Jo=C3=A3o seems to be hinting: creating a function that guesses (in o= ur case, look into config files to search for) the correct port number for this lsp server. I don't have this language environment setup nor even the gdscript-mode library installed, but my guess is that this skeleton code should be in gdscript-mode (modulo all my naming choices): ```emacs-lisp (defun gdscript-mode-find-lsp (interactive-p) (let (port) ;; search for the port in this order: $XDG_CONFIG_HOME, /etc, /usr. ;; This uses some regexp extracted from your awk expression. (ignore port 'todo) ;; then return the host-port list when found (and port (list "localhost" port)))) ``` One thing remains for eglot to decide (IMO), is what happens to the eglot entry. Do we do one of the two methods below, or is there a better way? ```emacs-lisp ;; Method 1: This requires `gdscript-mode-find-lsp' be already defined ;; or autoloaded. (push (cons 'gdscript-mode #'gdscript-mode-find-lsp)) ;; Method 2. (push (cons 'gdscript-mode (lambda (i) (and (require 'gdscript-mode nil t) (fboundp 'gdscript-mode-find-lsp) (gdscript-mode-find-lsp i))))) ``` The rest, including the discussion of how exactly to implement this function, should then be handled in the repo of "gdscript-mode", since it is not part of GNU Elpa nor NonGNU Elpa. --=20 Best, RY