add an option to use google-c-style
This commit is contained in:
parent
f3dbeec5dc
commit
16fd3e85a4
|
@ -13,6 +13,7 @@
|
|||
- [[#clang-format][clang-format]]
|
||||
- [[#company-clang-and-flycheck][Company-clang and flycheck]]
|
||||
- [[#cmake-configuration][CMake configuration]]
|
||||
- [[#enable-google-set-c-style][Enable google-set-c-style]]
|
||||
- [[#key-bindings][Key Bindings]]
|
||||
- [[#debugger-realgud][Debugger (realgud)]]
|
||||
|
||||
|
@ -134,6 +135,36 @@ build your project with ~SPC c c~ key binding.
|
|||
(helm-make-arguments . "-j7"))))
|
||||
#+END_SRC
|
||||
|
||||
** Enable google-set-c-style
|
||||
If you have clang enabled with =clang-format= as described earlier in this page
|
||||
you may not have a lot of neeed for =google-set-c-style= if you are already
|
||||
using a mode based on Google mode for most of your projects.
|
||||
|
||||
However, if you don't have (or want) =clang-format=, or if you have to do a lot
|
||||
[[https://www.emacswiki.org/emacs/TrampMode][Tramp]] remote editing on systems that don't have =clang-format= installed, you
|
||||
may want =google-c-style= enabled and added to your common hooks.
|
||||
|
||||
To get =google-c-style= actually install itself into your C/C++ common hooks,
|
||||
you need to have =c-c++-enable-google-style= defined to true when you load the
|
||||
C-C++ lang in Spacemacs. In your =~/.spacemacs= file, a possible way that this
|
||||
would look is that in your list of =dostpacemacs-configuration-layers= you have
|
||||
an entry like
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(c-c++ :variables
|
||||
c-c++-enable-google-style t)
|
||||
#+END_SRC emacs-lisp
|
||||
|
||||
Additionally, if you have =c-c++-enable-google-newline= variable set then
|
||||
=`google-make-newline-indent= will be set as a =c-mode-common-hook=. You would
|
||||
set that up like this:
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(c-c++ :variables
|
||||
c-c++-enable-google-style t
|
||||
c-c++-enable-google-newline t)
|
||||
#+END_SRC emacs-lisp
|
||||
|
||||
* Key Bindings
|
||||
|
||||
| Key Binding | Description |
|
||||
|
|
|
@ -20,6 +20,14 @@
|
|||
(defvar c-c++-enable-clang-support nil
|
||||
"If non nil Clang related packages and configuration are enabled.")
|
||||
|
||||
(defvar c-c++-enable-google-style nil
|
||||
"If non-nil `google-set-c-style' will be added as as
|
||||
`c-mode-common-hook'.")
|
||||
|
||||
(defvar c-c++-enable-google-newline nil
|
||||
"If non-nil `google-make-newline-indent' will be added as as
|
||||
`c-mode-common-hook'.")
|
||||
|
||||
(defvar c-c++-enable-cmake-ide-support nil
|
||||
"If non nil CMake related packages and configuration are enabled.")
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
gdb-mi
|
||||
ggtags
|
||||
counsel-gtags
|
||||
google-c-style
|
||||
helm-cscope
|
||||
helm-gtags
|
||||
realgud
|
||||
|
@ -157,6 +158,13 @@
|
|||
"q" 'realgud:cmd-quit
|
||||
"S" 'realgud-window-cmd-undisturb-src))))
|
||||
|
||||
(defun c-c++/init-google-c-style ()
|
||||
(use-package google-c-style
|
||||
:if (or 'c-c++-enable-google-style 'c-c++-enable-google-newline)
|
||||
:config (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-set-c-style)))))
|
||||
|
||||
(defun c-c++/post-init-semantic ()
|
||||
(spacemacs/add-to-hooks 'semantic-mode c-c++-mode-hooks))
|
||||
|
||||
|
|
Loading…
Reference in New Issue