Configure initializationOptions
per project
#1135
Replies: 3 comments 6 replies
-
Hello,
If rust-analyzer can indeed only read project-specific data via
`initializationOptions` (and not something more usual such as
workspaceConfiguration) then your best option is to set
eglot-server-programs directory-locally. In each directory where
you need a different rust-analyzer initialization, set
eglot-server-programs for 'rust-mode' in a way that includes a
:initializationOptions (presumably a slightly different one for
each project).
See the https://joaotavora.github.io/eglot/#Setting-Up-LSP-Servers
Hopefully it is clear what the "JSON object" is there. It's constructed
in a syntax identical to the one used for workspaceConfiguration,
which is described later in the manual.
João
|
Beta Was this translation helpful? Give feedback.
-
This is generally not true. Last time I looked, intializaionOptions was only necessary to set the location of the rustfmt executable. See #845 |
Beta Was this translation helpful? Give feedback.
-
@rbartlensky you might be interested by the "Experimental setup" section of #1214. This is my solution for per project initialization options. It might not be exactly what you want because I'm only interested in dynamically changing the options. In particular I don't persist them, which means that restarting emacs would lose any configuration. Maybe I'll add such feature if I need it, but so far I'm fine doing |
Beta Was this translation helpful? Give feedback.
-
Hi!
I am trying to implement a way to have eglot read a file, like
.dir-locals.el
, but forinitializationOptions
.I have attempted to implement this in
rustic
(PR), but the author suggested that maybe this can become aneglot
feature.My usecase is that I want to configure rust-analyzer on a per-project basis. Since rust-analyzer can only be configured via
initializationOptions
, there is no way to currently add the desired options into something like.dir-locals.el
. Do you have any thoughts on this?Beta Was this translation helpful? Give feedback.
All reactions