c-c++: move realgud config to c-c++ layer and delete debug layer

For now realug is used only to C and C++ so it makes more sense to add it to
the c-c++ layer for now.
Later if we can generalize the support of realgud for other languages and we
can start a debugger layer.
This commit is contained in:
syl20bnr 2017-05-14 13:20:10 -04:00
parent d5c4bb8b9a
commit 7d215cb089
8 changed files with 56 additions and 103 deletions

View File

@ -13,6 +13,7 @@
- [[#clang-format][clang-format]]
- [[#company-clang-and-flycheck][Company-clang and flycheck]]
- [[#key-bindings][Key Bindings]]
- [[#debugger-realgud][Debugger (realgud)]]
* Description
This layer adds configuration for C/C++ language as well support for [[https://cmake.org/][CMake]]
@ -32,6 +33,7 @@ scripts.
- Support auto-completion (when =auto-completion= layer is included) via
company-clang (when =c-c++-enable-clang-support= is turned on), or
company-ycmd (when =ycmd= layer is included).
- Support for [[https://github.com/realgud/realgud][realgud]] debugger.
* Install
** Layer
@ -112,3 +114,20 @@ doesn't complain about missing header files.
| ~SPC m r~ | srefactor: refactor thing at point. |
*Note:* [[https://github.com/tuhdo/semantic-refactor][semantic-refactor]] is only available for Emacs 24.4+
** Debugger (realgud)
| Key Binding | Description |
|-------------+-----------------|
| ~SPC m d d~ | open cmd buffer |
| ~SPC m d e~ | eval variable |
| ~s~ | step over |
| ~i~ | step into |
| ~b~ | set break |
| ~B~ | unset break |
| ~o~ | step out |
| ~c~ | continue |
| ~e~ | eval variable |
| ~r~ | restart |
| ~q~ | quit debug |
| ~S~ | goto cmd buffer |

View File

@ -69,3 +69,12 @@ and the arguments for flyckeck-clang based on a project-specific text file."
(append '("/usr/include" "/usr/local/include")
dirs))
(setq-local flycheck-clang-args flags))))
;; realgud
(defun spacemacs//short-key-state (modeon)
"Set evil-evilified-state explicitly."
(if modeon
(evil-evilified-state)
(evil-normal-state)))

View File

@ -23,6 +23,7 @@
ggtags
helm-cscope
helm-gtags
realgud
semantic
srefactor
stickyfunc-enhance
@ -112,6 +113,33 @@
(spacemacs/helm-gtags-define-keys-for-mode 'c-mode)
(spacemacs/helm-gtags-define-keys-for-mode 'c++-mode))
(defun c-c++/init-realgud()
(use-package realgud
:defer t
:commands (realgud:gdb)
:init
(progn
(dolist (mode '(c-mode c++-mode))
(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))))
(defun c-c++/post-init-semantic ()
(spacemacs/add-to-hooks 'semantic-mode '(c-mode-hook c++-mode-hook)))

View File

@ -1,53 +0,0 @@
#+TITLE: debug layer
[[file:img/debug.png]]
* Table of Contents :TOC_4_gh:noexport:
- [[#description][Description]]
- [[#install][Install]]
- [[#enable-c-c-debug][enable c-c++ debug]]
- [[#key-bindings][Key bindings]]
- [[#leader][Leader]]
- [[#shortkey-mode-c-c][shortkey-mode (c-c++)]]
* Description
This layer add debug for mutil language using [[https://github.com/realgud/realgud][realgud]].
* Install
To use this configuration layer, add it to your =~/.spacemacs=. You will need to
add =debug= to the existing =dotspacemacs-configuration-layers= list in this
file.
** enable c-c++ debug
To enable debug for c-c++ set the layer variable =c-c++-enable-debug= to =t= in the dotfile:
#+BEGIN_SRC emacs-lisp
(setq-default dotspacemacs-configuration-layers
'((debug :variables c-c++-enable-debug t)))
#+END_SRC
* Key bindings
** Leader
| Key Binding | Description |
|-------------+-----------------|
| ~SPC m d d~ | open cmd buffer |
** shortkey-mode (c-c++)
| Key Binding | Description |
|-------------+-----------------|
| ~SPC m d e~ | eval variable |
| ~s~ | step over |
| ~i~ | step into |
| ~b~ | set break |
| ~B~ | unset break |
| ~o~ | step out |
| ~c~ | continue |
| ~e~ | eval variable |
| ~r~ | restart |
| ~q~ | quit debug |
| ~S~ | goto cmd buffer |
*Note:* In c++ debug,the real debug will start after input "start" in cmd buffer.

View File

@ -1,2 +0,0 @@
(defvar c-c++-enable-debug nil
"If non nil realgud debug enabled for c-c++.")

View File

@ -1,6 +0,0 @@
(defun short-key-state (modeon)
(if modeon
(evil-evilified-state)
(evil-normal-state)))
(advice-add 'realgud-short-key-mode-setup :before #'short-key-state)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -1,42 +0,0 @@
;;; packages.el --- debug layer packages file for Spacemacs.
;;
;; Copyright (c) 2012-2017 Sylvain Benner & Contributors
;;
;; Author: hodge <hodge@5.local>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
(defconst debug-packages
'(realgud))
(defun debug/init-realgud()
(use-package realgud
:defer t
:commands (realgud:gdb)
:init
(when c-c++-enable-debug
(spacemacs/set-leader-keys-for-major-mode 'c++-mode
"dd" 'realgud:gdb
"de" 'realgud:cmd-eval-dwim)
(spacemacs/set-leader-keys-for-major-mode 'c-mode
"dd" 'realgud:gdb
"de" 'realgud:cmd-eval-dwim)
(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)
)
))