Skip to content

oncomouse/czs.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CZS = Cmdheight Zero Search

Behavior of czs.nvim

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:

  1. Hiding when leaving normal mode
  2. Only re-displaying after returning to normal when something has changed, such as:
    1. User presses 'n' or 'N' to move to next or previous selection
    2. User enters a new search pattern
  3. Handle buffer switching

Usage

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:

  1. require("czs").display_results() -- Will return true when search results should display; false when not.
  2. require("czs").output() -- Returns three values:
    1. target -- What the user is searching for
    2. current -- Which result is currently selected (will show ">" + maxcount if current is too high)
    3. count -- How many total results were found (will show ">" + maxcount if 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.

Mappings

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)

About

Proper search display for statuslines and cmdheight=0 in Neovim

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages