Skip to content

Instantly share code, notes, and snippets.

@pedrovanzella
Created February 15, 2017 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pedrovanzella/8f3b2893263f12d07ef37d1d2b541908 to your computer and use it in GitHub Desktop.
Save pedrovanzella/8f3b2893263f12d07ef37d1d2b541908 to your computer and use it in GitHub Desktop.
rtags
;;; packages.el --- rtags layer packages file for Spacemacs.
;;
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
;;
;; Author: Pedro Vanzella <pedrovanzella@Fenrir.orion>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
;;; Commentary:
;; See the Spacemacs documentation and FAQs for instructions on how to implement
;; a new layer:
;;
;; SPC h SPC layers RET
;;
;;
;; Briefly, each package to be installed or configured by this layer should be
;; added to `rtags-packages'. Then, for each package PACKAGE:
;;
;; - If PACKAGE is not referenced by any other Spacemacs layer, define a
;; function `rtags/init-PACKAGE' to load and initialize the package.
;; - Otherwise, PACKAGE is already referenced by another Spacemacs layer, so
;; define the functions `rtags/pre-init-PACKAGE' and/or
;; `rtags/post-init-PACKAGE' to customize the package as it is loaded.
;;; Code:
(defconst rtags-packages
'(
rtags)
"The list of Lisp packages required by the rtags layer.
Each entry is either:
1. A symbol, which is interpreted as a package to be installed, or
2. A list of the form (PACKAGE KEYS...), where PACKAGE is the
name of the package to be installed or loaded, and KEYS are
any number of keyword-value-pairs.
The following keys are accepted:
- :excluded (t or nil): Prevent the package from being loaded
if value is non-nil
- :location: Specify a custom installation location.
The following values are legal:
- The symbol `elpa' (default) means PACKAGE will be
installed using the Emacs package manager.
- The symbol `local' directs Spacemacs to load the file at
`./local/PACKAGE/PACKAGE.el'
- A list beginning with the symbol `recipe' is a melpa
recipe. See: https://github.com/milkypostman/melpa#recipe-format")
(defun rtags-evil-standard-keybindings (mode)
(spacemacs/declare-prefix-for-mode mode "mg" "goto")
(spacemacs/declare-prefix-for-mode mode "mr" "rtags")
(spacemacs/set-leader-keys-for-major-mode mode
"ga" 'projectile-find-other-file
"gA" 'projectile-find-other-file-other-window
"r." 'rtags-find-symbol-at-point
"r," 'rtags-find-references-at-point
"rv" 'rtags-find-virtuals-at-point
"rV" 'rtags-print-enum-value-at-point
"r/" 'rtags-find-all-references-at-point
"rY" 'rtags-cycle-overlays-on-screen
"r>" 'rtags-find-symbol
"r<" 'rtags-find-references
"r[" 'rtags-location-stack-back
"r]" 'rtags-location-stack-forward
"rD" 'rtags-diagnostics
"rG" 'rtags-guess-function-at-point
"rp" 'rtags-set-current-project
"rP" 'rtags-print-dependencies
"re" 'rtags-reparse-file
"rE" 'rtags-preprocess-file
"rR" 'rtags-rename-symbol
"rM" 'rtags-symbol-info
"rS" 'rtags-display-summary
"rO" 'rtags-goto-offset
"r;" 'rtags-find-file
"rF" 'rtags-fixit
"rL" 'rtags-copy-and-print-current-location
"rX" 'rtags-fix-fixit-at-point
"rB" 'rtags-show-rtags-buffer
"rI" 'rtags-imenu
"rT" 'rtags-taglist
"rh" 'rtags-print-class-hierarchy
"ra" 'rtags-print-source-arguments
"rj" 'rtags-next-match
"rk" 'rtags-previous-match
)
)
;; For each package, define a function rtags/init-<package-name>
;;
(defun rtags/init-rtags ()
(use-package rtags
:init
:ensure company
:config
(progn
(require 'company-rtags)
(add-to-list 'company-backends-c-mode-common 'company-rtags)
(setq company-rtags-begin-after-member-access t)
(setq rtags-autostart-diagnostics t) ;; added after checking rtags docs
(rtags-diagnostics)
(setq rtags-completions-enabled t)
(define-key evil-normal-state-map (kbd "RET") 'rtags-select-other-window)
(define-key evil-normal-state-map (kbd "M-RET") 'rtags-select)
(define-key evil-normal-state-map (kbd "q") 'rtags-bury-or-delete)
(rtags-evil-standard-keybindings 'c-mode)
(rtags-evil-standard-keybindings 'c++-mode)
)
)
)
;;; packages.el ends here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment