* bug#62795: 29.0.90; eglot: gdscript default port is 6005
@ 2023-04-12 10:33 xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-15 8:07 ` Eli Zaretskii
0 siblings, 1 reply; 18+ messages in thread
From: xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-04-12 10:33 UTC (permalink / raw)
To: 62795
[-- Attachment #1: Type: text/plain, Size: 210 bytes --]
The default port for godot lsp is defined in gdscript_language_server.h file:
:
> bool use_thread = false;
> String host = "127.0.0.1";
> int port = 6005;
> static void thread_main(void *p_userdata);
patch:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Change gdscript lsp port --]
[-- Type: text/x-patch, Size: 819 bytes --]
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 10b6c0cc2ca..f61040af636 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -230,7 +230,7 @@ eglot-server-programs
(erlang-mode . ("erlang_ls" "--transport" "stdio"))
((yaml-ts-mode yaml-mode) . ("yaml-language-server" "--stdio"))
(nix-mode . ,(eglot-alternatives '("nil" "rnix-lsp")))
- (gdscript-mode . ("localhost" 6008))
+ (gdscript-mode . ("localhost" 6005))
((fortran-mode f90-mode) . ("fortls"))
(futhark-mode . ("futhark" "lsp"))
(lua-mode . ,(eglot-alternatives
[-- Attachment #3: Type: text/plain, Size: 268 bytes --]
In GNU Emacs 29.0.90 (build 3, x86_64-pc-linux-gnu, GTK+ Version
3.24.37, cairo version 1.17.8) of 2023-04-12 built on xiliuya-pc
Repository revision: 7972b76c2c7426745fad8ea0fc9325f475f728b6
Repository branch: makepkg
System Description: Arch Linux
--
xiliuya :)
^ permalink raw reply related [flat|nested] 18+ messages in thread
* bug#62795: 29.0.90; eglot: gdscript default port is 6005
2023-04-12 10:33 bug#62795: 29.0.90; eglot: gdscript default port is 6005 xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-04-15 8:07 ` Eli Zaretskii
2023-04-15 8:17 ` João Távora
0 siblings, 1 reply; 18+ messages in thread
From: Eli Zaretskii @ 2023-04-15 8:07 UTC (permalink / raw)
To: xiliuya, João Távora; +Cc: 62795
> Date: Wed, 12 Apr 2023 18:33:01 +0800
> From: xiliuya via "Bug reports for GNU Emacs,
> the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>
> The default port for godot lsp is defined in gdscript_language_server.h file:
> :
> > bool use_thread = false;
> > String host = "127.0.0.1";
> > int port = 6005;
> > static void thread_main(void *p_userdata);
> patch:
>
> diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
> index 10b6c0cc2ca..f61040af636 100644
> --- a/lisp/progmodes/eglot.el
> +++ b/lisp/progmodes/eglot.el
> @@ -230,7 +230,7 @@ eglot-server-programs
> (erlang-mode . ("erlang_ls" "--transport" "stdio"))
> ((yaml-ts-mode yaml-mode) . ("yaml-language-server" "--stdio"))
> (nix-mode . ,(eglot-alternatives '("nil" "rnix-lsp")))
> - (gdscript-mode . ("localhost" 6008))
> + (gdscript-mode . ("localhost" 6005))
> ((fortran-mode f90-mode) . ("fortls"))
> (futhark-mode . ("futhark" "lsp"))
> (lua-mode . ,(eglot-alternatives
João, should I install this? Any idea why eglot.el uses an incorrect
or outdated value?
^ permalink raw reply [flat|nested] 18+ messages in thread
* bug#62795: 29.0.90; eglot: gdscript default port is 6005
2023-04-15 8:07 ` Eli Zaretskii
@ 2023-04-15 8:17 ` João Távora
2023-04-15 12:19 ` xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 18+ messages in thread
From: João Távora @ 2023-04-15 8:17 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 62795, xiliuya
On Sat, Apr 15, 2023 at 9:07 AM Eli Zaretskii <eliz@gnu.org> wrote:
>
> > Date: Wed, 12 Apr 2023 18:33:01 +0800
> > From: xiliuya via "Bug reports for GNU Emacs,
> > the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
> >
> > The default port for godot lsp is defined in gdscript_language_server.h file:
> > :
> > > bool use_thread = false;
> > > String host = "127.0.0.1";
> > > int port = 6005;
> > > static void thread_main(void *p_userdata);
> > patch:
> >
> > diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
> > index 10b6c0cc2ca..f61040af636 100644
> > --- a/lisp/progmodes/eglot.el
> > +++ b/lisp/progmodes/eglot.el
> > @@ -230,7 +230,7 @@ eglot-server-programs
> > (erlang-mode . ("erlang_ls" "--transport" "stdio"))
> > ((yaml-ts-mode yaml-mode) . ("yaml-language-server" "--stdio"))
> > (nix-mode . ,(eglot-alternatives '("nil" "rnix-lsp")))
> > - (gdscript-mode . ("localhost" 6008))
> > + (gdscript-mode . ("localhost" 6005))
> > ((fortran-mode f90-mode) . ("fortls"))
> > (futhark-mode . ("futhark" "lsp"))
> > (lua-mode . ,(eglot-alternatives
>
> João, should I install this? Any idea why eglot.el uses an incorrect
> or outdated value?
I don't know. It would be very hard to know. Should Eglot not
work with those presumably older versions of whichever server is
running in localhost?
This is a very poor entry anyway in the db anyway. I didn't even notice
that it's just assuming whatever is on localhost on that port is the
gdscript server. IMO we shouldn't touch it, but I suggest to xiliuya
to show the output of "whatever-executable-launches-the-server --help".
If that executable allows specifying a port, which is probably does
then the :autoport solution can be used like in the ruby entry.
And then we can commit that solution.
Else, I even think this should be just removed entirely
from eglot-server-programs. My intuition tells me it was added by
someone who just wanted eglot-ensure to work for them, but it's
very very brittle. And that person could have easily added that
entry to the config in their configuration.
So in summary, no I don't think Eglot should be tracking this.
João
^ permalink raw reply [flat|nested] 18+ messages in thread
* bug#62795: 29.0.90; eglot: gdscript default port is 6005
2023-04-15 8:17 ` João Távora
@ 2023-04-15 12:19 ` xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-15 13:13 ` João Távora
0 siblings, 1 reply; 18+ messages in thread
From: xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-04-15 12:19 UTC (permalink / raw)
To: João Távora; +Cc: Eli Zaretskii, 62795
João Távora <joaotavora@gmail.com> writes:
> On Sat, Apr 15, 2023 at 9:07 AM Eli Zaretskii <eliz@gnu.org> wrote:
> This is a very poor entry anyway in the db anyway. I didn't even notice
> that it's just assuming whatever is on localhost on that port is the
> gdscript server. IMO we shouldn't touch it, but I suggest to xiliuya
> to show the output of "whatever-executable-launches-the-server --help".
The GDScript language server is in Godot Engine.
> If that executable allows specifying a port, which is probably does
> then the :autoport solution can be used like in the ruby entry.
> And then we can commit that solution.
Yes, I can try changing the port in Godot as well.
Perhaps you need to wait until the GDScript language server is a separate
executable, such as clangd, before making changes?
--
xiliuya :)
^ permalink raw reply [flat|nested] 18+ messages in thread
* bug#62795: 29.0.90; eglot: gdscript default port is 6005
2023-04-15 12:19 ` xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-04-15 13:13 ` João Távora
2023-04-15 13:28 ` xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-16 3:48 ` xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 2 replies; 18+ messages in thread
From: João Távora @ 2023-04-15 13:13 UTC (permalink / raw)
To: xiliuya; +Cc: Eli Zaretskii, 62795
On Sat, Apr 15, 2023 at 1:43 PM xiliuya <xiliuya@aliyun.com> wrote:
> The GDScript language server is in Godot Engine.
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.
And are you sure that port has never been 6008? If
that was just a mistake, then I think we should change,
yes. But please let's not change this back and forth
every 3 months, or add alternatives for every positive
integer.
> Perhaps you need to wait until the GDScript language
> server is a separate executable, such as clangd, before
> making changes?
That would also be very good, yes. But the function idea
is also very good if the GDScript language server doesn't
have intentions to switch to this format soon
João
^ permalink raw reply [flat|nested] 18+ messages in thread
* bug#62795: 29.0.90; eglot: gdscript default port is 6005
2023-04-15 13:13 ` João Távora
@ 2023-04-15 13:28 ` xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-15 14:04 ` xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-16 3:48 ` xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
1 sibling, 1 reply; 18+ messages in thread
From: xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-04-15 13:28 UTC (permalink / raw)
To: João Távora; +Cc: Eli Zaretskii, 62795
João Távora <joaotavora@gmail.com> 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.
Yeah, that's a great idea.
Execute shell command `ss -lnpt | grep godot | awk -F':' '{print $2}' | awk '{print $1}'`
Will output:
6006
6005
The default port 6006 is an LSP port.
The default port 6005 is the Debug Adapter port.
> And are you sure that port has never been 6008? If
> that was just a mistake, then I think we should change,
> yes. But please let's not change this back and forth
> every 3 months, or add alternatives for every positive
> integer.
I checked the historical submission of Godot and found that
the default LSP port has been changed from 6005 to 6008,
which was submitted in Dec 5, 2021:
https://github.com/godotengine/godot/commit/de7873c2d87c3ee8af8c27e35f49767fcc384e75
--
xiliuya :)
^ permalink raw reply [flat|nested] 18+ messages in thread
* bug#62795: 29.0.90; eglot: gdscript default port is 6005
2023-04-15 13:28 ` xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-04-15 14:04 ` xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 0 replies; 18+ messages in thread
From: xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-04-15 14:04 UTC (permalink / raw)
To: xiliuya; +Cc: Eli Zaretskii, João Távora, 62795
xiliuya <xiliuya@aliyun.com> writes:
> The default port 6006 is an LSP port.
> The default port 6005 is the Debug Adapter port.
Sorry, typo.
The default port 6005 is an LSP port.
The default port 6006 is the Debug Adapter port.
--
xiliuya :)
^ permalink raw reply [flat|nested] 18+ messages in thread
* bug#62795: 29.0.90; eglot: gdscript default port is 6005
2023-04-15 13:13 ` João Távora
2023-04-15 13:28 ` xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-04-16 3:48 ` xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-16 5:49 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
1 sibling, 1 reply; 18+ messages in thread
From: xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-04-16 3:48 UTC (permalink / raw)
To: João Távora; +Cc: Eli Zaretskii, 62795
João Távora <joaotavora@gmail.com> 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'=' '/network\\/language_server\\/remote_port/ {print $2;}' $HOME/.config/godot/editor_settings-4.tres")))
(lsp-list (cons 'gdscript-mode (list "localhost" lsp-port
))))
(push lsp-list
eglot-server-programs)))
-----
--
xiliuya :)
^ permalink raw reply [flat|nested] 18+ messages in thread
* bug#62795: 29.0.90; eglot: gdscript default port is 6005
2023-04-16 3:48 ` xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-04-16 5:49 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-16 6:16 ` xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
` (2 more replies)
0 siblings, 3 replies; 18+ messages in thread
From: Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-04-16 5:49 UTC (permalink / raw)
To: xiliuya; +Cc: Eli Zaretskii, João Távora, 62795
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 editors" <bug-gnu-emacs@gnu.org> writes:
> João Távora <joaotavora@gmail.com> 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'=' '/network\\/language_server\\/remote_port/ {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ão seems to be hinting: creating a function that guesses (in our
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.
--
Best,
RY
^ permalink raw reply [flat|nested] 18+ messages in thread
* bug#62795: 29.0.90; eglot: gdscript default port is 6005
2023-04-16 5:49 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-04-16 6:16 ` xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-16 7:36 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-16 11:08 ` João Távora
2023-04-16 11:16 ` João Távora
2 siblings, 1 reply; 18+ messages in thread
From: xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-04-16 6:16 UTC (permalink / raw)
To: Ruijie Yu; +Cc: Eli Zaretskii, João Távora, 62795
Ruijie Yu <ruijie@netyu.xyz> writes:
> 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?
The "_4" suffix refers to the godot version number.
```
Godot3: editor_settings-3.tres
Godot4: editor_settings-4.tres
```
The default configuration file is not provided with the installation
package,but is automatically generated under `$HOME/.config/godot`
after `godot` starts.
> 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.
So should gdscript-mode handle this function?
--
xiliuya :)
^ permalink raw reply [flat|nested] 18+ messages in thread
* bug#62795: 29.0.90; eglot: gdscript default port is 6005
2023-04-16 6:16 ` xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-04-16 7:36 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-16 8:57 ` xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 18+ messages in thread
From: Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-04-16 7:36 UTC (permalink / raw)
To: xiliuya; +Cc: Eli Zaretskii, João Távora, 62795
On Apr 16, 2023, at 14:28, xiliuya <xiliuya@aliyun.com> wrote:
>
>
> Ruijie Yu <ruijie@netyu.xyz> writes:
>
>> 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?
>
> The "_4" suffix refers to the godot version number.
> ```
> Godot3: editor_settings-3.tres
> Godot4: editor_settings-4.tres
>
> ```
> The default configuration file is not provided with the installation
> package,but is automatically generated under `$HOME/.config/godot`
> after `godot` starts.
Great, that means the function only needs to look at one particular file which is guaranteed to exist unless the lsp server is not run. Note, though, that there might be a need for a defcustom on the godot version in effect because it is possible that a user does not have the newest environment installed, right?
>> 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.
>
> So should gdscript-mode handle this function?
That is my opinion as someone who happens to regularly use Emacs in the past few years. This should be João’s decision to make, since he is the maintainer of eglot.
> --
> xiliuya :)
--
Best,
RY
^ permalink raw reply [flat|nested] 18+ messages in thread
* bug#62795: 29.0.90; eglot: gdscript default port is 6005
2023-04-16 7:36 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-04-16 8:57 ` xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 0 replies; 18+ messages in thread
From: xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-04-16 8:57 UTC (permalink / raw)
To: Ruijie Yu; +Cc: Eli Zaretskii, João Távora, 62795
Ruijie Yu <ruijie@netyu.xyz> writes:
> Great, that means the function only needs to look at one particular
> file which is guaranteed to exist unless the lsp server is not run.
> Note, though, that there might be a need for a defcustom on the godot
> version in effect because it is possible that a user does not have the
> newest environment installed, right?
Yes, new users must start the `Godot engine` to generate this file.
After the `Godot engine` starts and opens the project file,
the `Gdscript LSP` opens and enables the port.
> That is my opinion as someone who happens to regularly use Emacs in
> the past few years. This should be João’s decision to make, since he
> is the maintainer of eglot.
>
>> --
>> xiliuya :)
--
xiliuya :)
^ permalink raw reply [flat|nested] 18+ messages in thread
* bug#62795: 29.0.90; eglot: gdscript default port is 6005
2023-04-16 5:49 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-16 6:16 ` xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-04-16 11:08 ` João Távora
2023-04-16 12:29 ` xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-16 11:16 ` João Távora
2 siblings, 1 reply; 18+ messages in thread
From: João Távora @ 2023-04-16 11:08 UTC (permalink / raw)
To: Ruijie Yu; +Cc: Eli Zaretskii, 62795, xiliuya
Ruijie Yu <ruijie@netyu.xyz> 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 editors" <bug-gnu-emacs@gnu.org> writes:
>
>> João Távora <joaotavora@gmail.com> 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'=' '/network\\/language_server\\/remote_port/ {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'=' '/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:
[...]
* A list (HOST PORT [TCP-ARGS...]) where HOST is a string and
PORT is a positive integer for connecting to a server via TCP.
[...]
* 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ão
^ permalink raw reply [flat|nested] 18+ messages in thread
* bug#62795: 29.0.90; eglot: gdscript default port is 6005
2023-04-16 5:49 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-16 6:16 ` xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-16 11:08 ` João Távora
@ 2023-04-16 11:16 ` João Távora
2 siblings, 0 replies; 18+ messages in thread
From: João Távora @ 2023-04-16 11:16 UTC (permalink / raw)
To: Ruijie Yu; +Cc: Eli Zaretskii, 62795, xiliuya
Ruijie Yu <ruijie@netyu.xyz> writes:
> I am looking at the last bullet point of `eglot-server-programs', at
> which João seems to be hinting: creating a function that guesses (in our
> case, look into config files to search for) the correct port number for
> this lsp server.
Exactly. In the meantime I have already supplied the solution to this
hint, along with some other comments.
> 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)))))
> ```
That's the idea, though it's missing the second argument to 'push'.
> 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.
Right.
^ permalink raw reply [flat|nested] 18+ messages in thread
* bug#62795: 29.0.90; eglot: gdscript default port is 6005
2023-04-16 11:08 ` João Távora
@ 2023-04-16 12:29 ` xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-17 7:33 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 18+ messages in thread
From: xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-04-16 12:29 UTC (permalink / raw)
To: João Távora; +Cc: Ruijie Yu, Eli Zaretskii, 62795
João Távora <joaotavora@gmail.com> writes:
> If it's not clear, let us know.
Yes, that's clear. It was my misunderstanding.
> 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.
I have modified it according to your suggestion, is that OK?
I tested it locally and it works.
```emacs-lisp
(defun gdscript-eglot-contact (&optional _interactive)
"Produce a suitable value for LSP contact in `eglot-server-programs'."
(list "localhost"
(string-to-number
(with-temp-buffer
(insert-file-contents
(expand-file-name "~/.config/godot/editor_settings-4.tres"))
(goto-char (point-min))
(goto-char (+ 39 (string-match
"network/language_server/remote_port"
(buffer-string))))
(buffer-substring
(point)
(line-end-position))))))
```
> 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ão
I submitted this question to the gdscript-mode codebase, but haven't
heard back yet.
[issues/121](https://github.com/godotengine/emacs-gdscript-mode/issues/121)
--
xiliuya :)
^ permalink raw reply [flat|nested] 18+ messages in thread
* bug#62795: 29.0.90; eglot: gdscript default port is 6005
2023-04-16 12:29 ` xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-04-17 7:33 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-17 8:43 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 18+ messages in thread
From: Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-04-17 7:33 UTC (permalink / raw)
To: xiliuya; +Cc: Eli Zaretskii, João Távora, 62795
xiliuya via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org> writes:
> I have modified it according to your suggestion, is that OK?
> I tested it locally and it works.
>
> ```emacs-lisp
> (defun gdscript-eglot-contact (&optional _interactive)
> "Produce a suitable value for LSP contact in `eglot-server-programs'."
> (list "localhost"
> (string-to-number
> (with-temp-buffer
> (insert-file-contents
> (expand-file-name "~/.config/godot/editor_settings-4.tres"))
> (goto-char (point-min))
> (goto-char (+ 39 (string-match
> "network/language_server/remote_port"
> (buffer-string))))
> (buffer-substring
> (point)
> (line-end-position))))))
> ```
>
>> 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ão
>
> I submitted this question to the gdscript-mode codebase, but haven't
> heard back yet.
> [issues/121](https://github.com/godotengine/emacs-gdscript-mode/issues/121)
I'll try to file a PR in that repo for this function within a few hours,
will send an update to this thread when done.
--
Best,
RY
^ permalink raw reply [flat|nested] 18+ messages in thread
* bug#62795: 29.0.90; eglot: gdscript default port is 6005
2023-04-17 7:33 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-04-17 8:43 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-17 13:22 ` xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 18+ messages in thread
From: Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-04-17 8:43 UTC (permalink / raw)
To: Ruijie Yu; +Cc: 62795, Eli Zaretskii, João Távora, xiliuya
Ruijie Yu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org> writes:
>> I submitted this question to the gdscript-mode codebase, but haven't
>> heard back yet.
>> [issues/121](https://github.com/godotengine/emacs-gdscript-mode/issues/121)
>
> I'll try to file a PR in that repo for this function within a few hours,
> will send an update to this thread when done.
Update: PR submitted, waiting for review. See
https://github.com/godotengine/emacs-gdscript-mode/pull/122 .
--
Best,
RY
^ permalink raw reply [flat|nested] 18+ messages in thread
* bug#62795: 29.0.90; eglot: gdscript default port is 6005
2023-04-17 8:43 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-04-17 13:22 ` xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 0 replies; 18+ messages in thread
From: xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-04-17 13:22 UTC (permalink / raw)
To: Ruijie Yu; +Cc: Eli Zaretskii, João Távora, 62795
Ruijie Yu <ruijie@netyu.xyz> writes:
> Ruijie Yu via "Bug reports for GNU Emacs, the Swiss army knife of text
> editors" <bug-gnu-emacs@gnu.org> writes:
>
>>> I submitted this question to the gdscript-mode codebase, but haven't
>>> heard back yet.
>>> [issues/121](https://github.com/godotengine/emacs-gdscript-mode/issues/121)
>>
>> I'll try to file a PR in that repo for this function within a few hours,
>> will send an update to this thread when done.
>
> Update: PR submitted, waiting for review. See
> https://github.com/godotengine/emacs-gdscript-mode/pull/122 .
Yes, that solves my problem, thank you very much.
--
xiliuya :)
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2023-04-17 13:22 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-12 10:33 bug#62795: 29.0.90; eglot: gdscript default port is 6005 xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-15 8:07 ` Eli Zaretskii
2023-04-15 8:17 ` João Távora
2023-04-15 12:19 ` xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-15 13:13 ` João Távora
2023-04-15 13:28 ` xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-15 14:04 ` xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-16 3:48 ` xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-16 5:49 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-16 6:16 ` xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-16 7:36 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-16 8:57 ` xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-16 11:08 ` João Távora
2023-04-16 12:29 ` xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-17 7:33 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-17 8:43 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-17 13:22 ` xiliuya via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-16 11:16 ` João Távora
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.