cp-find-file-dwim: Add
This commit is contained in:
parent
842a105af4
commit
ab400743e6
2 changed files with 35 additions and 18 deletions
|
|
@ -68,9 +68,10 @@ Note that if you turn on projectile mode but not counsel-projectile mode, the co
|
|||
Replacements for existing commands:
|
||||
|
||||
| Key binding | Command | Description |
|
||||
| :------------------- | :------------------------------------ | :-------------------------- |
|
||||
| :------------------- | :------------------------------------ | :------------------------------------------------------- |
|
||||
| <kbd>C-c p p</kbd> | `counsel-projectile-switch-project` | Switch project |
|
||||
| <kbd>C-c p f</kbd> | `counsel-projectile-find-file` | Jump to a project file |
|
||||
| <kbd>C-c p g</kbd> | `counsel-projectile-find-file-dwim` | Jump to a project file using completion based on context |
|
||||
| <kbd>C-c p d</kbd> | `counsel-projectile-find-dir` | Jump to a project directory |
|
||||
| <kbd>C-c p b</kbd> | `counsel-projectile-switch-to-buffer` | Jump to a project buffer |
|
||||
| <kbd>C-c p s g</kbd> | `counsel-projectile-grep` | Search project with grep |
|
||||
|
|
@ -142,6 +143,10 @@ This command is a replacement for `projectile-find-file`. It displays a list of
|
|||
| <kbd>r</kbd> | Open file as root |
|
||||
| <kbd>m</kbd> | Find file manually: call `counsel-find-file` from file's directory |
|
||||
| <kbd>p</kbd> | Switch project: call `counsel-projectile-switch-project` (see above) |
|
||||
## The `counsel-projectile-find-file-dwim` command
|
||||
Default key binding: <kbd>C-c p g</kbd>.
|
||||
|
||||
This command is a replacement for `projectile-find-file-dwim`. It is similar to `counsel-projectile-find-file` except that the list of project files is restricted to those matching the filename at point, if any.
|
||||
## The `counsel-projectile-find-dir` command
|
||||
Default key binding: <kbd>C-c p d</kbd>.
|
||||
|
||||
|
|
|
|||
|
|
@ -368,24 +368,35 @@ on `counsel-find-file-ignore-regexp'."
|
|||
str))
|
||||
|
||||
;;;###autoload
|
||||
(defun counsel-projectile-find-file (&optional arg)
|
||||
(defun counsel-projectile-find-file (&optional arg dwim)
|
||||
"Jump to a file in the current project.
|
||||
|
||||
With a prefix ARG, invalidate the cache first."
|
||||
With a prefix ARG, invalidate the cache first. If DWIM is
|
||||
non-nil, use completion based on context."
|
||||
(interactive "P")
|
||||
(projectile-maybe-invalidate-cache arg)
|
||||
(let* ((project-files (projectile-current-project-files))
|
||||
(files (and dwim (projectile-select-files project-files))))
|
||||
(ivy-read (projectile-prepend-project-name "Find file: ")
|
||||
(projectile-current-project-files)
|
||||
(or files project-files)
|
||||
:matcher counsel-projectile-find-file-matcher
|
||||
:require-match t
|
||||
:sort counsel-projectile-sort-files
|
||||
:action counsel-projectile-find-file-action
|
||||
:caller 'counsel-projectile-find-file))
|
||||
:caller 'counsel-projectile-find-file)))
|
||||
|
||||
(ivy-set-display-transformer
|
||||
'counsel-projectile-find-file
|
||||
'counsel-projectile-find-file-transformer)
|
||||
|
||||
;;;###autoload
|
||||
(defun counsel-projectile-find-file-dwim (&optional arg)
|
||||
"Jump to a file in the current project using completion based on context.
|
||||
|
||||
With a prefix ARG, invalidate the cache first."
|
||||
(interactive "P")
|
||||
(counsel-projectile-find-file arg t))
|
||||
|
||||
;;;; counsel-projectile-find-dir
|
||||
|
||||
(defcustom counsel-projectile-sort-directories nil
|
||||
|
|
@ -1363,6 +1374,7 @@ If not inside a project, call `counsel-projectile-switch-project'."
|
|||
|
||||
(defcustom counsel-projectile-key-bindings
|
||||
'((projectile-find-file . counsel-projectile-find-file)
|
||||
(projectile-find-file-dwim . counsel-projectile-find-file-dwim)
|
||||
(projectile-find-dir . counsel-projectile-find-dir)
|
||||
(projectile-switch-to-buffer . counsel-projectile-switch-to-buffer)
|
||||
(projectile-grep . counsel-projectile-grep)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue