-
-
Notifications
You must be signed in to change notification settings - Fork 68
Description
Hi! 👋🏻
I'm using vertico+orderless, which is an awesome combo unless trying to autocomplete tramp paths. I don't have a full understanding of the interactions between vertico, orderless and tramp, so I might be missing something obvious 😅
Tramp hostname completion isn't sufficient in my case because hitting TAB still picks the "selected"/first candidate which is not helpful when you can't narrow down the list to something manageable.
Instead of waiting for tramp to support more completion styles, I'm looking at the problem the other way: I need a way to tweak vertico-insert to preempt it from doing it's job, but only when dealing with tramp paths.
I've got this naive implementation bound to TAB in vertico-map
(defun my-vertico-insert-unless-tramp ()
"Insert current candidate in minibuffer, except for tramp."
(interactive)
;; build a regexp that matches tramp methods (/ssh:\\|/sftp:\\|...)
(let ((methods (string-join (mapcar (lambda (x) (concat "/" (car x) ":")) tramp-methods) "\\|")))
;; if looking at a tramp-ish minibuffer content, bail out and call minibuffer-complete
(if (string-match methods (vertico--candidate))
(minibuffer-complete)
(vertico-insert))))and it works OK, if hackish. I could not find any other way to disable vertico-insert temporarily, is there a better way to do this? I haven't found knobs to configure the behavior of vertico-insert other than advising it or defining a new function. I'm especially interested in improvements along the lines of
- having this custom behavior only active when hitting TAB during file completion, not commands (although there aren't many commands named
hello-/ssh:-worldout there, hopefully) - not calling
vertico--candidateif it is an internal function that may change - maybe having a hook that activates before
vertico-insertdoes it's job? - a more robust way to detect "interesting" minibuffer contents instead of blindly running regexp on the input
This might very well be outside of the scope of vertico to support such customizations, if so then anybody reading this feel free to steal this dumb function for your own config
Have a nice day 😄