-
-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting formatter via initializationOptions doesn't work #101
Comments
I have the same issue with the same setup. |
I also observe that automatic formatting is broken with |
I'm not familiar with emacs but the log seems weird since it sends Could you set env var |
I have this working with the following config. looks like, when you set (use-package eglot
:ensure nil
:after inheritenv
:hook
(prog-mode . eglot-ensure)
(prog-mode . (lambda () (add-hook 'before-save-hook 'eglot-format nil t)))
:config
(with-eval-after-load 'eglot
(dolist (mode '((nix-mode . ("nil" :initializationOptions
(:formatting (:command [ "nixpkgs-fmt" ]))))))
(add-to-list 'eglot-server-programs mode)))) |
@cmacrae This might be irrelevant to the original issue, but I had some problems setting this up. I did it without using the |
@yzhou216 glad it works for you :) without |
@cmacrae Thank you for the explanation! That was very helpful :) |
Overview
I'm not sure if I'm doing it wrong or if there's a bug in either nil or Emacs eglot, so I'm hoping you can help me. I'm trying to switch from lsp-mode to eglot with Emacs 29 and I can't seem to get initialization-time formatter configuration to work. I expect that calling
eglot-format-buffer
should work regardless of whether the formatter is configured during initialization or at run-time, but only the latter does anything.For reference, here's an online version of eglot's info page: https://joaotavora.github.io/eglot/#User_002dspecific-configuration
Version info:
Broken: initializationOptions
Config:
LSP messages shown after loading a nix file and running
eglot-format-buffer
:I notice there's a
workspace/didChangeConfiguration
message here, even though I'm not telling eglot to do that sinceeglot-workspace-configuration
is nil, but I think(:settings #s(hash-table size 1 test eql rehash-size 1.5 rehash-threshold 0.8125 data ())))
represents an empty table?Working: post-initialization settings
If I use this config instead, formatting works:
Messages:
The text was updated successfully, but these errors were encountered: