Merge pull request #4260 from gagbo/docs/cc_lsp

[:lang cc] Add LSP configuration snippets
This commit is contained in:
Henrik Lissner 2020-11-13 13:11:03 -05:00 committed by GitHub
commit 0136a238be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -17,6 +17,11 @@
- [[#configure][Configure]] - [[#configure][Configure]]
- [[#project-compile-settings][Project compile settings]] - [[#project-compile-settings][Project compile settings]]
- [[#known-issues-with-bear-on-macos][Known issues with bear on macOS]] - [[#known-issues-with-bear-on-macos][Known issues with bear on macOS]]
- [[#configure-lsp-servers][Configure LSP servers]]
- [[#lsp-mode-with-clangd][LSP-mode with clangd]]
- [[#lsp-mode-with-ccls][LSP-mode with ccls]]
- [[#eglot-with-clangd][Eglot with clangd]]
- [[#eglot-with-ccls][Eglot with ccls]]
- [[#appendix][Appendix]] - [[#appendix][Appendix]]
- [[#eglot-specific-bindings][Eglot specific bindings]] - [[#eglot-specific-bindings][Eglot specific bindings]]
@ -194,6 +199,55 @@ Additional info:
+ [[https://github.com/rizsotto/Bear/issues/158][Empty compilation database with compiler in /usr/local]] + [[https://github.com/rizsotto/Bear/issues/158][Empty compilation database with compiler in /usr/local]]
+ [[https://github.com/rizsotto/Bear/issues/152][Workaround for 'Empty compilation database on OS X Captain]] + [[https://github.com/rizsotto/Bear/issues/152][Workaround for 'Empty compilation database on OS X Captain]]
** Configure LSP servers
Search for your combination of =(LSP client package, LSP server)=. You are using
=LSP-mode= by default, =eglot= if you have =:tools (lsp +eglot)= active in your
=init.el= file.
*** LSP-mode with clangd
#+BEGIN_SRC elisp
(setq lsp-clients-clangd-args '("-j=3"
"--background-index"
"--clang-tidy"
"--completion-style=detailed"
"--header-insertion=never"))
(after! lsp-clangd (set-lsp-priority! 'clangd 2))
#+END_SRC
This will both set your clangd flags and choose =clangd= as the default LSP server everywhere clangd can be used.
*** LSP-mode with ccls
#+BEGIN_SRC elisp
(after! ccls
(setq ccls-initialization-options '(:index (:comments 2) :completion (:detailedLabel t)))
(set-lsp-priority! 'ccls 2)) ; optional as ccls is the default in Doom
#+END_SRC
This will both set your ccls flags and choose ccls as the default server. [[https://github.com/MaskRay/ccls/wiki/Customization#--initjson][CCLS
documentation]] lists available options, use =t= for ~true~, =:json-false= for
~false~, and =:json-null= for ~null~.
*** Eglot with clangd
#+BEGIN_SRC elisp
(set-eglot-client! 'cc-mode '("clangd" "-j=3" "--clang-tidy"))
#+END_SRC
This will both set your clangd flags and choose clangd as the default server (if
it is the last =set-eglot-client! 'cc-mode= in your config).
*** Eglot with ccls
#+BEGIN_SRC elisp
(set-eglot-client! 'cc-mode '("ccls" "--init={\"index\": {\"threads\": 3}}"))
#+END_SRC
This will both set your ccls flags and choose ccls as the default server (if it
is the last =set-eglot-client! 'cc-mode= in your config). [[https://github.com/MaskRay/ccls/wiki/Customization#--initjson][CCLS documentation]]
lists available options
* Appendix * Appendix
** Eglot specific bindings ** Eglot specific bindings
When using =+lsp= and =:tools (lsp +eglot)=, lsp-mode is replaced with eglot, When using =+lsp= and =:tools (lsp +eglot)=, lsp-mode is replaced with eglot,