spacemacs-helm: New layer
Collect helm configuration from spacemacs and spacemacs-base into one place. The purpose is to allow choice between this layer and spacemacs-ivy.
This commit is contained in:
parent
67abb7df58
commit
32f523e062
|
@ -346,7 +346,7 @@ Properties that can be copied are `:location', `:step' and `:excluded'."
|
|||
;; packages
|
||||
(when (file-exists-p packages-file)
|
||||
;; required for lazy-loading of unused layers
|
||||
;; for instance for helm-spacemacs
|
||||
;; for instance for helm-spacemacs-help
|
||||
(eval `(defvar ,(intern (format "%S-packages" name)) nil))
|
||||
(unless (configuration-layer/layer-usedp name)
|
||||
(load packages-file))
|
||||
|
@ -390,7 +390,7 @@ Properties that can be copied are `:location', `:step' and `:excluded'."
|
|||
;; TODO remove extensions in 0.106.0
|
||||
(when (file-exists-p extensions-file)
|
||||
;; required for lazy-loading of unused layers
|
||||
;; for instance for helm-spacemacs
|
||||
;; for instance for helm-spacemacs-help
|
||||
(unless (configuration-layer/layer-usedp name)
|
||||
(load extensions-file))
|
||||
(dolist (step '(pre post))
|
||||
|
|
|
@ -23,6 +23,7 @@ values."
|
|||
;; Uncomment some layer names and press <SPC f e R> (Vim style) or
|
||||
;; <M-m f e R> (Emacs style) to install them.
|
||||
;; ----------------------------------------------------------------
|
||||
spacemacs-helm
|
||||
;; auto-completion
|
||||
;; better-defaults
|
||||
emacs-lisp
|
||||
|
|
|
@ -791,7 +791,7 @@ Spacemacs ships with the following evil plugins:
|
|||
Spacemacs has unique UI elements to make the Emacs experience even more
|
||||
enjoyable:
|
||||
- dedicated startup page with a mode aimed at easily managing Spacemacs
|
||||
- dedicated helm source via =helm-spacemacs=
|
||||
- dedicated helm source via =helm-spacemacs-help=
|
||||
- a [[https://github.com/justbur/emacs-which-key][which-key]] buffer
|
||||
|
||||
** Graphical UI
|
||||
|
@ -929,8 +929,8 @@ and ~T~):
|
|||
| ~SPC T t~ | toggle tool bar |
|
||||
| ~SPC T T~ | toggle frame transparency and enter transparency micro-state |
|
||||
|
||||
*Note*: These toggles are all available via the =helm-spacemacs= interface (press
|
||||
~SPC h SPC~ to display the =helm-spacemacs= buffer).
|
||||
*Note*: These toggles are all available via the =helm-spacemacs-help= interface
|
||||
(press ~SPC f e h~ to display the =helm-spacemacs-help= buffer).
|
||||
|
||||
**** Global line numbers
|
||||
Line numbers can be toggled on in all =prog-mode= and =text-mode= buffers by
|
||||
|
@ -1300,8 +1300,8 @@ Navigation key bindings in =help-mode=:
|
|||
| ~g h~ | go to help for symbol under point |
|
||||
|
||||
*** Available layers
|
||||
All layers can be easily discovered via =helm-spacemacs= accessible with ~SPC f
|
||||
e h~.
|
||||
All layers can be easily discovered via =helm-spacemacs-help= accessible with
|
||||
~SPC f e h~.
|
||||
|
||||
The following helm actions are available:
|
||||
- default: open the layer =README.org=
|
||||
|
@ -1309,9 +1309,9 @@ The following helm actions are available:
|
|||
- 3nd: open the layer =extensions.el=
|
||||
|
||||
**** Available packages in Spacemacs
|
||||
=helm-spacemacs= also lists all the packages available in Spacemacs. The entry
|
||||
format is =(layer) packages=. If you type =flycheck= you'll be able to see all
|
||||
the layers where =flycheck= is used.
|
||||
=helm-spacemacs-help= also lists all the packages available in Spacemacs. The
|
||||
entry format is =(layer) packages=. If you type =flycheck= you'll be able to see
|
||||
all the layers where =flycheck= is used.
|
||||
|
||||
The following helm actions are available on packages:
|
||||
- default: go the package init function
|
||||
|
@ -1360,8 +1360,8 @@ Spacemacs.
|
|||
| ~x~ | execute (action flags) |
|
||||
|
||||
*** Toggles
|
||||
=helm-spacemacs= is also a central place to discover the available toggles. To
|
||||
display only the toggles source press ~C-l~ (or in [[Helm micro-state][Helm micro-state]] you can
|
||||
=helm-spacemacs-help= is also a central place to discover the available toggles.
|
||||
To display only the toggles source press ~C-l~ (or in [[Helm micro-state][Helm micro-state]] you can
|
||||
press just ~l~).
|
||||
|
||||
The following helm actions are available on packages:
|
||||
|
|
|
@ -122,7 +122,7 @@ In =vim= editing style the universal argument defaults to ~SPC u~
|
|||
instead of ~C-u~ because the latter is used to scroll up as in Vim.
|
||||
|
||||
** Configuration layers and Package discovery
|
||||
By using =helm-spacemacs= with ~SPC h SPC~ you can quickly search
|
||||
By using =helm-spacemacs-help= with ~SPC h SPC~ you can quickly search
|
||||
for a package and get the name of the layers using it.
|
||||
|
||||
You can also easily go to the =README.org= of a layer or go to the initialization
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
;;; keybindings.el --- Spacemacs Base Layer key-bindings File
|
||||
;;
|
||||
;; Copyright (c) 2012-2014 Sylvain Benner
|
||||
;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
|
||||
;;
|
||||
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
||||
;; URL: https://github.com/syl20bnr/spacemacs
|
||||
;;
|
||||
;; This file is not part of GNU Emacs.
|
||||
;;
|
||||
;;; License: GPLv3
|
||||
|
||||
;; describe functions ---------------------------------------------------------
|
||||
(defmacro spacemacs||set-helm-key (keys func)
|
||||
"Define a key bindings for FUNC using KEYS.
|
||||
Ensure that helm is required before calling FUNC."
|
||||
(let ((func-name (intern (format "spacemacs/%s" (symbol-name func)))))
|
||||
`(progn
|
||||
(defun ,func-name ()
|
||||
,(format "Wrapper to ensure that `helm' is loaded before calling %s."
|
||||
(symbol-name func))
|
||||
(interactive)
|
||||
(require 'helm)
|
||||
(call-interactively ',func))
|
||||
(spacemacs/set-leader-keys ,keys ',func-name))))
|
||||
(spacemacs||set-helm-key "hdb" describe-bindings)
|
||||
(spacemacs||set-helm-key "hdc" describe-char)
|
||||
(spacemacs||set-helm-key "hdf" describe-function)
|
||||
(spacemacs||set-helm-key "hdk" describe-key)
|
||||
(spacemacs||set-helm-key "hdm" describe-mode)
|
||||
(spacemacs||set-helm-key "hdp" describe-package)
|
||||
(spacemacs/set-leader-keys "hds" 'spacemacs/describe-system-info)
|
||||
(spacemacs||set-helm-key "hdt" describe-theme)
|
||||
(spacemacs||set-helm-key "hdv" describe-variable)
|
||||
(spacemacs||set-helm-key "hn" view-emacs-news)
|
||||
(spacemacs||set-helm-key "hL" helm-locate-library)
|
||||
;; search functions -----------------------------------------------------------
|
||||
(spacemacs||set-helm-key "sww" helm-wikipedia-suggest)
|
||||
(spacemacs||set-helm-key "swg" helm-google-suggest)
|
|
@ -1,4 +1,4 @@
|
|||
;;; helm-spacemacs.el --- Spacemacs layer exploration with `helm'.
|
||||
;;; helm-spacemacs-help.el --- Spacemacs layer exploration with `helm'.
|
||||
|
||||
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
||||
;; Keywords: helm, spacemacs
|
||||
|
@ -33,62 +33,62 @@
|
|||
(require 'helm-org)
|
||||
(require 'core-configuration-layer)
|
||||
|
||||
(defvar helm-spacemacs-all-layers nil
|
||||
(defvar helm-spacemacs-help-all-layers nil
|
||||
"Alist of all configuration layers.")
|
||||
|
||||
(defvar helm-spacemacs-all-packages nil
|
||||
(defvar helm-spacemacs-help-all-packages nil
|
||||
"Hash table of all packages in all layers.")
|
||||
|
||||
;;;###autoload
|
||||
(define-minor-mode helm-spacemacs-mode
|
||||
(define-minor-mode helm-spacemacs-help-mode
|
||||
"Layers discovery with helm interface."
|
||||
:group 'spacemacs
|
||||
:global t)
|
||||
|
||||
(defun helm-spacemacs//init (&optional arg)
|
||||
(when (or arg (null helm-spacemacs-all-packages))
|
||||
(defun helm-spacemacs-help//init (&optional arg)
|
||||
(when (or arg (null helm-spacemacs-help-all-packages))
|
||||
(mapc (lambda (layer) (push (configuration-layer/make-layer layer)
|
||||
helm-spacemacs-all-layers))
|
||||
helm-spacemacs-help-all-layers))
|
||||
(configuration-layer/get-layers-list))
|
||||
(dolist (layer helm-spacemacs-all-layers)
|
||||
(dolist (layer helm-spacemacs-help-all-layers)
|
||||
(unless (configuration-layer/layer-usedp (oref layer :name))
|
||||
(configuration-layer//load-layer-files layer '("funcs.el"
|
||||
"config.el"))))
|
||||
(setq helm-spacemacs-all-packages (configuration-layer/get-packages
|
||||
helm-spacemacs-all-layers))))
|
||||
(setq helm-spacemacs-help-all-packages (configuration-layer/get-packages
|
||||
helm-spacemacs-help-all-layers))))
|
||||
|
||||
;;;###autoload
|
||||
(defun helm-spacemacs (arg)
|
||||
(defun helm-spacemacs-help (arg)
|
||||
"Layers discovery with helm interface."
|
||||
(interactive "P")
|
||||
(helm-spacemacs-mode)
|
||||
(helm-spacemacs//init arg)
|
||||
(helm-spacemacs-help-mode)
|
||||
(helm-spacemacs-help//init arg)
|
||||
(helm :buffer "*helm: spacemacs*"
|
||||
:sources `(,(helm-spacemacs//documentation-source)
|
||||
,(helm-spacemacs//layer-source)
|
||||
,(helm-spacemacs//package-source)
|
||||
,(helm-spacemacs//dotspacemacs-source)
|
||||
,(helm-spacemacs//toggle-source)
|
||||
,(helm-spacemacs//faq-source))))
|
||||
:sources `(,(helm-spacemacs-help//documentation-source)
|
||||
,(helm-spacemacs-help//layer-source)
|
||||
,(helm-spacemacs-help//package-source)
|
||||
,(helm-spacemacs-help//dotspacemacs-source)
|
||||
,(helm-spacemacs-help//toggle-source)
|
||||
,(helm-spacemacs-help//faq-source))))
|
||||
|
||||
;;;###autoload
|
||||
(defun helm-spacemacs-faq (arg)
|
||||
(defun helm-spacemacs-help-faq (arg)
|
||||
"Looking in the FAQ with helm."
|
||||
(interactive "P")
|
||||
(helm-spacemacs-mode)
|
||||
(helm-spacemacs-help-mode)
|
||||
(helm :buffer "*helm: spacemacs*"
|
||||
:sources `(,(helm-spacemacs//faq-source))))
|
||||
:sources `(,(helm-spacemacs-help//faq-source))))
|
||||
|
||||
(defun helm-spacemacs//documentation-source ()
|
||||
(defun helm-spacemacs-help//documentation-source ()
|
||||
"Construct the helm source for the documentation section."
|
||||
(helm-build-sync-source "Spacemacs Documentation"
|
||||
:candidates #'helm-spacemacs//documentation-candidates
|
||||
:persistent-action #'helm-spacemacs//documentation-action-open-file
|
||||
:candidates #'helm-spacemacs-help//documentation-candidates
|
||||
:persistent-action #'helm-spacemacs-help//documentation-action-open-file
|
||||
:keymap helm-map
|
||||
:action (helm-make-actions
|
||||
"Open Documentation" #'helm-spacemacs//documentation-action-open-file)))
|
||||
"Open Documentation" #'helm-spacemacs-help//documentation-action-open-file)))
|
||||
|
||||
(defun helm-spacemacs//documentation-candidates ()
|
||||
(defun helm-spacemacs-help//documentation-candidates ()
|
||||
(let (result file-extension)
|
||||
(dolist (filename (directory-files spacemacs-docs-directory))
|
||||
(setq file-extension (file-name-extension filename))
|
||||
|
@ -127,7 +127,7 @@
|
|||
`(r . ,r))))
|
||||
result)))
|
||||
|
||||
(defun helm-spacemacs//documentation-action-open-file (candidate)
|
||||
(defun helm-spacemacs-help//documentation-action-open-file (candidate)
|
||||
"Open documentation FILE."
|
||||
(let ((file (if (string= candidate "CONTRIBUTING.org")
|
||||
;; CONTRIBUTING.org is a special case as it should be at the
|
||||
|
@ -148,25 +148,25 @@
|
|||
(t
|
||||
(find-file file)))))
|
||||
|
||||
(defun helm-spacemacs//layer-source ()
|
||||
(defun helm-spacemacs-help//layer-source ()
|
||||
"Construct the helm source for the layer section."
|
||||
`((name . "Layers")
|
||||
(candidates . ,(sort (configuration-layer/get-layers-list) 'string<))
|
||||
(candidate-number-limit)
|
||||
(keymap . ,helm-spacemacs--layer-map)
|
||||
(keymap . ,helm-spacemacs-help--layer-map)
|
||||
(action . (("Open README.org"
|
||||
. helm-spacemacs//layer-action-open-readme)
|
||||
. helm-spacemacs-help//layer-action-open-readme)
|
||||
("Open packages.el"
|
||||
. helm-spacemacs//layer-action-open-packages)
|
||||
. helm-spacemacs-help//layer-action-open-packages)
|
||||
;; TODO remove extensions in 0.106.0
|
||||
("Open extensions.el"
|
||||
. helm-spacemacs//layer-action-open-extensions)
|
||||
. helm-spacemacs-help//layer-action-open-extensions)
|
||||
("Add Layer"
|
||||
. helm-spacemacs//layer-action-add-layer)
|
||||
. helm-spacemacs-help//layer-action-add-layer)
|
||||
("Open README.org (for editing)"
|
||||
. helm-spacemacs//layer-action-open-readme-edit)))))
|
||||
. helm-spacemacs-help//layer-action-open-readme-edit)))))
|
||||
|
||||
(defvar helm-spacemacs--layer-map
|
||||
(defvar helm-spacemacs-help--layer-map
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(set-keymap-parent map helm-map)
|
||||
(define-key map (kbd "<S-return>") '(lambda () (interactive)
|
||||
|
@ -175,18 +175,18 @@
|
|||
map)
|
||||
"Keymap for Spacemacs Layers sources")
|
||||
|
||||
(defun helm-spacemacs//package-source ()
|
||||
(defun helm-spacemacs-help//package-source ()
|
||||
"Construct the helm source for the packages."
|
||||
`((name . "Packages")
|
||||
(candidates . ,(helm-spacemacs//package-candidates))
|
||||
(candidates . ,(helm-spacemacs-help//package-candidates))
|
||||
(candidate-number-limit)
|
||||
(action . (("Go to init function"
|
||||
. helm-spacemacs//package-action-goto-init-func)))))
|
||||
. helm-spacemacs-help//package-action-goto-init-func)))))
|
||||
|
||||
(defun helm-spacemacs//package-candidates ()
|
||||
(defun helm-spacemacs-help//package-candidates ()
|
||||
"Return the sorted candidates for package source."
|
||||
(let (result)
|
||||
(dolist (pkg helm-spacemacs-all-packages)
|
||||
(dolist (pkg helm-spacemacs-help-all-packages)
|
||||
(push (format "%s (%S layer)"
|
||||
(propertize (symbol-name (oref pkg :name))
|
||||
'face 'font-lock-type-face)
|
||||
|
@ -194,15 +194,15 @@
|
|||
result))
|
||||
(sort result 'string<)))
|
||||
|
||||
(defun helm-spacemacs//toggle-source ()
|
||||
(defun helm-spacemacs-help//toggle-source ()
|
||||
"Construct the helm source for the toggles."
|
||||
(helm-build-sync-source "Toggles"
|
||||
:candidates #'helm-spacemacs//toggle-candidates
|
||||
:persistent-action #'helm-spacemacs//toggle
|
||||
:candidates #'helm-spacemacs-help//toggle-candidates
|
||||
:persistent-action #'helm-spacemacs-help//toggle
|
||||
:keymap helm-map
|
||||
:action (helm-make-actions "Toggle" #'helm-spacemacs//toggle)))
|
||||
:action (helm-make-actions "Toggle" #'helm-spacemacs-help//toggle)))
|
||||
|
||||
(defun helm-spacemacs//toggle-candidates ()
|
||||
(defun helm-spacemacs-help//toggle-candidates ()
|
||||
"Return the sorted candidates for toggle source."
|
||||
(let (result)
|
||||
(dolist (toggle spacemacs-toggles)
|
||||
|
@ -227,17 +227,17 @@
|
|||
(setq result (cl-sort result 'string< :key 'car))
|
||||
result))
|
||||
|
||||
(defun helm-spacemacs//dotspacemacs-source ()
|
||||
(defun helm-spacemacs-help//dotspacemacs-source ()
|
||||
`((name . "Dotfile")
|
||||
(candidates . ,(helm-spacemacs//dotspacemacs-candidates))
|
||||
(candidates . ,(helm-spacemacs-help//dotspacemacs-candidates))
|
||||
(candidate-number-limit)
|
||||
(action . (("Go to variable" . helm-spacemacs//go-to-dotfile-variable)))))
|
||||
(action . (("Go to variable" . helm-spacemacs-help//go-to-dotfile-variable)))))
|
||||
|
||||
(defun helm-spacemacs//dotspacemacs-candidates ()
|
||||
(defun helm-spacemacs-help//dotspacemacs-candidates ()
|
||||
"Return the sorted candidates for all the dospacemacs variables."
|
||||
(sort (dotspacemacs/get-variable-string-list) 'string<))
|
||||
|
||||
(defun helm-spacemacs//layer-action-open-file (file candidate &optional edit)
|
||||
(defun helm-spacemacs-help//layer-action-open-file (file candidate &optional edit)
|
||||
"Open FILE of the passed CANDIDATE. If EDIT is false, open in view mode."
|
||||
(let ((path (if (and (equalp file "README.org") (equalp candidate "spacemacs"))
|
||||
;; Readme for spacemacs is in the project root
|
||||
|
@ -253,11 +253,11 @@
|
|||
(spacemacs/view-org-file (concat path file) "^" 'all))
|
||||
(find-file (concat path file)))))
|
||||
|
||||
(defun helm-spacemacs//layer-action-open-readme (candidate)
|
||||
(defun helm-spacemacs-help//layer-action-open-readme (candidate)
|
||||
"Open the `README.org' file of the passed CANDIDATE for reading."
|
||||
(helm-spacemacs//layer-action-open-file "README.org" candidate))
|
||||
(helm-spacemacs-help//layer-action-open-file "README.org" candidate))
|
||||
|
||||
(defun helm-spacemacs//layer-action-add-layer (candidate)
|
||||
(defun helm-spacemacs-help//layer-action-add-layer (candidate)
|
||||
"Adds layer to dotspacemacs file and reloads configuration"
|
||||
(if (configuration-layer/layer-usedp (intern candidate))
|
||||
(message "Layer already added.")
|
||||
|
@ -271,20 +271,19 @@
|
|||
(save-current-buffer)))
|
||||
(dotspacemacs/sync-configuration-layers))))
|
||||
|
||||
(defun helm-spacemacs//layer-action-open-readme-edit (candidate)
|
||||
(defun helm-spacemacs-help//layer-action-open-readme-edit (candidate)
|
||||
"Open the `README.org' file of the passed CANDIDATE for editing."
|
||||
(helm-spacemacs//layer-action-open-file "README.org" candidate t))
|
||||
(helm-spacemacs-help//layer-action-open-file "README.org" candidate t))
|
||||
|
||||
(defun helm-spacemacs//layer-action-open-packages (candidate)
|
||||
(defun helm-spacemacs-help//layer-action-open-packages (candidate)
|
||||
"Open the `packages.el' file of the passed CANDIDATE."
|
||||
(helm-spacemacs//layer-action-open-file "packages.el" candidate))
|
||||
(helm-spacemacs-help//layer-action-open-file "packages.el" candidate))
|
||||
|
||||
;; TODO remove extensions in 0.106.0
|
||||
(defun helm-spacemacs//layer-action-open-extensions (candidate)
|
||||
(defun helm-spacemacs-help//layer-action-open-extensions (candidate)
|
||||
"Open the `extensions.el' file of the passed CANDIDATE."
|
||||
(helm-spacemacs//layer-action-open-file "extensions.el" candidate))
|
||||
(helm-spacemacs-help//layer-action-open-file "extensions.el" candidate))
|
||||
|
||||
(defun helm-spacemacs//package-action-goto-init-func (candidate)
|
||||
(defun helm-spacemacs-help//package-action-goto-init-func (candidate)
|
||||
"Open the file `packages.el' and go to the init function."
|
||||
(save-match-data
|
||||
(string-match "^\\(.+\\)\s(\\(.+\\) layer)$" candidate)
|
||||
|
@ -300,13 +299,13 @@
|
|||
(re-search-forward (format "init-%s" package))
|
||||
(beginning-of-line))))
|
||||
|
||||
(defun helm-spacemacs//toggle (candidate)
|
||||
(defun helm-spacemacs-help//toggle (candidate)
|
||||
"Toggle candidate."
|
||||
(let ((toggle (assq (intern candidate) spacemacs-toggles)))
|
||||
(when toggle
|
||||
(funcall (plist-get (cdr toggle) :function)))))
|
||||
|
||||
(defun helm-spacemacs//go-to-dotfile-variable (candidate)
|
||||
(defun helm-spacemacs-help//go-to-dotfile-variable (candidate)
|
||||
"Go to candidate in the dotfile."
|
||||
(find-file dotspacemacs-filepath)
|
||||
(goto-char (point-min))
|
||||
|
@ -314,18 +313,18 @@
|
|||
(re-search-forward (format "^[a-z\s\\(\\-]*%s" candidate))
|
||||
(beginning-of-line))
|
||||
|
||||
(defvar helm-spacemacs--faq-filename
|
||||
(defvar helm-spacemacs-help--faq-filename
|
||||
(concat spacemacs-docs-directory "FAQ.org")
|
||||
"Location of the FAQ file.")
|
||||
|
||||
(defun helm-spacemacs//faq-source ()
|
||||
(defun helm-spacemacs-help//faq-source ()
|
||||
"Construct the helm source for the FAQ."
|
||||
`((name . "FAQ")
|
||||
(candidates . ,(helm-spacemacs//faq-candidates))
|
||||
(candidates . ,(helm-spacemacs-help//faq-candidates))
|
||||
(candidate-number-limit)
|
||||
(action . (("Go to question" . helm-spacemacs//faq-goto-marker)))))
|
||||
(action . (("Go to question" . helm-spacemacs-help//faq-goto-marker)))))
|
||||
|
||||
(defun helm-spacemacs//faq-candidate (cand)
|
||||
(defun helm-spacemacs-help//faq-candidate (cand)
|
||||
(let ((str (substring-no-properties (car cand))))
|
||||
(when (string-match "\\`.*/\\([^/]*\\)/\\(.*\\)\\'" str)
|
||||
(cons (concat (propertize
|
||||
|
@ -334,9 +333,9 @@
|
|||
": " (match-string 2 str))
|
||||
(cdr cand)))))
|
||||
|
||||
(defun helm-spacemacs//faq-candidates ()
|
||||
(defun helm-spacemacs-help//faq-candidates ()
|
||||
(let* ((helm-org-format-outline-path nil)
|
||||
(cands (helm-org-get-candidates (list helm-spacemacs--faq-filename)))
|
||||
(cands (helm-org-get-candidates (list helm-spacemacs-help--faq-filename)))
|
||||
section result)
|
||||
(dolist (c cands)
|
||||
(let ((str (substring-no-properties (car c))))
|
||||
|
@ -349,12 +348,12 @@
|
|||
result))))
|
||||
result))
|
||||
|
||||
(defun helm-spacemacs//faq-goto-marker (marker)
|
||||
(find-file helm-spacemacs--faq-filename)
|
||||
(defun helm-spacemacs-help//faq-goto-marker (marker)
|
||||
(find-file helm-spacemacs-help--faq-filename)
|
||||
(goto-char marker)
|
||||
(org-show-context)
|
||||
(org-show-entry))
|
||||
|
||||
(provide 'helm-spacemacs)
|
||||
(provide 'helm-spacemacs-help)
|
||||
|
||||
;;; helm-spacemacs.el ends here
|
||||
;;; helm-spacemacs-help.el ends here
|
|
@ -0,0 +1,892 @@
|
|||
;;; packages.el --- Spacemacs Core Layer packages File
|
||||
;;
|
||||
;; Copyright (c) 2012-2014 Sylvain Benner
|
||||
;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
|
||||
;;
|
||||
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
||||
;; URL: https://github.com/syl20bnr/spacemacs
|
||||
;;
|
||||
;; This file is not part of GNU Emacs.
|
||||
;;
|
||||
;;; License: GPLv3
|
||||
|
||||
(setq spacemacs-helm-packages
|
||||
'(ace-jump-helm-line
|
||||
helm
|
||||
helm-ag
|
||||
helm-descbinds
|
||||
helm-flx
|
||||
helm-make
|
||||
helm-mode-manager
|
||||
helm-projectile
|
||||
helm-swoop
|
||||
helm-themes
|
||||
(helm-spacemacs-help :location local)))
|
||||
|
||||
;; Initialization of packages
|
||||
|
||||
(defun spacemacs-helm/init-ace-jump-helm-line ()
|
||||
(use-package ace-jump-helm-line
|
||||
:defer t
|
||||
:init
|
||||
(with-eval-after-load 'helm
|
||||
(define-key helm-map (kbd "C-q") 'ace-jump-helm-line))))
|
||||
|
||||
(defun spacemacs-helm/init-helm ()
|
||||
(use-package helm
|
||||
:defer 1
|
||||
:commands (spacemacs/helm-find-files)
|
||||
:config
|
||||
(progn
|
||||
(when (and dotspacemacs-helm-resize
|
||||
(or (eq dotspacemacs-helm-position 'bottom)
|
||||
(eq dotspacemacs-helm-position 'top)))
|
||||
(setq helm-autoresize-min-height 10)
|
||||
(helm-autoresize-mode 1))
|
||||
|
||||
;; from https://www.reddit.com/r/emacs/comments/2z7nbv/lean_helm_window/
|
||||
(defvar helm-source-header-default-background (face-attribute 'helm-source-header :background))
|
||||
(defvar helm-source-header-default-foreground (face-attribute 'helm-source-header :foreground))
|
||||
(defvar helm-source-header-default-box (face-attribute 'helm-source-header :box))
|
||||
(defvar helm-source-header-default-height (face-attribute 'helm-source-header :height) )
|
||||
|
||||
(defun helm-toggle-header-line ()
|
||||
"Hide the `helm' header is there is only one source."
|
||||
(when dotspacemacs-helm-no-header
|
||||
(if (> (length helm-sources) 1)
|
||||
(set-face-attribute 'helm-source-header
|
||||
nil
|
||||
:foreground helm-source-header-default-foreground
|
||||
:background helm-source-header-default-background
|
||||
:box helm-source-header-default-box
|
||||
:height helm-source-header-default-height)
|
||||
(set-face-attribute 'helm-source-header
|
||||
nil
|
||||
:foreground (face-attribute 'helm-selection :background)
|
||||
:background (face-attribute 'helm-selection :background)
|
||||
:box nil
|
||||
:height 0.1))))
|
||||
(add-hook 'helm-before-initialize-hook 'helm-toggle-header-line)
|
||||
|
||||
(defun spacemacs/helm-find-files (arg)
|
||||
"Custom spacemacs implementation for calling helm-find-files-1.
|
||||
|
||||
Removes the automatic guessing of the initial value based on thing at point. "
|
||||
(interactive "P")
|
||||
(let* ((hist (and arg helm-ff-history (helm-find-files-history)))
|
||||
(default-input hist )
|
||||
(input (cond ((and (eq major-mode 'dired-mode) default-input)
|
||||
(file-name-directory default-input))
|
||||
((and (not (string= default-input ""))
|
||||
default-input))
|
||||
(t (expand-file-name (helm-current-directory))))))
|
||||
(set-text-properties 0 (length input) nil input)
|
||||
(helm-find-files-1 input ))))
|
||||
:init
|
||||
(progn
|
||||
(setq helm-prevent-escaping-from-minibuffer t
|
||||
helm-bookmark-show-location t
|
||||
helm-display-header-line nil
|
||||
helm-split-window-in-side-p t
|
||||
helm-always-two-windows t
|
||||
helm-echo-input-in-header-line t
|
||||
helm-imenu-execute-action-at-once-if-one nil
|
||||
helm-org-format-outline-path t)
|
||||
|
||||
;; hide minibuffer in Helm session, since we use the header line already
|
||||
(defun helm-hide-minibuffer-maybe ()
|
||||
(when (with-helm-buffer helm-echo-input-in-header-line)
|
||||
(let ((ov (make-overlay (point-min) (point-max) nil nil t)))
|
||||
(overlay-put ov 'window (selected-window))
|
||||
(overlay-put ov 'face (let ((bg-color (face-background 'default nil)))
|
||||
`(:background ,bg-color :foreground ,bg-color)))
|
||||
(setq-local cursor-type nil))))
|
||||
(add-hook 'helm-minibuffer-set-up-hook 'helm-hide-minibuffer-maybe)
|
||||
|
||||
;; fuzzy matching setting
|
||||
(setq helm-M-x-fuzzy-match t
|
||||
helm-apropos-fuzzy-match t
|
||||
helm-file-cache-fuzzy-match t
|
||||
helm-imenu-fuzzy-match t
|
||||
helm-lisp-fuzzy-completion t
|
||||
helm-recentf-fuzzy-match t
|
||||
helm-semantic-fuzzy-match t
|
||||
helm-buffers-fuzzy-matching t)
|
||||
|
||||
;; Use helm to provide :ls, unless ibuffer is used
|
||||
(unless (configuration-layer/package-usedp 'ibuffer)
|
||||
(evil-ex-define-cmd "buffers" 'helm-buffers-list))
|
||||
|
||||
(defun spacemacs//helm-do-grep-region-or-symbol (&optional targs use-region-or-symbol-p)
|
||||
"Version of `helm-do-grep' with a default input."
|
||||
(interactive)
|
||||
(require 'helm)
|
||||
(cl-letf*
|
||||
(((symbol-function 'this-fn) (symbol-function 'helm-do-grep-1))
|
||||
((symbol-function 'helm-do-grep-1)
|
||||
(lambda (targets &optional recurse zgrep exts default-input region-or-symbol-p)
|
||||
(let* ((new-input (when region-or-symbol-p
|
||||
(if (region-active-p)
|
||||
(buffer-substring-no-properties
|
||||
(region-beginning) (region-end))
|
||||
(thing-at-point 'symbol t))))
|
||||
(quoted-input (when new-input (rxt-quote-pcre new-input))))
|
||||
(this-fn targets recurse zgrep exts default-input quoted-input))))
|
||||
(preselection (or (dired-get-filename nil t)
|
||||
(buffer-file-name (current-buffer))))
|
||||
(targets (if targs
|
||||
targs
|
||||
(helm-read-file-name
|
||||
"Search in file(s): "
|
||||
:marked-candidates t
|
||||
:preselect (if helm-ff-transformer-show-only-basename
|
||||
(helm-basename preselection)
|
||||
preselection)))))
|
||||
(helm-do-grep-1 targets nil nil nil nil use-region-or-symbol-p)))
|
||||
|
||||
(defun spacemacs/helm-file-do-grep ()
|
||||
"Search in current file with `grep' using a default input."
|
||||
(interactive)
|
||||
(spacemacs//helm-do-grep-region-or-symbol
|
||||
(list (buffer-file-name (current-buffer))) nil))
|
||||
|
||||
(defun spacemacs/helm-file-do-grep-region-or-symbol ()
|
||||
"Search in current file with `grep' using a default input."
|
||||
(interactive)
|
||||
(spacemacs//helm-do-grep-region-or-symbol
|
||||
(list (buffer-file-name (current-buffer))) t))
|
||||
|
||||
(defun spacemacs/helm-files-do-grep ()
|
||||
"Search in files with `grep'."
|
||||
(interactive)
|
||||
(spacemacs//helm-do-grep-region-or-symbol nil nil))
|
||||
|
||||
(defun spacemacs/helm-files-do-grep-region-or-symbol ()
|
||||
"Search in files with `grep' using a default input."
|
||||
(interactive)
|
||||
(spacemacs//helm-do-grep-region-or-symbol nil t))
|
||||
|
||||
(defun spacemacs/helm-buffers-do-grep ()
|
||||
"Search in opened buffers with `grep'."
|
||||
(interactive)
|
||||
(let ((buffers (cl-loop for buffer in (buffer-list)
|
||||
when (buffer-file-name buffer)
|
||||
collect (buffer-file-name buffer))))
|
||||
(spacemacs//helm-do-grep-region-or-symbol buffers nil)))
|
||||
|
||||
(defun spacemacs/helm-buffers-do-grep-region-or-symbol ()
|
||||
"Search in opened buffers with `grep' with a default input."
|
||||
(interactive)
|
||||
(let ((buffers (cl-loop for buffer in (buffer-list)
|
||||
when (buffer-file-name buffer)
|
||||
collect (buffer-file-name buffer))))
|
||||
(spacemacs//helm-do-grep-region-or-symbol buffers t)))
|
||||
|
||||
(defun spacemacs/last-search-buffer ()
|
||||
"open last helm-ag or hgrep buffer."
|
||||
(interactive)
|
||||
(cond ((get-buffer "*helm ag results*")
|
||||
(switch-to-buffer-other-window "*helm ag results*"))
|
||||
((get-buffer "*helm-ag*")
|
||||
(helm-resume "*helm-ag*"))
|
||||
((get-buffer "*hgrep*")
|
||||
(switch-to-buffer-other-window "*hgrep*"))
|
||||
(t
|
||||
(message "No previous search buffer found"))))
|
||||
|
||||
(defun spacemacs/helm-faces ()
|
||||
"Describe face."
|
||||
(interactive)
|
||||
(require 'helm-elisp)
|
||||
(let ((default (or (face-at-point) (thing-at-point 'symbol))))
|
||||
(helm :sources (helm-def-source--emacs-faces
|
||||
(format "%s" (or default "default")))
|
||||
:buffer "*helm faces*")))
|
||||
|
||||
;; use helm by default for M-x
|
||||
(unless (configuration-layer/package-usedp 'smex)
|
||||
(global-set-key (kbd "M-x") 'helm-M-x))
|
||||
|
||||
(spacemacs/set-leader-keys
|
||||
"<f1>" 'helm-apropos
|
||||
"bb" 'helm-mini
|
||||
"Cl" 'helm-colors
|
||||
"ff" 'spacemacs/helm-find-files
|
||||
"fF" 'helm-find-files
|
||||
"fL" 'helm-locate
|
||||
"fr" 'helm-recentf
|
||||
"hb" 'helm-filtered-bookmarks
|
||||
"hdF" 'spacemacs/helm-faces
|
||||
"hi" 'helm-info-at-point
|
||||
"hl" 'helm-resume
|
||||
"hm" 'helm-man-woman
|
||||
"iu" 'helm-ucs
|
||||
"ry" 'helm-show-kill-ring
|
||||
"rr" 'helm-register
|
||||
"rm" 'helm-all-mark-rings
|
||||
"sl" 'spacemacs/last-search-buffer
|
||||
"sj" 'spacemacs/jump-in-buffer)
|
||||
|
||||
;; search with grep
|
||||
(spacemacs/set-leader-keys
|
||||
"sgb" 'spacemacs/helm-buffers-do-grep
|
||||
"sgB" 'spacemacs/helm-buffers-do-grep-region-or-symbol
|
||||
"sgf" 'spacemacs/helm-files-do-grep
|
||||
"sgF" 'spacemacs/helm-files-do-grep-region-or-symbol
|
||||
"sgg" 'spacemacs/helm-file-do-grep
|
||||
"sgG" 'spacemacs/helm-file-do-grep-region-or-symbol)
|
||||
|
||||
;; define the key binding at the very end in order to allow the user
|
||||
;; to overwrite any key binding
|
||||
(add-hook 'emacs-startup-hook
|
||||
(lambda ()
|
||||
(unless (configuration-layer/package-usedp 'smex)
|
||||
(spacemacs/set-leader-keys dotspacemacs-command-key 'helm-M-x))))
|
||||
|
||||
(defun spacemacs//hide-cursor-in-helm-buffer ()
|
||||
"Hide the cursor in helm buffers."
|
||||
(with-helm-buffer
|
||||
(setq cursor-in-non-selected-windows nil)))
|
||||
(add-hook 'helm-after-initialize-hook 'spacemacs//hide-cursor-in-helm-buffer)
|
||||
|
||||
(defvar spacemacs-helm-display-help-buffer-regexp '("*.*Helm.*Help.**"))
|
||||
(defvar spacemacs-helm-display-buffer-regexp `("*.*helm.**"
|
||||
(display-buffer-in-side-window)
|
||||
(inhibit-same-window . t)
|
||||
(side . ,dotspacemacs-helm-position)
|
||||
(window-width . 0.6)
|
||||
(window-height . 0.4)))
|
||||
(defvar spacemacs-display-buffer-alist nil)
|
||||
(defun spacemacs//helm-prepare-display ()
|
||||
"Prepare necessary settings to make Helm display properly."
|
||||
;; avoid Helm buffer being diplaye twice when user
|
||||
;; sets this variable to some function that pop buffer to
|
||||
;; a window. See https://github.com/syl20bnr/spacemacs/issues/1396
|
||||
(let ((display-buffer-base-action '(nil)))
|
||||
(setq spacemacs-display-buffer-alist display-buffer-alist)
|
||||
;; the only buffer to display is Helm, nothing else we must set this
|
||||
;; otherwise Helm cannot reuse its own windows for copyinng/deleting
|
||||
;; etc... because of existing popwin buffers in the alist
|
||||
(setq display-buffer-alist nil)
|
||||
(popwin-mode -1)
|
||||
;; workaround for a helm-evil incompatibility
|
||||
;; see https://github.com/syl20bnr/spacemacs/issues/3700
|
||||
(when helm-prevent-escaping-from-minibuffer
|
||||
(define-key evil-motion-state-map [down-mouse-1] nil))))
|
||||
|
||||
(defun spacemacs//display-helm-window (buffer)
|
||||
(let ((display-buffer-alist (list spacemacs-helm-display-help-buffer-regexp
|
||||
;; this or any specialized case of Helm buffer must be added AFTER
|
||||
;; `spacemacs-helm-display-buffer-regexp'. Otherwise,
|
||||
;; `spacemacs-helm-display-buffer-regexp' will be used before
|
||||
;; `spacemacs-helm-display-help-buffer-regexp' and display
|
||||
;; configuration for normal Helm buffer is applied for helm help
|
||||
;; buffer, making the help buffer unable to be displayed.
|
||||
spacemacs-helm-display-buffer-regexp)))
|
||||
(helm-default-display-buffer buffer)))
|
||||
(setq helm-display-function 'spacemacs//display-helm-window)
|
||||
|
||||
(defun spacemacs//restore-previous-display-config ()
|
||||
;; workaround for a helm-evil incompatibility
|
||||
;; see https://github.com/syl20bnr/spacemacs/issues/3700
|
||||
(when helm-prevent-escaping-from-minibuffer
|
||||
(define-key evil-motion-state-map [down-mouse-1] 'evil-mouse-drag-region))
|
||||
(popwin-mode 1)
|
||||
;; we must enable popwin-mode first then restore `display-buffer-alist'
|
||||
;; Otherwise, popwin keeps adding up its own buffers to `display-buffer-alist'
|
||||
;; and could slow down Emacs as the list grows
|
||||
(setq display-buffer-alist spacemacs-display-buffer-alist))
|
||||
|
||||
(add-hook 'helm-after-initialize-hook 'spacemacs//helm-prepare-display)
|
||||
;; Restore popwin-mode after a Helm session finishes.
|
||||
(add-hook 'helm-cleanup-hook 'spacemacs//restore-previous-display-config)
|
||||
|
||||
;; Add minibuffer history with `helm-minibuffer-history'
|
||||
(define-key minibuffer-local-map (kbd "C-c C-l") 'helm-minibuffer-history)
|
||||
|
||||
(defun spacemacs//helm-cleanup ()
|
||||
"Cleanup some helm related states when quitting."
|
||||
;; deactivate any running transient map (micro-state)
|
||||
(setq overriding-terminal-local-map nil))
|
||||
(add-hook 'helm-cleanup-hook 'spacemacs//helm-cleanup)
|
||||
|
||||
(defface spacemacs-helm-navigation-ms-face
|
||||
`((t :background ,(face-attribute 'error :foreground) :foreground "black"))
|
||||
"Face for helm heder when helm micro-state is activated."
|
||||
:group 'spacemacs))
|
||||
|
||||
:config
|
||||
(progn
|
||||
(helm-mode +1)
|
||||
|
||||
;; helm-locate uses es (from everything on windows, which doesnt like fuzzy)
|
||||
(helm-locate-set-command)
|
||||
(setq helm-locate-fuzzy-match (string-match "locate" helm-locate-command))
|
||||
|
||||
(defun spacemacs//set-dotted-directory ()
|
||||
"Set the face of diretories for `.' and `..'"
|
||||
(set-face-attribute 'helm-ff-dotted-directory
|
||||
nil
|
||||
:foreground nil
|
||||
:background nil
|
||||
:inherit 'helm-ff-directory))
|
||||
(add-hook 'helm-find-files-before-init-hook 'spacemacs//set-dotted-directory)
|
||||
|
||||
;; alter helm-bookmark key bindings to be simpler
|
||||
(defun simpler-helm-bookmark-keybindings ()
|
||||
(define-key helm-bookmark-map (kbd "C-d") 'helm-bookmark-run-delete)
|
||||
(define-key helm-bookmark-map (kbd "C-e") 'helm-bookmark-run-edit)
|
||||
(define-key helm-bookmark-map (kbd "C-f") 'helm-bookmark-toggle-filename)
|
||||
(define-key helm-bookmark-map (kbd "C-o") 'helm-bookmark-run-jump-other-window)
|
||||
(define-key helm-bookmark-map (kbd "C-/") 'helm-bookmark-help))
|
||||
(add-hook 'helm-mode-hook 'simpler-helm-bookmark-keybindings)
|
||||
|
||||
;; helm navigation on hjkl
|
||||
(defun spacemacs//helm-hjkl-navigation (&optional arg)
|
||||
"Set navigation in helm on `jklh'.
|
||||
ARG non nil means that the editing style is `vim'."
|
||||
(cond
|
||||
(arg
|
||||
;; better navigation on homerow
|
||||
;; rebind `describe-key' for convenience
|
||||
(define-key helm-map (kbd "C-j") 'helm-next-line)
|
||||
(define-key helm-map (kbd "C-k") 'helm-previous-line)
|
||||
(define-key helm-map (kbd "C-h") 'helm-next-source)
|
||||
(define-key helm-map (kbd "C-S-h") 'describe-key)
|
||||
(define-key helm-map (kbd "C-l") (kbd "RET"))
|
||||
(dolist (keymap (list helm-find-files-map helm-read-file-map))
|
||||
(define-key keymap (kbd "C-l") 'helm-execute-persistent-action)
|
||||
(define-key keymap (kbd "C-h") 'helm-find-files-up-one-level)
|
||||
(define-key keymap (kbd "C-S-h") 'describe-key)))
|
||||
(t
|
||||
(define-key helm-map (kbd "C-j") 'helm-execute-persistent-action)
|
||||
(define-key helm-map (kbd "C-k") 'helm-delete-minibuffer-contents)
|
||||
(define-key helm-map (kbd "C-h") nil)
|
||||
(define-key helm-map (kbd "C-l") 'helm-recenter-top-bottom-other-window))))
|
||||
(spacemacs//hjkl-completion-navigation)
|
||||
|
||||
(defun spacemacs/helm-edit ()
|
||||
"Switch in edit mode depending on the current helm buffer."
|
||||
(interactive)
|
||||
(cond
|
||||
((string-equal "*helm-ag*" helm-buffer)
|
||||
(helm-ag-edit))))
|
||||
|
||||
(defun spacemacs//helm-navigation-ms-on-enter ()
|
||||
"Initialization of helm micro-state."
|
||||
;; faces
|
||||
(spacemacs//helm-navigation-ms-set-face)
|
||||
(setq spacemacs--helm-navigation-ms-face-cookie-minibuffer
|
||||
(face-remap-add-relative
|
||||
'minibuffer-prompt
|
||||
'spacemacs-helm-navigation-ms-face)))
|
||||
|
||||
(defun spacemacs//helm-navigation-ms-set-face ()
|
||||
"Set the face for helm header in helm navigation micro-state"
|
||||
(with-helm-window
|
||||
(setq spacemacs--helm-navigation-ms-face-cookie-header
|
||||
(face-remap-add-relative
|
||||
'helm-header
|
||||
'spacemacs-helm-navigation-ms-face))))
|
||||
|
||||
(defun spacemacs//helm-navigation-ms-on-exit ()
|
||||
"Action to perform when exiting helm micro-state."
|
||||
(with-helm-window
|
||||
(face-remap-remove-relative
|
||||
spacemacs--helm-navigation-ms-face-cookie-header))
|
||||
(face-remap-remove-relative
|
||||
spacemacs--helm-navigation-ms-face-cookie-minibuffer))
|
||||
|
||||
(defun spacemacs//helm-navigation-ms-full-doc ()
|
||||
"Full documentation for helm navigation micro-state."
|
||||
"
|
||||
[?] display this help
|
||||
[a] toggle action selection page
|
||||
[e] edit occurrences if supported
|
||||
[j] [k] next/previous candidate
|
||||
[h] [l] previous/next source
|
||||
[t] toggle visible mark
|
||||
[T] toggle all mark
|
||||
[v] persistent action
|
||||
[q] quit")
|
||||
|
||||
;; Define functions to pick actions
|
||||
(dotimes (n 10)
|
||||
(let ((func (intern (format "spacemacs/helm-action-%d" n)))
|
||||
(doc (format "Select helm action #%d" n)))
|
||||
(eval `(defun ,func ()
|
||||
,doc
|
||||
(intern)
|
||||
(helm-select-nth-action ,(1- n))))))
|
||||
|
||||
(spacemacs|define-micro-state helm-navigation
|
||||
:persistent t
|
||||
:disable-evil-leader t
|
||||
:define-key (helm-map . "M-SPC") (helm-map . "s-M-SPC")
|
||||
:on-enter (spacemacs//helm-navigation-ms-on-enter)
|
||||
:on-exit (spacemacs//helm-navigation-ms-on-exit)
|
||||
:bindings
|
||||
("1" spacemacs/helm-action-1 :exit t)
|
||||
("2" spacemacs/helm-action-2 :exit t)
|
||||
("3" spacemacs/helm-action-3 :exit t)
|
||||
("4" spacemacs/helm-action-4 :exit t)
|
||||
("5" spacemacs/helm-action-5 :exit t)
|
||||
("6" spacemacs/helm-action-6 :exit t)
|
||||
("7" spacemacs/helm-action-7 :exit t)
|
||||
("8" spacemacs/helm-action-8 :exit t)
|
||||
("9" spacemacs/helm-action-9 :exit t)
|
||||
("0" spacemacs/helm-action-10 :exit t)
|
||||
("<tab>" helm-select-action :exit t)
|
||||
("TAB" helm-select-action :exit t)
|
||||
("<RET>" helm-maybe-exit-minibuffer :exit t)
|
||||
("?" nil :doc (spacemacs//helm-navigation-ms-full-doc))
|
||||
("a" helm-select-action :post (spacemacs//helm-navigation-ms-set-face))
|
||||
("e" spacemacs/helm-edit)
|
||||
("g" helm-beginning-of-buffer)
|
||||
("G" helm-end-of-buffer)
|
||||
("h" helm-previous-source)
|
||||
("j" helm-next-line)
|
||||
("k" helm-previous-line)
|
||||
("l" helm-next-source)
|
||||
("q" nil :exit t)
|
||||
("t" helm-toggle-visible-mark)
|
||||
("T" helm-toggle-all-marks)
|
||||
("v" helm-execute-persistent-action))
|
||||
|
||||
;; Swap default TAB and C-z commands.
|
||||
;; For GUI.
|
||||
(define-key helm-map (kbd "<tab>") 'helm-execute-persistent-action)
|
||||
(define-key helm-find-files-map (kbd "S-<tab>") 'helm-find-files-up-one-level)
|
||||
(define-key helm-find-files-map (kbd "<backtab>") 'helm-find-files-up-one-level)
|
||||
;; For terminal.
|
||||
(define-key helm-map (kbd "TAB") 'helm-execute-persistent-action)
|
||||
(define-key helm-find-files-map (kbd "S-TAB") 'helm-find-files-up-one-level)
|
||||
(define-key helm-map (kbd "C-z") 'helm-select-action)
|
||||
|
||||
(with-eval-after-load 'helm-mode ; required
|
||||
(spacemacs|hide-lighter helm-mode)))))
|
||||
|
||||
(defun spacemacs-helm/init-helm-ag ()
|
||||
(use-package helm-ag
|
||||
:defer t
|
||||
:init
|
||||
(progn
|
||||
(defun spacemacs//helm-do-ag-region-or-symbol (func &optional dir)
|
||||
"Search with `ag' with a default input."
|
||||
(require 'helm-ag)
|
||||
(cl-letf* (((symbol-value 'helm-ag-insert-at-point) 'symbol)
|
||||
;; make thing-at-point choosing the active region first
|
||||
((symbol-function 'this-fn) (symbol-function 'thing-at-point))
|
||||
((symbol-function 'thing-at-point)
|
||||
(lambda (thing)
|
||||
(let ((res (if (region-active-p)
|
||||
(buffer-substring-no-properties
|
||||
(region-beginning) (region-end))
|
||||
(this-fn thing))))
|
||||
(when res (rxt-quote-pcre res))))))
|
||||
(funcall func dir)))
|
||||
|
||||
(defun spacemacs//helm-do-search-find-tool (base tools default-inputp)
|
||||
"Create a cond form given a TOOLS string list and evaluate it."
|
||||
(eval
|
||||
`(cond
|
||||
,@(mapcar
|
||||
(lambda (x)
|
||||
`((executable-find ,x)
|
||||
',(let ((func
|
||||
(intern
|
||||
(format (if default-inputp
|
||||
"spacemacs/%s-%s-region-or-symbol"
|
||||
"spacemacs/%s-%s")
|
||||
base x))))
|
||||
(if (fboundp func)
|
||||
func
|
||||
(intern (format "%s-%s" base x))))))
|
||||
tools)
|
||||
(t 'helm-do-grep))))
|
||||
|
||||
;; Search in current file ----------------------------------------------
|
||||
|
||||
(defun spacemacs/helm-file-do-ag (&optional _)
|
||||
"Wrapper to execute `helm-ag-this-file.'"
|
||||
(interactive)
|
||||
(helm-ag-this-file))
|
||||
|
||||
(defun spacemacs/helm-file-do-ag-region-or-symbol ()
|
||||
"Search in current file with `ag' using a default input."
|
||||
(interactive)
|
||||
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-file-do-ag))
|
||||
|
||||
(defun spacemacs/helm-file-smart-do-search (&optional default-inputp)
|
||||
"Search in current file using `dotspacemacs-search-tools'.
|
||||
Search for a search tool in the order provided by `dotspacemacs-search-tools'
|
||||
If DEFAULT-INPUTP is non nil then the current region or symbol at point
|
||||
are used as default input."
|
||||
(interactive)
|
||||
(call-interactively
|
||||
(spacemacs//helm-do-search-find-tool "helm-file-do"
|
||||
dotspacemacs-search-tools
|
||||
default-inputp)))
|
||||
|
||||
(defun spacemacs/helm-file-smart-do-search-region-or-symbol ()
|
||||
"Search in current file using `dotspacemacs-search-tools' with
|
||||
default input.
|
||||
Search for a search tool in the order provided by `dotspacemacs-search-tools'."
|
||||
(interactive)
|
||||
(spacemacs/helm-file-smart-do-search t))
|
||||
|
||||
;; Search in files -----------------------------------------------------
|
||||
|
||||
(defun spacemacs/helm-files-do-ag (&optional dir)
|
||||
"Search in files with `ag' using a default input."
|
||||
(interactive)
|
||||
(helm-do-ag dir))
|
||||
|
||||
(defun spacemacs/helm-files-do-ag-region-or-symbol ()
|
||||
"Search in files with `ag' using a default input."
|
||||
(interactive)
|
||||
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-files-do-ag))
|
||||
|
||||
(defun spacemacs/helm-files-do-ack (&optional dir)
|
||||
"Search in files with `ack'."
|
||||
(interactive)
|
||||
(let ((helm-ag-base-command "ack --nocolor --nogroup"))
|
||||
(helm-do-ag dir)))
|
||||
|
||||
(defun spacemacs/helm-files-do-ack-region-or-symbol ()
|
||||
"Search in files with `ack' using a default input."
|
||||
(interactive)
|
||||
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-files-do-ack))
|
||||
|
||||
(defun spacemacs/helm-files-do-pt (&optional dir)
|
||||
"Search in files with `pt'."
|
||||
(interactive)
|
||||
(let ((helm-ag-base-command "pt -e --nocolor --nogroup"))
|
||||
(helm-do-ag dir)))
|
||||
|
||||
(defun spacemacs/helm-files-do-pt-region-or-symbol ()
|
||||
"Search in files with `pt' using a default input."
|
||||
(interactive)
|
||||
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-files-do-pt))
|
||||
|
||||
(defun spacemacs/helm-files-smart-do-search (&optional default-inputp)
|
||||
"Search in opened buffers using `dotspacemacs-search-tools'.
|
||||
Search for a search tool in the order provided by `dotspacemacs-search-tools'
|
||||
If DEFAULT-INPUTP is non nil then the current region or symbol at point
|
||||
are used as default input."
|
||||
(interactive)
|
||||
(call-interactively
|
||||
(spacemacs//helm-do-search-find-tool "helm-files-do"
|
||||
dotspacemacs-search-tools
|
||||
default-inputp)))
|
||||
|
||||
(defun spacemacs/helm-files-smart-do-search-region-or-symbol ()
|
||||
"Search in opened buffers using `dotspacemacs-search-tools'.
|
||||
with default input.
|
||||
Search for a search tool in the order provided by `dotspacemacs-search-tools'."
|
||||
(interactive)
|
||||
(spacemacs/helm-files-smart-do-search t))
|
||||
|
||||
;; Search in buffers ---------------------------------------------------
|
||||
|
||||
(defun spacemacs/helm-buffers-do-ag (&optional _)
|
||||
"Wrapper to execute `helm-ag-buffers.'"
|
||||
(interactive)
|
||||
(helm-do-ag-buffers))
|
||||
|
||||
(defun spacemacs/helm-buffers-do-ag-region-or-symbol ()
|
||||
"Search in opened buffers with `ag' with a default input."
|
||||
(interactive)
|
||||
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-buffers-do-ag))
|
||||
|
||||
(defun spacemacs/helm-buffers-do-ack (&optional _)
|
||||
"Search in opened buffers with `ack'."
|
||||
(interactive)
|
||||
(let ((helm-ag-base-command "ack --nocolor --nogroup"))
|
||||
(helm-do-ag-buffers)))
|
||||
|
||||
(defun spacemacs/helm-buffers-do-ack-region-or-symbol ()
|
||||
"Search in opened buffers with `ack' with a default input."
|
||||
(interactive)
|
||||
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-buffers-do-ack))
|
||||
|
||||
(defun spacemacs/helm-buffers-do-pt (&optional _)
|
||||
"Search in opened buffers with `pt'."
|
||||
(interactive)
|
||||
(let ((helm-ag-base-command "pt -e --nocolor --nogroup"))
|
||||
(helm-do-ag-buffers)))
|
||||
|
||||
(defun spacemacs/helm-buffers-do-pt-region-or-symbol ()
|
||||
"Search in opened buffers with `pt' using a default input."
|
||||
(interactive)
|
||||
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-buffers-do-pt))
|
||||
|
||||
(defun spacemacs/helm-buffers-smart-do-search (&optional default-inputp)
|
||||
"Search in opened buffers using `dotspacemacs-search-tools'.
|
||||
Search for a search tool in the order provided by `dotspacemacs-search-tools'
|
||||
If DEFAULT-INPUTP is non nil then the current region or symbol at point
|
||||
are used as default input."
|
||||
(interactive)
|
||||
(call-interactively
|
||||
(spacemacs//helm-do-search-find-tool "helm-buffers-do"
|
||||
dotspacemacs-search-tools
|
||||
default-inputp)))
|
||||
|
||||
(defun spacemacs/helm-buffers-smart-do-search-region-or-symbol ()
|
||||
"Search in opened buffers using `dotspacemacs-search-tools' with
|
||||
default input.
|
||||
Search for a search tool in the order provided by `dotspacemacs-search-tools'."
|
||||
(interactive)
|
||||
(spacemacs/helm-buffers-smart-do-search t))
|
||||
|
||||
;; Search in project ---------------------------------------------------
|
||||
|
||||
(defun spacemacs/helm-project-do-ag ()
|
||||
"Search in current project with `ag'."
|
||||
(interactive)
|
||||
(let ((dir (projectile-project-root)))
|
||||
(if dir
|
||||
(helm-do-ag dir)
|
||||
(message "error: Not in a project."))))
|
||||
|
||||
(defun spacemacs/helm-project-do-ag-region-or-symbol ()
|
||||
"Search in current project with `ag' using a default input."
|
||||
(interactive)
|
||||
(let ((dir (projectile-project-root)))
|
||||
(if dir
|
||||
(spacemacs//helm-do-ag-region-or-symbol 'helm-do-ag dir)
|
||||
(message "error: Not in a project."))))
|
||||
|
||||
(defun spacemacs/helm-project-do-ack ()
|
||||
"Search in current project with `ack'."
|
||||
(interactive)
|
||||
(let ((dir (projectile-project-root)))
|
||||
(if dir
|
||||
(spacemacs/helm-files-do-ack dir)
|
||||
(message "error: Not in a project."))))
|
||||
|
||||
(defun spacemacs/helm-project-do-ack-region-or-symbol ()
|
||||
"Search in current project with `ack' using a default input."
|
||||
(interactive)
|
||||
(let ((dir (projectile-project-root)))
|
||||
(if dir
|
||||
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-files-do-ack dir)
|
||||
(message "error: Not in a project."))))
|
||||
|
||||
(defun spacemacs/helm-project-do-pt ()
|
||||
"Search in current project with `pt'."
|
||||
(interactive)
|
||||
(let ((dir (projectile-project-root)))
|
||||
(if dir
|
||||
(spacemacs/helm-files-do-pt dir)
|
||||
(message "error: Not in a project."))))
|
||||
|
||||
(defun spacemacs/helm-project-do-pt-region-or-symbol ()
|
||||
"Search in current project with `pt' using a default input."
|
||||
(interactive)
|
||||
(let ((dir (projectile-project-root)))
|
||||
(if dir
|
||||
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-files-do-pt dir)
|
||||
(message "error: Not in a project."))))
|
||||
|
||||
(defun spacemacs/helm-project-smart-do-search (&optional default-inputp)
|
||||
"Search in current project using `dotspacemacs-search-tools'.
|
||||
Search for a search tool in the order provided by `dotspacemacs-search-tools'
|
||||
If DEFAULT-INPUTP is non nil then the current region or symbol at point
|
||||
are used as default input."
|
||||
(interactive)
|
||||
(let ((projectile-require-project-root nil))
|
||||
(call-interactively
|
||||
(spacemacs//helm-do-search-find-tool "helm-project-do"
|
||||
dotspacemacs-search-tools
|
||||
default-inputp))))
|
||||
|
||||
(defun spacemacs/helm-project-smart-do-search-region-or-symbol ()
|
||||
"Search in current project using `dotspacemacs-search-tools' with
|
||||
default input.
|
||||
Search for a search tool in the order provided by `dotspacemacs-search-tools'."
|
||||
(interactive)
|
||||
(spacemacs/helm-project-smart-do-search t))
|
||||
|
||||
;; This overrides the default C-s action in helm-projectile-switch-project
|
||||
;; to search using ag/pt/whatever instead of just grep
|
||||
(with-eval-after-load 'helm-projectile
|
||||
(defun spacemacs/helm-project-smart-do-search-in-dir (dir)
|
||||
(interactive)
|
||||
(let ((default-directory dir))
|
||||
(spacemacs/helm-project-smart-do-search)))
|
||||
(define-key helm-projectile-projects-map
|
||||
(kbd "C-s")
|
||||
(lambda ()
|
||||
(interactive)
|
||||
(helm-exit-and-execute-action 'spacemacs/helm-project-smart-do-search-in-dir))))
|
||||
|
||||
;; evilify the helm-grep buffer
|
||||
(evilified-state-evilify helm-grep-mode helm-grep-mode-map
|
||||
(kbd "RET") 'helm-grep-mode-jump-other-window
|
||||
(kbd "q") 'quit-window)
|
||||
|
||||
(spacemacs/set-leader-keys
|
||||
;; helm-ag marks
|
||||
"s`" 'helm-ag-pop-stack
|
||||
;; opened buffers scope
|
||||
"sb" 'spacemacs/helm-buffers-smart-do-search
|
||||
"sB" 'spacemacs/helm-buffers-smart-do-search-region-or-symbol
|
||||
"sab" 'helm-do-ag-buffers
|
||||
"saB" 'spacemacs/helm-buffers-do-ag-region-or-symbol
|
||||
"skb" 'spacemacs/helm-buffers-do-ack
|
||||
"skB" 'spacemacs/helm-buffers-do-ack-region-or-symbol
|
||||
"stb" 'spacemacs/helm-buffers-do-pt
|
||||
"stB" 'spacemacs/helm-buffers-do-pt-region-or-symbol
|
||||
;; current file scope
|
||||
"ss" 'spacemacs/helm-file-smart-do-search
|
||||
"sS" 'spacemacs/helm-file-smart-do-search-region-or-symbol
|
||||
"saa" 'helm-ag-this-file
|
||||
"saA" 'spacemacs/helm-file-do-ag-region-or-symbol
|
||||
;; files scope
|
||||
"sf" 'spacemacs/helm-files-smart-do-search
|
||||
"sF" 'spacemacs/helm-files-smart-do-search-region-or-symbol
|
||||
"saf" 'helm-do-ag
|
||||
"saF" 'spacemacs/helm-files-do-ag-region-or-symbol
|
||||
"skf" 'spacemacs/helm-files-do-ack
|
||||
"skF" 'spacemacs/helm-files-do-ack-region-or-symbol
|
||||
"stf" 'spacemacs/helm-files-do-pt
|
||||
"stF" 'spacemacs/helm-files-do-pt-region-or-symbol
|
||||
;; current project scope
|
||||
"/" 'spacemacs/helm-project-smart-do-search
|
||||
"*" 'spacemacs/helm-project-smart-do-search-region-or-symbol
|
||||
"sp" 'spacemacs/helm-project-smart-do-search
|
||||
"sP" 'spacemacs/helm-project-smart-do-search-region-or-symbol
|
||||
"sap" 'spacemacs/helm-project-do-ag
|
||||
"saP" 'spacemacs/helm-project-do-ag-region-or-symbol
|
||||
"skp" 'spacemacs/helm-project-do-ack
|
||||
"skP" 'spacemacs/helm-project-do-ack-region-or-symbol
|
||||
"stp" 'spacemacs/helm-project-do-pt
|
||||
"stP" 'spacemacs/helm-project-do-pt-region-or-symbol))
|
||||
:config
|
||||
(progn
|
||||
(evil-define-key 'normal helm-ag-map "SPC" spacemacs-default-map)
|
||||
(evilified-state-evilify helm-ag-mode helm-ag-mode-map
|
||||
(kbd "RET") 'helm-ag-mode-jump-other-window
|
||||
(kbd "q") 'quit-window))))
|
||||
|
||||
(defun spacemacs-helm/init-helm-descbinds ()
|
||||
(use-package helm-descbinds
|
||||
:defer t
|
||||
:init
|
||||
(progn
|
||||
(setq helm-descbinds-window-style 'split)
|
||||
(add-hook 'helm-mode-hook 'helm-descbinds-mode)
|
||||
(spacemacs/set-leader-keys "?" 'helm-descbinds))))
|
||||
|
||||
(defun spacemacs-helm/init-helm-flx ()
|
||||
(use-package helm-flx
|
||||
:defer t)
|
||||
(spacemacs|use-package-add-hook helm
|
||||
:pre-config
|
||||
(progn
|
||||
;; Disable for helm-find-files until performance issues are sorted
|
||||
;; https://github.com/PythonNut/helm-flx/issues/9
|
||||
(setq helm-flx-for-helm-find-files nil)
|
||||
(helm-flx-mode))))
|
||||
|
||||
(defun spacemacs-helm/init-helm-make ()
|
||||
(use-package helm-make
|
||||
:defer t
|
||||
:init
|
||||
(spacemacs/set-leader-keys
|
||||
"cc" 'helm-make-projectile
|
||||
"cm" 'helm-make)))
|
||||
|
||||
(defun spacemacs-helm/init-helm-mode-manager ()
|
||||
(use-package helm-mode-manager
|
||||
:defer t
|
||||
:init
|
||||
(spacemacs/set-leader-keys
|
||||
"hM" 'helm-switch-major-mode
|
||||
;; "hm" 'helm-disable-minor-mode
|
||||
"h C-m" 'helm-enable-minor-mode)))
|
||||
|
||||
(defun spacemacs-helm/init-helm-projectile ()
|
||||
(use-package helm-projectile
|
||||
:commands (helm-projectile-switch-to-buffer
|
||||
helm-projectile-find-dir
|
||||
helm-projectile-dired-find-dir
|
||||
helm-projectile-recentf
|
||||
helm-projectile-find-file
|
||||
helm-projectile-grep
|
||||
helm-projectile
|
||||
helm-projectile-switch-project)
|
||||
:init
|
||||
(progn
|
||||
(setq projectile-switch-project-action 'helm-projectile)
|
||||
|
||||
(defconst spacemacs-use-helm-projectile t
|
||||
"This variable is only defined if helm-projectile is used.")
|
||||
|
||||
;; needed for smart search if user's default tool is grep
|
||||
(defalias 'spacemacs/helm-project-do-grep 'helm-projectile-grep)
|
||||
(defalias
|
||||
'spacemacs/helm-project-do-grep-region-or-symbol 'helm-projectile-grep)
|
||||
|
||||
(spacemacs/set-leader-keys
|
||||
"pb" 'helm-projectile-switch-to-buffer
|
||||
"pd" 'helm-projectile-find-dir
|
||||
"pf" 'helm-projectile-find-file
|
||||
"ph" 'helm-projectile
|
||||
"pp" 'helm-projectile-switch-project
|
||||
"pr" 'helm-projectile-recentf
|
||||
"pv" 'projectile-vc
|
||||
"sgp" 'helm-projectile-grep))))
|
||||
|
||||
(defun spacemacs-helm/init-helm-spacemacs-help ()
|
||||
(use-package helm-spacemacs-help
|
||||
:commands (helm-spacemacs-help helm-spacemacs-help-faq)
|
||||
:init
|
||||
(progn
|
||||
(defun spacemacs-base/helm-spacemacs-deprecated (arg)
|
||||
"Provide helm-spacemacs with a binding's depreciation message."
|
||||
(interactive "P")
|
||||
(warn "The 'SPC f e h' (or 'M-m f e h') binding is now deprecated and will be remove in the next release. Please use 'SPC h SPC' (or 'M-m h SPC') instead.")
|
||||
(helm-spacemacs arg))
|
||||
(spacemacs/set-leader-keys "feh" 'spacemacs-base/helm-spacemacs-deprecated)
|
||||
(spacemacs/set-leader-keys "fef" 'helm-spacemacs-faq)
|
||||
(spacemacs/set-leader-keys "h SPC" 'helm-spacemacs))))
|
||||
|
||||
(defun spacemacs-helm/init-helm-swoop ()
|
||||
(use-package helm-swoop
|
||||
:defer t
|
||||
:init
|
||||
(progn
|
||||
(setq helm-swoop-split-with-multiple-windows t
|
||||
helm-swoop-split-direction 'split-window-vertically
|
||||
helm-swoop-speed-or-color t
|
||||
helm-swoop-split-window-function 'helm-default-display-buffer
|
||||
helm-swoop-pre-input-function (lambda () ""))
|
||||
|
||||
(defun spacemacs/helm-swoop-region-or-symbol ()
|
||||
"Call `helm-swoop' with default input."
|
||||
(interactive)
|
||||
(let ((helm-swoop-pre-input-function
|
||||
(lambda ()
|
||||
(if (region-active-p)
|
||||
(buffer-substring-no-properties (region-beginning)
|
||||
(region-end))
|
||||
(let ((thing (thing-at-point 'symbol t)))
|
||||
(if thing thing ""))))))
|
||||
(call-interactively 'helm-swoop)))
|
||||
|
||||
(spacemacs/set-leader-keys
|
||||
"ss" 'helm-swoop
|
||||
"sS" 'spacemacs/helm-swoop-region-or-symbol
|
||||
"s C-s" 'helm-multi-swoop-all)
|
||||
(defadvice helm-swoop (before add-evil-jump activate)
|
||||
(when (configuration-layer/package-usedp 'evil-jumper)
|
||||
(evil-set-jump))))))
|
||||
|
||||
(defun spacemacs-helm/init-helm-themes ()
|
||||
(use-package helm-themes
|
||||
:defer t
|
||||
:init
|
||||
(spacemacs/set-leader-keys
|
||||
"Th" 'helm-themes)))
|
|
@ -901,3 +901,35 @@ current major mode."
|
|||
(when (and (integerp shift-width)
|
||||
(< 0 shift-width))
|
||||
(setq-local evil-shift-width shift-width))))
|
||||
|
||||
(defun spacemacs//hjkl-completion-navigation ()
|
||||
(cond
|
||||
((and (configuration-layer/layer-usedp 'spacemacs-helm)
|
||||
(member dotspacemacs-editing-style '(vim hybrid)))
|
||||
;; better navigation on homerow
|
||||
;; rebind `describe-key' for convenience
|
||||
(define-key helm-map (kbd "C-j") 'helm-next-line)
|
||||
(define-key helm-map (kbd "C-k") 'helm-previous-line)
|
||||
(define-key helm-map (kbd "C-h") 'helm-next-source)
|
||||
(define-key helm-map (kbd "C-S-h") 'describe-key)
|
||||
(define-key helm-map (kbd "C-l") (kbd "RET"))
|
||||
(dolist (keymap (list helm-find-files-map helm-read-file-map))
|
||||
(define-key keymap (kbd "C-l") 'helm-execute-persistent-action)
|
||||
(define-key keymap (kbd "C-h") 'helm-find-files-up-one-level)
|
||||
(define-key keymap (kbd "C-S-h") 'describe-key)))
|
||||
((configuration-layer/layer-usedp 'spacemacs-helm)
|
||||
(define-key helm-map (kbd "C-j") 'helm-execute-persistent-action)
|
||||
(define-key helm-map (kbd "C-k") 'helm-delete-minibuffer-contents)
|
||||
(define-key helm-map (kbd "C-h") nil)
|
||||
(define-key helm-map (kbd "C-l") 'helm-recenter-top-bottom-other-window))
|
||||
((and (configuration-layer/layer-usedp 'spacemacs-ivy)
|
||||
(member dotspacemacs-editing-style '(vim hybrid)))
|
||||
(define-key ivy-minibuffer-map (kbd "C-j") 'ivy-next-line)
|
||||
(define-key ivy-minibuffer-map (kbd "C-k") 'ivy-previous-line)
|
||||
(define-key ivy-minibuffer-map (kbd "C-h") (kbd "DEL"))
|
||||
(define-key ivy-minibuffer-map (kbd "C-l") 'ivy-alt-done))
|
||||
((configuration-layer/layer-usedp 'spacemacs-ivy)
|
||||
(define-key ivy-minibuffer-map (kbd "C-j") 'ivy-alt-done)
|
||||
(define-key ivy-minibuffer-map (kbd "C-k") 'ivy-kill-line)
|
||||
(define-key ivy-minibuffer-map (kbd "C-h") nil)
|
||||
(define-key ivy-minibuffer-map (kbd "C-l") nil))))
|
||||
|
|
|
@ -76,32 +76,7 @@
|
|||
;; Cycling settings -----------------------------------------------------------
|
||||
(spacemacs/set-leader-keys "Tn" 'spacemacs/cycle-spacemacs-theme)
|
||||
;; describe functions ---------------------------------------------------------
|
||||
(defmacro spacemacs||set-helm-key (keys func)
|
||||
"Define a key bindings for FUNC using KEYS.
|
||||
Ensure that helm is required before calling FUNC."
|
||||
(let ((func-name (intern (format "spacemacs/%s" (symbol-name func)))))
|
||||
`(progn
|
||||
(defun ,func-name ()
|
||||
,(format "Wrapper to ensure that `helm' is loaded before calling %s."
|
||||
(symbol-name func))
|
||||
(interactive)
|
||||
(require 'helm)
|
||||
(call-interactively ',func))
|
||||
(spacemacs/set-leader-keys ,keys ',func-name))))
|
||||
(spacemacs||set-helm-key "hdb" describe-bindings)
|
||||
(spacemacs||set-helm-key "hdc" describe-char)
|
||||
(spacemacs||set-helm-key "hdf" describe-function)
|
||||
(spacemacs||set-helm-key "hdk" describe-key)
|
||||
(spacemacs||set-helm-key "hdm" describe-mode)
|
||||
(spacemacs||set-helm-key "hdp" describe-package)
|
||||
(spacemacs/set-leader-keys "hds" 'spacemacs/describe-system-info)
|
||||
(spacemacs||set-helm-key "hdt" describe-theme)
|
||||
(spacemacs||set-helm-key "hdv" describe-variable)
|
||||
(spacemacs||set-helm-key "hn" view-emacs-news)
|
||||
(spacemacs||set-helm-key "hL" helm-locate-library)
|
||||
;; search functions -----------------------------------------------------------
|
||||
(spacemacs||set-helm-key "sww" helm-wikipedia-suggest)
|
||||
(spacemacs||set-helm-key "swg" helm-google-suggest)
|
||||
;; errors ---------------------------------------------------------------------
|
||||
(spacemacs/set-leader-keys
|
||||
"en" 'spacemacs/next-error
|
||||
|
@ -571,7 +546,7 @@ otherwise it is scaled down."
|
|||
dotfile-setting
|
||||
'(100 . 100))))
|
||||
;; Immediately enter the micro-state, but also keep toggle
|
||||
;; accessible from helm-spacemacs
|
||||
;; accessible from helm-spacemacs-help
|
||||
(spacemacs/scale-transparency-micro-state))
|
||||
|
||||
(defun spacemacs/increase-transparency ()
|
||||
|
|
|
@ -27,11 +27,6 @@
|
|||
(evil-evilified-state :location local :step pre :protected t)
|
||||
exec-path-from-shell
|
||||
fill-column-indicator
|
||||
helm
|
||||
helm-descbinds
|
||||
helm-flx
|
||||
helm-projectile
|
||||
(helm-spacemacs :location local)
|
||||
help-fns+
|
||||
hl-todo
|
||||
(hs-minor-mode :location built-in)
|
||||
|
@ -482,507 +477,6 @@ Example: (evil-map visual \"<\" \"<gv\")"
|
|||
:config
|
||||
(spacemacs|hide-lighter fci-mode)))
|
||||
|
||||
(defun spacemacs-base/init-helm ()
|
||||
(use-package helm
|
||||
:defer 1
|
||||
:commands (spacemacs/helm-find-files)
|
||||
:config
|
||||
(progn
|
||||
(when (and dotspacemacs-helm-resize
|
||||
(or (eq dotspacemacs-helm-position 'bottom)
|
||||
(eq dotspacemacs-helm-position 'top)))
|
||||
(setq helm-autoresize-min-height 10)
|
||||
(helm-autoresize-mode 1))
|
||||
|
||||
;; from https://www.reddit.com/r/emacs/comments/2z7nbv/lean_helm_window/
|
||||
(defvar helm-source-header-default-background (face-attribute 'helm-source-header :background))
|
||||
(defvar helm-source-header-default-foreground (face-attribute 'helm-source-header :foreground))
|
||||
(defvar helm-source-header-default-box (face-attribute 'helm-source-header :box))
|
||||
(defvar helm-source-header-default-height (face-attribute 'helm-source-header :height) )
|
||||
|
||||
(defun helm-toggle-header-line ()
|
||||
"Hide the `helm' header is there is only one source."
|
||||
(when dotspacemacs-helm-no-header
|
||||
(if (> (length helm-sources) 1)
|
||||
(set-face-attribute 'helm-source-header
|
||||
nil
|
||||
:foreground helm-source-header-default-foreground
|
||||
:background helm-source-header-default-background
|
||||
:box helm-source-header-default-box
|
||||
:height helm-source-header-default-height)
|
||||
(set-face-attribute 'helm-source-header
|
||||
nil
|
||||
:foreground (face-attribute 'helm-selection :background)
|
||||
:background (face-attribute 'helm-selection :background)
|
||||
:box nil
|
||||
:height 0.1))))
|
||||
(add-hook 'helm-before-initialize-hook 'helm-toggle-header-line)
|
||||
|
||||
(defun spacemacs/helm-find-files (arg)
|
||||
"Custom spacemacs implementation for calling helm-find-files-1.
|
||||
|
||||
Removes the automatic guessing of the initial value based on thing at point. "
|
||||
(interactive "P")
|
||||
(let* ((hist (and arg helm-ff-history (helm-find-files-history)))
|
||||
(default-input hist )
|
||||
(input (cond ((and (eq major-mode 'dired-mode) default-input)
|
||||
(file-name-directory default-input))
|
||||
((and (not (string= default-input ""))
|
||||
default-input))
|
||||
(t (expand-file-name (helm-current-directory))))))
|
||||
(set-text-properties 0 (length input) nil input)
|
||||
(helm-find-files-1 input ))))
|
||||
:init
|
||||
(progn
|
||||
(setq helm-prevent-escaping-from-minibuffer t
|
||||
helm-bookmark-show-location t
|
||||
helm-display-header-line nil
|
||||
helm-split-window-in-side-p t
|
||||
helm-always-two-windows t
|
||||
helm-echo-input-in-header-line t
|
||||
helm-imenu-execute-action-at-once-if-one nil
|
||||
helm-org-format-outline-path t)
|
||||
|
||||
;; hide minibuffer in Helm session, since we use the header line already
|
||||
(defun helm-hide-minibuffer-maybe ()
|
||||
(when (with-helm-buffer helm-echo-input-in-header-line)
|
||||
(let ((ov (make-overlay (point-min) (point-max) nil nil t)))
|
||||
(overlay-put ov 'window (selected-window))
|
||||
(overlay-put ov 'face (let ((bg-color (face-background 'default nil)))
|
||||
`(:background ,bg-color :foreground ,bg-color)))
|
||||
(setq-local cursor-type nil))))
|
||||
(add-hook 'helm-minibuffer-set-up-hook 'helm-hide-minibuffer-maybe)
|
||||
|
||||
;; fuzzy matching setting
|
||||
(setq helm-M-x-fuzzy-match t
|
||||
helm-apropos-fuzzy-match t
|
||||
helm-file-cache-fuzzy-match t
|
||||
helm-imenu-fuzzy-match t
|
||||
helm-lisp-fuzzy-completion t
|
||||
helm-recentf-fuzzy-match t
|
||||
helm-semantic-fuzzy-match t
|
||||
helm-buffers-fuzzy-matching t)
|
||||
|
||||
;; Use helm to provide :ls, unless ibuffer is used
|
||||
(unless (configuration-layer/package-usedp 'ibuffer)
|
||||
(evil-ex-define-cmd "buffers" 'helm-buffers-list))
|
||||
|
||||
(defun spacemacs//helm-do-grep-region-or-symbol (&optional targs use-region-or-symbol-p)
|
||||
"Version of `helm-do-grep' with a default input."
|
||||
(interactive)
|
||||
(require 'helm)
|
||||
(cl-letf*
|
||||
(((symbol-function 'this-fn) (symbol-function 'helm-do-grep-1))
|
||||
((symbol-function 'helm-do-grep-1)
|
||||
(lambda (targets &optional recurse zgrep exts default-input region-or-symbol-p)
|
||||
(let* ((new-input (when region-or-symbol-p
|
||||
(if (region-active-p)
|
||||
(buffer-substring-no-properties
|
||||
(region-beginning) (region-end))
|
||||
(thing-at-point 'symbol t))))
|
||||
(quoted-input (when new-input (rxt-quote-pcre new-input))))
|
||||
(this-fn targets recurse zgrep exts default-input quoted-input))))
|
||||
(preselection (or (dired-get-filename nil t)
|
||||
(buffer-file-name (current-buffer))))
|
||||
(targets (if targs
|
||||
targs
|
||||
(helm-read-file-name
|
||||
"Search in file(s): "
|
||||
:marked-candidates t
|
||||
:preselect (if helm-ff-transformer-show-only-basename
|
||||
(helm-basename preselection)
|
||||
preselection)))))
|
||||
(helm-do-grep-1 targets nil nil nil nil use-region-or-symbol-p)))
|
||||
|
||||
(defun spacemacs/helm-file-do-grep ()
|
||||
"Search in current file with `grep' using a default input."
|
||||
(interactive)
|
||||
(spacemacs//helm-do-grep-region-or-symbol
|
||||
(list (buffer-file-name (current-buffer))) nil))
|
||||
|
||||
(defun spacemacs/helm-file-do-grep-region-or-symbol ()
|
||||
"Search in current file with `grep' using a default input."
|
||||
(interactive)
|
||||
(spacemacs//helm-do-grep-region-or-symbol
|
||||
(list (buffer-file-name (current-buffer))) t))
|
||||
|
||||
(defun spacemacs/helm-files-do-grep ()
|
||||
"Search in files with `grep'."
|
||||
(interactive)
|
||||
(spacemacs//helm-do-grep-region-or-symbol nil nil))
|
||||
|
||||
(defun spacemacs/helm-files-do-grep-region-or-symbol ()
|
||||
"Search in files with `grep' using a default input."
|
||||
(interactive)
|
||||
(spacemacs//helm-do-grep-region-or-symbol nil t))
|
||||
|
||||
(defun spacemacs/helm-buffers-do-grep ()
|
||||
"Search in opened buffers with `grep'."
|
||||
(interactive)
|
||||
(let ((buffers (cl-loop for buffer in (buffer-list)
|
||||
when (buffer-file-name buffer)
|
||||
collect (buffer-file-name buffer))))
|
||||
(spacemacs//helm-do-grep-region-or-symbol buffers nil)))
|
||||
|
||||
(defun spacemacs/helm-buffers-do-grep-region-or-symbol ()
|
||||
"Search in opened buffers with `grep' with a default input."
|
||||
(interactive)
|
||||
(let ((buffers (cl-loop for buffer in (buffer-list)
|
||||
when (buffer-file-name buffer)
|
||||
collect (buffer-file-name buffer))))
|
||||
(spacemacs//helm-do-grep-region-or-symbol buffers t)))
|
||||
|
||||
(defun spacemacs/last-search-buffer ()
|
||||
"open last helm-ag or hgrep buffer."
|
||||
(interactive)
|
||||
(cond ((get-buffer "*helm ag results*")
|
||||
(switch-to-buffer-other-window "*helm ag results*"))
|
||||
((get-buffer "*helm-ag*")
|
||||
(helm-resume "*helm-ag*"))
|
||||
((get-buffer "*hgrep*")
|
||||
(switch-to-buffer-other-window "*hgrep*"))
|
||||
(t
|
||||
(message "No previous search buffer found"))))
|
||||
|
||||
(defun spacemacs/helm-faces ()
|
||||
"Describe face."
|
||||
(interactive)
|
||||
(require 'helm-elisp)
|
||||
(let ((default (or (face-at-point) (thing-at-point 'symbol))))
|
||||
(helm :sources (helm-def-source--emacs-faces
|
||||
(format "%s" (or default "default")))
|
||||
:buffer "*helm faces*")))
|
||||
|
||||
;; use helm by default for M-x
|
||||
(unless (configuration-layer/package-usedp 'smex)
|
||||
(global-set-key (kbd "M-x") 'helm-M-x))
|
||||
|
||||
(spacemacs/set-leader-keys
|
||||
"<f1>" 'helm-apropos
|
||||
"bb" 'helm-mini
|
||||
"Cl" 'helm-colors
|
||||
"ff" 'spacemacs/helm-find-files
|
||||
"fF" 'helm-find-files
|
||||
"fL" 'helm-locate
|
||||
"fr" 'helm-recentf
|
||||
"hb" 'helm-filtered-bookmarks
|
||||
"hdF" 'spacemacs/helm-faces
|
||||
"hi" 'helm-info-at-point
|
||||
"hl" 'helm-resume
|
||||
"hm" 'helm-man-woman
|
||||
"iu" 'helm-ucs
|
||||
"ry" 'helm-show-kill-ring
|
||||
"rr" 'helm-register
|
||||
"rm" 'helm-all-mark-rings
|
||||
"sl" 'spacemacs/last-search-buffer
|
||||
"sj" 'spacemacs/jump-in-buffer)
|
||||
|
||||
;; search with grep
|
||||
(spacemacs/set-leader-keys
|
||||
"sgb" 'spacemacs/helm-buffers-do-grep
|
||||
"sgB" 'spacemacs/helm-buffers-do-grep-region-or-symbol
|
||||
"sgf" 'spacemacs/helm-files-do-grep
|
||||
"sgF" 'spacemacs/helm-files-do-grep-region-or-symbol
|
||||
"sgg" 'spacemacs/helm-file-do-grep
|
||||
"sgG" 'spacemacs/helm-file-do-grep-region-or-symbol)
|
||||
|
||||
;; define the key binding at the very end in order to allow the user
|
||||
;; to overwrite any key binding
|
||||
(add-hook 'emacs-startup-hook
|
||||
(lambda ()
|
||||
(unless (configuration-layer/package-usedp 'smex)
|
||||
(spacemacs/set-leader-keys
|
||||
dotspacemacs-emacs-command-key 'helm-M-x))))
|
||||
|
||||
(defun spacemacs//hide-cursor-in-helm-buffer ()
|
||||
"Hide the cursor in helm buffers."
|
||||
(with-helm-buffer
|
||||
(setq cursor-in-non-selected-windows nil)))
|
||||
(add-hook 'helm-after-initialize-hook 'spacemacs//hide-cursor-in-helm-buffer)
|
||||
|
||||
(defvar spacemacs-helm-display-help-buffer-regexp '("*.*Helm.*Help.**"))
|
||||
(defvar spacemacs-helm-display-buffer-regexp `("*.*helm.**"
|
||||
(display-buffer-in-side-window)
|
||||
(inhibit-same-window . t)
|
||||
(side . ,dotspacemacs-helm-position)
|
||||
(window-width . 0.6)
|
||||
(window-height . 0.4)))
|
||||
(defvar spacemacs-display-buffer-alist nil)
|
||||
(defun spacemacs//helm-prepare-display ()
|
||||
"Prepare necessary settings to make Helm display properly."
|
||||
;; avoid Helm buffer being diplaye twice when user
|
||||
;; sets this variable to some function that pop buffer to
|
||||
;; a window. See https://github.com/syl20bnr/spacemacs/issues/1396
|
||||
(let ((display-buffer-base-action '(nil)))
|
||||
(setq spacemacs-display-buffer-alist display-buffer-alist)
|
||||
;; the only buffer to display is Helm, nothing else we must set this
|
||||
;; otherwise Helm cannot reuse its own windows for copyinng/deleting
|
||||
;; etc... because of existing popwin buffers in the alist
|
||||
(setq display-buffer-alist nil)
|
||||
(popwin-mode -1)
|
||||
;; workaround for a helm-evil incompatibility
|
||||
;; see https://github.com/syl20bnr/spacemacs/issues/3700
|
||||
(when helm-prevent-escaping-from-minibuffer
|
||||
(define-key evil-motion-state-map [down-mouse-1] nil))))
|
||||
|
||||
(defun spacemacs//display-helm-window (buffer)
|
||||
(let ((display-buffer-alist (list spacemacs-helm-display-help-buffer-regexp
|
||||
;; this or any specialized case of Helm buffer must be added AFTER
|
||||
;; `spacemacs-helm-display-buffer-regexp'. Otherwise,
|
||||
;; `spacemacs-helm-display-buffer-regexp' will be used before
|
||||
;; `spacemacs-helm-display-help-buffer-regexp' and display
|
||||
;; configuration for normal Helm buffer is applied for helm help
|
||||
;; buffer, making the help buffer unable to be displayed.
|
||||
spacemacs-helm-display-buffer-regexp)))
|
||||
(helm-default-display-buffer buffer)))
|
||||
(setq helm-display-function 'spacemacs//display-helm-window)
|
||||
|
||||
(defun spacemacs//restore-previous-display-config ()
|
||||
;; workaround for a helm-evil incompatibility
|
||||
;; see https://github.com/syl20bnr/spacemacs/issues/3700
|
||||
(when helm-prevent-escaping-from-minibuffer
|
||||
(define-key evil-motion-state-map [down-mouse-1] 'evil-mouse-drag-region))
|
||||
(popwin-mode 1)
|
||||
;; we must enable popwin-mode first then restore `display-buffer-alist'
|
||||
;; Otherwise, popwin keeps adding up its own buffers to `display-buffer-alist'
|
||||
;; and could slow down Emacs as the list grows
|
||||
(setq display-buffer-alist spacemacs-display-buffer-alist))
|
||||
|
||||
(add-hook 'helm-after-initialize-hook 'spacemacs//helm-prepare-display)
|
||||
;; Restore popwin-mode after a Helm session finishes.
|
||||
(add-hook 'helm-cleanup-hook 'spacemacs//restore-previous-display-config)
|
||||
|
||||
;; Add minibuffer history with `helm-minibuffer-history'
|
||||
(define-key minibuffer-local-map (kbd "C-c C-l") 'helm-minibuffer-history)
|
||||
|
||||
(defun spacemacs//helm-cleanup ()
|
||||
"Cleanup some helm related states when quitting."
|
||||
;; deactivate any running transient map (micro-state)
|
||||
(setq overriding-terminal-local-map nil))
|
||||
(add-hook 'helm-cleanup-hook 'spacemacs//helm-cleanup)
|
||||
|
||||
(defface spacemacs-helm-navigation-ms-face
|
||||
`((t :background ,(face-attribute 'error :foreground) :foreground "black"))
|
||||
"Face for helm heder when helm micro-state is activated."
|
||||
:group 'spacemacs))
|
||||
|
||||
:config
|
||||
(progn
|
||||
(helm-mode +1)
|
||||
|
||||
;; helm-locate uses es (from everything on windows, which doesnt like fuzzy)
|
||||
(helm-locate-set-command)
|
||||
(setq helm-locate-fuzzy-match (string-match "locate" helm-locate-command))
|
||||
|
||||
(defun spacemacs//set-dotted-directory ()
|
||||
"Set the face of diretories for `.' and `..'"
|
||||
(set-face-attribute 'helm-ff-dotted-directory
|
||||
nil
|
||||
:foreground nil
|
||||
:background nil
|
||||
:inherit 'helm-ff-directory))
|
||||
(add-hook 'helm-find-files-before-init-hook 'spacemacs//set-dotted-directory)
|
||||
|
||||
;; alter helm-bookmark key bindings to be simpler
|
||||
(defun simpler-helm-bookmark-keybindings ()
|
||||
(define-key helm-bookmark-map (kbd "C-d") 'helm-bookmark-run-delete)
|
||||
(define-key helm-bookmark-map (kbd "C-e") 'helm-bookmark-run-edit)
|
||||
(define-key helm-bookmark-map (kbd "C-f") 'helm-bookmark-toggle-filename)
|
||||
(define-key helm-bookmark-map (kbd "C-o") 'helm-bookmark-run-jump-other-window)
|
||||
(define-key helm-bookmark-map (kbd "C-/") 'helm-bookmark-help))
|
||||
(add-hook 'helm-mode-hook 'simpler-helm-bookmark-keybindings)
|
||||
|
||||
;; helm navigation on hjkl
|
||||
(defun spacemacs//helm-hjkl-navigation (&optional arg)
|
||||
"Set navigation in helm on `jklh'.
|
||||
ARG non nil means that the editing style is `vim'."
|
||||
(cond
|
||||
(arg
|
||||
;; better navigation on homerow
|
||||
;; rebind `describe-key' for convenience
|
||||
(define-key helm-map (kbd "C-j") 'helm-next-line)
|
||||
(define-key helm-map (kbd "C-k") 'helm-previous-line)
|
||||
(define-key helm-map (kbd "C-h") 'helm-next-source)
|
||||
(define-key helm-map (kbd "C-S-h") 'describe-key)
|
||||
(define-key helm-map (kbd "C-l") (kbd "RET"))
|
||||
(dolist (keymap (list helm-find-files-map helm-read-file-map))
|
||||
(define-key keymap (kbd "C-l") 'helm-execute-persistent-action)
|
||||
(define-key keymap (kbd "C-h") 'helm-find-files-up-one-level)
|
||||
(define-key keymap (kbd "C-S-h") 'describe-key)))
|
||||
(t
|
||||
(define-key helm-map (kbd "C-j") 'helm-execute-persistent-action)
|
||||
(define-key helm-map (kbd "C-k") 'helm-delete-minibuffer-contents)
|
||||
(define-key helm-map (kbd "C-h") nil)
|
||||
(define-key helm-map (kbd "C-l") 'helm-recenter-top-bottom-other-window))))
|
||||
(spacemacs//helm-hjkl-navigation (member dotspacemacs-editing-style '(vim hybrid)))
|
||||
|
||||
(defun spacemacs/helm-edit ()
|
||||
"Switch in edit mode depending on the current helm buffer."
|
||||
(interactive)
|
||||
(cond
|
||||
((string-equal "*helm-ag*" helm-buffer)
|
||||
(helm-ag-edit))))
|
||||
|
||||
(defun spacemacs//helm-navigation-ms-on-enter ()
|
||||
"Initialization of helm micro-state."
|
||||
;; faces
|
||||
(spacemacs//helm-navigation-ms-set-face)
|
||||
(setq spacemacs--helm-navigation-ms-face-cookie-minibuffer
|
||||
(face-remap-add-relative
|
||||
'minibuffer-prompt
|
||||
'spacemacs-helm-navigation-ms-face)))
|
||||
|
||||
(defun spacemacs//helm-navigation-ms-set-face ()
|
||||
"Set the face for helm header in helm navigation micro-state"
|
||||
(with-helm-window
|
||||
(setq spacemacs--helm-navigation-ms-face-cookie-header
|
||||
(face-remap-add-relative
|
||||
'helm-header
|
||||
'spacemacs-helm-navigation-ms-face))))
|
||||
|
||||
(defun spacemacs//helm-navigation-ms-on-exit ()
|
||||
"Action to perform when exiting helm micro-state."
|
||||
(with-helm-window
|
||||
(face-remap-remove-relative
|
||||
spacemacs--helm-navigation-ms-face-cookie-header))
|
||||
(face-remap-remove-relative
|
||||
spacemacs--helm-navigation-ms-face-cookie-minibuffer))
|
||||
|
||||
(defun spacemacs//helm-navigation-ms-full-doc ()
|
||||
"Full documentation for helm navigation micro-state."
|
||||
"
|
||||
[?] display this help
|
||||
[a] toggle action selection page
|
||||
[e] edit occurrences if supported
|
||||
[j] [k] next/previous candidate
|
||||
[h] [l] previous/next source
|
||||
[t] toggle visible mark
|
||||
[T] toggle all mark
|
||||
[v] persistent action
|
||||
[q] quit")
|
||||
|
||||
;; Define functions to pick actions
|
||||
(dotimes (n 10)
|
||||
(let ((func (intern (format "spacemacs/helm-action-%d" n)))
|
||||
(doc (format "Select helm action #%d" n)))
|
||||
(eval `(defun ,func ()
|
||||
,doc
|
||||
(intern)
|
||||
(helm-select-nth-action ,(1- n))))))
|
||||
|
||||
(spacemacs|define-micro-state helm-navigation
|
||||
:persistent t
|
||||
:disable-evil-leader t
|
||||
:define-key (helm-map . "M-SPC") (helm-map . "s-M-SPC")
|
||||
:on-enter (spacemacs//helm-navigation-ms-on-enter)
|
||||
:on-exit (spacemacs//helm-navigation-ms-on-exit)
|
||||
:bindings
|
||||
("1" spacemacs/helm-action-1 :exit t)
|
||||
("2" spacemacs/helm-action-2 :exit t)
|
||||
("3" spacemacs/helm-action-3 :exit t)
|
||||
("4" spacemacs/helm-action-4 :exit t)
|
||||
("5" spacemacs/helm-action-5 :exit t)
|
||||
("6" spacemacs/helm-action-6 :exit t)
|
||||
("7" spacemacs/helm-action-7 :exit t)
|
||||
("8" spacemacs/helm-action-8 :exit t)
|
||||
("9" spacemacs/helm-action-9 :exit t)
|
||||
("0" spacemacs/helm-action-10 :exit t)
|
||||
("<tab>" helm-select-action :exit t)
|
||||
("TAB" helm-select-action :exit t)
|
||||
("<RET>" helm-maybe-exit-minibuffer :exit t)
|
||||
("?" nil :doc (spacemacs//helm-navigation-ms-full-doc))
|
||||
("a" helm-select-action :post (spacemacs//helm-navigation-ms-set-face))
|
||||
("e" spacemacs/helm-edit)
|
||||
("g" helm-beginning-of-buffer)
|
||||
("G" helm-end-of-buffer)
|
||||
("h" helm-previous-source)
|
||||
("j" helm-next-line)
|
||||
("k" helm-previous-line)
|
||||
("l" helm-next-source)
|
||||
("q" nil :exit t)
|
||||
("t" helm-toggle-visible-mark)
|
||||
("T" helm-toggle-all-marks)
|
||||
("v" helm-execute-persistent-action))
|
||||
|
||||
;; Swap default TAB and C-z commands.
|
||||
;; For GUI.
|
||||
(define-key helm-map (kbd "<tab>") 'helm-execute-persistent-action)
|
||||
(define-key helm-find-files-map (kbd "S-<tab>") 'helm-find-files-up-one-level)
|
||||
(define-key helm-find-files-map (kbd "<backtab>") 'helm-find-files-up-one-level)
|
||||
;; For terminal.
|
||||
(define-key helm-map (kbd "TAB") 'helm-execute-persistent-action)
|
||||
(define-key helm-find-files-map (kbd "S-TAB") 'helm-find-files-up-one-level)
|
||||
(define-key helm-map (kbd "C-z") 'helm-select-action)
|
||||
|
||||
(with-eval-after-load 'helm-mode ; required
|
||||
(spacemacs|hide-lighter helm-mode)))))
|
||||
|
||||
(defun spacemacs-base/init-helm-flx ()
|
||||
(use-package helm-flx
|
||||
:defer t)
|
||||
(spacemacs|use-package-add-hook helm
|
||||
:pre-config
|
||||
(progn
|
||||
;; Disable for helm-find-files until performance issues are sorted
|
||||
;; https://github.com/PythonNut/helm-flx/issues/9
|
||||
(setq helm-flx-for-helm-find-files nil)
|
||||
(helm-flx-mode))))
|
||||
|
||||
(defun spacemacs-base/init-helm-descbinds ()
|
||||
(use-package helm-descbinds
|
||||
:defer t
|
||||
:init
|
||||
(progn
|
||||
(setq helm-descbinds-window-style 'split)
|
||||
(add-hook 'helm-mode-hook 'helm-descbinds-mode)
|
||||
(spacemacs/set-leader-keys "?" 'helm-descbinds))))
|
||||
|
||||
(defun spacemacs-base/init-helm-projectile ()
|
||||
(use-package helm-projectile
|
||||
:commands (helm-projectile-switch-to-buffer
|
||||
helm-projectile-find-dir
|
||||
helm-projectile-dired-find-dir
|
||||
helm-projectile-recentf
|
||||
helm-projectile-find-file
|
||||
helm-projectile-grep
|
||||
helm-projectile
|
||||
helm-projectile-switch-project)
|
||||
:init
|
||||
(progn
|
||||
(setq projectile-switch-project-action 'helm-projectile)
|
||||
|
||||
(defconst spacemacs-use-helm-projectile t
|
||||
"This variable is only defined if helm-projectile is used.")
|
||||
|
||||
;; needed for smart search if user's default tool is grep
|
||||
(defalias 'spacemacs/helm-project-do-grep 'helm-projectile-grep)
|
||||
(defalias
|
||||
'spacemacs/helm-project-do-grep-region-or-symbol 'helm-projectile-grep)
|
||||
|
||||
(spacemacs/set-leader-keys
|
||||
"pb" 'helm-projectile-switch-to-buffer
|
||||
"pd" 'helm-projectile-find-dir
|
||||
"pf" 'helm-projectile-find-file
|
||||
"ph" 'helm-projectile
|
||||
"pp" 'helm-projectile-switch-project
|
||||
"pr" 'helm-projectile-recentf
|
||||
"pv" 'projectile-vc
|
||||
"sgp" 'helm-projectile-grep))))
|
||||
|
||||
(defun spacemacs-base/init-helm-spacemacs ()
|
||||
(use-package helm-spacemacs
|
||||
:commands (helm-spacemacs helm-spacemacs-faq)
|
||||
:init
|
||||
(progn
|
||||
(defun spacemacs-base/helm-spacemacs-deprecated (arg)
|
||||
"Provide helm-spacemacs with a binding's depreciation message."
|
||||
(interactive "P")
|
||||
(warn "The 'SPC f e h' (or 'M-m f e h') binding is now deprecated and will be remove in the next release. Please use 'SPC h SPC' (or 'M-m h SPC') instead.")
|
||||
(helm-spacemacs arg))
|
||||
(spacemacs/set-leader-keys "feh" 'spacemacs-base/helm-spacemacs-deprecated)
|
||||
(spacemacs/set-leader-keys "fef" 'helm-spacemacs-faq)
|
||||
(spacemacs/set-leader-keys "h SPC" 'helm-spacemacs))))
|
||||
|
||||
(defun spacemacs-base/init-help-fns+ ()
|
||||
(use-package help-fns+
|
||||
:commands (describe-keymap)
|
||||
|
@ -1315,8 +809,13 @@ ARG non nil means that the editing style is `vim'."
|
|||
"pT" 'projectile-find-test-file
|
||||
"py" 'projectile-find-tag)
|
||||
(when (configuration-layer/package-usedp 'persp-mode)
|
||||
(spacemacs/set-leader-keys
|
||||
"pl" 'spacemacs/helm-persp-switch-project)))
|
||||
(if (configuration-layer/layer-usedp 'spacemacs-helm)
|
||||
(spacemacs/set-leader-keys
|
||||
"pl" 'spacemacs/helm-persp-switch-project)
|
||||
(spacemacs/set-leader-keys
|
||||
"pl" 'spacemacs/ivy-persp-switch-project)
|
||||
)
|
||||
))
|
||||
:config
|
||||
(progn
|
||||
(projectile-global-mode)
|
||||
|
@ -1333,6 +832,9 @@ ARG non nil means that the editing style is `vim'."
|
|||
(add-hook 'find-file-hook (lambda () (unless recentf-mode
|
||||
(recentf-mode)
|
||||
(recentf-track-opened-file))))
|
||||
(add-hook 'ivy-mode-hook (lambda () (unless recentf-mode
|
||||
(recentf-mode)
|
||||
(recentf-track-opened-file))))
|
||||
(setq recentf-save-file (concat spacemacs-cache-directory "recentf")
|
||||
recentf-max-saved-items 1000
|
||||
recentf-auto-cleanup 'never
|
||||
|
|
|
@ -13,3 +13,8 @@
|
|||
;; Prerequisites
|
||||
|
||||
(configuration-layer/declare-layers '(spacemacs-base spacemacs-layouts))
|
||||
;; If the user has not explicitly declared spacemacs-helm or spacemacs-ivy and
|
||||
;; they are using the standard distribution, assume they want helm completion.
|
||||
(unless (or (configuration-layer/layer-usedp 'spacemacs-ivy)
|
||||
(configuration-layer/layer-usedp 'spacemacs-helm))
|
||||
(configuration-layer/declare-layers '(spacemacs-helm)))
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
(setq spacemacs-packages
|
||||
'(
|
||||
;; default
|
||||
ace-jump-helm-line
|
||||
ace-link
|
||||
ace-window
|
||||
adaptive-wrap
|
||||
|
@ -51,11 +50,6 @@
|
|||
flx-ido
|
||||
golden-ratio
|
||||
google-translate
|
||||
helm-ag
|
||||
helm-make
|
||||
helm-mode-manager
|
||||
helm-swoop
|
||||
helm-themes
|
||||
highlight-indentation
|
||||
highlight-numbers
|
||||
highlight-parentheses
|
||||
|
@ -92,13 +86,6 @@
|
|||
|
||||
;; Initialization of packages
|
||||
|
||||
(defun spacemacs/init-ace-jump-helm-line ()
|
||||
(use-package ace-jump-helm-line
|
||||
:defer t
|
||||
:init
|
||||
(with-eval-after-load 'helm
|
||||
(define-key helm-map (kbd "C-q") 'ace-jump-helm-line))))
|
||||
|
||||
(defun spacemacs/init-ace-link ()
|
||||
(use-package ace-link
|
||||
:commands spacemacs/ace-buffer-links
|
||||
|
@ -921,364 +908,6 @@ For instance pass En as source for English."
|
|||
(setq google-translate-default-source-language "en")
|
||||
(setq google-translate-default-target-language "fr"))))
|
||||
|
||||
(defun spacemacs/init-helm-ag ()
|
||||
(use-package helm-ag
|
||||
:defer t
|
||||
:init
|
||||
(progn
|
||||
(defun spacemacs//helm-do-ag-region-or-symbol (func &optional dir)
|
||||
"Search with `ag' with a default input."
|
||||
(require 'helm-ag)
|
||||
(cl-letf* (((symbol-value 'helm-ag-insert-at-point) 'symbol)
|
||||
;; make thing-at-point choosing the active region first
|
||||
((symbol-function 'this-fn) (symbol-function 'thing-at-point))
|
||||
((symbol-function 'thing-at-point)
|
||||
(lambda (thing)
|
||||
(let ((res (if (region-active-p)
|
||||
(buffer-substring-no-properties
|
||||
(region-beginning) (region-end))
|
||||
(this-fn thing))))
|
||||
(when res (rxt-quote-pcre res))))))
|
||||
(funcall func dir)))
|
||||
|
||||
(defun spacemacs//helm-do-search-find-tool (base tools default-inputp)
|
||||
"Create a cond form given a TOOLS string list and evaluate it."
|
||||
(eval
|
||||
`(cond
|
||||
,@(mapcar
|
||||
(lambda (x)
|
||||
`((executable-find ,x)
|
||||
',(let ((func
|
||||
(intern
|
||||
(format (if default-inputp
|
||||
"spacemacs/%s-%s-region-or-symbol"
|
||||
"spacemacs/%s-%s")
|
||||
base x))))
|
||||
(if (fboundp func)
|
||||
func
|
||||
(intern (format "%s-%s" base x))))))
|
||||
tools)
|
||||
(t 'helm-do-grep))))
|
||||
|
||||
;; Search in current file ----------------------------------------------
|
||||
|
||||
(defun spacemacs/helm-file-do-ag (&optional _)
|
||||
"Wrapper to execute `helm-ag-this-file.'"
|
||||
(interactive)
|
||||
(helm-ag-this-file))
|
||||
|
||||
(defun spacemacs/helm-file-do-ag-region-or-symbol ()
|
||||
"Search in current file with `ag' using a default input."
|
||||
(interactive)
|
||||
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-file-do-ag))
|
||||
|
||||
(defun spacemacs/helm-file-smart-do-search (&optional default-inputp)
|
||||
"Search in current file using `dotspacemacs-search-tools'.
|
||||
Search for a search tool in the order provided by `dotspacemacs-search-tools'
|
||||
If DEFAULT-INPUTP is non nil then the current region or symbol at point
|
||||
are used as default input."
|
||||
(interactive)
|
||||
(call-interactively
|
||||
(spacemacs//helm-do-search-find-tool "helm-file-do"
|
||||
dotspacemacs-search-tools
|
||||
default-inputp)))
|
||||
|
||||
(defun spacemacs/helm-file-smart-do-search-region-or-symbol ()
|
||||
"Search in current file using `dotspacemacs-search-tools' with
|
||||
default input.
|
||||
Search for a search tool in the order provided by `dotspacemacs-search-tools'."
|
||||
(interactive)
|
||||
(spacemacs/helm-file-smart-do-search t))
|
||||
|
||||
;; Search in files -----------------------------------------------------
|
||||
|
||||
(defun spacemacs/helm-files-do-ag (&optional dir)
|
||||
"Search in files with `ag' using a default input."
|
||||
(interactive)
|
||||
(helm-do-ag dir))
|
||||
|
||||
(defun spacemacs/helm-files-do-ag-region-or-symbol ()
|
||||
"Search in files with `ag' using a default input."
|
||||
(interactive)
|
||||
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-files-do-ag))
|
||||
|
||||
(defun spacemacs/helm-files-do-ack (&optional dir)
|
||||
"Search in files with `ack'."
|
||||
(interactive)
|
||||
(let ((helm-ag-base-command "ack --nocolor --nogroup"))
|
||||
(helm-do-ag dir)))
|
||||
|
||||
(defun spacemacs/helm-files-do-ack-region-or-symbol ()
|
||||
"Search in files with `ack' using a default input."
|
||||
(interactive)
|
||||
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-files-do-ack))
|
||||
|
||||
(defun spacemacs/helm-files-do-pt (&optional dir)
|
||||
"Search in files with `pt'."
|
||||
(interactive)
|
||||
(let ((helm-ag-base-command "pt -e --nocolor --nogroup"))
|
||||
(helm-do-ag dir)))
|
||||
|
||||
(defun spacemacs/helm-files-do-pt-region-or-symbol ()
|
||||
"Search in files with `pt' using a default input."
|
||||
(interactive)
|
||||
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-files-do-pt))
|
||||
|
||||
(defun spacemacs/helm-files-smart-do-search (&optional default-inputp)
|
||||
"Search in opened buffers using `dotspacemacs-search-tools'.
|
||||
Search for a search tool in the order provided by `dotspacemacs-search-tools'
|
||||
If DEFAULT-INPUTP is non nil then the current region or symbol at point
|
||||
are used as default input."
|
||||
(interactive)
|
||||
(call-interactively
|
||||
(spacemacs//helm-do-search-find-tool "helm-files-do"
|
||||
dotspacemacs-search-tools
|
||||
default-inputp)))
|
||||
|
||||
(defun spacemacs/helm-files-smart-do-search-region-or-symbol ()
|
||||
"Search in opened buffers using `dotspacemacs-search-tools'.
|
||||
with default input.
|
||||
Search for a search tool in the order provided by `dotspacemacs-search-tools'."
|
||||
(interactive)
|
||||
(spacemacs/helm-files-smart-do-search t))
|
||||
|
||||
;; Search in buffers ---------------------------------------------------
|
||||
|
||||
(defun spacemacs/helm-buffers-do-ag (&optional _)
|
||||
"Wrapper to execute `helm-ag-buffers.'"
|
||||
(interactive)
|
||||
(helm-do-ag-buffers))
|
||||
|
||||
(defun spacemacs/helm-buffers-do-ag-region-or-symbol ()
|
||||
"Search in opened buffers with `ag' with a default input."
|
||||
(interactive)
|
||||
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-buffers-do-ag))
|
||||
|
||||
(defun spacemacs/helm-buffers-do-ack (&optional _)
|
||||
"Search in opened buffers with `ack'."
|
||||
(interactive)
|
||||
(let ((helm-ag-base-command "ack --nocolor --nogroup"))
|
||||
(helm-do-ag-buffers)))
|
||||
|
||||
(defun spacemacs/helm-buffers-do-ack-region-or-symbol ()
|
||||
"Search in opened buffers with `ack' with a default input."
|
||||
(interactive)
|
||||
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-buffers-do-ack))
|
||||
|
||||
(defun spacemacs/helm-buffers-do-pt (&optional _)
|
||||
"Search in opened buffers with `pt'."
|
||||
(interactive)
|
||||
(let ((helm-ag-base-command "pt -e --nocolor --nogroup"))
|
||||
(helm-do-ag-buffers)))
|
||||
|
||||
(defun spacemacs/helm-buffers-do-pt-region-or-symbol ()
|
||||
"Search in opened buffers with `pt' using a default input."
|
||||
(interactive)
|
||||
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-buffers-do-pt))
|
||||
|
||||
(defun spacemacs/helm-buffers-smart-do-search (&optional default-inputp)
|
||||
"Search in opened buffers using `dotspacemacs-search-tools'.
|
||||
Search for a search tool in the order provided by `dotspacemacs-search-tools'
|
||||
If DEFAULT-INPUTP is non nil then the current region or symbol at point
|
||||
are used as default input."
|
||||
(interactive)
|
||||
(call-interactively
|
||||
(spacemacs//helm-do-search-find-tool "helm-buffers-do"
|
||||
dotspacemacs-search-tools
|
||||
default-inputp)))
|
||||
|
||||
(defun spacemacs/helm-buffers-smart-do-search-region-or-symbol ()
|
||||
"Search in opened buffers using `dotspacemacs-search-tools' with
|
||||
default input.
|
||||
Search for a search tool in the order provided by `dotspacemacs-search-tools'."
|
||||
(interactive)
|
||||
(spacemacs/helm-buffers-smart-do-search t))
|
||||
|
||||
;; Search in project ---------------------------------------------------
|
||||
|
||||
(defun spacemacs/helm-project-do-ag ()
|
||||
"Search in current project with `ag'."
|
||||
(interactive)
|
||||
(let ((dir (projectile-project-root)))
|
||||
(if dir
|
||||
(helm-do-ag dir)
|
||||
(message "error: Not in a project."))))
|
||||
|
||||
(defun spacemacs/helm-project-do-ag-region-or-symbol ()
|
||||
"Search in current project with `ag' using a default input."
|
||||
(interactive)
|
||||
(let ((dir (projectile-project-root)))
|
||||
(if dir
|
||||
(spacemacs//helm-do-ag-region-or-symbol 'helm-do-ag dir)
|
||||
(message "error: Not in a project."))))
|
||||
|
||||
(defun spacemacs/helm-project-do-ack ()
|
||||
"Search in current project with `ack'."
|
||||
(interactive)
|
||||
(let ((dir (projectile-project-root)))
|
||||
(if dir
|
||||
(spacemacs/helm-files-do-ack dir)
|
||||
(message "error: Not in a project."))))
|
||||
|
||||
(defun spacemacs/helm-project-do-ack-region-or-symbol ()
|
||||
"Search in current project with `ack' using a default input."
|
||||
(interactive)
|
||||
(let ((dir (projectile-project-root)))
|
||||
(if dir
|
||||
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-files-do-ack dir)
|
||||
(message "error: Not in a project."))))
|
||||
|
||||
(defun spacemacs/helm-project-do-pt ()
|
||||
"Search in current project with `pt'."
|
||||
(interactive)
|
||||
(let ((dir (projectile-project-root)))
|
||||
(if dir
|
||||
(spacemacs/helm-files-do-pt dir)
|
||||
(message "error: Not in a project."))))
|
||||
|
||||
(defun spacemacs/helm-project-do-pt-region-or-symbol ()
|
||||
"Search in current project with `pt' using a default input."
|
||||
(interactive)
|
||||
(let ((dir (projectile-project-root)))
|
||||
(if dir
|
||||
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-files-do-pt dir)
|
||||
(message "error: Not in a project."))))
|
||||
|
||||
(defun spacemacs/helm-project-smart-do-search (&optional default-inputp)
|
||||
"Search in current project using `dotspacemacs-search-tools'.
|
||||
Search for a search tool in the order provided by `dotspacemacs-search-tools'
|
||||
If DEFAULT-INPUTP is non nil then the current region or symbol at point
|
||||
are used as default input."
|
||||
(interactive)
|
||||
(let ((projectile-require-project-root nil))
|
||||
(call-interactively
|
||||
(spacemacs//helm-do-search-find-tool "helm-project-do"
|
||||
dotspacemacs-search-tools
|
||||
default-inputp))))
|
||||
|
||||
(defun spacemacs/helm-project-smart-do-search-region-or-symbol ()
|
||||
"Search in current project using `dotspacemacs-search-tools' with
|
||||
default input.
|
||||
Search for a search tool in the order provided by `dotspacemacs-search-tools'."
|
||||
(interactive)
|
||||
(spacemacs/helm-project-smart-do-search t))
|
||||
|
||||
;; This overrides the default C-s action in helm-projectile-switch-project
|
||||
;; to search using ag/pt/whatever instead of just grep
|
||||
(with-eval-after-load 'helm-projectile
|
||||
(defun spacemacs/helm-project-smart-do-search-in-dir (dir)
|
||||
(interactive)
|
||||
(let ((default-directory dir))
|
||||
(spacemacs/helm-project-smart-do-search)))
|
||||
(define-key helm-projectile-projects-map
|
||||
(kbd "C-s")
|
||||
(lambda ()
|
||||
(interactive)
|
||||
(helm-exit-and-execute-action 'spacemacs/helm-project-smart-do-search-in-dir))))
|
||||
|
||||
;; evilify the helm-grep buffer
|
||||
(evilified-state-evilify helm-grep-mode helm-grep-mode-map
|
||||
(kbd "RET") 'helm-grep-mode-jump-other-window
|
||||
(kbd "q") 'quit-window)
|
||||
|
||||
(spacemacs/set-leader-keys
|
||||
;; helm-ag marks
|
||||
"s`" 'helm-ag-pop-stack
|
||||
;; opened buffers scope
|
||||
"sb" 'spacemacs/helm-buffers-smart-do-search
|
||||
"sB" 'spacemacs/helm-buffers-smart-do-search-region-or-symbol
|
||||
"sab" 'helm-do-ag-buffers
|
||||
"saB" 'spacemacs/helm-buffers-do-ag-region-or-symbol
|
||||
"skb" 'spacemacs/helm-buffers-do-ack
|
||||
"skB" 'spacemacs/helm-buffers-do-ack-region-or-symbol
|
||||
"stb" 'spacemacs/helm-buffers-do-pt
|
||||
"stB" 'spacemacs/helm-buffers-do-pt-region-or-symbol
|
||||
;; current file scope
|
||||
"ss" 'spacemacs/helm-file-smart-do-search
|
||||
"sS" 'spacemacs/helm-file-smart-do-search-region-or-symbol
|
||||
"saa" 'helm-ag-this-file
|
||||
"saA" 'spacemacs/helm-file-do-ag-region-or-symbol
|
||||
;; files scope
|
||||
"sf" 'spacemacs/helm-files-smart-do-search
|
||||
"sF" 'spacemacs/helm-files-smart-do-search-region-or-symbol
|
||||
"saf" 'helm-do-ag
|
||||
"saF" 'spacemacs/helm-files-do-ag-region-or-symbol
|
||||
"skf" 'spacemacs/helm-files-do-ack
|
||||
"skF" 'spacemacs/helm-files-do-ack-region-or-symbol
|
||||
"stf" 'spacemacs/helm-files-do-pt
|
||||
"stF" 'spacemacs/helm-files-do-pt-region-or-symbol
|
||||
;; current project scope
|
||||
"/" 'spacemacs/helm-project-smart-do-search
|
||||
"*" 'spacemacs/helm-project-smart-do-search-region-or-symbol
|
||||
"sp" 'spacemacs/helm-project-smart-do-search
|
||||
"sP" 'spacemacs/helm-project-smart-do-search-region-or-symbol
|
||||
"sap" 'spacemacs/helm-project-do-ag
|
||||
"saP" 'spacemacs/helm-project-do-ag-region-or-symbol
|
||||
"skp" 'spacemacs/helm-project-do-ack
|
||||
"skP" 'spacemacs/helm-project-do-ack-region-or-symbol
|
||||
"stp" 'spacemacs/helm-project-do-pt
|
||||
"stP" 'spacemacs/helm-project-do-pt-region-or-symbol))
|
||||
:config
|
||||
(progn
|
||||
(evil-define-key 'normal helm-ag-map "SPC" spacemacs-default-map)
|
||||
(evilified-state-evilify helm-ag-mode helm-ag-mode-map
|
||||
(kbd "RET") 'helm-ag-mode-jump-other-window
|
||||
(kbd "q") 'quit-window))))
|
||||
|
||||
(defun spacemacs/init-helm-make ()
|
||||
(use-package helm-make
|
||||
:defer t
|
||||
:init
|
||||
(spacemacs/set-leader-keys
|
||||
"cc" 'helm-make-projectile
|
||||
"cm" 'helm-make)))
|
||||
|
||||
(defun spacemacs/init-helm-mode-manager ()
|
||||
(use-package helm-mode-manager
|
||||
:defer t
|
||||
:init
|
||||
(spacemacs/set-leader-keys
|
||||
"hM" 'helm-switch-major-mode
|
||||
;; "hm" 'helm-disable-minor-mode
|
||||
"h C-m" 'helm-enable-minor-mode)))
|
||||
|
||||
(defun spacemacs/init-helm-swoop ()
|
||||
(use-package helm-swoop
|
||||
:defer t
|
||||
:init
|
||||
(progn
|
||||
(setq helm-swoop-split-with-multiple-windows t
|
||||
helm-swoop-split-direction 'split-window-vertically
|
||||
helm-swoop-speed-or-color t
|
||||
helm-swoop-split-window-function 'helm-default-display-buffer
|
||||
helm-swoop-pre-input-function (lambda () ""))
|
||||
|
||||
(defun spacemacs/helm-swoop-region-or-symbol ()
|
||||
"Call `helm-swoop' with default input."
|
||||
(interactive)
|
||||
(let ((helm-swoop-pre-input-function
|
||||
(lambda ()
|
||||
(if (region-active-p)
|
||||
(buffer-substring-no-properties (region-beginning)
|
||||
(region-end))
|
||||
(let ((thing (thing-at-point 'symbol t)))
|
||||
(if thing thing ""))))))
|
||||
(call-interactively 'helm-swoop)))
|
||||
|
||||
(spacemacs/set-leader-keys
|
||||
"ss" 'helm-swoop
|
||||
"sS" 'spacemacs/helm-swoop-region-or-symbol
|
||||
"s C-s" 'helm-multi-swoop-all)
|
||||
(defadvice helm-swoop (before add-evil-jump activate)
|
||||
(when (configuration-layer/package-usedp 'evil-jumper)
|
||||
(evil-set-jump))))))
|
||||
|
||||
(defun spacemacs/init-helm-themes ()
|
||||
(use-package helm-themes
|
||||
:defer t
|
||||
:init
|
||||
(spacemacs/set-leader-keys
|
||||
"Th" 'helm-themes)))
|
||||
|
||||
(defun spacemacs/init-highlight-indentation ()
|
||||
(use-package highlight-indentation
|
||||
|
@ -1429,7 +1058,7 @@ Open junk file using helm, with `prefix-arg' search in junk files"
|
|||
(helm-ff-newfile-prompt-p nil)
|
||||
(default-directory junk-dir))
|
||||
(if arg
|
||||
(spacemacs/helm-files-smart-do-search)
|
||||
(spacemacs/helm-files-smart-do-search)
|
||||
(helm-find-files-1 fname))))
|
||||
(spacemacs/set-leader-keys "fJ" 'spacemacs/helm-open-junk-file)))
|
||||
|
||||
|
@ -1478,7 +1107,7 @@ Open junk file using helm, with `prefix-arg' search in junk files"
|
|||
:init
|
||||
(spacemacs|define-micro-state move-text
|
||||
:doc "[J] move down [K] move up"
|
||||
:use-minibuffer t
|
||||
:use-minibuffer t
|
||||
:execute-binding-on-enter t
|
||||
:evil-leader "xJ" "xK"
|
||||
:bindings
|
||||
|
@ -1966,3 +1595,4 @@ Open junk file using helm, with `prefix-arg' search in junk files"
|
|||
;; Font size, either with ctrl + mouse wheel
|
||||
(global-set-key (kbd "<C-wheel-up>") 'spacemacs/zoom-frm-in)
|
||||
(global-set-key (kbd "<C-wheel-down>") 'spacemacs/zoom-frm-out))))
|
||||
|
||||
|
|
Loading…
Reference in New Issue