Switch from irony to lsp-mode.

Remove irony, cmake-ide, ggtags. Add lsp-mode, lsp-mode-ui and company-lsp.
This commit is contained in:
tastytea 2019-10-08 15:46:27 +02:00
parent 0e6c527d24
commit e965cd88e7
2 changed files with 43 additions and 74 deletions

115
init.el
View File

@ -1,5 +1,5 @@
;;; init.el --- tastytea's Emacs init file.
;; Time-stamp: <2019-09-30T16:38:17+00:00>
;; Time-stamp: <2019-10-08T13:44:40+00:00>
;;; Commentary:
;; Requires at least Emacs 24.3.
@ -232,22 +232,29 @@ With argument, do this that many times."
(use-package flycheck-clang-tidy
:pin melpa
:after (flycheck projectile)
:after (flycheck projectile lsp-ui)
:if (executable-find "clang-tidy")
:config
(defun my/clang-tidy-off ()
"Disable c++-clang-tidy."
"Disable c/c++-clang-tidy."
(when (or (eq major-mode 'c++-mode) (eq major-mode 'c-mode))
(add-to-list 'flycheck-disabled-checkers 'c/c++-clang-tidy))
)
(defun my/clang-tidy-on ()
"Enable c++-clang-tidy."
"Enable c/c++-clang-tidy."
(when (or (eq major-mode 'c++-mode) (eq major-mode 'c-mode))
(setq-local flycheck-disabled-checkers
(remove 'c/c++-clang-tidy flycheck-disabled-checkers)))
)
(defun my/flycheck-clang-tidy-setup ()
(flycheck-clang-tidy-setup)
;; Run clang-tidy after the lsp-ui checker.
(when lsp-mode
(flycheck-add-next-checker 'lsp-ui '(warning . c/c++-clang-tidy)))
)
:hook
(flycheck-mode . flycheck-clang-tidy-setup)
(flycheck-mode . my/flycheck-clang-tidy-setup)
(first-change . my/clang-tidy-off) ; Disable when file is modified.
(before-save . my/clang-tidy-on) ; Enable if file is saved.
)
@ -325,15 +332,6 @@ With argument, do this that many times."
;; Mark variable as safe. This prevents prompts when using .dir-locals.el.
(put 'projectile-project-compilation-cmd 'safe-local-variable #'stringp)
(put 'projectile-project-configure-cmd 'safe-local-variable #'stringp)
;; Always run `cmake-ide-run-cmake` after configuring a project.
(defun my/configure-project (old-function &rest arguments)
"Runs `projectile-configure-project' followed by `cmake-ide-run-cmake'."
(apply old-function arguments)
;; (cmake-ide-run-cmake)
(cmake-ide-load-db)
)
(advice-add 'projectile-configure-project :around #'my/configure-project)
:bind
("C-c p" . 'projectile-command-map)
))
@ -404,7 +402,7 @@ With argument, do this that many times."
(dumb-jump-selector 'ivy)
:bind
("M-." . dumb-jump-go)
("M-," . dumb-jump-back))
)
;; Support .editorconfig files.
(use-package editorconfig
@ -457,52 +455,33 @@ With argument, do this that many times."
(c-default-style "tastytea"))
(unless slow-computer
;; irony communicates with a clang-server. It needs compile_commands.json.
(use-package irony
:pin melpa ; 1.3.1 Server does not compile.
:after yasnippet
:hook
(c++-mode . irony-mode)
(c-mode . irony-mode)
(irony-mode . irony-cdb-autosetup-compile-options)
:config
;; If irony server is not installed, install it.
(unless (irony--find-server-executable)
(call-interactively #'irony-install-server)))
;; Eldoc shows argument list of the function you are currently writing.
(use-package irony-eldoc
:after (eldoc irony)
:hook
(irony-mode . irony-eldoc))
;; Syntax checker.
(use-package flycheck-irony
:after (flycheck irony)
:hook
(flycheck-mode-hook . flycheck-irony-setup))
;; Auto-complete integration.
(use-package company-irony
:after (company irony)
;; Backend is added in company-irony-c-headers.
)
;; Auto-complete headers
(use-package company-irony-c-headers
:after company-irony
:config
(add-to-list 'company-backends '(company-irony-c-headers company-irony))
)
;; cmake integration.
(use-package cmake-ide
:after irony
;; Client for Language Server Protocol servers.
(use-package lsp-mode
:custom
(cmake-ide-build-dir "build")
(cmake-ide-cmake-opts "") ; Use the already configured options.
(lsp-prefer-flymake nil) ; Disable flymake.
:hook
(c++-mode . lsp)
(c-mode . lsp)
)
;; Eye-candy and flycheck support for lsp-mode.
(use-package lsp-ui
:after (lsp-mode flycheck)
:custom
(lsp-ui-sideline-enable nil)
:bind
(:map lsp-ui-mode-map
("M-." . lsp-ui-peek-find-definitions))
:hook
(lsp-mode . lsp-ui-mode)
)
;; Completions with lsp-mode.
(use-package company-lsp
:after (lsp-mode company)
:config
(cmake-ide-setup))
(push 'company-lsp company-backends)
)
) ; unless slow-computer
@ -551,20 +530,6 @@ With argument, do this that many times."
(c++-mode . modern-c++-font-lock-mode)
)
;; Jump to definition. Overwrites dumb-jump keybindings.
(use-package ggtags
:if (executable-find "gtags")
:bind
(:map ggtags-mode-map
("C-M-." . ggtags-navigation-next-mark)
("C-M-," . ggtags-navigation-previous-mark)
("C-M-:" . ggtags-navigation-next-file)
("C-M-;" . ggtags-navigation-previous-file)
)
:hook
(c++-mode . ggtags-mode)
)
;; Add #include directives for missing symbols.
(use-package clang-include-fixer
:ensure nil ; Installed by clang.
@ -851,6 +816,9 @@ With argument, do this that many times."
(if my/ws-enabled
(whitespace-mode t)))
(defun my/whitespace-mode-off ()
(whitespace-mode -1))
(if (display-graphic-p)
(custom-set-faces
'(whitespace-line ((t (:inherit whitespace-line
@ -878,6 +846,7 @@ With argument, do this that many times."
(prog-mode . my/ws-load-local-vars-first)
(conf-mode . my/ws-load-local-vars-first)
(text-mode . my/ws-load-local-vars-first)
(lsp-ui-peek-mode . my/whitespace-mode-off) ; Dots in wrong color.
:custom-face
(whitespace-space ((nil :foreground "gray18")))
)

View File

@ -1,2 +1,2 @@
127.0.0.1:51313 23841
127.0.0.1:51313 32519
phahw2ohVoh0oopheish7IVie9desh8aequeenei3uo8wahShe%thuadaeNa4ieh