2015-12-02 14:23:39 +00:00
#+TITLE : C/C++ layer
2015-06-10 16:44:30 +00:00
2019-05-07 08:53:56 +00:00
#+TAGS : general|layer|multi-paradigm|programming
2019-05-05 17:26:40 +00:00
2015-06-10 16:44:30 +00:00
[[file:img/ccpp.jpg ]]
2019-05-07 20:05:06 +00:00
* Table of Contents :TOC_5_gh:noexport:
2017-05-22 14:16:12 +00:00
- [[#description ][Description ]]
2017-08-06 02:14:10 +00:00
- [[#features ][Features: ]]
2017-05-22 14:16:12 +00:00
- [[#install ][Install ]]
- [[#layer ][Layer ]]
2018-08-30 20:03:11 +00:00
- [[#backends ][Backends ]]
2019-09-05 09:19:07 +00:00
- [[#lsp ][LSP ]]
- [[#features-1 ][Features ]]
2019-10-01 03:48:24 +00:00
- [[#external-dependencies ][External dependencies ]]
2019-09-05 09:19:07 +00:00
- [[#clangd ][clangd ]]
2019-05-07 20:05:06 +00:00
- [[#ccls-server ][ccls server ]]
2019-10-01 03:48:24 +00:00
- [[#configuration ][Configuration ]]
2019-05-07 20:05:06 +00:00
- [[#basic ][Basic ]]
2019-09-05 09:19:07 +00:00
- [[#selecting-an-alternate-lsp-server ][Selecting an alternate LSP server ]]
2019-11-03 01:53:35 +00:00
- [[#path-to-lsp-server-executables ][Path to LSP server executables ]]
2019-05-07 20:05:06 +00:00
- [[#semantic-highlighting ][Semantic highlighting ]]
2019-10-01 03:48:24 +00:00
- [[#cache-directory-absolute-or-relative ][Cache directory (absolute or relative) ]]
2019-05-07 20:05:06 +00:00
- [[#example-dotspacemacs-configuration-layers-entry ][Example dotspacemacs-configuration-layers entry ]]
2018-08-30 20:03:11 +00:00
- [[#completion ][Completion ]]
2019-04-14 12:44:51 +00:00
- [[#debugger-dap-integration ][Debugger (dap integration) ]]
2021-01-20 14:33:17 +00:00
- [[#adapter-selection ][Adapter selection ]]
- [[#microsoft-adapter-installation ][Microsoft adapter installation ]]
- [[#codefreak-adapter-installation ][CodeFreak adapter installation ]]
- [[#lldb-adapter-installation ][LLDB adapter installation ]]
2019-10-01 03:48:24 +00:00
- [[#rtags ][rtags ]]
- [[#external-dependencies-1 ][External dependencies ]]
- [[#configuration-1 ][Configuration ]]
- [[#default-mode-for-header-files ][Default mode for header files ]]
2019-05-10 17:40:06 +00:00
- [[#organize-file-header-includes-on-save ][Organize file header includes on save ]]
2019-10-01 03:48:24 +00:00
- [[#clang-format ][clang-format ]]
2016-03-31 19:36:56 +00:00
- [[#enable-google-set-c-style ][Enable google-set-c-style ]]
2018-05-15 20:54:03 +00:00
- [[#newlines ][Newlines ]]
2018-08-30 20:03:11 +00:00
- [[#projectile-sub-project-adoption ][Projectile sub-project adoption ]]
2018-12-05 03:03:03 +00:00
- [[#key-bindings ][Key bindings ]]
2019-09-05 09:19:07 +00:00
- [[#lsp-1 ][LSP ]]
2020-04-02 16:16:36 +00:00
- [[#ccls ][ccls ]]
2019-10-01 03:48:24 +00:00
- [[#backend-language-server ][backend (language server) ]]
- [[#goto ][goto ]]
2018-11-22 10:56:35 +00:00
- [[#gotohierarchy ][goto/hierarchy ]]
- [[#gotomember ][goto/member ]]
2019-10-01 03:48:24 +00:00
- [[#debugger ][debugger ]]
- [[#rtags-1 ][RTags ]]
2019-11-03 01:53:35 +00:00
- [[#additional-key-bindings ][Additional key bindings ]]
2019-10-01 03:48:24 +00:00
- [[#disassemble ][Disassemble ]]
- [[#formatting-clang-format ][Formatting (clang-format) ]]
- [[#open-matching-files ][Open matching files ]]
- [[#refactor ][Refactor ]]
2015-06-10 16:44:30 +00:00
* Description
2018-01-20 16:08:51 +00:00
This layer adds configuration for C/C++ language.
2015-06-10 16:44:30 +00:00
2017-08-06 02:14:10 +00:00
** Features:
2019-10-01 03:48:24 +00:00
- Multiple backends support:
2020-04-02 16:16:36 +00:00
- LSP with either =clangd= or [[https://github.com/MaskRay/ccls ][ccls ]]
2019-10-01 03:48:24 +00:00
- [[https://github.com/Andersbakken/rtags ][rtags ]] (gtags)
- [[https://github.com/abingham/emacs-ycmd ][emacs-ycmd ]]
- Support for debuggers [[https://github.com/realgud/realgud ][realgud ]] and [[https://github.com/emacs-lsp/dap-mode ][dap ]] (with LSP backend)
- Support syntax checking via flycheck (=syntax-checking= layer required)
- Auto-completion via company (=auto-completion= layer required)
2015-06-10 16:44:30 +00:00
- Support code reformatting with [[http://clang.llvm.org/docs/ClangFormat.html ][clang-format ]].
2019-10-01 03:48:24 +00:00
- Support for disassembly of code with [[https://github.com/jart/disaster ][disaster ]].
- =sematic= layer integration:
- Function or variable definition at the bottom
2019-11-03 01:05:53 +00:00
- Current function cursor is at the top. See [[https://github.com/tuhdo/semantic-stickyfunc-enhance ][stickyfunc-demos ]] for
2019-10-01 03:48:24 +00:00
demos in some programming languages.
- Support common refactoring with [[https://github.com/tuhdo/semantic-refactor ][semantic-refactor ]]. See [[https://github.com/tuhdo/semantic-refactor/blob/master/srefactor-demos/demos.org ][srefactor-demos ]] for
demonstration of refactoring features.
- =cscope= layer integration:
- code navigation
2015-06-10 16:44:30 +00:00
* Install
** Layer
2016-01-06 05:21:55 +00:00
To use this configuration layer, add it to your =~/.spacemacs= . You will need to
add =c-c++= to the existing =dotspacemacs-configuration-layers= list in this
file.
2015-06-10 16:44:30 +00:00
2019-10-01 03:48:24 +00:00
** Backends
Supported backends are:
2019-11-09 15:00:44 +00:00
- =lsp-clangd= using clangd LSP server
- =lsp-ccls= using ccls LSP server
- =rtags= using [[https://github.com/Andersbakken/rtags ][rtags ]]
- =ycmd= using [[https://github.com/abingham/emacs-ycmd ][emacs-ycmd ]]
2015-06-10 16:44:30 +00:00
2019-10-01 03:48:24 +00:00
To choose a default backend set the layer variable =c-c++-backend= :
2015-06-10 16:44:30 +00:00
2019-10-01 03:48:24 +00:00
#+BEGIN_SRC elisp
2020-02-23 10:05:22 +00:00
(c-c++ :variables c-c+ +-backend 'lsp-clangd)
2015-06-10 16:44:30 +00:00
#+END_SRC
2019-10-01 03:48:24 +00:00
Alternatively the =lsp-clangd= backend will be automatically chosen if the layer
=lsp= is used and you did not specify any value for =c-c++-backend= .
2018-08-30 20:03:11 +00:00
2019-10-01 03:48:24 +00:00
*Note:* It is recommended to use a modern backend like the =lsp= ones.
2018-08-30 20:03:11 +00:00
2019-11-03 01:05:53 +00:00
The backend can be chosen on a per project basis using directory local variables
(files named =.dir-locals.el= at the root of a project), an example is to use the
2019-10-01 03:48:24 +00:00
=lsp-ccls= backend:
2018-08-30 20:03:11 +00:00
2019-10-01 03:48:24 +00:00
#+BEGIN_SRC elisp
;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")
2018-08-30 20:03:11 +00:00
2019-10-01 03:48:24 +00:00
((c++-mode (c-c+ +-backend . lsp-ccls)))
2018-08-30 20:03:11 +00:00
#+END_SRC
2019-10-01 03:48:24 +00:00
*Note:* you can easily add a directory local variable with ~SPC f v d~ .
2018-08-30 20:03:11 +00:00
2019-09-05 09:19:07 +00:00
*** LSP
2020-09-09 07:47:12 +00:00
LSP support is provided via the [[file:../../+tools/lsp/README.org ][LSP layer ]], using one of two available backends
2019-10-01 03:48:24 +00:00
(all based on libclang).
2019-11-09 15:00:44 +00:00
- [[https://clang.llvm.org/extra/clangd/ ][clangd ]]
- [[https://github.com/MaskRay/ccls ][ccls ]]
2019-09-05 09:19:07 +00:00
They claim to be more efficient than existing tools at indexing large code bases.
2018-08-30 20:03:11 +00:00
2019-09-05 09:19:07 +00:00
**** Features
2018-08-30 20:03:11 +00:00
- Cross references (definitions, references, base/derived classes/methods, type instances, ...)
- Diagnostics
2020-04-02 16:41:28 +00:00
- Completion with =lsp=
2020-04-02 16:16:36 +00:00
- Semantic highlighting (=ccls= or =clangd= )
2019-10-13 05:27:17 +00:00
- Cross-platform - functional on Windows, Linux and macOS.
2018-08-30 20:03:11 +00:00
**** External dependencies
2019-10-01 03:48:24 +00:00
Install one (or more) of the following (=clangd= is used by default):
2018-08-30 20:03:11 +00:00
2019-09-05 09:19:07 +00:00
***** clangd
2019-11-09 15:00:44 +00:00
Install =clang= using a binary distribution downloaded from the [[http://releases.llvm.org/download.html][LLVM releases
page]] or via your package manager. This is the default implementation that's used by the
Emacs =lsp-mode= package and probably the easiest to install.
- [[https://clang.llvm.org/extra/clangd/Extensions.html ][clangd protocol extensions page ]]
2018-08-30 20:03:11 +00:00
***** ccls server
2019-10-01 03:48:24 +00:00
Install the =ccls= server. See [[https://github.com/MaskRay/ccls/wiki ][instructions ]]. This is currently the most fully
featured implementation, including semantic highlighting and some navigation/
2019-11-03 01:05:53 +00:00
introspection features that are not provided by clangd.
2019-09-05 09:19:07 +00:00
2019-10-01 03:48:24 +00:00
Note that prebuild binaries exist for most Linux distros and MacOS using
Homebrew.
2018-08-30 20:03:11 +00:00
**** Configuration
***** Basic
2019-10-01 03:48:24 +00:00
To use the default =clangd= language server, select =lsp-clangd= as the =c-c++=
layer backend by adding the following to your dotfile:
2018-08-30 20:03:11 +00:00
2019-11-09 15:00:44 +00:00
#+BEGIN_SRC emacs-lisp
(setq-default dotspacemacs-configuration-layers
'((c-c++ :variables c-c+ +-backend 'lsp-clangd)))
#+END_SRC
2019-09-05 09:19:07 +00:00
***** Selecting an alternate LSP server
2019-10-01 03:48:24 +00:00
To choose an alternate LSP server set the layer variable =c-c++-backend= to
another supported backend, for instance =lsp-ccls= :
2018-08-30 20:03:11 +00:00
2019-11-09 15:00:44 +00:00
#+BEGIN_SRC emacs-lisp
(setq-default dotspacemacs-configuration-layers
'((c-c++ :variables c-c+ +-backend 'lsp-ccls)))
#+END_SRC
2018-08-30 20:03:11 +00:00
2019-11-03 01:53:35 +00:00
***** Path to LSP server executables
LSP expects to find the LSP server executables in your =PATH= . If you want to
specify the location of an executable then you need to set the appropriate
variable:
| Server | Variable name |
|--------+---------------------------------|
| clangd | =lsp-clients-clangd-executable= |
| ccls | =ccls-executable= |
2019-10-01 03:48:24 +00:00
***** Semantic highlighting
2020-04-02 16:16:36 +00:00
Currently only available for =lsp-ccls= and =clangd= . Semantic highlighting
2019-10-01 03:48:24 +00:00
can precisely highlight identifiers.
2018-08-30 20:03:11 +00:00
2019-10-01 03:48:24 +00:00
Semantic highlighting is disabled by default. To enable it set the layer
=c-c++-lsp-enable-semantic-highlight= to non-nil. It is possible to give a
different color for each identifier by setting the variable to ='rainbow= .
2018-08-30 20:03:11 +00:00
2019-11-03 01:05:53 +00:00
When semantic highlighting is enabled then the method that's used to highlight the text
relies on Emacs' fastest =font-lock= mechanism. A more
accurate but also slower method is to use overlays. To use overlays set
2019-10-01 03:48:24 +00:00
the layer variable =c-c++-lsp-semantic-highlight-method= to ='overlay= .
2018-08-30 20:03:11 +00:00
2019-10-01 03:48:24 +00:00
***** Cache directory (absolute or relative)
2019-11-03 02:21:17 +00:00
=clangd= cache directoy is =.clangd= and cannot be changed.
2018-08-30 20:03:11 +00:00
2019-11-03 02:21:17 +00:00
=ccls= default directory is =.ccls-cache= , it can be changed by setting the
=:cache= option in the variable =ccls-initialization-options= .
2019-10-01 03:48:24 +00:00
See the full list of configuration options you can set at:
2018-08-30 20:03:11 +00:00
- [[https://github.com/MaskRay/ccls/wiki/Emacs ][Emacs section of =ccls= wiki ]]
***** Example dotspacemacs-configuration-layers entry
2019-11-09 15:00:44 +00:00
#+BEGIN_SRC emacs-lisp
(setq-default dotspacemacs-configuration-layers
'((c-c++ :variables
c-c++-adopt-subprojects t
c-c++-backend 'lsp-ccls
c-c++-lsp-enable-semantic-highlight 'rainbow)))
#+END_SRC
2018-08-30 20:03:11 +00:00
**** Completion
2020-04-02 16:41:28 +00:00
=company-capf= provides completion functionality. Client-side cache and sorting
2019-09-30 04:49:44 +00:00
have been disabled in favour of server,
2020-04-02 16:16:36 +00:00
as recommended by =ccls= wikis.
2018-08-30 20:03:11 +00:00
2019-04-14 12:44:51 +00:00
**** Debugger (dap integration)
2021-01-20 14:33:17 +00:00
***** Adapter selection
To select the active adapters, configure the =c-c++-dap-adapters= layer variable.
By default only the Microsoft extension is available.
| Adapter | Supported debuggers | DAP mode |
|--------------+-----------------------------------+----------------|
| Microsoft | gdb, lldb, Visual Studio Debugger | =dap-cpptools= |
| CodeFreak | gdb, lldb | =dap-gdb-lldb= |
| LLVM Project | lldb | =dap-lldb= |
Example configuration with two adapters selected:
#+BEGIN_SRC emacs-lisp
(setq-default dotspacemacs-configuration-layers
'((c-c++ :variables
c-c++-dap-adapters '(dap-lldb dap-cpptools)))
#+END_SRC
***** Microsoft adapter installation
To install the debug adapter you may run =M-x dap-cpptools-setup= when you are
on Linux.
***** CodeFreak adapter installation
2019-09-30 04:49:44 +00:00
To install the debug adapter you may run =M-x dap-gdb-lldb-setup= when you are
2019-10-01 03:48:24 +00:00
on Linux or download it manually from [[https://marketplace.visualstudio.com/items?itemName=webfreak.debug ][Native Debug ]] and adjust the
=dap-gdb-lldb-path= variable.
2019-04-14 12:44:51 +00:00
2021-01-20 14:33:17 +00:00
***** LLDB adapter installation
Install the =lldb-vscode= program. It usually comes with =lldb= from your
distribution's package repository.
Alternatively build directly following the [[https://github.com/llvm/llvm-project/tree/master/lldb/tools/lldb-vscode#installation-for-visual-studio-code ][official installation instructions ]].
Adjust the =dap-lldb-debug-program= variable to match the executable.
2019-10-01 03:48:24 +00:00
*** rtags
rtags is a well established clang-based source code indexing tool.
**** External dependencies
Install the RTags server via [[https://formulae.brew.sh/formula/rtags ][homebrew ]], the [[https://aur.archlinux.org/packages/rtags/ ][aur ]] or from source according to the
2019-11-03 01:05:53 +00:00
instructions [[https://github.com/Andersbakken/rtags ][here ]].
*Note:* RTags is not supported on Windows at the time of
2019-10-01 03:48:24 +00:00
writing, although there is an [[https://github.com/Andersbakken/rtags/issues/770 ][open issue with some recent activity ]] on github.
**** Configuration
To enable support for =rtags= , set the layer variable =c-c++-backend= :
2019-11-09 15:00:44 +00:00
#+BEGIN_SRC emacs-lisp
(setq-default dotspacemacs-configuration-layers
'((c-c++ :variables c-c+ +-backend 'rtags)))
#+END_SRC
2019-10-01 03:48:24 +00:00
This will also enable =company-rtags= to be used as a backend for
2019-11-03 01:05:53 +00:00
auto-completion (when the =auto-completion= layer is enabled).
To prevent this, while retaining the rest of Rtags' functionality,
2019-10-01 03:48:24 +00:00
set the variable =c-c++-rtags-completion= to =nil= :
2019-11-09 15:00:44 +00:00
#+BEGIN_SRC emacs-lisp
(setq-default dotspacemacs-configuration-layers
'((c-c++ :variables
c-c++-backend 'rtags
c-c++-enable-rtags-completion nil)))
#+END_SRC
2019-10-01 03:48:24 +00:00
** Default mode for header files
2019-11-03 01:05:53 +00:00
The mode for header files is auto detected by `c-or-c++-mode' in Emacs > 26.1+ .
Older versions of Emacs will open header files in =c-mode= by default, you can open them in
2019-10-01 03:48:24 +00:00
=c++-mode= by setting the variable =c-c++-default-mode-for-headers= as follow.
2019-05-10 17:40:06 +00:00
#+BEGIN_SRC emacs-lisp
(setq-default dotspacemacs-configuration-layers
2019-10-01 03:48:24 +00:00
'((c-c++ :variables c-c+ +-default-mode-for-headers 'c+ +-mode)))
2019-05-10 17:40:06 +00:00
#+END_SRC
2019-10-01 03:48:24 +00:00
*Note:* To set the variable for a given project, create a directory local
variable at the root of your project. More info on directory local variables
2019-11-03 01:05:53 +00:00
can be found in the manual: [[http://www.gnu.org/software/emacs/manual/html_node/elisp/Directory-Local-Variables.html ][dir-locals ]].
2019-10-01 03:48:24 +00:00
** Organize file header includes on save
To organize the file header includes on save, set the layer variable
=c++-enable-organize-includes-on-save= to =t= in the dotfile:
2015-06-10 16:44:30 +00:00
#+BEGIN_SRC emacs-lisp
(setq-default dotspacemacs-configuration-layers
2019-10-01 03:48:24 +00:00
'((c-c++ :variables c+ +-enable-organize-includes-on-save t)))
2015-06-10 16:44:30 +00:00
#+END_SRC
2019-10-01 03:48:24 +00:00
** clang-format
2019-11-03 01:05:53 +00:00
[[http://clang.llvm.org/docs/ClangFormat.html ][clang-format ]] allows for reformatting either a selected region of code
2019-10-01 03:48:24 +00:00
(=clang-format-region= ) or a whole buffer (=clang-format-buffer= ) according to a
style defined in a =.clang-format= file. This file is either located in the same
2019-11-03 01:05:53 +00:00
directory as the file being edited, or in any of its parent directories. If no
=.clang-format= file is found, then a default style will be used.
2015-06-10 16:44:30 +00:00
2017-04-07 09:21:05 +00:00
To enable automatic buffer formatting on save, set the variable
=c-c++-enable-clang-format-on-save= to =t= :
#+BEGIN_SRC emacs-lisp
2018-08-30 20:03:11 +00:00
(setq-default dotspacemacs-configuration-layers
'((c-c++ :variables c-c+ +-enable-clang-format-on-save t)))
2017-04-07 09:21:05 +00:00
#+END_SRC
2016-03-31 19:36:56 +00:00
** Enable google-set-c-style
If you have clang enabled with =clang-format= as described earlier in this page
2020-10-17 06:22:26 +00:00
you may not have a lot of need for =google-set-c-style= if you are already
2016-03-31 19:36:56 +00:00
using a mode based on Google mode for most of your projects.
2019-05-26 20:58:52 +00:00
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
2016-03-31 19:36:56 +00:00
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
2018-11-09 21:04:48 +00:00
(c-c++ :variables c-c+ +-enable-google-style t)
#+END_SRC
2016-03-31 19:36:56 +00:00
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
2018-11-09 21:04:48 +00:00
(c-c++ :variables c-c+ +-enable-google-style t
c-c++-enable-google-newline t)
#+END_SRC
2016-03-31 19:36:56 +00:00
2018-05-15 20:54:03 +00:00
** Newlines
You can enable the =Auto-newline= minor mode that automatically adds newlines
2018-05-24 02:12:30 +00:00
after certain characters by setting the =c-c++-enable-auto-newline= variable.
2018-05-15 20:54:03 +00:00
#+BEGIN_SRC emacs-lisp
2018-11-09 21:04:48 +00:00
(c-c++ :variables c-c+ +-enable-auto-newline t)
#+END_SRC
2018-05-15 20:54:03 +00:00
2018-08-30 20:03:11 +00:00
** Projectile sub-project adoption
To prevent projectile from using subproject root when visiting files in a subproject,
set =c-c++-adopt-subprojects= to =t= .
#+BEGIN_SRC emacs-lisp
2018-11-09 21:04:48 +00:00
(c-c++ :variables c-c+ +-adopt-subprojects t)
#+END_SRC
2018-08-30 20:03:11 +00:00
2020-04-02 16:16:36 +00:00
This is based on a recommendation on the =ccls= wikis, but should be more
2018-08-30 20:03:11 +00:00
generally applicable.
2018-12-05 03:03:03 +00:00
* Key bindings
2019-09-05 09:19:07 +00:00
** LSP
2019-11-03 01:05:53 +00:00
The default key bindings for the LSP implementations are defined and documented in
2019-10-01 03:48:24 +00:00
the [[file:../../+tools/lsp/README.org ][LSP layer ]].
2019-09-05 09:19:07 +00:00
2020-04-02 16:16:36 +00:00
*** ccls
A ~[ccls]~ suffix indicates that the binding is for the indicated backend only.
2018-11-22 10:56:35 +00:00
2019-10-01 03:48:24 +00:00
**** backend (language server)
2018-11-22 10:56:35 +00:00
2018-12-22 11:04:49 +00:00
| Key binding | Description |
2018-11-22 10:56:35 +00:00
|-------------+------------------------------------------|
| ~SPC m b f~ | refresh index (e.g. after branch change) |
| ~SPC m b p~ | preprocess file |
2018-08-30 20:03:11 +00:00
2019-10-01 03:48:24 +00:00
**** goto
2018-08-30 20:03:11 +00:00
2018-12-05 03:03:03 +00:00
| Key binding | Description |
2018-08-30 20:03:11 +00:00
|-------------+---------------------------|
| ~SPC m g &~ | find references (address) |
| ~SPC m g R~ | find references (read) |
| ~SPC m g W~ | find references (write) |
| ~SPC m g c~ | find callers |
2018-11-09 18:25:27 +00:00
| ~SPC m g C~ | find callees |
2018-08-30 20:03:11 +00:00
| ~SPC m g v~ | vars |
2018-11-22 10:56:35 +00:00
| ~SPC m g f~ | find file at point (ffap) |
| ~SPC m g F~ | ffap other window |
**** goto/hierarchy
2018-12-22 11:04:49 +00:00
| Key binding | Description |
2018-11-22 10:56:35 +00:00
|---------------+-----------------------------|
| ~SPC m g h b~ | base class(es) |
| ~SPC m g h d~ | derived class(es) [ccls] |
| ~SPC m g h c~ | call hierarchy |
| ~SPC m g h C~ | call hierarchy (inv) |
| ~SPC m g h i~ | inheritance hierarchy |
| ~SPC m g h I~ | inheritance hierarchy (inv) |
**** goto/member
2018-12-22 11:04:49 +00:00
| Key binding | Description |
|---------------+-------------------------|
| ~SPC m g m h~ | member hierarchy |
| ~SPC m g m t~ | member types [ccls] |
| ~SPC m g m f~ | member functions [ccls] |
| ~SPC m g m v~ | member variables [ccls] |
2019-04-14 12:44:51 +00:00
2019-10-01 03:48:24 +00:00
*** debugger
2019-04-14 12:44:51 +00:00
| Key binding | Description |
|---------------+---------------------------------|
| ~SPC m d d d~ | start debugging |
| ~SPC m d d l~ | debug last configuration |
| ~SPC m d d r~ | debug recent configuration |
|---------------+---------------------------------|
| ~SPC m d c~ | continue |
| ~SPC m d i~ | step in |
| ~SPC m d o~ | step out |
| ~SPC m d s~ | next step |
| ~SPC m d v~ | inspect value at point |
| ~SPC m d r~ | restart frame |
|---------------+---------------------------------|
| ~SPC m d .~ | debug transient state |
|---------------+---------------------------------|
| ~SPC m d a~ | abandon current session |
| ~SPC m d A~ | abandon all process |
|---------------+---------------------------------|
| ~SPC m d e e~ | eval |
| ~SPC m d e r~ | eval region |
| ~SPC m d e t~ | eval value at point |
|---------------+---------------------------------|
| ~SPC m d S s~ | switch session |
| ~SPC m d S t~ | switch thread |
| ~SPC m d S f~ | switch frame |
|---------------+---------------------------------|
| ~SPC m d I i~ | inspect |
| ~SPC m d I r~ | inspect region |
| ~SPC m d I t~ | inspect value at point |
|---------------+---------------------------------|
| ~SPC m d b b~ | toggle a breakpoint |
| ~SPC m d b c~ | change breakpoint condition |
| ~SPC m d b l~ | change breakpoint log condition |
| ~SPC m d b h~ | change breakpoint hit count |
| ~SPC m d b a~ | add a breakpoint |
| ~SPC m d b d~ | delete a breakpoint |
| ~SPC m d b D~ | clear all breakpoints |
|---------------+---------------------------------|
| ~SPC m d '_~ | Run debug REPL |
|---------------+---------------------------------|
| ~SPC m d w l~ | list local variables |
| ~SPC m d w o~ | goto output buffer if present |
| ~SPC m d w s~ | list sessions |
| ~SPC m d w b~ | list breakpoints |
2019-10-01 03:48:24 +00:00
** RTags
| Key binding | Description |
|-------------+---------------------------------|
| ~SPC m g .~ | find symbol at point |
| ~SPC m g ,~ | find references at point |
| ~SPC m g ;~ | find file |
| ~SPC m g /~ | find all references at point |
| ~SPC m g [~ | location stack back |
| ~SPC m g ]~ | location stack forward |
| ~SPC m g >~ | c++ tags find symbol |
| ~SPC m g <~ | c++ tags find references |
| ~SPC m g B~ | show rtags buffer |
| ~SPC m g d~ | print dependencies |
| ~SPC m g D~ | diagnostics |
| ~SPC m g e~ | reparse file |
| ~SPC m g E~ | preprocess file |
2020-08-19 21:00:23 +00:00
| ~SPC m g f~ | find dead functions |
2019-10-01 03:48:24 +00:00
| ~SPC m g F~ | fixit |
| ~SPC m g G~ | guess function at point |
| ~SPC m g h~ | print class hierarchy |
| ~SPC m g I~ | c++ tags imenu |
| ~SPC m g L~ | copy and print current location |
| ~SPC m g M~ | symbol info |
| ~SPC m g O~ | goto offset |
| ~SPC m g p~ | set current project |
2020-08-19 21:00:23 +00:00
| ~SPC m g r~ | display reference tree at point |
2019-10-01 03:48:24 +00:00
| ~SPC m g R~ | rename symbol |
| ~SPC m g s~ | print source arguments |
| ~SPC m g S~ | display summary |
2020-09-08 19:17:31 +00:00
| ~SPC m g t~ | symbol type |
2019-10-01 03:48:24 +00:00
| ~SPC m g T~ | taglist |
2020-09-08 19:17:31 +00:00
| ~SPC m g u~ | display include dependency tree |
2019-10-01 03:48:24 +00:00
| ~SPC m g v~ | find virtuals at point |
| ~SPC m g V~ | print enum value at point |
| ~SPC m g X~ | fix fixit at point |
| ~SPC m g Y~ | cycle overlays on screen |
2019-11-03 01:05:53 +00:00
** Additional key bindings
2019-10-01 03:48:24 +00:00
*** Disassemble
| Key binding | Description |
|-------------+----------------------------------|
| ~SPC m D~ | disaster: disassemble c/c++ code |
*** Formatting (clang-format)
| Key binding | Description |
|-------------+---------------------------------|
| ~SPC m = =~ | format current region or buffer |
| ~SPC m = f~ | format current function |
*** Open matching files
| Key binding | Description |
|-------------+---------------------------------------------------------------|
| ~SPC m g a~ | open matching file |
| | (e.g. switch between .cpp and .h, requires a project to work) |
| ~SPC m g A~ | open matching file in another window |
| | (e.g. switch between .cpp and .h, requires a project to work) |
*** Refactor
| Key binding | Description |
|-------------+-------------------------------------|
| ~SPC m r .~ | srefactor: refactor thing at point. |
| ~SPC m r i~ | organize includes |