From f3914c266fcf81bb735e733222d6a4aa70948548 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Wed, 2 Jan 2019 17:12:36 +0000 Subject: [PATCH] Run connection hooks with proper dir-locals eglot-connect-hook and eglot-server-initialized-hook must run in a buffer with properly setup directory-local variables for the project. This is crucial for things like eglot-signal-didChangeConfiguration, which needs a properly setup value of eglot-workspace-configuration to succeed. I could have chosen any of the buffers where Eglot is activating itself, but the approach using hack-dir-local-variables-non-file-buffer seems more correct, despite the name. * eglot.el (eglot--connect): Run connection hooks with proper dir-locals. GitHub-reference: fix https://github.com/joaotavora/eglot/issues/196 --- lisp/progmodes/eglot.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 4416e52c705..39f484220aa 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -840,8 +840,11 @@ This docstring appeases checkdoc, that's all." (lambda () (setf (eglot--inhibit-autoreconnect server) (null eglot-autoreconnect))))))) - (run-hook-with-args 'eglot-connect-hook server) - (run-hook-with-args 'eglot-server-initialized-hook server) + (let ((default-directory (car (project-roots project))) + (major-mode managed-major-mode)) + (hack-dir-local-variables-non-file-buffer) + (run-hook-with-args 'eglot-connect-hook server) + (run-hook-with-args 'eglot-server-initialized-hook server)) (eglot--message "Connected! Server `%s' now managing `%s' buffers \ in project `%s'." -- 2.39.2