apt-get install clang-tools-7 clang-format
export PATH=/usr/lib/llvm-7/bin:${PATH}
M-x package-install lsp-mode lsp-ui company-lsp dash-el elpa-f s-el elpa-markdown-mode dash-el
package name | package repository URI | remark |
---|---|---|
lsp-mode | http://github.com/emacs-lsp/lsp-mode.git | 各種LSPの言語モードを実装している。 C/C++ の設定もここに含まれる。 |
lsp-ui | https://github.com/emacs-lsp/lsp-ui.git | 補完を担うcompany-modeのLSP向け設定 |
company-lsp | https://github.com/tigersoldier/company-lsp.git | ドキュメントの表示など各種アクションを実装している。 |
elpa | https://git.savannah.gnu.org/git/emacs/elpa.git | elpa/packages/cl-generic 等を使用する為に取得する。サイズが大きいので注意。 |
ht | https://github.com/Wilfred/ht.el.git | debian9のパッケージには存在しない。lsp-mode の動作に必要 |
dash | https://github.com/magnars/dash.el | |
f | https://github.com/rejeep/f.el | |
s | https://github.com/magnars/s.el | |
markdown-mode | https://github.com/jrblevin/markdown-mode.git | |
flycheck-mode | https://github.com/flycheck/flycheck | |
projectile | https://github.com/bbatsov/projectile |
package name | tag | remark |
---|---|---|
lsp-mode | refs/tags/7.0 | |
lsp-ui | refs/tags/7.0 | |
company-lsp | refs/tags/2.1.0 | |
elpa | (HEAD) | tagは試行中。動かなかったら検討する。 |
;;; ~/.emacs/init.el ;;; ~/.emacs.d/site-lisp 配下に各リポジトリを配置した場合の設定例 (setq load-path (cons (expand-file-name "~/.emacs.d/site-lisp/dash") load-path)) ; dash (setq load-path (cons (expand-file-name "~/.emacs.d/site-lisp/elpa/packages/cl-generic") load-path)) ; cl-generic (setq load-path (cons (expand-file-name "~/.emacs.d/site-lisp/ht") load-path)) ; ht.el (setq load-path (cons (expand-file-name "~/.emacs.d/site-lisp/elpa/packages/hydra") load-path)) ; lv.el (setq load-path (cons (expand-file-name "~/.emacs.d/site-lisp/elpa/packages/spinner") load-path)) ; spinner.el (setq load-path (cons (expand-file-name "~/.emacs.d/site-lisp/elpa/packages/company") load-path)) ; company.el (setq load-path (cons (expand-file-name "~/.emacs.d/site-lisp/markdown-mode") load-path)) ; markdown-mode (setq load-path (cons (expand-file-name "~/.emacs.d/site-lisp/flycheck") load-path)) ; flycheck (setq load-path (cons (expand-file-name "~/.emacs.d/site-lisp/projectile") load-path)) ; projectile (require 'projectile) (setq load-path (cons (expand-file-name "~/.emacs.d/site-lisp/lsp-mode") load-path)) (require 'lsp-mode) (setq load-path (cons (expand-file-name "~/.emacs.d/site-lisp/lsp-ui") load-path)) (require 'lsp-ui) (setq load-path (cons (expand-file-name "~/.emacs.d/site-lisp/company-lsp") load-path)) (require 'company-lsp)
;;; lsp-mode ;; https://qiita.com/false-git@github/items/3cb6ebd7f4d6f77acc54 (setq lsp-clients-clangd-executable "/usr/bin/clangd-7") ;; hooks (add-hook 'c++-mode-hook 'company-mode) ; 補完用 (add-hook 'c-mode-hook 'company-mode) ; 補完用 (add-hook 'c++-mode-hook 'flycheck-mode) ; チェック用 (add-hook 'c-mode-hook 'flycheck-mode) ; チェック用 (add-hook 'c++-mode-hook #'lsp) (add-hook 'c-mode-hook #'lsp) (with-eval-after-load 'lsp-mode (custom-set-variables '(lsp-prefer-flymake nil)) ; flycheckを優先する (define-key lsp-mode-map (kbd "C-c C-d") 'lsp-describe-thing-at-point) (define-key lsp-mode-map (kbd "C-c C-e") 'lsp-workspace-restart) (define-key lsp-mode-map (kbd "C-c C-i") 'lsp-format-buffer) (define-key lsp-mode-map (kbd "C-c C-n") 'lsp-rename) (define-key lsp-mode-map (kbd "C-c C-r") 'lsp-execute-code-action) )