├── README.md ├── keybindings.el └── packages.el /README.md: -------------------------------------------------------------------------------- 1 | # spacemacs-cmake-ide 2 | 3 | Adds [cmake-ide](https://github.com/atilaneves/cmake-ide) as a rudimentary spacemacs layer. 4 | 5 | ## To install 6 | 7 | 1. Install RTags and its dependencies as described [here](https://github.com/andersbakken/rtags). 8 | 2. Clone this repo under ~/.emacs.d/private (or equivalent) 9 | 10 | ```Shell 11 | cd ~/.emacs.d/private 12 | git clone https://github.com/nagunn/spacemacs-cmake-ide.git 13 | ``` 14 | 15 | 3. Edit your .spacemacs file and tell emacs where rtags.el is installed (this is required because 16 | RTags will install this file to site-lisp by default, but spacemacs normally removes these 17 | directories from the load-path). 18 | 19 | ```elisp 20 | (defun dotspacemacs/user-init () 21 | (push "/usr/local/share/emacs/site-lisp/rtags" load-path)) 22 | ``` 23 | 24 | 4. After installation, restart emacs and type 25 | 26 | M-x irony-install-server 27 | 28 | 5. Navigate to a c++ source file and see if autocompletion and navigation are working. 29 | -------------------------------------------------------------------------------- /keybindings.el: -------------------------------------------------------------------------------- 1 | (dolist (mode '(c-mode c++-mode)) 2 | (evil-leader/set-key-for-mode mode 3 | "m g ." 'rtags-find-symbol-at-point 4 | "m g ," 'rtags-find-references-at-point 5 | "m g v" 'rtags-find-virtuals-at-point 6 | "m g V" 'rtags-print-enum-value-at-point 7 | "m g /" 'rtags-find-all-references-at-point 8 | "m g Y" 'rtags-cycle-overlays-on-screen 9 | "m g >" 'rtags-find-symbol 10 | "m g <" 'rtags-find-references 11 | "m g [" 'rtags-location-stack-back 12 | "m g ]" 'rtags-location-stack-forward 13 | "m g D" 'rtags-diagnostics 14 | "m g G" 'rtags-guess-function-at-point 15 | "m g p" 'rtags-set-current-project 16 | "m g P" 'rtags-print-dependencies 17 | "m g e" 'rtags-reparse-file 18 | "m g E" 'rtags-preprocess-file 19 | "m g R" 'rtags-rename-symbol 20 | "m g M" 'rtags-symbol-info 21 | "m g S" 'rtags-display-summary 22 | "m g O" 'rtags-goto-offset 23 | "m g ;" 'rtags-find-file 24 | "m g F" 'rtags-fixit 25 | "m g L" 'rtags-copy-and-print-current-location 26 | "m g X" 'rtags-fix-fixit-at-point 27 | "m g B" 'rtags-show-rtags-buffer 28 | "m g I" 'rtags-imenu 29 | "m g T" 'rtags-taglist 30 | "m g h" 'rtags-print-class-hierarchy 31 | "m g a" 'rtags-print-source-arguments)) 32 | 33 | -------------------------------------------------------------------------------- /packages.el: -------------------------------------------------------------------------------- 1 | ;;; packages.el --- cmake-ide layer packages file for Spacemacs. 2 | ;; 3 | ;; Copyright (c) 2012-2016 Sylvain Benner & Contributors 4 | ;; 5 | ;; Author: nick 6 | ;; URL: https://github.com/syl20bnr/spacemacs 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;;; License: GPLv3 11 | 12 | ;;; Commentary: 13 | 14 | ;; See the Spacemacs documentation and FAQs for instructions on how to implement 15 | ;; a new layer: 16 | ;; 17 | ;; SPC h SPC layers RET 18 | ;; 19 | ;; 20 | ;; Briefly, each package to be installed or configured by this layer should be 21 | ;; added to `cmake-ide-packages'. Then, for each package PACKAGE: 22 | ;; 23 | ;; - If PACKAGE is not referenced by any other Spacemacs layer, define a 24 | ;; function `cmake-ide/init-PACKAGE' to load and initialize the package. 25 | 26 | ;; - Otherwise, PACKAGE is already referenced by another Spacemacs layer, so 27 | ;; define the functions `cmake-ide/pre-init-PACKAGE' and/or 28 | ;; `cmake-ide/post-init-PACKAGE' to customize the package as it is loaded. 29 | 30 | ;;; Code: 31 | 32 | (defconst spacemacs-cmake-ide-packages 33 | '(cmake-ide company-irony irony) 34 | "The list of Lisp packages required by the cmake-ide layer. 35 | 36 | Each entry is either: 37 | 38 | 1. A symbol, which is interpreted as a package to be installed, or 39 | 40 | 2. A list of the form (PACKAGE KEYS...), where PACKAGE is the 41 | name of the package to be installed or loaded, and KEYS are 42 | any number of keyword-value-pairs. 43 | 44 | The following keys are accepted: 45 | 46 | - :excluded (t or nil): Prevent the package from being loaded 47 | if value is non-nil 48 | 49 | - :location: Specify a custom installation location. 50 | The following values are legal: 51 | 52 | - The symbol `elpa' (default) means PACKAGE will be 53 | installed using the Emacs package manager. 54 | 55 | - The symbol `local' directs Spacemacs to load the file at 56 | `./local/PACKAGE/PACKAGE.el' 57 | 58 | - A list beginning with the symbol `recipe' is a melpa 59 | recipe. See: https://github.com/milkypostman/melpa#recipe-format") 60 | 61 | (defun spacemacs-cmake-ide/init-cmake-ide () 62 | (use-package cmake-ide)) 63 | 64 | (defun spacemacs-cmake-ide/init-irony () 65 | (use-package irony)) 66 | 67 | (defun spacemacs-cmake-ide/init-company-irony () 68 | (use-package company-irony)) 69 | 70 | (defun spacemacs-cmake-ide/post-init-cmake-ide () 71 | (require 'rtags) 72 | (cmake-ide-setup)) 73 | 74 | (defun spacemacs-cmake-ide/post-init-irony () 75 | (add-hook 'c++-mode-hook 'irony-mode) 76 | (add-hook 'c++-mode-hook 'company-mode) 77 | (add-hook 'c-mode-hook 'irony-mode) 78 | (add-hook 'c-mode-hook 'company-mode) 79 | (add-hook 'irony-mode-hook 'my-irony-mode-hook) 80 | (add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)) 81 | 82 | ;; replace the `completion-at-point' and `complete-symbol' bindings in 83 | ;; irony-mode's buffers by irony-mode's function 84 | (defun my-irony-mode-hook () 85 | (define-key irony-mode-map [remap completion-at-point] 86 | 'irony-completion-at-point-async) 87 | (define-key irony-mode-map [remap complete-symbol] 88 | 'irony-completion-at-point-async)) 89 | 90 | ;;; packages.el ends here 91 | --------------------------------------------------------------------------------