-
-
Notifications
You must be signed in to change notification settings - Fork 339
Dont open directory mode
Oleh Krehel edited this page Nov 18, 2017
·
1 revision
When enable "Don't open directory" mode, ivy-mode will only open file and don't open directory. if user want to open dirctory, another key should typed, for example: "C-f". This mode is simple and predictable.
When the below code is an example:
- when type "enter", if current candidate is a directory, its subdir will be completed, if a file, open it.
- if user want to open directory, type "C-f".
(require 'swiper)
(ivy-mode 1)
(setq ivy-extra-directories nil)
(defun eh-ivy-open-current-typed-path ()
(interactive)
(when ivy--directory
(let* ((dir ivy--directory)
(text-typed ivy-text)
(path (concat dir text-typed)))
(delete-minibuffer-contents)
(ivy--done path))))
(define-key ivy-minibuffer-map (kbd "<return>") 'ivy-alt-done)
(define-key ivy-minibuffer-map (kbd "C-f") 'eh-ivy-open-current-typed-path)