mirror of
https://github.com/godotengine/emacs-gdscript-mode.git
synced 2026-01-05 22:10:05 +03:00
Merge pull request #173 from Passky/master
This commit is contained in:
@@ -38,30 +38,41 @@
|
|||||||
:group 'gdscript)
|
:group 'gdscript)
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defcustom gdscript-eglot-version "4.3"
|
(defcustom gdscript-eglot-version "4.5"
|
||||||
"The version of godot in use."
|
"The version of godot in use."
|
||||||
:type 'string)
|
:type 'string)
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defcustom gdscript-eglot-default-lsp-port 6005
|
||||||
|
"The default port for eglot to connect when extraction fails."
|
||||||
|
:type 'integer
|
||||||
|
:group 'gdscript-eglot)
|
||||||
|
|
||||||
(defun gdscript-eglot--get-config-dir ()
|
(defun gdscript-eglot--get-config-dir ()
|
||||||
"Get system-specific directory with Godot configuration files."
|
"Get system-specific directory with Godot configuration files."
|
||||||
(pcase system-type
|
(pcase system-type
|
||||||
('darwin "~/Library/Application Support/Godot/")
|
('darwin (expand-file-name "~/Library/Application Support/Godot/"))
|
||||||
('windows-nt (substitute-in-file-name "$APPDATA/Godot/"))
|
('windows-nt (file-name-concat (getenv "APPDATA") "Godot"))
|
||||||
('gnu/linux (file-name-concat
|
('gnu/linux (file-name-concat
|
||||||
(or (getenv "XDG_CONFIG_HOME") "~/.config/")
|
(or (getenv "XDG_CONFIG_HOME") (expand-file-name "~/.config"))
|
||||||
"godot"))))
|
"godot"))))
|
||||||
|
|
||||||
(defun gdscript-eglot--extract-port (editor-settings-file)
|
(defun gdscript-eglot--extract-port (editor-settings-file)
|
||||||
"Extract LSP port from Godot editor settings file."
|
"Extract LSP port from Godot EDITOR-SETTINGS-FILE.
|
||||||
(when (file-exists-p editor-settings-file)
|
If extraction fails, return `gdscript-eglot-default-port'.
|
||||||
(with-temp-buffer
|
NOTE: remote_port value only presents if it has been modified from the default value,
|
||||||
(insert-file-contents editor-settings-file)
|
So this extract shall fail by default."
|
||||||
(when (re-search-forward
|
(or
|
||||||
(rx "network/language_server/remote_port"
|
(when (file-exists-p editor-settings-file)
|
||||||
(* space) ?= (* space)
|
(with-temp-buffer
|
||||||
(group (+ digit)))
|
(insert-file-contents editor-settings-file)
|
||||||
nil t)
|
(when (re-search-forward
|
||||||
(string-to-number (match-string 1))))))
|
(rx "network/language_server/remote_port"
|
||||||
|
(* space) ?= (* space)
|
||||||
|
(group (+ digit)))
|
||||||
|
nil t)
|
||||||
|
(string-to-number (match-string 1)))))
|
||||||
|
gdscript-eglot-default-lsp-port))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun gdscript-eglot-contact (_interactive)
|
(defun gdscript-eglot-contact (_interactive)
|
||||||
@@ -77,7 +88,7 @@ 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-let ((port (gdscript-eglot--extract-port settings-file)))
|
(when-let* ((port (gdscript-eglot--extract-port settings-file)))
|
||||||
(list "localhost" port)))))
|
(list "localhost" port)))))
|
||||||
|
|
||||||
(provide 'gdscript-eglot)
|
(provide 'gdscript-eglot)
|
||||||
|
|||||||
Reference in New Issue
Block a user