[eglot] Add support for eglot lsp client in emacs

- Update README
- Add eglot-specifics to cc, rs, py, hs
  removing unused lsp-mode packages when eglot is active
- Add eglot-specific bindings
- Add doctor warnings for debugger +lsp and +peek
- Add eglot-backed lookup-handlers
- Add flycheck checker using eglot for :checkers
  syntax users (using flycheck/flycheck#1676 and
  flycheck/flycheck#1592 discussion).
  This implementation is based on @marsam code, and uses recent
  Flycheck development in order to make the code smaller and
  easier to maintain.
This commit is contained in:
Gerry Agbobada 2020-05-01 11:01:11 +02:00 committed by Gerry Agbobada
parent f2a3dee7ff
commit 3e5b7cce3f
No known key found for this signature in database
GPG key ID: BE26DBAFD866BE34
18 changed files with 248 additions and 47 deletions

View file

@ -236,9 +236,45 @@ If rtags or rdm aren't available, fail silently instead of throwing a breaking e
(setq-local company-lsp-cache-candidates nil)
(lsp!))))
(when (and (featurep! +lsp) (featurep! :tools lsp +eglot))
;; TODO : test this value
;; IS-MAC custom configuration
(when IS-MAC
(add-to-list 'eglot-workspace-configuration
((:ccls . ((:clang . ,(list :extraArgs ["-isystem/Library/Developer/CommandLineTools/usr/include/c++/v1"
"-isystem/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"
"-isystem/usr/local/include"]
:resourceDir (string-trim (shell-command-to-string "clang -print-resource-dir")))))))))
;; Eglot specific helper, courtesy of MaskRay
(defun eglot-ccls-inheritance-hierarchy (&optional derived)
"Show inheritance hierarchy for the thing at point.
If DERIVED is non-nil (interactively, with prefix argument), show
the children of class at point."
(interactive "P")
(if-let* ((res (jsonrpc-request
(eglot--current-server-or-lose)
:$ccls/inheritance
(append (eglot--TextDocumentPositionParams)
`(:derived ,(if derived t :json-false))
'(:levels 100) '(:hierarchy t))))
(tree (list (cons 0 res))))
(with-help-window "*ccls inheritance*"
(with-current-buffer standard-output
(while tree
(pcase-let ((`(,depth . ,node) (pop tree)))
(cl-destructuring-bind (&key uri range) (plist-get node :location)
(insert (make-string depth ?\ ) (plist-get node :name) "\n")
(make-text-button (+ (point-at-bol 0) depth) (point-at-eol 0)
'action (lambda (_arg)
(interactive)
(find-file (eglot--uri-to-path uri))
(goto-char (car (eglot--range-region range)))))
(cl-loop for child across (plist-get node :children)
do (push (cons (1+ depth) child) tree)))))))
(eglot--error "Hierarchy unavailable"))))
(use-package! ccls
:when (featurep! +lsp)
:when (and (featurep! +lsp) (not (featurep! :tools lsp +eglot)))
:after lsp
:init
(after! projectile

View file

@ -17,7 +17,9 @@
:pin "404cd0694a")))
(if (featurep! +lsp)
(package! ccls :pin "17ec7bb4cf")
(unless (featurep! :tools lsp +eglot)
;; ccls package is necessary only for lsp-mode.
(package! ccls :pin "17ec7bb4cf"))
(when (package! irony :pin "5f75fc0c92")
(package! irony-eldoc :pin "0df5831eaa")
(when (featurep! :checkers syntax)

View file

@ -6,6 +6,6 @@
(when (featurep! +dante)
(package! dante :pin "4955bc7363")
(package! attrap :pin "4cf3e4a162"))
(when (or (featurep! +lsp)
(when (or (and (featurep! +lsp) (not (featurep! :tools lsp +eglot)))
(featurep! +ghcide))
(package! lsp-haskell :pin "582fa27c88"))

View file

@ -22,7 +22,10 @@ called.")
python-indent-guess-indent-offset-verbose nil)
(when (featurep! +lsp)
(add-hook 'python-mode-local-vars-hook #'lsp!))
(add-hook 'python-mode-local-vars-hook #'lsp!)
;; Use "mspyls" in eglot if in PATH
(when (executable-find "Microsoft.Python.LanguageServer")
(set-eglot-client! 'python-mode '("Microsoft.Python.LanguageServer"))))
:config
(set-repl-handler! 'python-mode #'+python/open-repl :persist t)
(set-docsets! 'python-mode "Python 3" "NumPy" "SciPy")
@ -98,6 +101,7 @@ called.")
"Enable `anaconda-mode' if `lsp-mode' is absent and
`python-shell-interpreter' is present."
(unless (or (bound-and-true-p lsp-mode)
(bound-and-true-p eglot--managed-mode)
(bound-and-true-p lsp--buffer-deferred)
(not (executable-find python-shell-interpreter)))
(anaconda-mode +1))))
@ -286,7 +290,7 @@ called.")
(use-package! lsp-python-ms
:when (featurep! +lsp)
:when (and (featurep! +lsp) (not (featurep! :tools lsp +eglot)))
:after lsp-clients
:preface
(after! python

View file

@ -9,7 +9,7 @@
(package! flycheck-cython :pin "ecc4454d35")))
;; LSP
(when (featurep! +lsp)
(when (and (featurep! +lsp) (not (featurep! :tools lsp +eglot)))
(package! lsp-python-ms :pin "5d0c799099"))
;; Programming environment

View file

@ -27,6 +27,11 @@
(after! rustic-flycheck
(add-to-list 'flycheck-checkers 'rustic-clippy)))
(when (featurep! +lsp)
(if (featurep! :tools lsp +eglot)
(setq rustic-lsp-client 'eglot)
(setq rustic-lsp-client 'lsp-mode)))
(map! :map rustic-mode-map
:localleader
(:prefix ("b" . "build")