feature/lookup: fix docset lookup & setting; add doom-etc-dir/docsets to default paths
This commit is contained in:
parent
de730535a4
commit
e728e8d04f
2 changed files with 29 additions and 26 deletions
|
@ -145,9 +145,11 @@ Goes down a list of possible backends:
|
||||||
(+lookup--jump-to :documentation identifier)))
|
(+lookup--jump-to :documentation identifier)))
|
||||||
|
|
||||||
((and (featurep! :feature lookup +docsets)
|
((and (featurep! :feature lookup +docsets)
|
||||||
(cl-find-if #'helm-dash-docset-installed-p
|
(or (require 'counsel-dash nil t)
|
||||||
(or (bound-and-true-p counsel-dash-docsets)
|
(require 'helm-dash nil t))
|
||||||
(bound-and-true-p helm-dash-docsets))))
|
(or (bound-and-true-p counsel-dash-docsets)
|
||||||
|
(bound-and-true-p helm-dash-docsets))
|
||||||
|
(helm-dash-installed-docsets))
|
||||||
(+lookup/in-docsets identifier))
|
(+lookup/in-docsets identifier))
|
||||||
|
|
||||||
((featurep! :feature lookup +devdocs)
|
((featurep! :feature lookup +devdocs)
|
||||||
|
|
|
@ -138,34 +138,35 @@ DOCSETS, to instruct it to append (or remove) those from the docsets already set
|
||||||
by a major-mode, if any.
|
by a major-mode, if any.
|
||||||
|
|
||||||
Used by `+lookup/in-docsets' and `+lookup/documentation'."
|
Used by `+lookup/in-docsets' and `+lookup/documentation'."
|
||||||
(cl-loop with ivy-p = (featurep! :completion ivy)
|
(let* ((modes (doom-unquote modes))
|
||||||
for mode in (doom-enlist (doom-unquote modes))
|
(ivy-p (featurep! :completion ivy))
|
||||||
for hook-sym = (intern (format "+docs|init-for-%s" mode))
|
(hook-sym (intern (format "+lookup|%s-docsets--%s"
|
||||||
for var-sym = (if ivy-p 'counsel-dash-docsets 'helm-dash-docsets)
|
(cond ((eq ',(car docsets) :add) 'add)
|
||||||
collect hook-sym into hooks
|
((eq ',(car docsets) :remove) 'remove)
|
||||||
collect
|
('set))
|
||||||
`(defun ,hook-sym ()
|
(string-join docsets "-"))))
|
||||||
(make-variable-buffer-local ',var-sym)
|
(var-sym (if ivy-p 'counsel-dash-docsets 'helm-dash-docsets)))
|
||||||
(cond ((eq ',(car docsets) :add)
|
`(progn
|
||||||
`(setq ,var-sym (append ,var-sym (list ,@(cdr docsets)))))
|
(defun ,hook-sym ()
|
||||||
((eq ',(car docsets) :remove)
|
(make-variable-buffer-local ',var-sym)
|
||||||
`(setq ,var-sym
|
,(cond ((eq ',(car docsets) :add)
|
||||||
(cl-loop with to-delete = (list ,@(cdr docsets))
|
`(setq ,var-sym (append ,var-sym (list ,@(cdr docsets)))))
|
||||||
for docset in ,var-sym
|
((eq ',(car docsets) :remove)
|
||||||
unless (member docset to-delete)
|
`(setq ,var-sym
|
||||||
collect docset)))
|
(cl-loop with to-delete = (list ,@(cdr docsets))
|
||||||
(`(setq ,var-sym (list ,@docsets)))))
|
for docset in ,var-sym
|
||||||
into forms
|
unless (member docset to-delete)
|
||||||
finally return `(progn ,@forms (add-hook! ,modes ',hooks))))
|
collect docset)))
|
||||||
|
(`(setq ,var-sym (list ,@docsets)))))
|
||||||
|
(add-hook! ,modes #',hook-sym))))
|
||||||
|
|
||||||
;; Both packages depend on helm-dash
|
;; Both packages depend on helm-dash
|
||||||
(def-package! helm-dash
|
(def-package! helm-dash
|
||||||
:commands (helm-dash helm-dash-install-docset helm-dash-at-point
|
:commands (helm-dash helm-dash-install-docset helm-dash-at-point
|
||||||
helm-dash-docset-installed-p)
|
helm-dash-docset-installed-p helm-dash-installed-docsets)
|
||||||
:config
|
:config
|
||||||
;; Obey XDG conventions
|
(unless (file-directory-p helm-dash-docsets-path)
|
||||||
(when-let* ((xdg-data-home (getenv "XDG_DATA_HOME")))
|
(setq helm-dash-docsets-path (concat doom-etc-dir "docsets/")))
|
||||||
(setq helm-dash-docsets-path (expand-file-name "docsets" xdg-data-home)))
|
|
||||||
(unless (file-directory-p helm-dash-docsets-path)
|
(unless (file-directory-p helm-dash-docsets-path)
|
||||||
(make-directory helm-dash-docsets-path t))
|
(make-directory helm-dash-docsets-path t))
|
||||||
(setq helm-dash-enable-debugging doom-debug-mode))
|
(setq helm-dash-enable-debugging doom-debug-mode))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue