1
1
Fork
You've already forked winpick.nvim
0
Simple window picker for Neovim
  • Lua 96%
  • Dockerfile 2.2%
  • Shell 1.1%
  • Vim script 0.7%
2022年08月12日 16:05:01 -03:00
doc Stop ignoring some windows by default 2022年08月12日 16:04:09 -03:00
lua Pass down default filter to secondary filters 2022年08月12日 16:05:01 -03:00
scripts Set up CI 2022年05月18日 12:26:19 -03:00
tests Pass down default filter to secondary filters 2022年08月12日 16:05:01 -03:00
.editorconfig Add config for EditorConfig 2022年05月18日 12:26:27 -03:00
.woodpecker.yml Reproduce steps from Dockerfile in CI config 2022年05月22日 16:36:03 -03:00
Dockerfile Pass explicit domain for container image 2022年08月09日 17:41:31 -03:00
LICENSE Add MIT license 2021年10月31日 18:25:02 -03:00
README.md Pass down default filter to secondary filters 2022年08月12日 16:05:01 -03:00
stylua.toml Add first version 2021年10月31日 14:32:33 -03:00

winpick

Codeberg CI

Example of how winpick works

Plugin that helps with picking windows.

Installation

Use whichever plugin management practices you prefer. Personally I like Neovim's built-in plugin management system (:help packages) combined with Git submodules, but that choice is up to you!

Usage

Note: use :help winpick.txt for a Vim friendly documentation.

This plugin is a single-function library that helps with picking a window inside Neovim.

Basically, it shows visual cues with labels assigned to them. Meanwhile, it also prompts the user with a label. Once the user presses the respective key to a label, the function returns the selected window's ID and its corresponding buffer ID, or just nil if no window is selected.

Setup

Here an example with all default options:

winpick.setup({
	border = "double",
	filter = nil, -- doesn't ignore any window by default
	prompt = "Pick a window: ",
	format_label = winpick.defaults.format_label, -- formatted as "<label>: <buffer name>"
	chars = nil,
})

Options

From :help winpick-options:

• border (string) Style of visual cues' borders. Defaults to `double`.
• filter (function) Predicate function that receives a target window's
corresponding ID and buffer ID and returns whether that window is eligible
for being picked. Defaults to `nil`, thus not ignoring any window.
• prompt (string) Prompt message when cues are visible.
• format_label (function) Function that formats the labels for visual
cues. It receives the target window ID as first parameter and the
corresponding label for the visual cue (A, B, C, etc). Defaults to
printing the respective label and the buffer name, if any.
• chars (table) List containing `n` characters that will be used for labels
in the first `n` visual cues opened. For a number of windows greater than
`n`, complementary characters will be additionally used. Defaults to `nil`,
and a default alphabet is used.

Some examples

Moving to a window
local winid = winpick.select()
if winid then
	vim.api.nvim_set_current_win(winid)
end
Copying a buffer's path
local winid, bufnr = winpick.select({
	filter = function(winid, bufnr, default_filter)
		if vim.api.nvim_buf_get_option(bufnr, "buftype") == "terminal" then
			return false
		end
		return default_filter(winid, bufnr)
	end,
})
if not winid then
	return
end
local name = api.nvim_buf_get_name(bufnr)
if name then
	vim.fn.setreg("+", vim.fn.fnamemodify(name, ":~:."))
end