Skip to content
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

lsp-defcustom not compatible with setting local variables #4337

Open
3 tasks done
brownts opened this issue Feb 18, 2024 · 0 comments · May be fixed by #4349
Open
3 tasks done

lsp-defcustom not compatible with setting local variables #4337

brownts opened this issue Feb 18, 2024 · 0 comments · May be fixed by #4349
Labels

Comments

@brownts
Copy link
Contributor

brownts commented Feb 18, 2024

Thank you for the bug report

  • I am using the latest version of lsp-mode related packages.
  • I checked FAQ and Troubleshooting sections
  • You may also try reproduce the issue using clean environment using the following command: M-x lsp-start-plain

Bug description

LSP servers which need to be configured by a directory local variable (e.g., project file for Ada LS), aren't initialized correctly when that configuration is set using a normal directory local variable. This happens even when delaying the initialization of lsp to the hack-local-variables-hook as specified in the FAQ. The reason for this is that lsp-defcustom utilizes a custom set function which invokes lsp-register-custom-settings, and this setter is not invoked using the hack-local-variables initialization, which just creates a buffer local variable (via make-local-variable).

I've been able to work around this by using eval and setopt in my .dir-locals.el to cause the setter to be invoked, like this:

;;; Directory Local Variables            -*- no-byte-compile: t -*-
;;; For more information see (info "(emacs) Directory Variables")

((ada-ts-mode . ((eval . (setopt lsp-ada-project-file "src/gtkada.gpr")))))

However, I think it might be better for lsp-mode to look through the buffer local variables when it starts up and call the setter for any of them which correlate to an lsp-defcustom. That would allow the normal setting of directory local variables to work without resorting to eval and setopt as demonstrated above.

Steps to reproduce

Setting a directory local variable in the normal way for a lsp-defcustom (i.e., lsp-ada-project-file) should cause the issue to be observed. Using this approach, the lsp-defcustom's default value (e.g., "default.gpr") is used when first connecting with the server.

Expected behavior

I expect the value specified in the directory-local variable to be used when communicating with the server.

Which Language Server did you use?

Ada Language Server

OS

Linux

Error callstack

No response

Anything else?

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant