Comments (20)
You can use this advice https://github.com/minad/vertico/blob/buffer-display/buffer.el to get a display action as in Selectrum which I wrote as a prototype. But it is not upside down.
In case you really want it upside down you can reverse the candidates using nreverse
. And then you have to remap the up down keys. You can try it out. I didn't really like it tbh.
(defun vertico--display-in-buffer (candidates)
(let ((buffer (get-buffer-create (format " *vertico-%s*" (- (recursion-depth) 1)))))
(with-current-buffer buffer
(setq-local display-line-numbers nil
show-trailing-whitespace nil
inhibit-modification-hooks t)
(erase-buffer)
(insert (string-join (nreverse candidates))) ;; NOTE: Reverse the candidates!
(goto-char (point-min)))
(display-buffer buffer
`(display-buffer-in-side-window
(window-parameters (mode-line-format . none))
(window-height . ,vertico-count)
(side . bottom)
(slot . -1)))))
(advice-add #'vertico--display-candidates
:override #'vertico--display-in-buffer)
(define-key vertico-map [up] #'vertico-next)
(define-key vertico-map [down] #'vertico-previous)
from vertico.
Follow up here.
I redid this and added some spacing. @grolongo
(use-package vertico
:ensure
:bind (:map vertico-map
("C-n" . vertico-previous)
("C-p" . vertico-next)
([up] . vertico-next)
([down] . vertico-previous))
:init
(defun vertico--display-in-buffer (candidates)
(let ((buffer (get-buffer-create (format " *vertico-%s*" (- (recursion-depth) 1))))
(fill-rows (max 0 (- vertico-count (length candidates)))))
(with-current-buffer buffer
(setq-local display-line-numbers nil
show-trailing-whitespace nil
inhibit-modification-hooks t)
(erase-buffer)
(insert (apply #'concat (make-list fill-rows "\n")))
(insert (string-join (nreverse candidates))) ;; NOTE: Reverse the candidates!
(goto-char (point-min)))
(display-buffer buffer
`(display-buffer-in-side-window
(window-parameters (mode-line-format . none))
(window-height . ,vertico-count)
(side . bottom)
(slot . -1)))))
(advice-add #'vertico--display-candidates
:override #'vertico--display-in-buffer))
This actually looks really nice.
@minad is there a way to customize the indentation besides modifying this function more? also, I'd like to change the formatting of the currently selected item (maybe prefix with >
). But so far, it's working well.
from vertico.
Hey that works fine thanks!
Is there a way to automatically resize the buffer so there is no gap between the results and prompt? Maybe I'm wrong but is it because for the reverse display we're using a custom buffer while by default we're using the minibuffer, therefore (setq resize-mini-windows t)
doesn't apply anymore?
from vertico.
Is there a way to automatically resize the buffer so there is no gap between the results and prompt? Maybe I'm wrong but is it because for the reverse display we're using a custom buffer while by default we're using the minibuffer, therefore (setq resize-mini-windows t) doesn't apply anymore?
Yes, you may want to add your own resizing code to the function vertico--display-in-buffer
.
I close this issue since I don't have an intention to add this functionality to the package itself as of now. In case you want more ootb configurability/functionality, there is also Selectrum as you are aware.
from vertico.
There is currently no possibility to modify the formatting of the candidates. You could do it in this display function or advise vertico--format-candidates.
I could split vertico--format-candidates and introduce some helper functions which could be advised additionally to affect the formatting of individual candidates.
from vertico.
@milkypostman I split up vertico--format-candidates
a little bit, you can do this now:
(advice-add #'vertico--format-candidate :around
(lambda (orig cand prefix suffix index)
(setq cand (funcall orig cand prefix suffix index))
(concat
(if (= vertico--index index)
(propertize "> " 'face 'vertico-current)
" ")
cand)))
Note that using advices for these individual adjustments can be a bit brittle. I am not making guarantees that these internals won't change at some point. But Vertico is simple enough, such that it should be no big deal to follow potential changes.
from vertico.
yeah advice is whatever. this is pretty great though thank you!
from vertico.
This is great! Thank you for this.
Something I noticed, how could I disable the cursor in the candidates buffer? It doesn't show up by default (without using the function). You can see what I'm talking about in the screenshot I posted above (cursor is top left over vertico-exit-input
).
from vertico.
Something I noticed, how could I disable the cursor in the candidates buffer? It doesn't show up by default (without using the function). You can see what I'm talking about in the screenshot I posted above (cursor is top left over vertico-exit-input).
You can adjust cursor-in-non-selected-window
. Another alternative one may want to consider is to show the candidates in an overlay above the prompt instead of an additional buffer. I will try this, maybe this is even easier than the solution given here.
from vertico.
I figured it out by adding cursor-in-non-selected-windows
to nil
in the setq-local
list of variables.
Maybe you have this set globally so you don't have to do this.
edit: thanks minad looks like we were answering at the same time :)
from vertico.
See https://github.com/minad/vertico/wiki#show-candidates-in-an-overlay-above-the-prompt for a solution which uses the overlay instead of a separate buffer. You may prefer this since it is more lightweight and since it does not introduce the cursor issue. This is probably also interesting for @milkypostman.
from vertico.
wow this is amazing.
To put them at the bottom of the overlay.
(defun vertico--display-above-prompt (lines)
(move-overlay vertico--candidates-ov (point-min) (point-min))
(overlay-put vertico--candidates-ov 'before-string
(concat (make-string (- vertico-count (length lines)) ?\n)
(apply #'concat (nreverse lines))))
(vertico--resize-window (length lines)))
from vertico.
@minad maybe I'm wrong but shouldn't the new variable vertico-resize
you introduced work for both @milkypostman's vertico--display-in-buffer
function and your overlay solution too?
Or does vertico-resize
only act on the *Completions*
buffer when used with vertico like resize-mini-windows
do by default?
from vertico.
vertico-resize
works only for the minibuffer/overlay. vertico--display-in-buffer
is not taking the variable into account, but you can add this of course.
from vertico.
@grolongo to clarify the previous comments, the height of the buffer generated by my code is specified in the call to display-buffer
where the line used is (window-height . ,vertico-count)
.
from vertico.
I decided to add Vertico extensions to the repository: These are small packages, which extend Vertico but which are not part of the opinionated main package. I won't use these extensions but I feel more comfortable maintaining them as part of the repository in contrast to the wiki.
See https://github.com/minad/vertico/blob/main/extensions/vertico-reverse.el which offers the vertico-reverse-mode
.
from vertico.
very cool. thanks for that!
I agree it's probably better to have some story about this. I think the extensions are nice.
from vertico.
Yes, I think extensions fit the spirit very well here, since these allow you to plug together your own completion system and the core is kept simple. One of the main ideas of Vertico/Consult/Marginalia/Orderless/Embark/... is that you have these pluggable components.
from vertico.
Compartmentalized and organized, that's very good.
Also great for discoverability, I didn't know about the other options.
Is the ido extension for vertico
similar to fido-mode
for icomplete
?
from vertico.
@grolongo No, vertico-directory
(as it is now called) only provides better directory navigation commands. But there are also other extensions which give you a more ido-like look (e.g. vertico-flat
).
from vertico.
Related Issues (20)
- find file when switching to the root of a drive I get all kinds of entries which are not folders or files HOT 1
- Error in post-command-hook (vertico--exhibit): (void-function compat--string-width) HOT 1
- File name column takes to much space (even truncated with custom code).)
- Error in `execute extended command` minibuffer
- Refresh on `backward-kill-word`
- The alternative to M-RET doesn't work or is poorly described
- Emacs 30 freezes if there isn't enough room due to window-size-fixed HOT 1
- Lagging cursor movement in Wayland
- Vertico distorts email attachments
- reject completions?
- Problematic completion Org mode commands
- Performance issues
- Pull request: don't delete right side of minibuffer after TAB HOT 1
- vertico-flat-mode with vertico-flat-max-lines > 1 does not respect (setq vertico-resize 'grow-only) HOT 5
- Query Regarding Functionality Similar to ivy-restrict-to-matches
- How to achieve fuzzy completion HOT 1
- Use a different sort strategy per command
- Error in post-command-hook (vertico--exhibit): (cyclic-function-indirection ConTeXt-mode)
- Keyboard macro and default M-x command selection
- Blank line among function completions with llama installed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vertico.