cscope layer: Make it agnostic of c-c++ and python modes
This commit is contained in:
parent
bf47c76535
commit
15d90743f7
|
@ -20,11 +20,13 @@
|
|||
company-ycmd
|
||||
flycheck
|
||||
gdb-mi
|
||||
helm-cscope
|
||||
helm-gtags
|
||||
semantic
|
||||
srefactor
|
||||
stickyfunc-enhance
|
||||
ycmd
|
||||
xscope
|
||||
))
|
||||
|
||||
(unless (version< emacs-version "24.4")
|
||||
|
@ -148,3 +150,13 @@
|
|||
|
||||
(defun c-c++/post-init-company-ycmd ()
|
||||
(push 'company-ycmd company-backends-c-mode-common))
|
||||
|
||||
(defun c-c++/pre-init-xcscope ()
|
||||
(spacemacs|use-package-add-hook xcscope
|
||||
:post-init
|
||||
(evil-leader/set-key-for-mode 'c-mode-common "mgi" 'cscope-index-files)))
|
||||
|
||||
(defun c-c++/pre-init-helm-cscope ()
|
||||
(spacemacs|use-package-add-hook xcscope
|
||||
:post-init
|
||||
(spacemacs/setup-helm-cscope 'c-mode-common)))
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
eldoc
|
||||
evil-jumper
|
||||
flycheck
|
||||
helm-cscope
|
||||
helm-pydoc
|
||||
hy-mode
|
||||
pip-requirements
|
||||
|
@ -29,6 +30,7 @@
|
|||
semantic
|
||||
smartparens
|
||||
stickyfunc-enhance
|
||||
xcscope
|
||||
))
|
||||
|
||||
(defun python/init-anaconda-mode ()
|
||||
|
@ -285,3 +287,13 @@ fix this issue."
|
|||
|
||||
(defun python/post-init-stickyfunc-enhance ()
|
||||
(add-hook 'python-mode-hook 'spacemacs/lazy-load-stickyfunc-enhance))
|
||||
|
||||
(defun python/pre-init-xcscope ()
|
||||
(spacemacs|use-package-add-hook xcscope
|
||||
:post-init
|
||||
(evil-leader/set-key-for-mode 'python-mode "mgi" 'cscope/run-pycscope)))
|
||||
|
||||
(defun python/pre-init-helm-cscope ()
|
||||
(spacemacs|use-package-add-hook xcscope
|
||||
:post-init
|
||||
(spacemacs/setup-helm-cscope 'python-mode)))
|
||||
|
|
|
@ -22,11 +22,13 @@
|
|||
|
||||
(defun cscope/init-xcscope ()
|
||||
(use-package xcscope
|
||||
:config
|
||||
:commands (cscope-index-files cscope/run-pycscope)
|
||||
:init
|
||||
(progn
|
||||
;; for python projects, we don't want xcscope to rebuild the databse,
|
||||
;; because it uses cscope instead of pycscope
|
||||
(setq-default cscope-option-do-not-update-database t)
|
||||
(setq-default cscope-display-cscope-buffer nil)
|
||||
(setq cscope-option-do-not-update-database t
|
||||
cscope-display-cscope-buffer nil)
|
||||
|
||||
(defun cscope//safe-project-root ()
|
||||
"Return project's root, or nil if not in a project."
|
||||
|
@ -39,17 +41,16 @@
|
|||
(read-directory-name "Run pycscope in directory: "
|
||||
(cscope//safe-project-root)))))
|
||||
(let ((default-directory directory))
|
||||
(shell-command (format "pycscope -R -f '%s'"
|
||||
(expand-file-name "cscope.out" directory)))))
|
||||
|
||||
(evil-leader/set-key-for-mode 'python-mode "mgi" 'cscope/run-pycscope)
|
||||
(evil-leader/set-key-for-mode 'c-mode "mgi" 'cscope-index-files)
|
||||
(evil-leader/set-key-for-mode 'c++-mode "mgi" 'cscope-index-files)))
|
||||
(shell-command
|
||||
(format "pycscope -R -f '%s'"
|
||||
(expand-file-name "cscope.out" directory))))))))
|
||||
|
||||
(defun cscope/init-helm-cscope ()
|
||||
(use-package helm-cscope
|
||||
:config
|
||||
(dolist (mode '(python-mode c-mode c++-mode))
|
||||
:defer t
|
||||
:init
|
||||
(defun spacemacs/setup-helm-cscope (mode)
|
||||
"Setup `helm-cscope' for MODE"
|
||||
(evil-leader/set-key-for-mode mode
|
||||
"mgc" 'helm-cscope-find-called-function
|
||||
"mgC" 'helm-cscope-find-calling-this-funtcion
|
||||
|
|
Loading…
Reference in a new issue