mirror of
https://github.com/godotengine/emacs-gdscript-mode.git
synced 2026-01-04 18:09:55 +03:00
Add gdscript-eglot--extract-port function
This commit is contained in:
@@ -50,6 +50,17 @@
|
|||||||
(or (getenv "XDG_CONFIG_HOME") "~/.config/")
|
(or (getenv "XDG_CONFIG_HOME") "~/.config/")
|
||||||
"godot"))))
|
"godot"))))
|
||||||
|
|
||||||
|
(defun gdscript-eglot--extract-port (editor-settings-file)
|
||||||
|
(when (file-exists-p editor-settings-file)
|
||||||
|
(with-temp-buffer
|
||||||
|
(insert-file-contents editor-settings-file)
|
||||||
|
(when (re-search-forward
|
||||||
|
(rx "network/language_server/remote_port"
|
||||||
|
(* space) ?= (* space)
|
||||||
|
(group (+ digit)))
|
||||||
|
nil t)
|
||||||
|
(string-to-number (match-string 1))))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun gdscript-eglot-contact (_interactive)
|
(defun gdscript-eglot-contact (_interactive)
|
||||||
"Attempt to help `eglot' contact the running gdscript LSP.
|
"Attempt to help `eglot' contact the running gdscript LSP.
|
||||||
@@ -64,16 +75,8 @@ https://lists.gnu.org/archive/html/bug-gnu-emacs/2023-04/msg01070.html."
|
|||||||
(settings-file (file-name-concat
|
(settings-file (file-name-concat
|
||||||
config-dir
|
config-dir
|
||||||
(format "editor_settings-%s.tres" gdscript-eglot-version))))
|
(format "editor_settings-%s.tres" gdscript-eglot-version))))
|
||||||
(when (file-exists-p settings-file)
|
(when-let ((port (gdscript-eglot--extract-port settings-file)))
|
||||||
(when-let ((port (with-temp-buffer
|
(list "localhost" port)))))
|
||||||
(insert-file-contents settings-file)
|
|
||||||
(when (re-search-forward
|
|
||||||
(rx "network/language_server/remote_port"
|
|
||||||
(* space) ?= (* space)
|
|
||||||
(group (+ digit)))
|
|
||||||
nil t)
|
|
||||||
(string-to-number (match-string 1))))))
|
|
||||||
(list "localhost" port))))))
|
|
||||||
|
|
||||||
(provide 'gdscript-eglot)
|
(provide 'gdscript-eglot)
|
||||||
;;; gdscript-eglot.el ends here.
|
;;; gdscript-eglot.el ends here.
|
||||||
|
|||||||
Reference in New Issue
Block a user