diff --git a/core/core-evil.el b/core/core-evil.el index 2082cb2d7..b707a78d7 100644 --- a/core/core-evil.el +++ b/core/core-evil.el @@ -53,6 +53,7 @@ (debugger-mode . normal) (image-mode . normal) (doc-view-mode . normal) + (eww-mode . normal) (tabulated-list-mode . emacs) (profile-report-mode . emacs) (Info-mode . emacs) diff --git a/core/core-helm.el b/core/core-helm.el index 247ccccbb..1d4b621c8 100644 --- a/core/core-helm.el +++ b/core/core-helm.el @@ -73,6 +73,15 @@ (defun helm*buffer-list (&rest _) (doom/get-buffer-names doom-helm-force-project-buffers)) (advice-add 'helm-buffer-list :override 'helm*buffer-list)) +(use-package helm-dash + :when (not IS-WINDOWS) + :commands (helm-dash helm-dash-at-point helm-dash-install-docset def-docset!) + :config + (setq helm-dash-browser-func 'doom/dash-open + helm-dash-candidate-format "%d → %n (%t)") + (defmacro def-docset! (mode docsets) + `(add-hook! ,mode (setq-local helm-dash-docsets ',docsets)))) + (use-package helm-tags :commands (helm-tags-get-tag-file helm-etags-select)) diff --git a/core/core-os-osx.el b/core/core-os-osx.el index 5775ac81c..8d3a56049 100644 --- a/core/core-os-osx.el +++ b/core/core-os-osx.el @@ -46,14 +46,9 @@ ;; OSX-related plugins + hacks ;; -(use-package dash-at-point - :commands (dash-at-point dash-at-point-with-docset dash-at-point-run-search - dash-at-point-guess-docset) - :init - (defmacro def-docset! (mode docset) - `(add-hook! ,mode (setq-local dash-at-point-docset ,docset)))) - -(use-package applescript-mode :mode "\\.applescript$") +(use-package applescript-mode + :mode "\\.applescript$" + :config (def-docset! applescript-mode ("AppleScript"))) (def-project-type! lb6 "lb6" :match "\\.lb\\(action\\|ext\\)/.+$" diff --git a/core/core-popup.el b/core/core-popup.el index f4bfc5a89..449ed9973 100644 --- a/core/core-popup.el +++ b/core/core-popup.el @@ -25,6 +25,7 @@ ("*nosetests*" :align below :size 0.4 :noselect t) ("*esup*" :align below :size 30 :noselect t) ("*ert*" :align below :size 20 :noselect t) + (eww-mode :align below :size 30 :select t) ;; vcs ("*git-messenger*" :align left :size 55 :select t) ("^\\*git-gutter.+\\*$" :align below :size 15 :noselect t :regexp t) diff --git a/core/defuns/defuns-dash.el b/core/defuns/defuns-dash.el index be5eaf771..b69b70ebd 100644 --- a/core/defuns/defuns-dash.el +++ b/core/defuns/defuns-dash.el @@ -1,24 +1,66 @@ -;;; defuns-dash.el --- Dash.app integration +;;; defuns-dash.el --- helm-dash integration ;;;###autoload (defun doom/dash-at-pt () (interactive) - (if (evil-visual-state-p) - (dash-at-point-run-search (buffer-substring-no-properties (region-beginning) (region-end)) - (dash-at-point-guess-docset)) - (dash-at-point))) + (let (helm-dash-common-docsets) + (call-interactively 'helm-dash-at-point))) + +;;;###autoload +(defun doom/dash-open (url) + "Open url in an *eww* popup." + (interactive) + (save-window-excursion (eww url)) + (doom/popup-buffer "*eww*")) ;;;###autoload (autoload 'doom:dash "defuns-dash" nil t) -(evil-define-command doom:dash (bang input) +(evil-define-command doom:dash (&optional bang input) + "" (interactive "") - (let ((docset (unless bang (dash-at-point-guess-docset))) - (query input)) - (when (evil-visual-state-p) - (setq query (concat (buffer-substring-no-properties (region-beginning) (region-end)) - " " query))) - (when (or (not query) (zerop (length query))) - (setq query (thing-at-point 'symbol))) - (dash-at-point-run-search query docset))) + (let ((helm-dash-common-docsets (when bang (helm-dash-installed-docsets)))) + (helm-dash-initialize-debugging-buffer) + (helm-dash-create-common-connections) + (helm-dash-create-buffer-connections) + (helm :sources (helm-dash-sources--narrowed-docsets) + :buffer "*helm-dash*" + :prompt "Doc for: " + :history 'helm-dash-history-input + :input (or input "") + :helm-candidate-number-limit 500))) + +(defvar doom--dash-docsets nil) +(defvar doom--dash-user-docsets nil) +;;;###autoload (autoload 'doom:dash-install "defuns-dash" nil t) +(evil-define-command doom:dash-install (&optional docset) + "Async docset install." + (interactive "") + (let ((docsets (or doom--dash-docsets + (setq doom--dash-docsets (helm-dash-available-docsets)))) + (user-docsets (or doom--dash-user-docsets + (setq doom--dash-user-docsets (helm-dash-search-all-user-docsets))))) + (unless docset + (setq docset (helm-dash-read-docset + "Install docset" + (append docsets (mapcar 'car user-docsets))))) + (message "Installing ...") + (async-start `(lambda () + ,(async-inject-variables "\\`\\(load-path\\|helm-dash-*\\)$") + (require 'f) + (require 'helm) + (require 'helm-dash) + (cond ((member ,docset ',docsets) + (helm-dash-install-docset ,docset) + ,docset) + ((assoc ,docset ',user-docsets) + (helm-dash-install-user-docset ,docset) + (f-no-ext (f-base (car-safe (cdr-safe (assoc ,docset ',user-docsets)))))))) + (lambda (doc) + (unless doc + (error "Invalid docset id" doc)) + (message "Installing docset %s ..." doc) + (helm-dash-activate-docset doc) + (setq helm-dash-common-docsets nil) + (message "Docset %s installed" doc))))) (provide 'defuns-dash) ;;; defuns-dash.el ends here