1

Refresh generated neovim config

This commit is contained in:
2024-07-14 21:12:36 +02:00
parent f215ce2ab5
commit 00464e0e65
731 changed files with 6780 additions and 31110 deletions

View File

@ -1,5 +1,56 @@
# Changelog
## [2.1.0](https://github.com/folke/which-key.nvim/compare/v2.0.1...v2.1.0) (2024-06-06)
### Features
* **presets:** add descriptions for fold deletion ([#504](https://github.com/folke/which-key.nvim/issues/504)) ([53b6085](https://github.com/folke/which-key.nvim/commit/53b6085367a92740664783330583facd958dbceb))
### Bug Fixes
* black hole z= replacements ([#602](https://github.com/folke/which-key.nvim/issues/602)) ([f5b9124](https://github.com/folke/which-key.nvim/commit/f5b912451f33fd19e52230e73617ad099ffd3ab1))
* **keys:** fix nested operators. See [#600](https://github.com/folke/which-key.nvim/issues/600). Fixes [#609](https://github.com/folke/which-key.nvim/issues/609) ([25d5b9e](https://github.com/folke/which-key.nvim/commit/25d5b9e9b5775525248b8d5c95271ba28f75d326))
* restore win view after rendering buffer ([#516](https://github.com/folke/which-key.nvim/issues/516)) ([ea4a17d](https://github.com/folke/which-key.nvim/commit/ea4a17d63571c81f529669a373d20c855b9b351d)), closes [#515](https://github.com/folke/which-key.nvim/issues/515)
* support nested operators ([#600](https://github.com/folke/which-key.nvim/issues/600)) ([476f4ca](https://github.com/folke/which-key.nvim/commit/476f4cacb15da81dcebe68ea45333e660409612d))
## [2.0.1](https://github.com/folke/which-key.nvim/compare/v2.0.0...v2.0.1) (2024-06-06)
### Bug Fixes
* label -> desc ([b8eb534](https://github.com/folke/which-key.nvim/commit/b8eb5348a749e214dfd08d38654a736d91191918))
## [2.0.0](https://github.com/folke/which-key.nvim/compare/v1.6.1...v2.0.0) (2024-06-06)
### ⚠ BREAKING CHANGES
* which-key now requires Neovim >= 0.9
### Features
* **keys:** `desc` in `"<nop>"` or `""` keymaps can now become prefix label ([#522](https://github.com/folke/which-key.nvim/issues/522)) ([c1958e2](https://github.com/folke/which-key.nvim/commit/c1958e2529433ef096e924c72315733790ca7f88))
* **mappings:** check if desc exists when parsing mappings ([#589](https://github.com/folke/which-key.nvim/issues/589)) ([a7ced9f](https://github.com/folke/which-key.nvim/commit/a7ced9f00a309418865ec2e3c272113147d167fe))
* which-key now requires Neovim >= 0.9 ([53ba0ac](https://github.com/folke/which-key.nvim/commit/53ba0accc2d607ef3f2b4f6e40aa9ac75e611dee))
### Bug Fixes
* **ignore_missing:** not showing key maps with desc field ([#577](https://github.com/folke/which-key.nvim/issues/577)) ([928c6c8](https://github.com/folke/which-key.nvim/commit/928c6c8fb62df55fa640399b7d76410c037b5f55))
* **is_enabled:** disable whichkey in cmdline-window ([#581](https://github.com/folke/which-key.nvim/issues/581)) ([26ff0e6](https://github.com/folke/which-key.nvim/commit/26ff0e6084a4e957fc13ffe00bafd7c0c5ab81cc))
* **keys:** fix buffer-local mapping groups ([d87c01c](https://github.com/folke/which-key.nvim/commit/d87c01c9bbcc7c1c2d248dca1b11285259d66be8))
* **mappings:** dont remove desc ([4a7d732](https://github.com/folke/which-key.nvim/commit/4a7d7328b26d3f3355a43af4d8dc5ffd33cbd793))
## [1.6.1](https://github.com/folke/which-key.nvim/compare/v1.6.0...v1.6.1) (2024-05-31)
### Bug Fixes
* **reg:** Added check for OSC 52 to disable related register previews ([#604](https://github.com/folke/which-key.nvim/issues/604)) ([8063a7f](https://github.com/folke/which-key.nvim/commit/8063a7f33bfea6a6387907c93a30a5877aa02633))
* small typo in operator description ([#528](https://github.com/folke/which-key.nvim/issues/528)) ([d65087b](https://github.com/folke/which-key.nvim/commit/d65087b892c45d3722b6511c83a029671d6290e5))
## [1.6.0](https://github.com/folke/which-key.nvim/compare/v1.5.1...v1.6.0) (2023-10-17)

View File

@ -139,7 +139,7 @@ WhichKey comes with the following defaults:
show_help = true, -- show a help message in the command line for using WhichKey
show_keys = true, -- show the currently pressed key and its label as a message in the command line
triggers = "auto", -- automatically setup triggers
-- triggers = {"<leader>"} -- or specifiy a list manually
-- triggers = {"<leader>"} -- or specify a list manually
-- list of triggers, where WhichKey should not wait for timeoutlen and show immediately
triggers_nowait = {
-- marks

View File

@ -1,4 +1,4 @@
*which-key.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 October 20
*which-key.nvim.txt* For Neovim >= 0.8.0 Last change: 2024 June 07
==============================================================================
Table of Contents *which-key.nvim-table-of-contents*
@ -12,6 +12,7 @@ Table of Contents *which-key.nvim-table-of-contents*
- Usage |which-key.nvim-which-key-usage|
- Plugins |which-key.nvim-which-key-plugins|
- Colors |which-key.nvim-which-key-colors|
2. Links |which-key.nvim-links|
==============================================================================
1. Which Key *which-key.nvim-which-key*
@ -164,7 +165,7 @@ WhichKey comes with the following defaults:
show_help = true, -- show a help message in the command line for using WhichKey
show_keys = true, -- show the currently pressed key and its label as a message in the command line
triggers = "auto", -- automatically setup triggers
-- triggers = {"<leader>"} -- or specifiy a list manually
-- triggers = {"<leader>"} -- or specify a list manually
-- list of triggers, where WhichKey should not wait for timeoutlen and show immediately
triggers_nowait = {
-- marks

View File

@ -64,7 +64,7 @@ local defaults = {
show_help = true, -- show a help message in the command line for using WhichKey
show_keys = true, -- show the currently pressed key and its label as a message in the command line
triggers = "auto", -- automatically setup triggers
-- triggers = {"<leader>"} -- or specifiy a list manually
-- triggers = {"<leader>"} -- or specify a list manually
-- list of triggers, where WhichKey should not wait for timeoutlen and show immediately
triggers_nowait = {
-- marks
@ -85,7 +85,7 @@ local defaults = {
v = { "j", "k" },
},
-- disable the WhichKey popup for certain buf types and file types.
-- Disabled by deafult for Telescope
-- Disabled by default for Telescope
disable = {
buftypes = {},
filetypes = {},
@ -97,6 +97,9 @@ M.options = {}
---@param options? Options
function M.setup(options)
if vim.fn.has("nvim-0.9") == 0 then
return vim.notify("WhichKey.nvim requires Neovim 0.9 or higher", vim.log.levels.ERROR)
end
M.options = vim.tbl_deep_extend("force", {}, defaults, options or {})
end

View File

@ -25,11 +25,6 @@ function M.setup(options)
schedule_load()
end
function M.execute(id)
local func = Keys.functions[id]
return func()
end
function M.show(keys, opts)
opts = opts or {}
if type(opts) == "string" then
@ -98,11 +93,4 @@ function M.load()
loaded = true
end
function M.reset()
-- local mappings = Keys.mappings
require("plenary.reload").reload_module("which-key")
-- require("which-key.Keys").mappings = mappings
require("which-key").setup()
end
return M

View File

@ -8,10 +8,9 @@ local secret = "Þ"
---@class Keys
local M = {}
M.functions = {}
M.operators = {}
M.nowait = {}
M.blacklist = {}
M.operators = {} ---@type table<string, boolean>
M.nowait = {} ---@type table<string, boolean>
M.blacklist = {} ---@type table<string, table<string, boolean>>
function M.setup()
local builtin_ops = require("which-key.plugins.presets").operators
@ -39,12 +38,14 @@ function M.setup()
end
function M.get_operator(prefix_i)
local ret = { i = nil, n = nil, len = nil }
for op_n, _ in pairs(Config.options.operators) do
local op_i = Util.t(op_n)
if prefix_i:sub(1, #op_i) == op_i then
return op_i, op_n
if prefix_i:sub(1, #op_i) == op_i and (ret.len == nil or #op_i > ret.len) then
ret = { i = op_i, n = op_n, len = #op_i }
end
end
return ret.i, ret.n
end
function M.process_motions(ret, mode, prefix_i, buf)
@ -102,11 +103,11 @@ function M.get_mappings(mode, prefix_i, buf)
for k, child in pairs(node.children) do
if
child.mapping
and child.mapping.label ~= "which_key_ignore"
and child.mapping.desc ~= "which_key_ignore"
and not (child.mapping.group and vim.tbl_isempty(child.children))
then
ret.mappings[k] = vim.tbl_deep_extend("force", {}, ret.mappings[k] or {}, child.mapping)
local child_mapping = vim.deepcopy(child.mapping)
ret.mappings[k] = vim.tbl_deep_extend("force", ret.mappings[k] or {}, child_mapping)
end
end
end
@ -126,19 +127,19 @@ function M.get_mappings(mode, prefix_i, buf)
if Config.options.key_labels[value.key] then
value.key = Config.options.key_labels[value.key]
end
local skip = not value.label and Config.options.ignore_missing == true
local skip = not value.desc and Config.options.ignore_missing == true
if Util.t(value.key) == Util.t("<esc>") then
skip = true
end
if not skip then
if value.group then
value.label = value.label or "+prefix"
value.label = value.label:gsub("^%+", "")
value.label = Config.options.icons.group .. value.label
elseif not value.label then
value.label = value.desc or value.cmd or ""
value.desc = value.desc or "+prefix"
value.desc = value.desc:gsub("^%+", "")
value.desc = Config.options.icons.group .. value.desc
elseif not value.desc then
value.desc = value.cmd or ""
for _, v in ipairs(Config.options.hidden) do
value.label = value.label:gsub(v, "")
value.desc = value.desc:gsub(v, "")
end
end
if value.value then
@ -342,7 +343,7 @@ function M.add_hooks(mode, buf, node, secret_only)
node.mapping = { prefix = node.prefix_n, group = true, keys = Util.parse_keys(node.prefix_n) }
end
if node.prefix_n ~= "" and node.mapping.group == true and not (node.mapping.cmd or node.mapping.callback) then
-- first non-cmd level, so create hook and make all decendents secret only
-- first non-cmd level, so create hook and make all descendents secret only
M.hook_add(node.prefix_n, mode, buf, secret_only)
secret_only = true
end
@ -360,7 +361,7 @@ function M.dump()
---@param node Node
function(node)
if node.mapping then
if node.mapping.label then
if node.mapping.desc then
ok[node.mapping.prefix] = true
todo[node.mapping.prefix] = nil
elseif not ok[node.mapping.prefix] then
@ -374,7 +375,7 @@ function M.dump()
end
---@param mode string
---@param buf? buffer
---@param buf? number
function M.get_tree(mode, buf)
if mode == "s" or mode == "x" then
mode = "v"
@ -411,24 +412,34 @@ function M.update_keymaps(mode, buf)
for _, keymap in pairs(keymaps) do
local skip = M.is_hook(keymap.lhs, keymap.rhs)
local is_group = false
if is_nop(keymap) then
skip = true
if not skip and is_nop(keymap) then
if keymap.desc then
pcall(vim.keymap.del, { mode }, keymap.lhs, { buffer = buf })
is_group = true
else
skip = true
end
end
if not skip then
---@type Mapping
local mapping = {
prefix = keymap.lhs,
cmd = keymap.rhs,
cmd = not is_group and keymap.rhs or nil,
desc = keymap.desc,
group = is_group,
callback = keymap.callback,
keys = Util.parse_keys(keymap.lhs),
buf = buf,
mode = mode,
}
-- don't include Plug keymaps
if mapping.keys.notation[1]:lower() ~= "<plug>" then
local node = tree:add(mapping)
if node.mapping and node.mapping.preset and mapping.desc then
node.mapping.label = mapping.desc
node.mapping.desc = mapping.desc
end
end
end

View File

@ -45,12 +45,12 @@ function Layout:trail()
local cmd_line = { { " " } }
for i = 1, len, 1 do
local node = buf_path[i]
if not (node and node.mapping and node.mapping.label) then
if not (node and node.mapping and node.mapping.desc) then
node = path[i]
end
local step = self.mapping.keys.notation[i]
if node and node.mapping and node.mapping.label then
step = self.options.icons.group .. node.mapping.label
if node and node.mapping and node.mapping.desc then
step = self.options.icons.group .. node.mapping.desc
end
if Config.options.key_labels[step] then
step = Config.options.key_labels[step]
@ -113,7 +113,7 @@ function Layout:layout(win)
width = width - pad_right - pad_left
local max_key_width = self:max_width("key")
local max_label_width = self:max_width("label")
local max_label_width = self:max_width("desc")
local max_value_width = self:max_width("value")
local intro_width = max_key_width + 2 + Text.len(self.options.icons.separator) + self.options.layout.spacing
@ -192,7 +192,7 @@ function Layout:layout(win)
start = start + max_value_width + 2
end
local label = item.label
local label = item.desc
if Text.len(label) > max_label_width then
label = vim.fn.strcharpart(label, 0, max_label_width - 2) .. ""
end

View File

@ -134,7 +134,7 @@ function M._parse(value, mappings, opts)
if type(list[1]) ~= "string" then
error("Invalid mapping for " .. vim.inspect({ value = value, opts = opts }))
end
opts.desc = list[1]
opts.desc = opts.desc or list[1]
-- { cmd, desc }
elseif #list == 2 then
-- desc
@ -179,7 +179,8 @@ function M.to_mapping(mapping)
mapping.buffer = nil
mapping.mode = mapping.mode or "n"
mapping.label = mapping.desc or mapping.name
mapping.desc = mapping.desc or mapping.name
mapping.name = nil
mapping.keys = Util.parse_keys(mapping.prefix or "")
local opts = {}
@ -187,25 +188,8 @@ function M.to_mapping(mapping)
opts[o] = mapping[o]
mapping[o] = nil
end
if vim.fn.has("nvim-0.7.0") == 0 then
opts.replace_keycodes = nil
-- Neovim < 0.7.0 doesn't support descriptions
opts.desc = nil
-- use lua functions proxy for Neovim < 0.7.0
if opts.callback then
local functions = require("which-key.keys").functions
table.insert(functions, opts.callback)
if opts.expr then
opts.cmd = string.format([[luaeval('require("which-key").execute(%d)')]], #functions)
else
opts.cmd = string.format([[<cmd>lua require("which-key").execute(%d)<cr>]], #functions)
end
opts.callback = nil
end
end
-- restore desc
mapping.desc = opts.desc
mapping.opts = opts
return mapping

View File

@ -55,7 +55,7 @@ function M.run(_trigger, _mode, buf)
table.insert(items, {
key = key,
label = labels[key] or file and ("file: " .. file) or "",
desc = labels[key] or file and ("file: " .. file) or "",
value = value,
highlights = { { 1, 5, "Number" } },
})

View File

@ -32,6 +32,9 @@ local misc = {
O = "Open all folds under cursor",
c = "Close fold under cursor",
C = "Close all folds under cursor",
d = "Delete fold under cursor",
D = "Delete all folds under cursor",
E = "Delete all folds in file",
a = "Toggle fold under cursor",
A = "Toggle all folds under cursor",
v = "Show cursor line",
@ -92,6 +95,7 @@ function M.setup(wk, config)
wk.register(mappings, { mode = "n", prefix = "", preset = true })
end
end
wk.register({ ["zf"] = "Create fold from selection" }, { mode = "x", prefix = "", preset = true })
end
return M

View File

@ -30,20 +30,44 @@ local labels = {
["/"] = "last search pattern",
}
-- This function makes the assumption that OSC 52 is set up per :help osc-52
M.osc52_active = function()
-- If no clipboard set, can't be OSC 52
if not vim.g.clipboard then
return false
end
-- Per the docs, OSC 52 should be set up with a name field in the table
if vim.g.clipboard.name == "OSC 52" then
return true
end
return false
end
---@type Plugin
---@return PluginItem[]
function M.run(_trigger, _mode, _buf)
local items = {}
local osc52_skip_keys = { "+", "*" }
for i = 1, #M.registers, 1 do
local key = M.registers:sub(i, i)
local ok, value = pcall(vim.fn.getreg, key, 1)
if not ok then
value = ""
local value = ""
if M.osc52_active() and vim.tbl_contains(osc52_skip_keys, key) then
value = "OSC 52 detected, register not checked to maintain compatibility"
else
local ok, reg_value = pcall(vim.fn.getreg, key, 1)
if ok then
value = reg_value
end
end
if value ~= "" then
table.insert(items, { key = key, label = labels[key] or "", value = value })
table.insert(items, { key = key, desc = labels[key] or "", value = value })
end
end
return items

View File

@ -21,7 +21,7 @@ function M.run()
---@diagnostic disable-next-line: missing-parameter
local cursor_word = vim.fn.expand("<cword>")
-- get a misspellled word from under the cursor, if not found, then use the cursor_word instead
-- get a misspelled word from under the cursor, if not found, then use the cursor_word instead
---@diagnostic disable-next-line: redundant-parameter
local bad = vim.fn.spellbadword(cursor_word)
local word = bad[1]
@ -39,9 +39,9 @@ function M.run()
table.insert(items, {
key = key,
label = label,
desc = label,
fn = function()
vim.cmd("norm! ciw" .. label)
vim.cmd('norm! "_ciw' .. label)
end,
})
end

View File

@ -83,7 +83,11 @@ function Tree:add(mapping, opts)
path_i = path_i .. prefix_i[i]
path_n = path_n .. prefix_n[i]
if not node.children[prefix_i[i]] then
node.children[prefix_i[i]] = { children = {}, prefix_i = path_i, prefix_n = path_n }
node.children[prefix_i[i]] = {
children = {},
prefix_i = path_i,
prefix_n = path_n,
}
end
node = node.children[prefix_i[i]]
end

View File

@ -32,7 +32,6 @@
---@class Mapping
---@field buf number
---@field group boolean
---@field label string
---@field desc string
---@field prefix string
---@field cmd string

View File

@ -52,17 +52,13 @@ function M.show()
local opts = {
relative = "editor",
width = vim.o.columns
- margins[2]
- margins[4]
- (vim.fn.has("nvim-0.6") == 0 and config.options.window.border ~= "none" and 2 or 0),
width = vim.o.columns - margins[2] - margins[4],
height = config.options.layout.height.min,
focusable = false,
anchor = "SW",
border = config.options.window.border,
row = vim.o.lines
- margins[3]
- (vim.fn.has("nvim-0.6") == 0 and config.options.window.border ~= "none" and 2 or 0)
+ ((vim.o.laststatus == 0 or vim.o.laststatus == 1 and #wins == 1) and 1 or 0)
- vim.o.cmdheight,
col = margins[4],
@ -76,18 +72,13 @@ function M.show()
end
M.buf = vim.api.nvim_create_buf(false, true)
M.win = vim.api.nvim_open_win(M.buf, false, opts)
vim.api.nvim_buf_set_option(M.buf, "filetype", "WhichKey")
vim.api.nvim_buf_set_option(M.buf, "buftype", "nofile")
vim.api.nvim_buf_set_option(M.buf, "bufhidden", "wipe")
vim.api.nvim_buf_set_option(M.buf, "modifiable", true)
local winhl = "NormalFloat:WhichKeyFloat"
if vim.fn.hlexists("FloatBorder") == 1 then
winhl = winhl .. ",FloatBorder:WhichKeyBorder"
end
vim.api.nvim_win_set_option(M.win, "winhighlight", winhl)
vim.api.nvim_win_set_option(M.win, "foldmethod", "manual")
vim.api.nvim_win_set_option(M.win, "winblend", config.options.window.winblend)
vim.bo[M.buf].filetype = "WhichKey"
vim.bo[M.buf].buftype = "nofile"
vim.bo[M.buf].bufhidden = "wipe"
vim.bo[M.buf].modifiable = true
vim.wo[M.win].winhighlight = "NormalFloat:WhichKeyFloat,FloatBorder:WhichKeyBorder"
vim.wo[M.win].foldmethod = "manual"
vim.wo[M.win].winblend = config.options.window.winblend
end
function M.read_pending()
@ -204,7 +195,7 @@ function M.execute(prefix_i, mode, buf)
end
-- make sure we remove all WK hooks before executing the sequence
-- this is to make existing keybindongs work and prevent recursion
-- this is to make existing keybindings work and prevent recursion
unhook(Keys.get_tree(mode).tree:path(prefix_i))
if buf then
unhook(Keys.get_tree(mode, buf).tree:path(prefix_i), buf)
@ -256,20 +247,24 @@ function M.open(keys, opts)
end
function M.is_enabled(buf)
local buftype = vim.api.nvim_buf_get_option(buf, "buftype")
local buftype = vim.bo[buf].buftype
for _, bt in ipairs(config.options.disable.buftypes) do
if bt == buftype then
return false
end
end
local filetype = vim.api.nvim_buf_get_option(buf, "filetype")
local filetype = vim.bo[buf].filetype
for _, bt in ipairs(config.options.disable.filetypes) do
if bt == filetype then
return false
end
end
if vim.fn.getcmdwintype() ~= "" then
return false
end
return true
end
@ -333,6 +328,7 @@ end
---@param text Text
function M.render(text)
local view = vim.api.nvim_win_call(M.win, vim.fn.winsaveview)
vim.api.nvim_buf_set_lines(M.buf, 0, -1, false, text.lines)
local height = #text.lines
if height > config.options.layout.height.max then
@ -345,6 +341,9 @@ function M.render(text)
for _, data in ipairs(text.hl) do
highlight(M.buf, config.namespace, data.group, data.line, data.from, data.to)
end
vim.api.nvim_win_call(M.win, function()
vim.fn.winrestview(view)
end)
end
return M