diff --git a/README.md b/README.md index 06f8ff15..f0cbc1ea 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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. + # Reporting bugs diff --git a/eglot.el b/eglot.el index 9a0960d7..75ce9376 100644 --- a/eglot.el +++ b/eglot.el @@ -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 ;;;