From fad0df1881e4681750c2b9429d2f215bfc92f897 Mon Sep 17 00:00:00 2001 From: laurensmiers Date: Mon, 26 Aug 2019 22:11:12 +0200 Subject: [PATCH] Add Language Server - Use ccls as language server for C/C++ --- config.org | 79 +++++++++++++++--------------------------------------- 1 file changed, 22 insertions(+), 57 deletions(-) diff --git a/config.org b/config.org index 80a6eca..0de08f5 100644 --- a/config.org +++ b/config.org @@ -15,14 +15,11 @@ My personal emacs configuration This configuration requires the installation of : - the GNU =global= package (for gtags) - - =clang= (for ivory) - - =cmake= (for ivory) - - =llvm-libs= (for cmake, somehow not a dependency on Manjaro when installing cmake) + - =ccls=, a language server for C/C++ - Use python-pip to install requirements for elpy: =pip install jedi flake8 importmagic autopep8 yapf= - =ditaa= (for ascii to image generation in org-mode) -When first checking out this config, run =irony-install-server= to make and install the irony-server. * Workarounds ** Emacs 26.2 @@ -846,29 +843,6 @@ https://github.com/joaotavora/yasnippet ) #+END_SRC -** Flycheck - -On-the-fly syntax checking. - -#+BEGIN_SRC emacs-lisp -(use-package flycheck - :ensure t - :config - (add-hook 'prog-mode-hook 'flycheck-mode) -) -#+END_SRC - -** Company mode - -#+BEGIN_SRC emacs-lisp -(use-package company - :ensure t - :config - (setq company-idle-delay 0) - (setq company-minimum-prefix-length 2)) - (add-hook 'prog-mode-hook 'company-mode) -#+END_SRC - ** (Relative) Line numbers #+BEGIN_SRC emacs-lisp @@ -883,10 +857,9 @@ On-the-fly syntax checking. *** Flycheck -Clang static analyzer with flycheck +Clang static analyzer with flycheck (On-the-fly syntax checking) https://github.com/alexmurray/flycheck-clang-analyzer -https://github.com/Sarcasm/flycheck-irony #+BEGIN_SRC emacs-lisp (use-package flycheck-clang-analyzer @@ -895,44 +868,36 @@ https://github.com/Sarcasm/flycheck-irony (with-eval-after-load 'flycheck (require 'flycheck-clang-analyzer) (flycheck-clang-analyzer-setup))) - -(use-package flycheck-irony - :ensure t - :config - (eval-after-load 'flycheck - '(add-hook 'flycheck-mode-hook #'flycheck-irony-setup)) -) #+END_SRC *** Company -https://github.com/ikirill/irony-eldoc - #+BEGIN_SRC emacs-lisp -(use-package company-c-headers - :ensure t) - -(use-package company-irony - :ensure t - :config - (setq company-backends '((company-c-headers -;; company-dabbrev-code ;; not sure what this is - company-irony)))) - -(use-package irony - :ensure t - :config - (add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options) - (add-hook 'c++-mode-hook 'irony-mode) - (add-hook 'c-mode-hook 'irony-mode) - (add-hook 'objc-mode-hook 'irony-mode) +(use-package lsp-mode + :commands lsp + :ensure t ) -(use-package irony-eldoc +(use-package lsp-ui + :commands lsp-ui-mode + :ensure t +) + +(use-package company-lsp + :ensure t + :commands company-lsp + :config (push 'company-lsp company-backends)) ;; add company-lsp as a backend + +(use-package ccls :ensure t :config - (add-hook 'irony-mode-hook 'irony-eldoc) + (setq ccls-executable "ccls") + (setq lsp-prefer-flymake nil) ;; Disable flymake for syntax checking, use flycheck instead + (setq-default flycheck-disabled-checkers '(c/c++-clang c/c++-cppcheck c/c++-gcc)) + :hook ((c-mode c++-mode objc-mode) . + (lambda () (require 'ccls) (lsp))) ) + #+END_SRC ** Python mode