-
Notifications
You must be signed in to change notification settings - Fork 12
/
smart-jump-cc-mode.el
107 lines (91 loc) · 4.18 KB
/
smart-jump-cc-mode.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
;;; smart-jump-cc-mode.el --- Register `cc-mode' for `smart-jump'. -*- lexical-binding: t -*-
;; Copyright (C) 2017 James Nguyen
;; Author: James Nguyen <[email protected]>
;; Maintainer: James Nguyen <[email protected]>
;; URL: https://github.com/jojojames/smart-jump
;; Version: 0.0.1
;; Package-Requires: ((emacs "25.1"))
;; Keywords: emacs, tools
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;; Register `cc-mode' for `smart-jump'.
;;; This file is pretty hacky since cc-mode doesn't provide the language feature.
;;; Adding `smart-jump-register's here that are related to `cc-mode'.
;;; I would love if someone had an idea on how to fix this elegantly.
;;; Code:
(require 'smart-jump)
(defvar rtags-rc-binary-name)
;;;###autoload
(defun smart-jump-cc-mode-register ()
"Register `cc-mode' for `smart-jump'."
;; Java
(smart-jump-register :modes 'java-mode
:jump-fn 'ggtags-find-tag-dwim
:pop-fn 'ggtags-prev-mark
:refs-fn 'ggtags-find-reference
:should-jump t
:heuristic 'point
:async 700
:order 2)
(smart-jump-register :modes 'java-mode
:jump-fn 'meghanada-jump-declaration
:pop-fn 'meghanada-back-jump
:refs-fn 'meghanada-reference
:should-jump t
:heuristic 'point
:async 700
:order 1)
;; C/C++
(smart-jump-register :modes '(c-mode c++-mode)
:jump-fn 'ycmd-goto
:refs-fn 'ycmd-goto-references
:should-jump (lambda ()
(bound-and-true-p ycmd-mode))
:heuristic 'point
:async 2000
:order 2)
(smart-jump-register :modes '(c-mode c++-mode)
:jump-fn 'rtags-find-symbol-at-point
:pop-fn 'rtags-location-stack-back
:refs-fn 'rtags-find-all-references-at-point
:should-jump (lambda ()
(and
(fboundp 'rtags-executable-find)
(fboundp 'rtags-is-indexed)
(rtags-executable-find rtags-rc-binary-name)
(rtags-is-indexed)))
:heuristic 'point
:async 2000
:order 1)
(smart-jump-register :modes '(c-mode c++-mode)
:jump-fn 'ggtags-find-tag-dwim
:pop-fn 'ggtags-prev-mark
:refs-fn 'ggtags-find-reference
:should-jump (lambda ()
(bound-and-true-p ggtags-mode))
:heuristic 'point
:async 3000
:order 3)
;; Objective-C
(smart-jump-register :modes 'objc-mode
:jump-fn 'ycmd-goto
:refs-fn 'ycmd-goto-references
:should-jump (lambda ()
(bound-and-true-p ycmd-mode))
:heuristic 'point
:async 2000)
(smart-jump-register :modes 'objc-mode
:jump-fn 'etags-select-find-tag-at-point
:heuristic 'point
:async t))
(provide 'smart-jump-cc-mode)
;;; smart-jump-cc-mode.el ends here