emacs-devel
[Top][All Lists]
Advanced

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

Re: Explain a bit more on how to configure language server in Eglot's ma


From: Augusto Stoffel
Subject: Re: Explain a bit more on how to configure language server in Eglot's manual
Date: Wed, 08 Mar 2023 16:01:17 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

On Wed,  8 Mar 2023 at 13:54, João Távora wrote:

>> > The dotted-to-plist translator proposed is optional.  Some people
>> > requested use of dotted notation and that will surely need a
>> > translator.  I wouldn't use it.
>>
>> Given how selective you are with the features you want to add, I don't
>> understand why you think this particular one should make it in.  It
>> would sure help a little, maybe, sometimes.
>
> I don't understand: didn't you state you _like_ dotted notation?

Yes, as a quick fix.  But you and the circumstances showed that it isn't
nearly good enough.

> A special plist editing mode for a single Eglot variable falls into
> that category, IMNSHO.

By the way, my suggestion is to edit a JSON value, which is what the
server receives, you can copy and paste from other places, and doesn't
require you to know jsonrpc.el internals such as :json-false and the
translation of nil.

> Dotted option notation does not.  It seems to be an LSP practice,

It may be a practice, but the ground truth is a JSON object.

> and I don't see any other good place to put a single utility function
> that facilitates it but in Eglot.

The utility function belongs to map.el.  It is called `assoc-in` in
Clojure.

Speaking of bloat, and I know I shouldn't insist, but a basic version of
the savable eglot-show-workspace-configuration barely adds 30 LOC.

I'm pasting it here in case it helps anybody.

--8<---------------cut here---------------start------------->8---
(defvar-local eglot-wsconf--server nil)

(defvar eglot-wsconf-map
  (let ((map (make-sparse-keymap)))
    (define-key map "\C-c\C-c" #'eglot-wsconf-commit)
    map))

(defun eglot-wsconf-commit ()
  (interactive)
  (let ((wsconf (save-excursion
                  (goto-char (point-min))
                  (jsonrpc--json-read))))
    (save-window-excursion
      (let ((default-directory (project-root (eglot--project 
eglot-wsconf--server)))
            (buffers (buffer-list)))
        (add-dir-local-variable nil 'eglot-workspace-configuration wsconf)
        (save-buffer)
        (if (memq (current-buffer) buffers) (bury-buffer) (kill-buffer))))
    (eglot-signal-didChangeConfiguration eglot-wsconf--server)
    (quit-window t)))

;;;###autoload
(defun eglot-wsconf-edit (server)
  "Edit the language server workspace configuration."
  (interactive (list (eglot--read-server "Show workspace configuration for" t)))
  (pop-to-buffer (eglot-show-workspace-configuration server))
  (use-local-map eglot-wsconf-map)
  (setq-local header-line-format (substitute-command-keys "\
Press \\[eglot-wsconf-commit] to commit changes"))
  (setq eglot-wsconf--server server))
--8<---------------cut here---------------end--------------->8---



reply via email to

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