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

Implement per-server variable bindings #152

Open
mkcms opened this issue Nov 14, 2018 · 8 comments
Open

Implement per-server variable bindings #152

mkcms opened this issue Nov 14, 2018 · 8 comments

Comments

@mkcms
Copy link
Collaborator

mkcms commented Nov 14, 2018

Per #125 (comment)
The idea is to have a way to automatically bind some buffer-local variables for chosen servers.
For example, eglot-move-to-column-function needs to be set for specific servers buffer-locally.

@joaotavora
Copy link
Owner

This should probably be a generic function on the server right?

(cl-defgeneric eglot-server-bindings (server) ...)

sounds right, but what to do when eglot disconnects? Restore the bindings as they were before connection?

@mkcms
Copy link
Collaborator Author

mkcms commented Dec 2, 2018

This should probably be a generic function on the server right?

Hmm, what's wrong with having an alist, like you suggested? I think it would be more user friendly.

what to do when eglot disconnects? Restore the bindings as they were before connection?

I thought we could just set them in eglot--managed-mode and when eglot shuts down, we don't restore anything. I think that for most use cases, users enable eglot in a buffer, and it is connected until the user kills that buffer.

@joaotavora
Copy link
Owner

Hmm, what's wrong with having an alist, like you suggested? I think it would be more user friendly.

The generic function would return an alist.

I thought we could just set them in eglot--managed-mode and when eglot shuts down, we don't restore anything. I think that for most use cases, users enable eglot in a buffer, and it is connected until the user kills that buffer.

Good idea, this seems a reasonable cop-out away from the problem :-)

@joaotavora
Copy link
Owner

The generic function would return an alist.

Perhaps I didn't explain myself very well. ((VAR .VALUE)) is the bindings alist I am thinking of. If you meant an alist ((SERVER . BINDINGS)), then I think that the best way to establish an association between a server and something else, currently, is by using cl-defmethod on the server class.

@mkcms
Copy link
Collaborator Author

mkcms commented Dec 2, 2018

The generic function would return an alist.

A generic function makes sense, I'm just in favor of a variable because, at least for me, they're easier to use. With a generic function I actually have to edit my init file, with a variable I can just edit dir-locals.
You also mentioned here that we could match the server executable.

@joaotavora
Copy link
Owner

A generic function makes sense, I'm just in favor of a variable because, at least for me, they're easier to use. With a generic function I actually have to edit my init file, with a variable I can just edit dir-locals.

But are these variables intended to be set by the user regularly per-project? Or are they properties/quirks of the servers themselves that we sometimes handle in eglot.el?

@mkcms
Copy link
Collaborator Author

mkcms commented Dec 4, 2018

But are these variables intended to be set by the user regularly per-project? Or are they properties/quirks of the servers themselves that we sometimes handle in eglot.el?

Oh, I thought they were meant to be set by users (your suggested variable name implies it, I think). If it's supposed to be set internally by us, then defgeneric would probably be the way to go... Although maintaining different server variables in eglot will take some work.

@joaotavora
Copy link
Owner

Oh, I thought they were meant to be set by users (your suggested variable name implies it, I think).

Yes, if I thought that earlier, then I was wrong, I think.

Although maintaining different server variables in eglot will take some work.

Sure, but all of this is a way for us to escape non-conforming servers, which is something we live with. Eventually, as servers become more and more conforming (yeah right), these things would fade...

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

No branches or pull requests

2 participants