bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#61868: 29.0.60; Eglot: setting "workspace" configurations should be


From: Augusto Stoffel
Subject: bug#61868: 29.0.60; Eglot: setting "workspace" configurations should be easier
Date: Tue, 28 Feb 2023 13:49:55 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Arranging for Eglot to send the correct configuration via the
`eglot-signal-didChangeConfiguration' command or
`eglot-workspace-configuration' variable is very tricky and error prone.

The following command, which reads a configuration plist from the
minibuffer with history, makes this trial and error process much easier
for me:

  (defvar eglot-edit-workspace-configuration--history nil)
  (defun eglot-edit-workspace-configuration ()
    (interactive)
    (let* ((server (eglot-current-server))
           (config (read-from-minibuffer
                    (format "New configuration for `%s': "
                            (eglot-project-nickname server))
                    (when-let ((old (eglot--workspace-configuration-plist 
server)))
                      (concat "\n" (pp-to-string old)))
                    minibuffer-local-map t
                    'eglot-edit-workspace-configuration--history)))
      (setq-local eglot-workspace-configuration config)
      (save-window-excursion
        (let ((default-directory (project-root (eglot--current-project))))
          (add-dir-local-variable nil 'eglot-workspace-configuration config)
          (save-buffer)))
      (eglot-signal-didChangeConfiguration server)))

I would suggest adding a refined version of this, using a regular buffer
for input.  Moreover, one could allow editing the configuration as a
JSON (perhaps also retaining the option to edit as a plist).  This would
be a natural extension of the existing
`eglot-show-workspace-configuration' command.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]