Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature(input): keep history of inputs for named prompts #591

Closed
1 task done
jdrouhard opened this issue Jan 17, 2025 · 6 comments · Fixed by #667
Closed
1 task done

feature(input): keep history of inputs for named prompts #591

jdrouhard opened this issue Jan 17, 2025 · 6 comments · Fixed by #667
Labels
enhancement New feature or request

Comments

@jdrouhard
Copy link
Contributor

Did you check the docs?

  • I have read all the snacks.nvim docs

Is your feature request related to a problem? Please describe.

vim.fn.input() and vim.ui.input() both keep a separate history for inputs with the same prompt. That is, when typing input for a particular prompt, you can press the up arrow and get previous inputs you've used for it.

I use this for repeating searches I've typed before, using something like:

local function search()
  vim.ui.input({ prompt = "Grep For" }, function(input)
    Snacks.picker.grep({ live = false, search = input })
  end)
end

M.keys = {
  { '<leader>s',   search, { desc = 'grep' } },
  { '<leader>rg',  function() Snacks.picker.grep() end },
}

Describe the solution you'd like

I can type <leader>s followed by up and scroll through my history of typed greps. Snacks.input doesn't seem to support this, but would be amazing if it did.

Describe alternatives you've considered

For now, I'm using vim.fn.input to type my search queries instead of vim.ui.input, but would love to switch.

Additional context

No response

@jdrouhard jdrouhard added the enhancement New feature or request label Jan 17, 2025
@folke
Copy link
Owner

folke commented Jan 20, 2025

Pickers already support history with <c-Up> and <c-Down>

@folke folke closed this as not planned Won't fix, can't repro, duplicate, stale Jan 20, 2025
@jdrouhard
Copy link
Contributor Author

@folke - For sure, pickers definitely support it, but this was specifically a feature request for Snacks.input (which is supposed to be a drop in replacement for vim.ui.input). The latter does support a history, but the former doesn't yet.

I guess my usage of picker in my example was confusing but in fact it was irrelevant since you could use the input for anything. Is it possible to reconsider opening this request?

Thanks for making such fantastic quality plugins.

@folke folke reopened this Jan 20, 2025
@folke folke closed this as completed in 80db91f Jan 20, 2025
@folke
Copy link
Owner

folke commented Jan 20, 2025

Just added this. Default keymaps are <Up> and <Down>

@jdrouhard
Copy link
Contributor Author

jdrouhard commented Jan 20, 2025

Thank you! Does it save the history to shada so it is persistent between neovim sessions?

Edit: #528

folke added a commit that referenced this issue Jan 20, 2025
@folke
Copy link
Owner

folke commented Jan 20, 2025

Added persistent history as well

@jdrouhard
Copy link
Contributor Author

Incredible. Thank you @folke!

folke pushed a commit that referenced this issue Jan 23, 2025
🤖 I have created a release *beep* *boop*
---


##
[2.15.0](v2.14.0...v2.15.0)
(2025-01-23)


### Features

* **debug:** truncate inspect to 2000 lines max
([570d219](570d219))
* **input:** input history. Closes
[#591](#591)
([80db91f](80db91f))
* **input:** persistent history. Closes
[#591](#591)
([0ed68bd](0ed68bd))
* **picker.debug:** more info about potential leaks
([8d9677f](8d9677f))
* **picker.filter:** Filter arg for filter
([5a4b684](5a4b684))
* **picker.finder:** optional transform function
([5e69fb8](5e69fb8))
* **picker.format:** `filename_only` option
([0396bdf](0396bdf))
* **picker.git:** git_log, git_log_file, git_log_line now do
git_checkout as confirm. Closes
[#722](#722)
([e6fb538](e6fb538))
* **picker.help:** add more color to help tags
([5778234](5778234))
* **picker.keymaps:** add global + buffer toggles
([#705](#705))
([b7c08df](b7c08df))
* **picker.keymaps:** improvements to keymaps picker
([2762c37](2762c37))
* **picker.matcher:** frecency and cwd bonus can now be enabled on any
picker
([7b85dfc](7b85dfc))
* **picker.multi:** multi now also merges keymaps
([8b2c78a](8b2c78a))
* **picker.preview:** better positioning of preview location
([3864955](3864955))
* **picker.preview:** fallback highlight of results when no `end_pos`.
Mostly useful for grep.
([d12e454](d12e454))
* **picker.smart:** add bufdelete actions from buffers picker
([#679](#679))
([67fbab1](67fbab1))
* **picker.smart:** re-implemented smart as multi-source picker
([450d1d4](450d1d4))
* **picker.util:** smart path truncate. Defaults to 40. Closes
[#708](#708)
([bab8243](bab8243))
* **picker:** added `lazy` source to search for a plugin spec. Closes
[#680](#680)
([d03bd00](d03bd00))
* **picker:** added `opts.rtp` (bool) to find/grep over files in the
rtp. See [#680](#680)
([9d5d3bd](9d5d3bd))
* **picker:** added new `icons` picker for nerd fonts and emoji. Closes
[#703](#703)
([97898e9](97898e9))
* **picker:** getters and setters for cwd
([2c2ff4c](2c2ff4c))
* **picker:** multi source picker. Combine multiple pickers (as opposed
to just finders) in one picker
([9434986](9434986))
* **picker:** persistent history. Closes
[#528](#528)
([ea665eb](ea665eb))
* **picker:** preview window horizontal scrolling
([#686](#686))
([bc47e0b](bc47e0b))
* **picker:** syntax highlighting for command and search history
([efb6d1f](efb6d1f))
* **profiler:** added support for `Snacks.profiler` and dropped support
for fzf-lua / telescope. Closes
[#695](#695)
([ada83de](ada83de))


### Bug Fixes

* **picker.actions:** `checktime` after `git_checkout`
([b86d90e](b86d90e))
* **picker.async:** better handling of abort and schedule/defer util
function
([dfcf27e](dfcf27e))
* **picker.async:** fixed aborting a coroutine from the coroutine
itself. See [#665](https://github.com/folke/snacks.nvim/issues/665)
([c1e2c61](c1e2c61))
* **picker.files:** include symlinks
([dc9c6fb](dc9c6fb))
* **picker.frecency:** track visit on BufWinEnter instead of BufReadPost
and exclude floating windows
([024a448](024a448))
* **picker.git_branches:** handle detached HEAD
([#671](#671))
([390f687](390f687))
* **picker.git:** `--follow` only works for `git_log_file`. Closes
[#666](#666)
([23a8668](23a8668))
* **picker.git:** parse all detached states. See
[#671](#671)
([2cac667](2cac667))
* **picker.grep:** off-by-one for grep results col
([e3455ef](e3455ef))
* **picker.icons:** bump build for nerd fonts
([ba108e2](ba108e2))
* **picker.icons:** fix typo in Nerd Fonts and display the full category
name ([#716](#716))
([a4b0a85](a4b0a85))
* **picker.icons:** opts.icons -&gt; opts.icon_sources. Fixes
[#715](#715)
([9e7bfc0](9e7bfc0))
* **picker.input:** better handling of `stopinsert` with prompt buffers.
Closes [#723](#723)
([c2916cb](c2916cb))
* **picker.input:** correct cursor position in input when cycling /
focus. Fixes [#688](#688)
([93cca7a](93cca7a))
* **picker.lsp:** include_current on Windows. Closes
[#678](#678)
([66d2854](66d2854))
* **picker.lsp:** make `lsp_symbols` work for unloaded buffers
([9db49b7](9db49b7))
* **picker.lsp:** schedule_wrap cancel functions and resume when no
clients
([6cbca8a](6cbca8a))
* **picker.lsp:** use async from ctx
([b878caa](b878caa))
* **picker.lsp:** use correct buf/win
([8006caa](8006caa))
* **picker.preview:** clear buftype for file previews
([5429dff](5429dff))
* **picker.undo:** use new API. Closes
[#707](#707)
([79a6eab](79a6eab))
* **picker.util:** for `--` args require a space before
([ee6f21b](ee6f21b))
* **picker.util:** more relaxed resolve_loc
([964beb1](964beb1))
* **picker.util:** prevent empty shortened paths if it's the cwd. Fixes
[#721](#721)
([14f16ce](14f16ce))
* **picker:** better handling of buffers with custom URIs. Fixes
[#677](#677)
([cd5eddb](cd5eddb))
* **picker:** don't jump to invalid positions. Fixes
[#712](#712)
([51adb67](51adb67))
* **picker:** don't try showing the preview when the picker is closed.
Fixes [#714](#714)
([11c0761](11c0761))
* **picker:** resume. Closes
[#709](#709)
([9b55a90](9b55a90))
* **picker:** starting a picker from the picker sometimes didnt start in
insert mode. Fixes
[#718](#718)
([08d4f14](08d4f14))
* **picker:** update title on find. Fixes
[#717](#717)
([431a24e](431a24e))
* **scroll:** handle buffer changes while animating
([3da0b0e](3da0b0e))
* **win:** better way of finding a main window when fixbuf is `true`
([84ee7dd](84ee7dd))
* **zen:** parent buf. Fixes
[#720](#720)
([f314676](f314676))


### Performance Improvements

* **picker.frecency:** cache all deadlines on load
([5b3625b](5b3625b))
* **picker:** gc optims
([3fa2ea3](3fa2ea3))
* **picker:** small optims
([ee76e9b](ee76e9b))
* **picker:** small optims for abort
([317a209](317a209))
* **picker:** use picker ref in progress updater. Fixes
[#710](#710)
([37f3888](37f3888))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants