This plugin adds proper search status and monitoring (useful for statusline plugins) for Neovim when using cmdheight=0.
When I say "proper," I mean I mean behaving the way Neovim does when displaying search information with set cmdheight=1. This includes:
- Hiding when leaving normal mode
- Only re-displaying after returning to normal when something has changed, such as:
- User presses 'n' or 'N' to move to next or previous selection
- User enters a new search pattern
- Handle buffer switching
Install czs.nvim as you would any other plugin (use { "oncomouse/czs.nvim" } in packer.nvim, for instance).
There are two functions provided by czs.nvim for displaying search results:
require("czs").display_results()-- Will returntruewhen search results should display;falsewhen not.require("czs").output()-- Returns three values:target-- What the user is searching forcurrent-- Which result is currently selected (will show ">" +maxcountif current is too high)count-- How many total results were found (will show ">" +maxcountif search returned too many results)
How you use these functions depends on your statusline configuration, but using heirline.nvim, I have the following component in my configuration:
local Search = {
condition = function()
return require("czs").display_results()
end,
provider = function()
local target, current, count = require("czs").output()
return string.format("/%s [%s/%s]", target, current, count)
end,
}You could use something similar for any of the other plugins available for Neovim.
This plugin remaps n and N. If you would prefer that to not happen, set vim.g.czs_do_not_map = true somewhere in your Neovim configuration. The bindings necessary for czs.nvim are set to plug-bindings:
<Plug>(czs-move-n)<Plug>(czs-move-N)
