Giter VIP home page Giter VIP logo

counsel-projectile's Introduction

MELPA MELPA Stable Github commits (since latest release)

Table of Contents

Description

Projectile has native support for using ivy as its completion system. Counsel-projectile provides further ivy integration into projectile by taking advantage of ivy's support for selecting from a list of actions and applying an action without leaving the completion session. Concretely, counsel-projectile defines replacements for existing projectile commands as well as new commands that have no projectile counterparts. A minor mode is also provided that adds key bindings for all these commands on top of the projectile key bindings.

News

  • [2019-01-27] New version 0.3. If you are upgrading from 0.2, please read here about breaking changes.
  • [2018-01-05] Package now available on MELPA Stable.
  • [2017-12-18] New version 0.2. If you are upgrading from 0.1, please read here about breaking changes.
  • [2016-04-12] First version 0.1.

Installation

Install the package from

Usage

Getting started

To turn on counsel-projectile mode, either call the command counsel-projectile-mode or use the Customize interface to toggle on the variable counsel-projectile-mode. This will turn on projectile mode, thus enabling all projectile key bindings, and add the counsel-projectile key bindings on top of them.

Note that starting with projectile version 1.1, the projectile (and counsel-projectile) key bindings are only available after you select a keymap prefix for them. For instance, to select C-c p as prefix (the default prior to version 1.1), you need to execute the following form:

(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)

The counsel-projectile key bindings either remap existing projectile commands to their counsel-projectile replacements (e.g. C-c p f now calls counsel-projectile-find-file instead of projectile-find-file) or bind keys to counsel-projectile commands that have no projectile counterparts (e.g. C-c p SPC calls the command counsel-projectile).

Calling the command counsel-projectile-mode once again or toggling off the variable counsel-projectile-mode disables the counsel-projectile key bindings and turns off projectile mode.

Note that if you turn on projectile mode but not counsel-projectile mode, the counsel-projectile commands can still be called with M-x, only the key bindings for these commands are not enabled.

Summary of interactive commands

Replacements for existing commands:

Key binding Command Description
C-c p p counsel-projectile-switch-project Switch project
C-c p f counsel-projectile-find-file Jump to a project file
C-c p g counsel-projectile-find-file-dwim Jump to a project file using completion based on context
C-c p d counsel-projectile-find-dir Jump to a project directory
C-c p b counsel-projectile-switch-to-buffer Jump to a project buffer
C-c p s g counsel-projectile-grep Search project with grep
C-c p s s counsel-projectile-ag Search project with ag
C-c p s r counsel-projectile-rg Search project with rg

New commands:

Key binding Command Description
C-c p SPC counsel-projectile Jump to a project buffer or file, or switch project
C-c p s i counsel-projectile-git-grep Search project with git grep
C-c p O c counsel-projectile-org-capture Capture into project
C-c p O a counsel-projectile-org-agenda Open project agenda

The counsel-projectile command

Default key binding: C-c p SPC.

This command lets you quickly jump to a project buffer or file. It uses ivy to display in the minibuffer a list of all project buffers as well as all project files that are not currently visited by a buffer. Buffers are fontified according to their major mode and files are fontified as virtual buffers, as in the command ivy-switch-buffer. As in all ivy commands, you can use M-o / C-M-o + key to select from a list of actions to apply (or M-RET / C-M-RET to apply the default action) to the selected candidate:

Key Action
o Open buffer or file in current window (default action)
j Open buffer or file in other window
k Kill buffer or delete file
x Open file externally (does nothing for buffers)
r Open file as root (does nothing for buffers)
m Find file manually: call counsel-find-file from buffer or file's directory
p Switch project: call counsel-projectile-switch-project (see below)

The key binding C-c C-k can also be used from the minibuffer to kill the buffer corresponding to the current candidate (same as C-M-o k).

If not called inside a project, counsel-projectile first offers to select a project to switch to by calling counsel-projectile-switch-project (see below). Once you select a project and hit RET, it lets you jump to a buffer or file in this project as described above.

The counsel-projectile-switch-project command

Default key binding: C-c p p.

This command is a replacement for projectile-switch-project. It adds the possibility to select from a list of switch-project actions to apply to the selected project:

Key Action
o Jump to a project buffer or file: call counsel-projectile (default action; see above)
f Jump to a project file: call counsel-projectile-find-file (see below)
d Jump to a project directory: call counsel-projectile-find-dir (see below)
D Open project in dired
b Jump to a project buffer: call counsel-projectile-switch-to-buffer (see below)
m Find file manually: call counsel-find-file from the project root
S Save all project buffers
k Kill all project buffers
K Remove project from the list of known projects
c Run project compilation command
C Run project configure command
E Edit project directory-local variables
v Open project in vc-dir / magit / monky
s g Search project with grep: call counsel-projectile-grep (see below)
s i Search project with git grep: call counsel-projectile-git-grep (see below)
s s Search project with ag: call counsel-projectile-ag (see below)
s r Search project with rg: call counsel-projectile-rg (see below)
x s Invoke shell from the project root
x e Invoke eshell from the project root
x t Invoke term from the project root
x v Invoke vterm from the project root
O c Capture into project: call counsel-projectile-org-capture (see below)
O a Open project agenda: call counsel-projectile-org-agenda (see below)

The counsel-projectile-find-file command

Default key binding: C-c p f.

This command is a replacement for projectile-find-file. It displays a list of all project files and offers several actions:

Key Action
o Open file in current window (default action)
j Open file in other window
x Open file externally
r Open file as root
m Find file manually: call counsel-find-file from file's directory
k Delete file
p Switch project: call counsel-projectile-switch-project (see above)

The counsel-projectile-find-file-dwim command

Default key binding: C-c p g.

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: C-c p d.

This command is a replacement for projectile-find-dir. It displays a list of all project directories and offers several actions:

Key Action
o Open directory with dired in current window (default action)
j Open directory with dired in other window
x Open directory externally
r Open directory as root
m Find file manually: call counsel-find-file from directory
p Switch project: call counsel-projectile-switch-project (see above)

The counsel-projectile-switch-to-buffer command

Default key binding: C-c p b.

This command is a replacement for projectile-switch-to-buffer. It displays a list of all project buffers and offers several actions:

Key Action
o Open buffer in current window (default action)
j Open buffer in other window
k Kill buffer
m Find file manually: call counsel-find-file from buffer's directory
p Switch project: call counsel-projectile-switch-project (see above)

The key binding C-c C-k can also be used from the minibuffer to kill the buffer corresponding to the current candidate (same as C-M-o k).

The counsel-projectile-grep command

Default key binding: C-c p s g.

This command is a replacement for projectile-grep. It searches all project files with grep, taking advantage of ivy's support for updating the list of candidates after each input (dynamic collections). Each candidate corresponds to a matching line in some project file, and the following actions are offered:

Key Action
o Jump to the candidate file and line
p Switch project: call counsel-projectile-switch-project (see above)

If inside a git project and the variable projectile-use-git-grep is non-nil, then counsel-projectile-grep uses git grep instead of grep, by calling the function counsel-projectile-git-grep (see below).

The counsel-projectile-git-grep command

Default key binding: C-c p s i.

This command is similar to counsel-projectile-grep (see above) but uses git grep instead of grep (hence it only works in git projects).

The counsel-projectile-ag command

Default key binding: C-c p s s.

This command is a replacement for projectile-ag. It is similar to counsel-projectile-grep (see above) but uses ag (the silver searcher) instead of grep.

The counsel-projectile-rg command

Default key binding: C-c p s r.

This command is a replacement for projectile-ripgrep. It is similar to counsel-projectile-grep (see above) but uses rg (ripgrep) instead of grep.

The counsel-projectile-org-capture command

Default key binding: C-c p O c.

This command is a replacement for org-capture (or counsel-org-capture) offering project-specific capture templates, in addition to the regular templates available from org-capture. By default, there is a single project template, named [<project-name>] Tasks, which stores the captured information under headline Tasks in file <project-root>/notes.org.

If not inside a project, the project templates are ignored and only the regular ones are offered. So you may want to systematically use counsel-projectile-org-capture isntead of org-capture or counsel-org-capture (you may also want to give it a global key binding, such as C-c c).

The following actions are offered:

Key Action
o Capture
t Go to target
l Go to last stored
p Insert template at point
c Customize org-capture-templates
P Switch project: call counsel-projectile-switch-project (see above)

The counsel-projectile-org-agenda command

Default key binding: C-c p O a.

This command opens the current project's agenda. It simply calls org-agenda after filtering out all agenda files that do not belong to the current project.

Configuration

Enabling counsel-projectile mode when emacs starts

To automatically enable counsel-projectile mode when emacs starts, you can either use the Customize interface to toggle on the variable counsel-projectile-mode and save your customization, or add (counsel-projectile-mode) to your init file.

Note that starting with projectile version 1.1, the projectile (and counsel-projectile) key bindings are only available after you select a keymap prefix for them. For instance, to select C-c p as prefix (the default prior to version 1.1), you need to add the following form to your init file:

(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)

Customizing counsel-projectile key bindings

The key bindings that are added when counsel-projectile-mode is turned on are determined by the variable counsel-projectile-key-bindings. You can set this variable, either directly or through the customize interface, to customize these key bindings. It holds an alist of (KEY . DEF) pairs, where KEY is either a key sequence to bind in projectile-command-map or a projectile command to remap in projectile-mode-map, and DEF is the counsel-projectile command to which KEY is remapped or bound.

Customizing action lists

The lists of available actions (including the default action) for most of the commands above are stored in custom variables. If you set one of these variables, either directly or through the through the Customize interface, the new value will be picked up the next time you invoke the corresponding command.

The variable holding the action list for <command> is named <command>-action. The following action list variables are defined:

  • counsel-projectile-action
  • counsel-projectile-switch-project-action
  • counsel-projectile-find-file-action
  • counsel-projectile-find-dir-action
  • counsel-projectile-switch-to-buffer-action
  • counsel-projectile-grep-action

For instance, the default value of counsel-projectile-action is:

'(1
  ("o" counsel-projectile-action
   "current window")
  ("j" counsel-projectile-action-other-window
   "other window")
  ("x" counsel-projectile-action-file-extern
   "open file externally")
  ("r" counsel-projectile-action-file-root
   "open file as root")
  ("m" counsel-projectile-action-find-file-manually
   "find file manually")
  ("p" (lambda (_) (counsel-projectile-switch-project))
   "switch project"))

The first element is the index of the default action, and the remainig ones are the available actions (a key, an action function, and a name for each action). Thus the default action in this list is the first one (o key).

Extra actions can be added to these lists or, alternatively, can be set through ivy's ivy-set-actions mechanism. If you prefer setting all actions (except the default one) through this mechanism, you can set the action list variable to a single action (e.g. counsel-projectile-action) instead of a list. If you are not using the Customize interface and want to amend the value of one of these lists rather than setting it from scratch, you can use the function counsel-projectile-modify-action, which lets you easily:

  • add, remove, or move an action,
  • change an action key, function, or name,
  • change the index of the default action.

See its docstring for details.

The mechanism to customize action lists is slightly different for some commands that internally rely on built-in ivy commands and hence inherit these command's actions. For these commands, a variable <command>-extra-actions is defined:

  • counsel-projectile-git-grep-extra-actions
  • counsel-projectile-ag-extra-actions
  • counsel-projectile-rg-extra-actions
  • counsel-projectile-org-capture-extra-actions

These variable have the same format as above without the initial index. You can also modify the built-in command's action through ivy's ivy-set-actions mechanism.

Setting counsel-projectile-org-capture templates

The project-specific capture templates for counsel-projectile-org-capture are read from the variable counsel-projectile-org-capture-templates. This variable has the same format as the variable org-capture-templates, except that in a template's name or target, the placeholders ${root} and ${name} can be used to stand for the current project root and name, respectively.

The default value contains a single template, whose name is [${name}] Task and whose target is:

(file+headline "${root}/notes.org}" "Tasks")

This points to headline Tasks in file notes.org in the project root directory (one file per project).

Two other examples of valid targets are:

(file+headline "${root}/${name}.org}" "Tasks")
(file+olp "~/notes.org" "${root}" "Tasks")

The first one is similar to the default value's target, except that the file is named after the project name (this can be handy if you use org-mode's agenda since the project name is then displayed as category). The second one points to outline path <project-root>/Tasks in file ~/notes.org (same file for all projects).

Project-specific template contexts are read from the variable counsel-projectile-org-capture-templates-contexts, which has the same format as org-capture-templates-contexts

Removing the current project or buffer from the list of candidates

By default, when calling counsel-projectile-switch-project, the current project (if any) is included in the candidates list and preselected. Similarly, when calling counsel-projectile-switch-to-buffer, the current buffer is included in the candidates list and preselected. If you prefer removing these elements from the candidate lists of these commands, you can set the variables counsel-projectile-remove-current-project and counsel-projectile-remove-current-buffer accordingly.

Initial input for the project search commands

If you want some initial input to be inserted in the minibuffer every time you call counsel-projectile-grep, counsel-projectile-ag, or counsel-projectile-rg, you can customize the variables counsel-projectile-grep-initial-input, counsel-projectile-ag-initial-input, or counsel-projectile-rg-initial-input accordingly. Each of these variable, if non nil, should hold a Lisp expression whose evaluation yields the initial input string. If you use the Customize interface, some choices are proposed based on various versions of the thing-at-point function. Note that you can always insert the value of (ivy-thing-at-point) by hitting M-n in the minibuffer.

Matcher for counsel-projectile-find-file

By default, the command counsel-projectile-find-file relies on the the matcher of the command counsel-find-file to display files matching minibuffer input, allowing to ignore some files based on the variable counsel-find-file-ignore-regexp. It is possible to use another matcher by setting the variable counsel-projectile-find-file-matcher. Some choices are proposed if you use the Customize interface, in particular the counsel-projectile-find-file-matcher-basename matcher which is provided by counsel-projectile and only displays files whose basename matches the minibuffer input (if there is none, it shows all matching files).

Independently of the chosen matcher, it is possible to specifying a minimum number of characters to input before the matching project files are shown through the variable counsel-projectile-find-file-more-chars. The default value is 0, but a strictly positive value can improve performance in large projects.

The values of counsel-projectile-find-file-matcher and counsel-projectile-find-file-more-chars are also used by counsel-projectile to match files.

Sorting candidates

The following commands allow to modify the way candidates are sorted:

  • counsel-projectile-switch-project
  • counsel-projectile-find-file
  • counsel-projectile-find-dir
  • counsel-projectile-switch-to-buffer

Sorting for these commands is controlled by the following variables, respectively:

  • counsel-projectile-sort-projects
  • counsel-projectile-sort-files
  • counsel-projectile-sort-directories
  • counsel-projectile-sort-buffers

If one of these variable is nil, the default, the command's candidates are not sorted. If it is non-nil, they are sorted. The sorting criterion can be customized through the variable ivy-sort-functions-alist. For instance, if you want files to be sorted from newest to oldest, then you need to add the following entry to this list:

'(counsel-projectile-find-file . file-newer-than-file-p)

Note that the counsel-projectile command always sorts buffers before files. Buffers are sorted as in counsel-projectile-switch-to-buffer and files are sorted according to counsel-projectile-find-file.

Preview in counsel-projectile-switch-to-buffer and counsel-projectile

If the variable counsel-projectile-preview-buffers is non-nil, counsel-projectile-switch-to-buffer and counsel-projectile display a preview of the selected buffer in the current window. This makes these commands behave similarly to counsel-switch-buffer. If counsel-switch-buffer-preview-virtual-buffers is also non-nil, counsel-projectile also displays a preview of the selected non-visited file.

Upgrading

Breaking changes in version 0.3

Key bindings

The keymaps counsel-projectile-mode-map and counsel-projectile-command-map no longer exist. The counsel-projectile key bindings are now determined by the variable counsel-projectile-key-bindings, which see, and added directly to the native projectile keymaps (projectile-mode-map and projectile-command-map).

Breaking changes in version 0.2

Key bindings

The commands counsel-projectile-on, counsel-projectile-off and counsel-projectile-toggle no longer exist. They are replaced with the counsel-projectile minor mode. You can toggle this mode either by calling the counsel-projectile-mode command. or by setting the counsel-projectile-mode variable throught the Customize interface.

Action lists

The available actions for the various counsel-projectile commands are now customized differently:

  • The custom variable corresponding to <command> is now named <command-action> instead of <command-actions>.
  • This variable now stores all the available actions, including the default action, not only the extra actions.
  • It also stores the index of the default action (it is a list whose first element is this index and whose remaining elements are the available actions).
  • This variable is now used as the value of the :action parameter for the command's ivy-read call. Hence if you set it outside the Customize interface, you no longer need to call ivy-set-actions afterwards. If you set extra actions through ivy-set-actions, they will not replace the variable's actions but will be added to them.

Also, in the default action lists, the keys set for some actions have changed, mainly for the counsel-projectile-switch-project command. Indeed, as new actions were added to this command, the corresponding list of keys was becoming somewhat inconsistent. The new keys replicate the default projectile key bindings (for instance, the action to save all project buffers is now called with the key S, mimicking the default key binding C-c p S for the command projectile-save-project-buffers). When an action calls a command that has no default projectile key binding, its key is chosen among those that are not bound by projectile by default.

Minibuffer keymap

The minibuffer keymap counsel-projectile-map no longer exists. It was only used to bind a key (M-SPC by default) to the command counsel-projectile-drop-to-switch-project exiting the current command and calling counsel-projectile-switch-project. The same functionality is now implemented in a simpler way through an action that calls counsel-projectile-switch-project, whose key is p by default. Concretely, you should now hit M-o p instead of M-SP.

Contributors

Counsel-projectile is inspired by helm-projectile. Many thanks to abo-abo and DamienCassou who encouraged and helped me to start this repository, as well as all contributors and users who have submitted issues and pull requests.

counsel-projectile's People

Contributors

abo-abo avatar ambihelical avatar basil-conto avatar bbigras avatar benide avatar bluewww avatar ctechols avatar damiencassou avatar deadb17 avatar dsdshcym avatar ericdanan avatar kguidonimartins avatar lafrenierejm avatar leungbk avatar manuel-uberti avatar pinetr2e avatar raxod502 avatar rgrinberg avatar seudut avatar syohex avatar tummychow avatar wmedrano avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

counsel-projectile's Issues

Perhaps tag a stable release?

There haven't been any updates in a couple of months---if the project is stable, perhaps you could tag a release so melpa-stable will pick it up.

counsel-projectile-ag shows no results for some projects

counsel-projectile-ag always displays No matches found, regardless of what I search, in some projects. Running counsel-ag from the project root finds the correct results for the same searches. In other projects, counsel-projectile-ag works as expected. Whether it works or not seems to depend on what kind of project I'm in. I've only tested with a few different projects:

  • A Gradle project using Git works
  • A Maven project using Git works
  • A generic project using Git works
  • A Haskell Stack project with no vcs doesn't work
  • A generic project with no vcs doesn't work

It seems to be related to the vcs. From looking at the code, it seems that the --ignore options are only used when the vcs is not Git, which makes me think that there might be a problem with that ...

Now that I look at it further, it seems that the arguments to the --ignore options aren't being escaped properly. counsel-ag uses shell-command-to-string to run the ag command, which appears to feed the command through the default shell, which will prematurely expand wildcards before they reach ag. This would cause some files to show up in the results when they aren't supposed to ... but, it seems like one of the patterns in grep-find-ignored-files, which you use to build the --ignore options, is .#*, which matches the correct files in bash, but in my zsh it expands to all files in the current directory. So that would explain why I'm not getting any results ...

So, it seems that this ignore list should be properly escaped, using shell-quote-argument on each element, or something like that.

Retain search results pointer after ivy-resume

After clicking on one of the search results for counsel-projectile-rg, if I want to go back to search results with ivy-resume it starts from the very beginning of the list. It does not continue from the point I selected one of the results. Is there a way to remember that point in the search buffer?

Fails package-lint

If I load counsel-projectile.el and run package-lint-current-buffer, I get the following errors:

502:33: error: You should depend on (emacs "24.4") if you need `string-remove-prefix'.
264:37: error: You should depend on (emacs "24.4") if you need `string-remove-prefix'.
831:41: error: You should depend on (emacs "24") if you need `pcase'.
262:31: error: You should depend on (emacs "24") if you need `string-prefix-p'.
192:7: error: You should depend on (emacs "24") if you need `pcase'.
9:24: error: Package counsel is not installable.
9:43: error: Package projectile is not installable.
1:1: error: package.el cannot parse this buffer: Package lacks a file header

Obviously the one about packages not being installable is specific to my environment, but the others aren't.

It would appear the last item is simply the lack of a third ; on the first line, which means that it doesn't actually match the package.el specification.

counsel-projectile-rg not respecting .projectile file

I am using ripgrep using counsel-projectile-rg routine.
However, I see ag respecting .projectile (I have the directories I want to include in the search) but ripgrep does not, it searches in all the files.

What is the issue?

Pressing Enter on a counsel-projectile-ag result appends path to the current file

This issue suddenly popped up, I don't know what I upgraded. I am already using (counsel-projectile-mode) instead of the older command.

When I search for a word in my project (using counsel-projectile-ag) from a project file project/apps/foo/lib/foo.ex and get matching results like:

- apps/bar/lib/bar.ex:6 - ...
- ...

If I select apps/bar/lib/bar.ex and press Enter, I am taken to a missing file project/apps/foo/lib/apps/bar/lib/bar.ex instead of project/apps/bar/lib/bar.ex. This was not the behaviour before.

How can I debug this further?

Support for grep/counsel-git-grep

git grep is a fast and convenient search tool that comes with git. This package implements similar functionality to counsel-git and counsel-ag consistently, but it's missing projectile support to mirror counsel-git-grep. It would be nice if we could add (or replace) a projectile command to support git grepping through projects instead of using counsel directly. Note that projectile has a built in projectile-grep command, which supports git grep if you enable projectile-use-git-grep (but it unfortunately doesn't use counsel as its completing-read-function either way).

counsel-projectile-switch-project doesn't open same named files from other projects.

I have an issue switching between projects that have common filename like README, CHANGELOG, etc. The problem is that once I have a file called README.md open in any project I will always go back to this buffer when I try to open any other README.md in another project.

For example I have 2 projects foo and bar. Both have a README.md file at their root. After I start emacs I first open foo:README.md. When I then use counsel-projectile-switch-project to open bar:README.md I will stay in the foo:README.md buffer.

This is annoying for me because I usually interact with a git-repository with magit and when I do some routine fetching and updating from collaborator projects/branches I open the README of the project and then start magit.

Support ag's `--path-to-ignore` flag

There's current support for including the .gitignore, but there are many files in my companies git projects I would like to ignore that are checked into github. One the command line, I use --path-to-ignore to skip these files when I use ag, and I would like to be able to use that here too. Right now, I'm just manually editing the counsel-projectile.el to be:

             (options
              (concat options " "
                      (mapconcat (lambda (i)
                                   (concat "--ignore " (shell-quote-argument i)))
                                 ignored
                                 " ")
                      " --path-to-ignore ~/.agignore ")))

However, this is overwritten each time I upgrade to the latest version.

Insert a default search symbol for counsel-projectile-rg

counsel-projectile-rg is my main function for search since it is much faster than ag.
But I am envy of projectile-ag for having a default search (for symbol at point), also helm has this feature.

Is it possible to add this enhancement?

projectile-switch-project-action cannot be resumed

If I use counsel-projectile-switch-project, select a project with any action that opens another ivy buffer (for example, counsel-projectile-find-file), and select a file, I should be able to get back to the file listing using ivy-resume. Instead, the minibuffer just says Selecting deleted buffer.

counsel-projectile--file-list very slow with large project

I have a large project (A non-public project) with about 420K files. I noticed that counsel-projectile-find-file was quite slow, taking about 15s to show the list of files, so I experimented. I replaced counsel-projectile--file-list with projectile-current-project-files and somewhat surprisingly, the list of files appears almost instantly.
The drawback of course is the extra functionality added by counsel-projectile--file-list is not present, but it actually makes the package usable for larger projects. Maybe counsel-projectile--file-list can gracefully degrade for large projects? I'm not sure what would be a good solution, but it is an issue.

Here is my modified function:

;; version of counsel-projectile-find-file which uses
;; projectile-current-project-files instead of the fontified
;; counsel-projectile--file-list
;; To see if performance is better
(defun me:counsel-projectile-find-file (&optional arg)
  (interactive "P")
  (projectile-maybe-invalidate-cache arg)
  (ivy-read (projectile-prepend-project-name "Find file: ")
            (projectile-current-project-files)
            :matcher #'counsel--find-file-matcher
            :require-match t
            :keymap counsel-projectile-map
            :action #'counsel-projectile--find-file-action
            :caller 'counsel-projectile-find-file))

Current project is removed instead of selected project

m-x counsel-projectile-switch-project m-o r removes the current project
from projectile-known-projects instead of the selected one.

The expected behaviour is for the action to operate on the selection, which is
the case for the rest of the actions.

Proposed fix: #33

How to use counsel-projectile?

Hello,

I'm in the process of switching from helm to ivy. I used helm-projectile like that:

(use-package helm-projectile
  :ensure t
  :config (progn
    (helm-projectile-on)))

Here it seems there is no such thing as (helm-projectile-on).

Do I manually need to set all keybindings to functions that replace projectile function with ivy enhanced ones?

counsel-projectile-grep with error code 2

I am using counsel-projectile in macOS, sometimes the counsel-projectile-grep results with
error code 2, but the original projectile-grep can be used. I think this may be a bug of counsel-projectile-grep.

Current file appears after switching projects

Say I've got a project foo with files foo-a, foo-b, foo-c, and a project bar with files bar-a, bar-b, bar-c, and say I'm currently editing file foo-a. When I press C-c p SPC I see:

foo-a
foo-b
foo-c

Then when I press M-SPC I see:

foo
bar

Now let's say I select bar. What I expect to see next is:

bar-a
bar-b
bar-c

But what I actually see is:

foo-a
bar-a
bar-b
bar-c

In other words, when I am selecting a file in another project, the current file is always shown at the top of the list, even if it is not part of that project!

My best guess for why this happens is:

  • the default action after switching projects is counsel-projectile, so
  • not only files but also buffers for the new project are shown, but
  • as soon as the new project is selected, the "current project" is changed, so
  • the current buffer suddenly looks like it belongs to the new project, and
  • it gets shown in the list.

I can reproduce this with emacs -Q loading just counsel-projectile and its dependencies.

issues with ag searches

if I use projectiles-ag and search, I get a bunch of results
if I use counsel-projectile, I'm not getting any results. I hit enter and nothing...

I'm on windows 64 using the emacs64 build on chocolatey.
Let me know what I can provide to help.

Add version requirements

I guess you have to specify minimum versions for counsel and projectile in:

;; Package-Requires: ((counsel) (projectile))

Thing at point support

I need to use some functions with thing at point implementation, but it requires changes of this function signature (add optional initial-input argument, for example).
Can I do this?
If this is ok I'll try to make pull request with this changes and at-point functions.

Problem on projectile-mode-hook

On recent change the counsel-projectile-on is replaced by counsel-projectile-mode. I enable counsel-projectile on projectile-mode-hook before, so the first thing I did after upgrade is using counsel-projectile-mode in the hook, but actually this will cause nesting exceeds max-lisp-eval-depth error. I think maybe it's worth to mention in README that counsel-projectile-mode will call projectile-mode automatically.

Change default binding for counsel-projectile-switch-project

Hello, I'm an mac user and I use alfred as a my default launcher which is bound to M-SPC. Maybe you could change the default key binding for counsel-projectile-switch-project which is bound to M-SPC when in ivy-minibuffer for counsel-projectile?
I wouldn't want to change the default key for alfred as its too ingrained in my muscle memory.

ps. I'm not sure how i can change the key bindings when only in counsel-projectile.
I know I can do this

:map ivy-minibuffer-map
(("C-c C-p" . counsel-projectile-switch-project))

But this would add it to ivy and not counsel-projectile. But I see there is a counsel-projectile-map. I tried to do this :-

:map counsel-projectile-map
(("C-c C-p" . counsel-projectile-switch-project))

But this doesnt seem to work.

show list of projects instead of showing you are not in a project for counsel-projectile-find-file

Hi,

First of all, thanks for making this. I switched from helm-projectile to counsel-projectile.

I usually press C-c p f for counsel-projectile-find-file as soon as i run emacs. Most of the time, the path where i run emacs won't be a project, so i would want counsel-projectile to show list of projects (run counsel-projectile-switch-project) when counsel-projectile-find-file is invoked and currently if we are not inside a project. Instead of showing "you are not in a project", which i think is not useful because i need to run counsel-projectile-switch-project manually. How do i automate this behaviour?

Thanks,
Hari

Performance

I'm working with a project of some 30K files. projectile-use-cache is t. With helm, find file starts almost instantly. With counsel, it takes like 2-3 seconds. Is it expected that the performance is that much worse?

Allow to enter counsel-projectile-switch-project from counsel-projectile-find-files

I sometimes end up in counsel-projectile-find-file in the wrong project, either because:

  • I was in the wrong buffer.
  • A buffer outside all projects became associated with a project for some reason.

It would be nice that when listing files in a project, it was possible to press M-o, a binding (let's say p) to switch projects instead. The current way is to enter C-g C-p p SPC (abort, enter counsel-projectile-switch-project). The proposed solution would be to simply run M-o p.

Thanks!

Hide files in counsel-projectile-find-file

Hello,

I stumbled upon counsel-find-file-ignore-regexp today in this discussion. Is it possible to get similar functionality for counsel-projectile-find-file where I can ignore some files like dot files or files beginning with # or ~ by setting an ignore-regexp for counsel-projectile-find-file

Change default action of counsel-projectile-switch-project

I used to

(setq projectile-switch-project-action #'projectile-vc)

to start Magit after selecting a project in projectile. This doesn't seem to work anymore. Instead, I came up with the following workaround:

(setcar
     counsel-projectile-switch-project-action
     (1+ (cl-position #'counsel-projectile-switch-project-action-vc
                      (cdr counsel-projectile-switch-project-action)
                      :key #'cadr)))

Is that the recommend way? Is there anything simpler?

add a counsel-projectile-ag function.

It would be nice to have function to also search with ag with the projectile-ag binding C-c p s s. Something like this

(defun counsel-projectile-ag (&optional options)
  (interactive "P")
  (counsel-ag "" (projectile-project-root) ))

This works calling it with M-x but not when I bind it with (define-key projectile-command-map [remap projectile-ag] #'counsel-projectile-ag). I don't have a lot of elisp experience so I don't know what the problem is.

Also this is a great package. It makes switching from helm a lot easier

projectile-switch-project-hook not called

Seems like the projectile-switch-project-hook doesn't get called when switching to project or when opening a file in a specific project.
Does this package handle this?

How to add projectile-run-term action?

I've tried adding this as an action, but projectile-run-term

("t" (lambda (dir)
              (let ((projectile-switch-project-action 'projectile-run-term))
                (projectile-switch-project-by-name dir arg)))
        "start term for project")

But projectile-run-term expects another arg (the term program to run), and I'm not sure how to give it this arg.

Error in defhydra ivy-read-action: (Key sequence s g starts with non-prefix key s)

When I press C-c p p to launch counsel-projectile-switch-project followed by M-o to select the action I’m presented with the error message in the issue title:

Error in defhydra ivy-read-action: (Key sequence s g starts with non-prefix key s) 

This is a regression that has been introduced in 2fc8dca. I’m using counsel-0.10.0 and ivy-0.10.0. (I don’t have time to test the master branches of those right now).

Make ivy-set-actions customizable

Currently, if I don't like the value passed to ivy-set-actions for counsel-projectile-switch-project, my only future-proof option for overriding it is forking counsel-projectile. Perhaps we could have a customizable alist that affected the generation of the data structure passed to ivy-set-action.

Keep a binding for projectile-ag?

Hi,

From time to time I still like to use projectile-ag without counsel. For example when I want to use wgrep 😉
Would it be possible to remap projectile-ag to s S (for instance) so it can still be used?

Thanks!

counsel-projectile-ag not working

Hello,

I am trying to execute counsel-projectile-ag but while typing nothing happens and it is stuck at reporting 1 char more while i've typed a bunch of characters.

Please advise

Switching project broken after update.

After a recent update, switching project fails with either "You're not in a project" or a buffer being created for a non-existing file.

Steps to reproduce

From emacs -Q, eval:

(require 'package)
(package-initialize)

(require 'projectile)
(require 'counsel-projectile)
(projectile-global-mode)
(counsel-projectile-on)

C-c p p, pick a project, pick a file.
Result:

  • If the current buffer (the one in which you typed C-c p p) is in a project: a new buffer gets created for a non existing path in current project, but with the path and name of the file you've tried to open. Eg, if you try the step above from ~/Code/ProjectA/somefile.c and try to open ~/Code/ProjectB/src/SomeOtherFile.hs, the new buffer is for the file ~/Code/ProjectA/src/SomeOtherFile.hs. If the base path doesn't exist, you get the usual type M-x make-directory etc message.
  • Otherwise: an error message "You're not in a project" appears and nothing happens.

Attempted solutions

I tried to

  • delete Projectile cache and bookmarks.
  • delete .emacs.d/elpa and reinstall everything.

Without success.

Configuration

Debian Stretch x86_64, Emacs 24.5.1 from official repositories, all packages from Melpa.

The bug cannot be reproduced in the same machine with Emacs 25 from official repositories, all packages (by order of priority) from: Melpa Stable, then Gnu, then Melpa.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.