2015-01-14 04:12:56 +00:00
|
|
|
;;; packages.el --- C/C++ Layer packages File for Spacemacs
|
|
|
|
;;
|
2021-03-22 20:11:29 +00:00
|
|
|
;; Copyright (c) 2012-2021 Sylvain Benner & Contributors
|
2015-01-14 04:12:56 +00:00
|
|
|
;;
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
2021-03-24 03:31:44 +00:00
|
|
|
;; This program is free software; you can redistribute it and/or modify
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
|
|
|
;;
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
;;
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2015-01-14 04:12:56 +00:00
|
|
|
|
2020-05-16 21:32:30 +00:00
|
|
|
(defconst c-c++-packages
|
|
|
|
'(
|
|
|
|
cc-mode
|
|
|
|
clang-format
|
2020-06-05 20:35:06 +00:00
|
|
|
company
|
2020-05-16 21:32:30 +00:00
|
|
|
(company-c-headers :requires company)
|
|
|
|
(cpp-auto-include
|
|
|
|
:location (recipe :fetcher github
|
|
|
|
:repo "syohex/emacs-cpp-auto-include"))
|
|
|
|
disaster
|
|
|
|
eldoc
|
|
|
|
flycheck
|
|
|
|
gdb-mi
|
|
|
|
google-c-style
|
|
|
|
helm-cscope
|
|
|
|
org
|
|
|
|
projectile
|
|
|
|
realgud
|
|
|
|
semantic
|
|
|
|
srefactor
|
|
|
|
stickyfunc-enhance
|
|
|
|
xcscope
|
|
|
|
;; lsp
|
|
|
|
(ccls :requires lsp-mode)
|
|
|
|
dap-mode
|
|
|
|
;; rtags
|
|
|
|
(company-rtags :requires (company rtags))
|
|
|
|
counsel-gtags
|
|
|
|
(flycheck-rtags :requires (flycheck rtags))
|
|
|
|
ggtags
|
|
|
|
helm-gtags
|
|
|
|
(helm-rtags :requires (helm rtags))
|
|
|
|
(ivy-rtags :requires (ivy rtags))
|
|
|
|
rtags
|
|
|
|
;; ycmd
|
|
|
|
(company-ycmd :requires company)
|
|
|
|
(flycheck-ycmd :requires flycheck)
|
2021-09-02 12:19:26 +00:00
|
|
|
(gendoxy :location (recipe
|
|
|
|
:fetcher github
|
|
|
|
:repo "cormacc/gendoxy"
|
|
|
|
:branch "provides"))
|
2020-05-16 21:32:30 +00:00
|
|
|
ycmd))
|
2014-12-14 04:08:55 +00:00
|
|
|
|
2021-09-02 12:19:26 +00:00
|
|
|
(defun c-c++/init-gendoxy ()
|
|
|
|
"Initialise gendoxy (doxygen package)"
|
|
|
|
(use-package gendoxy
|
|
|
|
:defer t
|
|
|
|
:init (dolist (mode c-c++-modes)
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "mi" "insert")
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode
|
|
|
|
"ih" 'gendoxy-header
|
|
|
|
"id" 'gendoxy-tag
|
|
|
|
"iD" 'gendoxy-tag-header
|
|
|
|
"ig" 'gendoxy-group
|
|
|
|
"iG" 'gendoxy-group-header
|
|
|
|
"is" 'gendoxy-group-start
|
|
|
|
"ie" 'gendoxy-group-end))))
|
|
|
|
|
2014-12-14 04:08:55 +00:00
|
|
|
(defun c-c++/init-cc-mode ()
|
|
|
|
(use-package cc-mode
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2015-05-02 13:52:15 +00:00
|
|
|
:init
|
2016-08-13 13:43:37 +00:00
|
|
|
(progn
|
2019-10-01 03:48:24 +00:00
|
|
|
(add-hook 'c-mode-local-vars-hook #'spacemacs//c-c++-setup-backend)
|
|
|
|
(add-hook 'c++-mode-local-vars-hook #'spacemacs//c-c++-setup-backend)
|
|
|
|
(put 'c-c++-backend 'safe-local-variable 'symbolp)
|
2019-08-15 23:21:00 +00:00
|
|
|
(when c-c++-default-mode-for-headers
|
|
|
|
(add-to-list 'auto-mode-alist
|
|
|
|
`("\\.h\\'" . ,c-c++-default-mode-for-headers)))
|
2018-05-15 20:54:03 +00:00
|
|
|
(when c-c++-enable-auto-newline
|
|
|
|
(add-hook 'c-mode-common-hook 'spacemacs//c-toggle-auto-newline)))
|
2014-12-14 04:08:55 +00:00
|
|
|
:config
|
|
|
|
(progn
|
2015-02-23 14:59:01 +00:00
|
|
|
(require 'compile)
|
2017-07-30 21:05:50 +00:00
|
|
|
(dolist (mode c-c++-modes)
|
2017-08-14 07:54:15 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode mode "mc" "compile")
|
2017-07-30 21:05:50 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode mode "mg" "goto")
|
2017-08-23 09:09:38 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode mode "mp" "project")
|
2017-07-30 21:05:50 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode
|
|
|
|
"ga" 'projectile-find-other-file
|
|
|
|
"gA" 'projectile-find-other-file-other-window)))))
|
2015-02-23 14:59:01 +00:00
|
|
|
|
2019-10-01 03:48:24 +00:00
|
|
|
(defun c-c++/init-ccls ()
|
2019-11-09 14:53:55 +00:00
|
|
|
(use-package ccls
|
|
|
|
:defer t))
|
2019-10-01 03:48:24 +00:00
|
|
|
|
2015-05-13 07:35:46 +00:00
|
|
|
(defun c-c++/init-clang-format ()
|
|
|
|
(use-package clang-format
|
2019-12-08 22:36:38 +00:00
|
|
|
:init (spacemacs//c-c++-setup-clang-format)))
|
2015-05-13 07:35:46 +00:00
|
|
|
|
2015-05-14 02:32:39 +00:00
|
|
|
(defun c-c++/post-init-company ()
|
2019-10-01 03:48:24 +00:00
|
|
|
(add-hook 'c-mode-local-vars-hook #'spacemacs//c-c++-setup-company)
|
|
|
|
(add-hook 'c++-mode-local-vars-hook #'spacemacs//c-c++-setup-company))
|
2015-05-14 02:32:39 +00:00
|
|
|
|
2016-05-30 02:39:21 +00:00
|
|
|
(defun c-c++/init-company-c-headers ()
|
|
|
|
(use-package company-c-headers
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2017-01-02 05:39:04 +00:00
|
|
|
:init (spacemacs|add-company-backends
|
|
|
|
:backends company-c-headers
|
|
|
|
:modes c-mode-common)))
|
2015-05-14 02:32:39 +00:00
|
|
|
|
2018-01-06 07:44:33 +00:00
|
|
|
(defun c-c++/init-company-rtags ()
|
|
|
|
(use-package company-rtags
|
2019-10-01 03:48:24 +00:00
|
|
|
:defer t))
|
2018-01-06 07:44:33 +00:00
|
|
|
|
2019-10-01 03:48:24 +00:00
|
|
|
(defun c-c++/init-company-ycmd ()
|
|
|
|
(use-package company-ycmd
|
|
|
|
:defer t
|
|
|
|
:commands company-ycmd))
|
2018-05-13 03:59:50 +00:00
|
|
|
|
|
|
|
(defun c-c++/post-init-counsel-gtags ()
|
|
|
|
(dolist (mode c-c++-modes)
|
|
|
|
(spacemacs/counsel-gtags-define-keys-for-mode mode)))
|
|
|
|
|
2019-05-10 17:40:06 +00:00
|
|
|
(defun c-c++/init-cpp-auto-include ()
|
|
|
|
(use-package cpp-auto-include
|
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(progn
|
2020-02-11 16:09:59 +00:00
|
|
|
(when c-c++-enable-organize-includes-on-save
|
|
|
|
(add-hook 'c++-mode-hook #'spacemacs/c-c++-organize-includes-on-save))
|
2019-05-10 17:40:06 +00:00
|
|
|
|
|
|
|
(spacemacs/declare-prefix-for-mode 'c++-mode
|
|
|
|
"mr" "refactor")
|
2021-09-02 12:19:26 +00:00
|
|
|
|
2019-05-10 17:40:06 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'c++-mode
|
2021-09-02 09:36:32 +00:00
|
|
|
"ri" #'spacemacs/c-c++-organize-includes))))
|
2019-05-10 17:40:06 +00:00
|
|
|
|
2019-10-01 03:48:24 +00:00
|
|
|
(defun c-c++/pre-init-dap-mode ()
|
2021-04-04 16:58:30 +00:00
|
|
|
(pcase c-c++-backend
|
|
|
|
('lsp-clangd (add-to-list 'spacemacs--dap-supported-modes 'c-mode)
|
2020-05-16 21:32:30 +00:00
|
|
|
(add-to-list 'spacemacs--dap-supported-modes 'c++-mode))
|
2021-04-04 16:58:30 +00:00
|
|
|
('lsp-ccls (add-to-list 'spacemacs--dap-supported-modes 'c-mode)
|
2020-05-16 21:32:30 +00:00
|
|
|
(add-to-list 'spacemacs--dap-supported-modes 'c++-mode)))
|
2019-10-01 03:48:24 +00:00
|
|
|
(add-hook 'c-mode-local-vars-hook #'spacemacs//c-c++-setup-dap)
|
|
|
|
(add-hook 'c++-mode-local-vars-hook #'spacemacs//c-c++-setup-dap))
|
|
|
|
|
2018-05-13 03:59:50 +00:00
|
|
|
(defun c-c++/init-disaster ()
|
|
|
|
(use-package disaster
|
|
|
|
:defer t
|
|
|
|
:commands (disaster)
|
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(dolist (mode c-c++-modes)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode
|
|
|
|
"D" 'disaster)))))
|
|
|
|
|
2019-10-01 03:48:24 +00:00
|
|
|
(defun c-c++/post-init-eldoc ()
|
|
|
|
(add-hook 'c-mode-local-vars-hook #'spacemacs//c-c++-setup-eldoc)
|
|
|
|
(add-hook 'c++-mode-local-vars-hook #'spacemacs//c-c++-setup-eldoc))
|
|
|
|
|
2015-04-11 02:23:16 +00:00
|
|
|
(defun c-c++/post-init-flycheck ()
|
2019-10-01 03:48:24 +00:00
|
|
|
(add-hook 'c-mode-local-vars-hook #'spacemacs//c-c++-setup-flycheck)
|
|
|
|
(add-hook 'c++-mode-local-vars-hook #'spacemacs//c-c++-setup-flycheck))
|
2015-03-16 01:44:10 +00:00
|
|
|
|
2018-01-06 07:44:33 +00:00
|
|
|
(defun c-c++/init-flycheck-rtags ()
|
|
|
|
(use-package flycheck-rtags
|
2019-10-01 03:48:24 +00:00
|
|
|
:defer t))
|
|
|
|
|
|
|
|
(defun c-c++/init-flycheck-ycmd ()
|
|
|
|
(use-package flycheck-ycmd
|
|
|
|
:defer t))
|
2018-01-06 07:44:33 +00:00
|
|
|
|
2016-04-05 04:08:34 +00:00
|
|
|
(defun c-c++/post-init-ggtags ()
|
2016-08-15 19:24:44 +00:00
|
|
|
(add-hook 'c-mode-local-vars-hook #'spacemacs/ggtags-mode-enable)
|
|
|
|
(add-hook 'c++-mode-local-vars-hook #'spacemacs/ggtags-mode-enable))
|
2016-04-05 04:08:34 +00:00
|
|
|
|
2015-05-29 03:42:01 +00:00
|
|
|
(defun c-c++/init-gdb-mi ()
|
|
|
|
(use-package gdb-mi
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2015-05-29 03:42:01 +00:00
|
|
|
:init
|
|
|
|
(setq
|
|
|
|
;; use gdb-many-windows by default when `M-x gdb'
|
|
|
|
gdb-many-windows t
|
|
|
|
;; Non-nil means display source file containing the main routine at startup
|
|
|
|
gdb-show-main t)))
|
|
|
|
|
2018-05-13 03:59:50 +00:00
|
|
|
(defun c-c++/init-google-c-style ()
|
|
|
|
(use-package google-c-style
|
2019-10-01 03:48:24 +00:00
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(when c-c++-enable-google-style
|
|
|
|
(add-hook 'c-mode-common-hook 'google-set-c-style))
|
|
|
|
(when c-c++-enable-google-newline
|
|
|
|
(add-hook 'c-mode-common-hook 'google-make-newline-indent)))))
|
2018-05-13 03:59:50 +00:00
|
|
|
|
|
|
|
(defun c-c++/pre-init-helm-cscope ()
|
|
|
|
(spacemacs|use-package-add-hook xcscope
|
|
|
|
:post-init
|
|
|
|
(dolist (mode c-c++-modes)
|
|
|
|
(spacemacs/setup-helm-cscope mode))))
|
2017-08-26 21:18:09 +00:00
|
|
|
|
2016-05-30 02:39:21 +00:00
|
|
|
(defun c-c++/post-init-helm-gtags ()
|
2017-07-30 21:05:50 +00:00
|
|
|
(dolist (mode c-c++-modes)
|
|
|
|
(spacemacs/helm-gtags-define-keys-for-mode mode)))
|
2015-04-15 05:36:37 +00:00
|
|
|
|
2018-01-06 07:44:33 +00:00
|
|
|
(defun c-c++/init-helm-rtags ()
|
|
|
|
(use-package helm-rtags
|
2019-10-01 03:48:24 +00:00
|
|
|
:defer t
|
2018-01-06 07:44:33 +00:00
|
|
|
:init (setq rtags-display-result-backend 'helm)))
|
|
|
|
|
|
|
|
(defun c-c++/init-ivy-rtags ()
|
|
|
|
(use-package ivy-rtags
|
2019-10-01 03:48:24 +00:00
|
|
|
:defer t
|
2018-01-06 07:44:33 +00:00
|
|
|
:init (setq rtags-display-result-backend 'ivy)))
|
|
|
|
|
2019-10-01 03:48:24 +00:00
|
|
|
(defun c-c++/pre-init-org ()
|
|
|
|
(spacemacs|use-package-add-hook org
|
|
|
|
:post-config (add-to-list 'org-babel-load-languages '(C . t))))
|
|
|
|
|
|
|
|
(defun c-c++/pre-init-projectile ()
|
|
|
|
(spacemacs|use-package-add-hook projectile
|
|
|
|
:post-config
|
|
|
|
(progn
|
|
|
|
(when c-c++-adopt-subprojects
|
|
|
|
(setq projectile-project-root-files-top-down-recurring
|
|
|
|
(append '("compile_commands.json"
|
|
|
|
".ccls")
|
|
|
|
projectile-project-root-files-top-down-recurring))))))
|
|
|
|
|
2018-01-06 07:44:33 +00:00
|
|
|
(defun c-c++/init-rtags ()
|
2019-10-01 03:48:24 +00:00
|
|
|
;; config in `funcs.el'
|
2018-01-06 07:44:33 +00:00
|
|
|
(use-package rtags
|
2019-10-01 03:48:24 +00:00
|
|
|
:defer t))
|
2018-01-06 07:44:33 +00:00
|
|
|
|
2021-02-10 07:51:55 +00:00
|
|
|
(defun c-c++/post-init-realgud ()
|
2017-07-18 21:54:00 +00:00
|
|
|
(dolist (mode c-c++-modes)
|
|
|
|
(spacemacs/add-realgud-debugger mode "gdb")))
|
2017-05-14 17:20:10 +00:00
|
|
|
|
2015-04-23 14:35:04 +00:00
|
|
|
(defun c-c++/post-init-semantic ()
|
2019-10-01 03:48:24 +00:00
|
|
|
(add-hook 'c-mode-local-vars-hook #'spacemacs//c-c++-setup-semantic)
|
|
|
|
(add-hook 'c++-mode-local-vars-hook #'spacemacs//c-c++-setup-semantic))
|
2015-04-23 14:35:04 +00:00
|
|
|
|
|
|
|
(defun c-c++/post-init-srefactor ()
|
2017-07-30 21:05:50 +00:00
|
|
|
(dolist (mode c-c++-modes)
|
2018-08-30 20:03:11 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "r." 'srefactor-refactor-at-point))
|
2018-01-18 04:03:00 +00:00
|
|
|
(spacemacs/add-to-hooks 'spacemacs/load-srefactor c-c++-mode-hooks))
|
2015-03-16 01:44:10 +00:00
|
|
|
|
2015-04-16 10:43:10 +00:00
|
|
|
(defun c-c++/post-init-stickyfunc-enhance ()
|
2018-01-18 04:03:00 +00:00
|
|
|
(spacemacs/add-to-hooks 'spacemacs/load-stickyfunc-enhance c-c++-mode-hooks))
|
2015-04-03 21:12:56 +00:00
|
|
|
|
2015-07-24 02:20:25 +00:00
|
|
|
(defun c-c++/pre-init-xcscope ()
|
|
|
|
(spacemacs|use-package-add-hook xcscope
|
|
|
|
:post-init
|
2017-07-30 21:05:50 +00:00
|
|
|
(dolist (mode c-c++-modes)
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "gi" 'cscope-index-files))))
|
2018-08-30 20:03:11 +00:00
|
|
|
|
2019-10-01 03:48:24 +00:00
|
|
|
(defun c-c++/init-ycmd ()
|
|
|
|
(use-package ycmd
|
|
|
|
:defer t
|
|
|
|
:init
|
2018-08-30 20:03:11 +00:00
|
|
|
(progn
|
2019-10-01 03:48:24 +00:00
|
|
|
(unless (boundp 'ycmd-global-config)
|
|
|
|
(setq-default ycmd-global-config
|
|
|
|
(concat (configuration-layer/get-layer-path 'ycmd)
|
|
|
|
"global_conf.py")))
|
|
|
|
(setq-default ycmd-parse-conditions '(save mode-enabled)))))
|