From 2bf73ee34c888ad980727ac47d4579be6b292d70 Mon Sep 17 00:00:00 2001 From: Gerry Agbobada Date: Fri, 13 Nov 2020 01:35:54 +0100 Subject: [PATCH] [:lang cc] Add LSP configuration snippets --- modules/lang/cc/README.org | 54 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/modules/lang/cc/README.org b/modules/lang/cc/README.org index f7442e38b..cfe7c2deb 100644 --- a/modules/lang/cc/README.org +++ b/modules/lang/cc/README.org @@ -17,6 +17,11 @@ - [[#configure][Configure]] - [[#project-compile-settings][Project compile settings]] - [[#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]] - [[#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/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 ** Eglot specific bindings When using =+lsp= and =:tools (lsp +eglot)=, lsp-mode is replaced with eglot,