2019-04-21 19:59:44 -04:00
|
|
|
;;; tools/lookup/config.el -*- lexical-binding: t; -*-
|
2018-01-04 17:05:37 -05:00
|
|
|
|
|
|
|
;; "What am I looking at?" This module helps you answer this question.
|
|
|
|
;;
|
|
|
|
;; + `+lookup/definition': a jump-to-definition that should 'just work'
|
|
|
|
;; + `+lookup/references': find a symbol's references in the current project
|
2019-04-16 20:22:17 -04:00
|
|
|
;; + `+lookup/file': open the file referenced at point
|
2018-01-04 17:05:37 -05:00
|
|
|
;; + `+lookup/online'; look up a symbol on online resources
|
2018-08-28 20:48:49 +02:00
|
|
|
;; + `+lookup/in-docsets': look up in Dash docsets
|
2018-01-04 17:05:37 -05:00
|
|
|
;;
|
|
|
|
;; This module uses `xref', an experimental new library in Emacs. It may change
|
|
|
|
;; in the future. When xref can't be depended on it will fall back to
|
|
|
|
;; `dumb-jump' to find what you want.
|
|
|
|
|
|
|
|
(defvar +lookup-provider-url-alist
|
|
|
|
'(("Google" . "https://google.com/search?q=%s")
|
|
|
|
("Google images" . "https://google.com/images?q=%s")
|
|
|
|
("Google maps" . "https://maps.google.com/maps?q=%s")
|
|
|
|
("Project Gutenberg" . "http://www.gutenberg.org/ebooks/search/?query=%s")
|
|
|
|
("DuckDuckGo" . "https://duckduckgo.com/?q=%s")
|
|
|
|
("DevDocs.io" . "https://devdocs.io/#q=%s")
|
|
|
|
("StackOverflow" . "https://stackoverflow.com/search?q=%s")
|
|
|
|
("Github" . "https://github.com/search?ref=simplesearch&q=%s")
|
|
|
|
("Youtube" . "https://youtube.com/results?aq=f&oq=&search_query=%s")
|
|
|
|
("Wolfram alpha" . "https://wolframalpha.com/input/?i=%s")
|
|
|
|
("Wikipedia" . "https://wikipedia.org/search-redirect.php?language=en&go=Go&search=%s"))
|
|
|
|
"An alist that maps online resources to their search url or a function that
|
|
|
|
produces an url. Used by `+lookup/online'.")
|
|
|
|
|
|
|
|
(defvar +lookup-open-url-fn #'browse-url
|
|
|
|
"Function to use to open search urls.")
|
|
|
|
|
2018-09-12 23:11:22 -04:00
|
|
|
(defvar +lookup-definition-functions
|
|
|
|
'(+lookup-xref-definitions-backend
|
|
|
|
+lookup-dumb-jump-backend
|
|
|
|
+lookup-project-search-backend
|
|
|
|
+lookup-evil-goto-definition-backend)
|
2018-04-22 23:55:49 -04:00
|
|
|
"Functions for `+lookup/definition' to try, before resorting to `dumb-jump'.
|
|
|
|
Stops at the first function to return non-nil or change the current
|
2018-05-11 20:22:37 +02:00
|
|
|
window/point.
|
|
|
|
|
|
|
|
If the argument is interactive (satisfies `commandp'), it is called with
|
|
|
|
`call-interactively' (with no arguments). Otherwise, it is called with one
|
|
|
|
argument: the identifier at point.")
|
2018-01-04 17:05:37 -05:00
|
|
|
|
2018-09-12 23:11:22 -04:00
|
|
|
(defvar +lookup-references-functions
|
|
|
|
'(+lookup-xref-references-backend
|
|
|
|
+lookup-project-search-backend)
|
2018-04-22 23:55:49 -04:00
|
|
|
"Functions for `+lookup/references' to try, before resorting to `dumb-jump'.
|
|
|
|
Stops at the first function to return non-nil or change the current
|
2018-05-11 20:22:37 +02:00
|
|
|
window/point.
|
|
|
|
|
|
|
|
If the argument is interactive (satisfies `commandp'), it is called with
|
|
|
|
`call-interactively' (with no arguments). Otherwise, it is called with one
|
|
|
|
argument: the identifier at point.")
|
2018-04-22 23:55:49 -04:00
|
|
|
|
2018-09-12 23:11:22 -04:00
|
|
|
(defvar +lookup-documentation-functions
|
|
|
|
'(+lookup-dash-docsets-backend
|
|
|
|
+lookup-online-backend)
|
2018-04-22 23:55:49 -04:00
|
|
|
"Functions for `+lookup/documentation' to try, before resorting to
|
|
|
|
`dumb-jump'. Stops at the first function to return non-nil or change the current
|
2018-05-11 20:22:37 +02:00
|
|
|
window/point.
|
|
|
|
|
|
|
|
If the argument is interactive (satisfies `commandp'), it is called with
|
|
|
|
`call-interactively' (with no arguments). Otherwise, it is called with one
|
|
|
|
argument: the identifier at point.")
|
|
|
|
|
|
|
|
(defvar +lookup-file-functions ()
|
|
|
|
"Function for `+lookup/file' to try, before restoring to `find-file-at-point'.
|
|
|
|
Stops at the first function to return non-nil or change the current
|
|
|
|
window/point.
|
|
|
|
|
|
|
|
If the argument is interactive (satisfies `commandp'), it is called with
|
|
|
|
`call-interactively' (with no arguments). Otherwise, it is called with one
|
|
|
|
argument: the identifier at point.")
|
2018-01-04 17:05:37 -05:00
|
|
|
|
|
|
|
|
|
|
|
;;
|
2019-04-16 20:22:17 -04:00
|
|
|
;;; dumb-jump
|
2018-01-04 17:05:37 -05:00
|
|
|
|
|
|
|
(def-package! dumb-jump
|
2018-05-25 00:46:11 +02:00
|
|
|
:commands dumb-jump-result-follow
|
2018-01-04 17:05:37 -05:00
|
|
|
:config
|
|
|
|
(setq dumb-jump-default-project doom-emacs-dir
|
|
|
|
dumb-jump-aggressive nil
|
|
|
|
dumb-jump-selector
|
|
|
|
(cond ((featurep! :completion ivy) 'ivy)
|
|
|
|
((featurep! :completion helm) 'helm)
|
2019-04-21 23:22:06 -04:00
|
|
|
('popup)))
|
|
|
|
(add-hook 'dumb-jump-after-jump-hook #'better-jumper-set-jump))
|
2018-01-04 17:05:37 -05:00
|
|
|
|
|
|
|
|
|
|
|
;;
|
2019-04-16 20:22:17 -04:00
|
|
|
;;; xref
|
2018-01-04 17:05:37 -05:00
|
|
|
|
2019-04-30 15:11:23 -04:00
|
|
|
(after! xref
|
|
|
|
;; We already have `projectile-find-tag' and `evil-jump-to-tag', no need for
|
|
|
|
;; xref to be one too.
|
2019-05-03 20:03:32 -04:00
|
|
|
(remove-hook 'xref-backend-functions #'etags--xref-backend)
|
|
|
|
;; The lookup commands are superior, and will consult xref if there are no
|
|
|
|
;; better backends available.
|
|
|
|
(global-set-key [remap xref-find-definitions] #'+lookup/definition)
|
|
|
|
(global-set-key [remap xref-find-references] #'+lookup/references))
|
2018-02-03 15:07:18 -05:00
|
|
|
|
2019-04-21 23:22:06 -04:00
|
|
|
;; Use `better-jumper' instead of xref's marker stack
|
|
|
|
(advice-add #'xref-push-marker-stack :around #'doom*set-jump)
|
|
|
|
|
2018-05-25 00:46:11 +02:00
|
|
|
;; ...however, it breaks `projectile-find-tag', unless we put it back.
|
|
|
|
(defun +lookup*projectile-find-tag (orig-fn)
|
|
|
|
(let ((xref-backend-functions '(etags--xref-backend t)))
|
|
|
|
(funcall orig-fn)))
|
|
|
|
(advice-add #'projectile-find-tag :around #'+lookup*projectile-find-tag)
|
2018-01-04 17:05:37 -05:00
|
|
|
|
|
|
|
|
|
|
|
(def-package! ivy-xref
|
|
|
|
:when (featurep! :completion ivy)
|
|
|
|
:after xref
|
|
|
|
:config (setq xref-show-xrefs-function #'ivy-xref-show-xrefs))
|
|
|
|
|
|
|
|
|
|
|
|
(def-package! helm-xref
|
|
|
|
:when (featurep! :completion helm)
|
|
|
|
:after xref
|
|
|
|
:config (setq xref-show-xrefs-function #'helm-xref-show-xrefs))
|
|
|
|
|
|
|
|
|
|
|
|
;;
|
2019-04-16 20:22:17 -04:00
|
|
|
;;; Dash docset integration
|
2018-01-04 17:05:37 -05:00
|
|
|
|
2018-06-22 01:48:04 +02:00
|
|
|
;; Both packages depend on helm-dash, for now
|
|
|
|
(def-package! helm-dash
|
|
|
|
:when (featurep! +docsets)
|
feature/lookup: rewrite dash docset integration
+ Uses alist variable to store config, rather than hooks
+ Added check for installed docsets in +lookup/documentation
+ Set docsets for various language modules (c-mode, c++-mode, css-mode,
scss-mode, sass-mode, web-mode, go-mode, racket-mode, emacs-lisp-mode,
js2-mode, rjsx-mode, typescript-mode, rust-mode, and php-mode)
+ Made *eww* popups for dash docsets larger
+ Renamed set-docset! => set-docsets! (set-docset! is aliased to
set-docsets!)
+ New +lookup/install-docset alias
2018-08-31 02:44:49 +02:00
|
|
|
:defer t
|
2018-06-22 01:48:04 +02:00
|
|
|
:init
|
|
|
|
(setq helm-dash-enable-debugging doom-debug-mode
|
|
|
|
helm-dash-browser-func #'eww)
|
|
|
|
:config
|
|
|
|
(unless (file-directory-p helm-dash-docsets-path)
|
|
|
|
(setq helm-dash-docsets-path (concat doom-etc-dir "docsets/")))
|
|
|
|
(unless (file-directory-p helm-dash-docsets-path)
|
|
|
|
(make-directory helm-dash-docsets-path t)))
|
|
|
|
|
|
|
|
(def-package! counsel-dash
|
|
|
|
:when (and (featurep! +docsets)
|
|
|
|
(featurep! :completion ivy))
|
|
|
|
:commands counsel-dash-install-docset
|
|
|
|
:config (setq counsel-dash-min-length 2))
|