2015-01-14 04:12:56 +00:00
|
|
|
;;; packages.el --- C/C++ Layer packages File for Spacemacs
|
|
|
|
;;
|
2018-01-04 07:00:25 +00:00
|
|
|
;; Copyright (c) 2012-2018 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.
|
|
|
|
;;
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
2015-04-19 03:40:24 +00:00
|
|
|
(setq c-c++-packages
|
2018-11-20 19:55:37 +00:00
|
|
|
'(
|
|
|
|
cc-mode
|
|
|
|
clang-format
|
|
|
|
(company-c-headers :requires company)
|
2019-05-10 17:40:06 +00:00
|
|
|
(cpp-auto-include
|
|
|
|
:location (recipe :fetcher github
|
|
|
|
:repo "syohex/emacs-cpp-auto-include"))
|
2018-11-20 19:55:37 +00:00
|
|
|
disaster
|
2019-10-01 03:48:24 +00:00
|
|
|
eldoc
|
2018-11-20 19:55:37 +00:00
|
|
|
flycheck
|
|
|
|
gdb-mi
|
|
|
|
google-c-style
|
|
|
|
helm-cscope
|
|
|
|
org
|
2019-10-01 03:48:24 +00:00
|
|
|
projectile
|
2018-11-20 19:55:37 +00:00
|
|
|
realgud
|
|
|
|
semantic
|
|
|
|
srefactor
|
|
|
|
stickyfunc-enhance
|
|
|
|
xcscope
|
2019-10-01 03:48:24 +00:00
|
|
|
;; lsp
|
2018-11-20 19:55:37 +00:00
|
|
|
(ccls :requires lsp-mode)
|
2019-10-01 03:48:24 +00:00
|
|
|
dap-mode
|
|
|
|
;; rtags
|
2019-11-03 04:01:13 +00:00
|
|
|
(company-rtags :requires (company rtags))
|
2019-10-01 03:48:24 +00:00
|
|
|
counsel-gtags
|
2019-11-03 04:01:13 +00:00
|
|
|
(flycheck-rtags :requires (flycheck rtags))
|
2019-10-01 03:48:24 +00:00
|
|
|
ggtags
|
|
|
|
helm-gtags
|
2019-11-03 04:01:13 +00:00
|
|
|
(helm-rtags :requires (helm rtags))
|
|
|
|
(ivy-rtags :requires (ivy rtags))
|
2019-10-01 03:48:24 +00:00
|
|
|
rtags
|
|
|
|
;; ycmd
|
|
|
|
(company-ycmd :requires company)
|
|
|
|
(flycheck-ycmd :requires flycheck)
|
|
|
|
ycmd))
|
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
|
|
|
|
(when c++-enable-organize-includes-on-save
|
|
|
|
(add-hook 'c++-mode-hook #'spacemacs/c++-organize-includes-on-save))
|
|
|
|
|
|
|
|
(spacemacs/declare-prefix-for-mode 'c++-mode
|
|
|
|
"mr" "refactor")
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'c++-mode
|
|
|
|
"ri" #'spacemacs/c++-organize-includes))))
|
|
|
|
|
2019-10-01 03:48:24 +00:00
|
|
|
(defun c-c++/pre-init-dap-mode ()
|
|
|
|
(add-to-list 'spacemacs--dap-supported-modes 'c-mode)
|
|
|
|
(add-to-list 'spacemacs--dap-supported-modes 'c++-mode)
|
|
|
|
(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
|
|
|
|
2017-07-18 21:54:00 +00:00
|
|
|
(defun c-c++/post-init-realgud()
|
|
|
|
(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)))))
|