2015-01-14 04:12:56 +00:00
|
|
|
;;; packages.el --- C/C++ Layer packages File for Spacemacs
|
|
|
|
;;
|
2017-01-06 03:51:13 +00:00
|
|
|
;; Copyright (c) 2012-2017 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
|
2014-12-14 04:08:55 +00:00
|
|
|
'(
|
|
|
|
cc-mode
|
2015-07-27 22:04:39 +00:00
|
|
|
disaster
|
2015-05-13 07:35:46 +00:00
|
|
|
clang-format
|
2017-08-14 07:54:15 +00:00
|
|
|
cmake-ide
|
2014-12-14 04:08:55 +00:00
|
|
|
cmake-mode
|
2015-03-22 06:23:12 +00:00
|
|
|
company
|
2017-07-03 07:52:54 +00:00
|
|
|
(company-c-headers :requires company)
|
2015-04-28 01:26:51 +00:00
|
|
|
company-ycmd
|
2014-12-23 03:51:44 +00:00
|
|
|
flycheck
|
2015-05-29 03:42:01 +00:00
|
|
|
gdb-mi
|
2016-04-05 04:08:34 +00:00
|
|
|
ggtags
|
2015-07-24 02:20:25 +00:00
|
|
|
helm-cscope
|
2015-04-15 05:36:37 +00:00
|
|
|
helm-gtags
|
2017-05-14 17:20:10 +00:00
|
|
|
realgud
|
2015-04-23 14:35:04 +00:00
|
|
|
semantic
|
2016-03-10 13:29:04 +00:00
|
|
|
srefactor
|
2015-03-12 09:16:14 +00:00
|
|
|
stickyfunc-enhance
|
2015-04-28 01:26:51 +00:00
|
|
|
ycmd
|
2015-07-28 18:09:23 +00:00
|
|
|
xcscope
|
2015-04-19 03:40:24 +00:00
|
|
|
))
|
2014-12-14 04:08:55 +00:00
|
|
|
|
|
|
|
(defun c-c++/init-cc-mode ()
|
|
|
|
(use-package cc-mode
|
|
|
|
:defer t
|
2015-05-02 13:52:15 +00:00
|
|
|
:init
|
2016-08-13 13:43:37 +00:00
|
|
|
(progn
|
2016-09-05 02:29:41 +00:00
|
|
|
(add-to-list 'auto-mode-alist
|
|
|
|
`("\\.h\\'" . ,c-c++-default-mode-for-headers)))
|
2014-12-14 04:08:55 +00:00
|
|
|
:config
|
|
|
|
(progn
|
2015-02-23 14:59:01 +00:00
|
|
|
(require 'compile)
|
2015-03-11 00:26:16 +00:00
|
|
|
(c-toggle-auto-newline 1)
|
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
|
|
|
|
2015-07-27 22:04:39 +00:00
|
|
|
(defun c-c++/init-disaster ()
|
|
|
|
(use-package disaster
|
|
|
|
:defer t
|
|
|
|
:commands (disaster)
|
|
|
|
:init
|
|
|
|
(progn
|
2017-07-30 21:05:50 +00:00
|
|
|
(dolist (mode c-c++-modes)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode
|
|
|
|
"D" 'disaster)))))
|
2015-07-27 22:04:39 +00:00
|
|
|
|
2015-05-13 07:35:46 +00:00
|
|
|
(defun c-c++/init-clang-format ()
|
|
|
|
(use-package clang-format
|
2017-04-07 09:21:05 +00:00
|
|
|
:if c-c++-enable-clang-support
|
|
|
|
:init
|
|
|
|
(when c-c++-enable-clang-format-on-save
|
2017-07-30 21:05:50 +00:00
|
|
|
(spacemacs/add-to-hooks 'spacemacs/clang-format-on-save c-c++-mode-hooks))))
|
2015-05-13 07:35:46 +00:00
|
|
|
|
2017-08-14 07:54:15 +00:00
|
|
|
(defun c-c++/init-cmake-ide ()
|
|
|
|
(use-package cmake-ide)
|
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
(cmake-ide-setup)
|
|
|
|
(dolist (mode c-c++-modes)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode
|
|
|
|
"cc" 'cmake-ide-compile
|
|
|
|
"pc" 'cmake-ide-run-cmake
|
|
|
|
"pC" 'cmake-ide-maybe-run-cmake
|
|
|
|
"pd" 'cmake-ide-delete-file))))
|
|
|
|
|
2014-12-14 04:08:55 +00:00
|
|
|
(defun c-c++/init-cmake-mode ()
|
2015-02-23 14:59:01 +00:00
|
|
|
(use-package cmake-mode
|
2017-01-06 11:01:18 +00:00
|
|
|
:mode (("CMakeLists\\.txt\\'" . cmake-mode) ("\\.cmake\\'" . cmake-mode))))
|
2014-12-23 03:51:44 +00:00
|
|
|
|
2015-05-14 02:32:39 +00:00
|
|
|
(defun c-c++/post-init-company ()
|
2017-07-02 13:48:06 +00:00
|
|
|
(when (configuration-layer/package-used-p 'cmake-mode)
|
2017-01-02 05:39:04 +00:00
|
|
|
(spacemacs|add-company-backends :backends company-cmake :modes cmake-mode))
|
2016-02-04 13:08:55 +00:00
|
|
|
(when c-c++-enable-clang-support
|
2017-01-02 05:39:04 +00:00
|
|
|
(spacemacs|add-company-backends :backends company-clang
|
|
|
|
:modes c-mode-common)
|
2017-04-09 21:55:50 +00:00
|
|
|
(setq company-clang-prefix-guesser 'spacemacs/company-more-than-prefix-guesser)
|
2017-07-30 21:05:50 +00:00
|
|
|
(spacemacs/add-to-hooks 'spacemacs/c-c++-load-clang-args c-c++-mode-hooks)))
|
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
|
|
|
|
: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
|
|
|
|
2015-04-11 02:23:16 +00:00
|
|
|
(defun c-c++/post-init-flycheck ()
|
2017-07-30 21:05:50 +00:00
|
|
|
(dolist (mode c-c++-modes)
|
2017-02-14 03:27:29 +00:00
|
|
|
(spacemacs/enable-flycheck mode))
|
2015-11-15 12:21:53 +00:00
|
|
|
(when c-c++-enable-clang-support
|
2017-07-30 21:05:50 +00:00
|
|
|
(spacemacs/add-to-hooks 'spacemacs/c-c++-load-clang-args c-c++-mode-hooks)))
|
2015-03-16 01:44:10 +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
|
|
|
|
:defer t
|
|
|
|
: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)))
|
|
|
|
|
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
|
|
|
|
2017-05-14 17:20:10 +00:00
|
|
|
(defun c-c++/init-realgud()
|
|
|
|
(use-package realgud
|
|
|
|
:defer t
|
|
|
|
:commands (realgud:gdb)
|
|
|
|
:init
|
|
|
|
(progn
|
2017-07-30 21:05:50 +00:00
|
|
|
(dolist (mode c-c++-modes)
|
2017-05-14 17:20:10 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode
|
|
|
|
"dd" 'realgud:gdb
|
|
|
|
"de" 'realgud:cmd-eval-dwim))
|
|
|
|
(advice-add 'realgud-short-key-mode-setup
|
|
|
|
:before #'spacemacs//short-key-state)
|
|
|
|
(evilified-state-evilify-map realgud:shortkey-mode-map
|
|
|
|
:eval-after-load realgud
|
|
|
|
:mode realgud-short-key-mode
|
|
|
|
:bindings
|
|
|
|
"s" 'realgud:cmd-next
|
|
|
|
"i" 'realgud:cmd-step
|
|
|
|
"b" 'realgud:cmd-break
|
|
|
|
"B" 'realgud:cmd-clear
|
|
|
|
"o" 'realgud:cmd-finish
|
|
|
|
"c" 'realgud:cmd-continue
|
|
|
|
"e" 'realgud:cmd-eval
|
|
|
|
"r" 'realgud:cmd-restart
|
|
|
|
"q" 'realgud:cmd-quit
|
|
|
|
"S" 'realgud-window-cmd-undisturb-src))))
|
|
|
|
|
2015-04-23 14:35:04 +00:00
|
|
|
(defun c-c++/post-init-semantic ()
|
2017-07-30 21:05:50 +00:00
|
|
|
(spacemacs/add-to-hooks 'semantic-mode c-c++-mode-hooks))
|
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)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "r" 'srefactor-refactor-at-point))
|
|
|
|
(spacemacs/add-to-hooks 'spacemacs/lazy-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 ()
|
2017-07-30 21:05:50 +00:00
|
|
|
(spacemacs/add-to-hooks 'spacemacs/lazy-load-stickyfunc-enhance c-c++-mode-hooks))
|
2015-04-03 21:12:56 +00:00
|
|
|
|
2015-04-28 02:27:11 +00:00
|
|
|
(defun c-c++/post-init-ycmd ()
|
2017-07-30 21:05:50 +00:00
|
|
|
(spacemacs/add-to-hooks 'ycmd-mode c-c++-mode-hooks)
|
2016-09-04 16:24:43 +00:00
|
|
|
(add-to-list 'spacemacs-jump-handlers-c++-mode '(ycmd-goto :async t))
|
|
|
|
(add-to-list 'spacemacs-jump-handlers-c-mode '(ycmd-goto :async t))
|
2017-07-30 21:05:50 +00:00
|
|
|
(dolist (mode c-c++-modes)
|
2016-08-13 13:43:37 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode
|
|
|
|
"gG" 'ycmd-goto-imprecise)))
|
2015-04-28 02:27:11 +00:00
|
|
|
|
|
|
|
(defun c-c++/post-init-company-ycmd ()
|
2017-01-02 05:39:04 +00:00
|
|
|
(spacemacs|add-company-backends :backends company-ycmd :modes c-mode-common))
|
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))))
|
2015-07-24 02:20:25 +00:00
|
|
|
|
2016-05-30 02:39:21 +00:00
|
|
|
(defun c-c++/pre-init-helm-cscope ()
|
|
|
|
(spacemacs|use-package-add-hook xcscope
|
|
|
|
:post-init
|
2017-07-30 21:05:50 +00:00
|
|
|
(dolist (mode c-c++-modes)
|
2016-05-30 02:39:21 +00:00
|
|
|
(spacemacs/setup-helm-cscope mode))))
|