Skip to content

Commit

Permalink
Expand README.md section on handling quirky servers
Browse files Browse the repository at this point in the history
Also remove explicit cquery support (cquery seems to be dead anyway).

* README.md (Handling quirky servers): New section.

* eglot.el (eglot-initialization-options eglot-cquery): Remove.
  • Loading branch information
joaotavora committed Oct 24, 2019
1 parent 6dd5de9 commit 32ba9d0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
37 changes: 27 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,9 @@ customize `eglot-server-programs`:
(add-to-list 'eglot-server-programs '(foo-mode . ("foo-language-server" "--args")))
```

Let me know how well it works and we can add it to the list. If the
server has some quirk or non-conformity, it's possible to extend Eglot
to adapt to it. Here's how to get [cquery][cquery] working for
example:
Let me know how well it works and we can add it to the list.

```lisp
(add-to-list 'eglot-server-programs '((c++ mode c-mode) . (eglot-cquery "cquery")))
```

You can also enter a `server:port` pattern to connect to an LSP
server. To skip the guess and always be prompted use `C-u M-x eglot`.
To skip the guess and always be prompted use `C-u M-x eglot`.

## Connecting automatically

Expand Down Expand Up @@ -102,6 +94,31 @@ it be started as a server. Notice the `:autoport` symbol in there: it
is replaced dynamically by a local port believed to be vacant, so that
the ensuing TCP connection finds a listening server.

## Handling quirky servers

Most servers can guess good defaults and will operate nicely
out-of-the-box, but some need to be configured specially via LSP's
interfaces. If your server has some quirk or non-conformity, it's
possible to extend Eglot to adapt to it. Here's an example on how to
get [cquery][cquery] working:

```lisp
(add-to-list 'eglot-server-programs '((c++ mode c-mode) . (eglot-cquery "cquery")))
(defclass eglot-cquery (eglot-lsp-server) ()
:documentation "A custom class for cquery's C/C++ langserver.")
(cl-defmethod eglot-initialization-options ((server eglot-cquery))
"Passes through required cquery initialization options"
(let* ((root (car (project-roots (eglot--project server))))
(cache (expand-file-name ".cquery_cached_index/" root)))
(list :cacheDirectory (file-name-as-directory cache)
:progressReportFrequencyMs -1)))
```

See `eglot.el`'s section on Java's JDT server for an even more
sophisticated example.

<a name="reporting bugs"></a>
# Reporting bugs

Expand Down
13 changes: 0 additions & 13 deletions eglot.el
Original file line number Diff line number Diff line change
Expand Up @@ -2511,19 +2511,6 @@ If SKIP-SIGNATURE, don't try to send textDocument/signatureHelp."
"Handle notification window/progress"
(setf (eglot--spinner server) (list id title done message)))


;;; cquery-specific
;;;
(defclass eglot-cquery (eglot-lsp-server) ()
:documentation "Cquery's C/C++ langserver.")

(cl-defmethod eglot-initialization-options ((server eglot-cquery))
"Passes through required cquery initialization options"
(let* ((root (car (project-roots (eglot--project server))))
(cache (expand-file-name ".cquery_cached_index/" root)))
(list :cacheDirectory (file-name-as-directory cache)
:progressReportFrequencyMs -1)))


;;; eclipse-jdt-specific
;;;
Expand Down

0 comments on commit 32ba9d0

Please sign in to comment.