1

I'm using Ivy in a fairly standard Spacemacs setup.

When I'm opening a file I'd like . and .. to be omitted from the list of completion candidates. In particular, I'd like to be able to tab through directories with only one entry; right now if I spam TAB in the middle of a long Java path I get a Dired buffer for a directory I don't particularly care about.

E.g., if my current directory is ~/src and I find a file in the following file hierarchy, I'd like C-xC-fjTABTABTABTABBRET to open java/com/example/foo/Bar.java.

ls -R
.:
Makefile java

./java:
com

./java/com:
example

./java/com/example:
foo

./java/com/example/foo:
Bar.java
Quux.java
  • 1
    Have you tried setting ivy-extra-directories to nil? See (ivy) File Name Completion. – Basil Mar 19 '18 at 22:02
  • @Basil This worked -- please add it as an answer and I will accept. – ruds Mar 20 '18 at 12:51
3

When I'm opening a file I'd like . and .. to be omitted from the list of completion candidates.

This is what the user option ivy-extra-directories is for:

ivy-extra-directories is a variable defined in ‘ivy.el’.
Its value is ("../" "./")

Documentation:
Add this to the front of the list when completing file names.
Only "./" and "../" apply here.  They appear in reverse order.

In your case, you just need to clear the list:

(setq ivy-extra-directories ())

Quoth (ivy) File Name Completion:

-- User Option: ivy-extra-directories
    Decide if you want to see ‘../’ and ‘./’ during file name
    completion.

    Reason to remove: ‘../’ is the same as ‘DEL’.

    Reason not to remove: navigate anywhere with only ‘C-n’, ‘C-p’ and
    ‘C-j’.

    Likewise, ‘./’ can be removed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.