spacemacs/layers/+completion/ivy
Miciah Masters 322528ca8d spacemacs-layouts: Fix adding buffers to new persp
Delete the hook that commit 9fcf8c898d added
to persp-created-functions, and change spacemacs/ivy-spacemacs-layouts,
spacemacs/helm-perspectives, spacemacs/helm-persp-switch-project, and
spacemacs/ivy-persp-switch-project to achieve the intended goal of adding
the desired buffers after creating a new perspective.

Change spacemacs/helm-persp-switch-project and
spacemacs/ivy-persp-switch-project as follows: If the user selects a
project but then quits without selecting a file or buffer, the new
perspective is now immediately killed.  Otherwise, if the perspective did
not already exist, any buffers that belong to the selected project are
added to the perspective.

Add the following actions to spacemacs/ivy-spacemacs-layouts and
spacemacs/helm-perspectives:

* Create a new perspective with the Spacemacs home buffer (default action).
* Create a new perspective with the buffers that belong to the current
  buffer's project.
* Create a new perspective with the buffers that belong to the current
  perspective (i.e., make a copy of the current perspective).

This commit resolves the problem reported in
9fcf8c898d (commitcomment-33343455).

This commit also fixes a problem with the default action for
spacemacs/ivy-spacemacs-layouts and spacemacs/helm-perspectives.  According to
commit 7b931a9f5b, the default action is supposed
to display the home buffer if the action creates a new perspective, which was
determined by checking whether the perspective was missing from the list of
perspectives _before_ switching.  However, commit
eb7ca651fe changed this logic so it was checking
whether the perspective was missing from the list of perspectives _after_
switching.  This commit restores the correct logic.

* CHANGELOG.develop: Update.
* layers/+completion/ivy/funcs.el (spacemacs/ivy-spacemacs-layouts): Add
"Copy Current Layout" and "Create Project Layout" actions to the docstring.
Use spacemacs//create-persp-with-home-buffer for the default action.
* layers/+completion/ivy/packages.el (ivy/post-init-persp-mode): Add
actions for spacemacs//create-persp-with-current-project-buffers and
persp-copy.
* layers/+spacemacs/spacemacs-layouts/funcs.el
(spacemacs||switch-layout): New macro.  Switch to the named perspective,
and initialize it using the provided forms if the perspective is new.
(spacemacs//create-persp-with-current-project-buffers): New function.
Create a new perspective with the current project's buffers.
(spacemacs||switch-project-persp): New macro.  Switch to the named
perspective, and evaluate the provided forms with
projectile-after-switch-project-hook bound with a hook that adds the
current project's buffers to the perspective.  If the user quits during the
evaluation of the forms, kill the perspective.
(spacemacs//create-persp-with-home-buffer): New function.  Switch to the
named perspective, and go to the Spacemacs home buffer if the perspective
is new.
(spacemacs/helm-perspectives): Use spacemacs//create-persp-with-home-buffer
for the default action.  Add actions for
spacemacs//create-persp-with-current-project-buffers and persp-copy.
(spacemacs//helm-persp-switch-project-action): New function.  Switch to the
named perspective and call projectile-switch-project-by-name, using the new
spacemacs||switch-project-persp macro.  Bind helm-quit-hook with a hook
that kills the new perspective if the user quits
projectile-switch-project-by-name.
(spacemacs/helm-persp-switch-project): Use
spacemacs//helm-persp-switch-project-action.
(spacemacs//ivy-persp-switch-project-action): New function.  Switch to the
named perspective and call counsel-projectile-switch-project-action with a
hook to add the project's buffers to the new perspective.
(spacemacs/ivy-persp-switch-project): Delete advice for
counsel-projectile-switch-project-action.  Use
spacemacs//ivy-persp-switch-project-action instead.
(spacemacs//add-project-buffers-to-persp): Deleted.
* layers/+spacemacs/spacemacs-layouts/packages.el
(spacemacs-layouts/init-persp-mode): Don't add a hook to
persp-created-functions.
2019-05-13 17:11:27 +02:00
..
local/ivy-spacemacs-help
README.org Add more tags 2019-05-03 03:44:19 +03:00
config.el
funcs.el spacemacs-layouts: Fix adding buffers to new persp 2019-05-13 17:11:27 +02:00
layers.el
packages.el spacemacs-layouts: Fix adding buffers to new persp 2019-05-13 17:11:27 +02:00

README.org

Ivy layer

Description

This layer enables Ivy for completion. It will replace the default completion by Helm.

These completion systems are the central control towers of Spacemacs, they are used to manage buffers, projects, search results, configuration layers, toggles and more…

Mastering your choice of completion system will make you a Spacemacs power user.

Features:

  • Project wide grep like text search via search-auto
  • Project wide text replacements using counsel-imenu
  • Buffer wide dynamic text search via swiper
  • Detailed configuration parameters for ivy appearance
  • Intuitive transient state
  • Advanced buffer information with ivy-rich

Install

To use this configuration layer, add it to your ~/.spacemacs. You will need to add ivy to the existing dotspacemacs-configuration-layers list in this file.

Configuration

General

You can customize ivy with the following variables:

  • ivy-wrap Whether C-n and C-p should wrap-around when at the first or last candidate. The default value is nil.
  • ivy-extra-directories Setting this to nil hides . and .. directories from file name completion. You can still go up a directory up by DEL. The default value is (“../”, “./”).
  • ivy-use-virtual-buffers Add bookmarks and recent files to buffer completion menu. The Spacemacs default is t.
  • ivy-height The height of the minibuffer. The Spacemacs default is 15.
  • ivy-use-selectable-prompt When non-nil, make the prompt line selectable like a candidate. The Spacemacs default value is t.
  • ivy-re-builders-alist An alist of regex building functions for each collection function. See ivy documentation for possible choices. Use spacemacs/ivy--regex-plus instead of ivy--regex-plus to get correct highlighting in the search results of spacemacs/search-project-auto and similar search commands provided by Spacemacs.

Advanced buffer information

To display more information about buffers set the layer variable ivy-enable-advanced-buffer-information to t which will enable ivy-rich.

Note that ivy-rich has been reported to be very slow on macOS. This feature is disabled by default.

  (setq-default dotspacemacs-configuration-layers '(
    (ivy :variables ivy-enable-advanced-buffer-information t)))

Key bindings

If you choose ivy as completion system, make sure to read the official manual. In case you dont want to read everything, at least familiarise with minibuffer key bindings.

Some useful key bindings are presented in the following table.

Key binding Description
RET call default action on current candidate
M-RET the same as RET but doesnt close completion minibuffer
C-M-j use current input immediately (this can be used to create a new file in Find File)
tab complete partially
M-o show the list of valid actions on current candidate (then press any of described keys to execute it)
C-M-o the same as M-o but doesnt close completion minibuffer
C-' use avy to quickly select completion on current page (sometimes faster than using arrows)
<ESC> close minibuffer

Transient state

Press M-SPC anytime in Ivy to get into the transient state.

Key binding Description
j select next candidate
k select previous candidate
d call default action on candidate
g the same as d but doesnt close completion minibuffer
o leave transient state