Handle eglot-ensure' by means of
dir-local-variables-alist'
This commit is contained in:
parent
92147e4ba5
commit
8b84f17940
27
README.org
27
README.org
@ -1774,10 +1774,11 @@ compatible with [[info:org#Editing Source Code][source code block editing]] whil
|
|||||||
'(python-shell-interpreter-args "-i -E")))
|
'(python-shell-interpreter-args "-i -E")))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
Listing [[lst:configure-eglot-for-python]] configures [[https://github.com/joaotavora/eglot][eglot]] for [[https://www.python.org][Python]]. It may be a
|
Listing [[lst:configure-eglot-for-python]] configures [[https://github.com/joaotavora/eglot][eglot]] for [[https://www.python.org][Python]]. It defines
|
||||||
good idea to launch [[https://github.com/joaotavora/eglot][eglot]] by means of [[info:emacs#Directory Variables][directory variables]] in the root directory
|
a hook function to launch [[https://github.com/joaotavora/eglot][eglot]] by means of a proper [[info:emacs#Directory Variables][directory variables]] file in
|
||||||
of any [[https://www.python.org][Python]] project. Listing [[lst:eglot-directory-variables-for-python]] does a
|
the root directory of any [[https://www.python.org][Python]] project. Listing
|
||||||
proposal.
|
[[lst:eglot-directory-variables-for-python]] does shows such a proper [[info:emacs#Directory Variables][directory
|
||||||
|
variables]] file.
|
||||||
|
|
||||||
#+caption[Configure =eglot= for Python]:
|
#+caption[Configure =eglot= for Python]:
|
||||||
#+caption: Configure =eglot= for Python.
|
#+caption: Configure =eglot= for Python.
|
||||||
@ -1792,6 +1793,16 @@ proposal.
|
|||||||
"numpy"
|
"numpy"
|
||||||
"scipy"))))))
|
"scipy"))))))
|
||||||
(:pylsp . (:plugins (:jedi_completion (:eager nil)))))))
|
(:pylsp . (:plugins (:jedi_completion (:eager nil)))))))
|
||||||
|
|
||||||
|
(when (fboundp 'eglot-ensure)
|
||||||
|
;; The two hooks `after-change-major-mode-hook' and
|
||||||
|
;; `hack-local-variables-hook' are OK, but `<ANY>-mode-hook' is not.
|
||||||
|
(add-hook 'hack-local-variables-hook
|
||||||
|
(defun on-hack-local-variables-hook-eglot-maybe ()
|
||||||
|
(when (and (derived-mode-p 'python-mode)
|
||||||
|
(assoc 'eglot-workspace-configuration
|
||||||
|
dir-local-variables-alist))
|
||||||
|
(eglot-ensure)))))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+caption[Propose =directory-variables= to launch =eglot=]:
|
#+caption[Propose =directory-variables= to launch =eglot=]:
|
||||||
@ -1802,11 +1813,9 @@ proposal.
|
|||||||
;; Proposal for a .dir-locals.el file in the root of any Python project.
|
;; Proposal for a .dir-locals.el file in the root of any Python project.
|
||||||
((python-mode
|
((python-mode
|
||||||
. ((eglot-workspace-configuration
|
. ((eglot-workspace-configuration
|
||||||
. `((:pylsp . (:plugins (:jedi_completion
|
. ((:pylsp . (:plugins (:jedi_completion
|
||||||
(:cache_for ,(vconcat '("astropy"
|
(:cache_for ["astropy" "numpy" "scipy"]))))
|
||||||
"numpy"
|
(:pylsp . (:plugins (:jedi_completion (:eager nil)))))))))
|
||||||
"scipy"))))))
|
|
||||||
(:pylsp . (:plugins (:jedi_completion (:eager nil)))))))))
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
Listing [[lst:configure-anaconda-for-python]] configures [[https://github.com/pythonic-emacs/anaconda-mode][anaconda]]. See
|
Listing [[lst:configure-anaconda-for-python]] configures [[https://github.com/pythonic-emacs/anaconda-mode][anaconda]]. See
|
||||||
|
Loading…
x
Reference in New Issue
Block a user