install whichkey.lua
This commit is contained in:
@@ -29,12 +29,12 @@
|
|||||||
(c) Frank Zechert 2026
|
(c) Frank Zechert 2026
|
||||||
]]
|
]]
|
||||||
|
|
||||||
-- enable loading of precompiled lua modules to improve startup time
|
|
||||||
vim.loader.enable()
|
|
||||||
|
|
||||||
vim.g.mapleader = " "
|
vim.g.mapleader = " "
|
||||||
vim.g.maplocalleader = " "
|
vim.g.maplocalleader = " "
|
||||||
|
|
||||||
|
-- enable loading of precompiled lua modules to improve startup time
|
||||||
|
vim.loader.enable()
|
||||||
|
|
||||||
-- load configuration
|
-- load configuration
|
||||||
require("config.ui")
|
require("config.ui")
|
||||||
require("config.options")
|
require("config.options")
|
||||||
|
|||||||
@@ -62,6 +62,15 @@ create_cmd({"BufRead", "BufNewFile"}, {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- disable list chars in specific filetypes, e.g. netrw
|
||||||
|
create_cmd({"FileType"}, {
|
||||||
|
desc = "Disable list chars for some filetypes",
|
||||||
|
pattern = { "netrw" },
|
||||||
|
callback = function(args)
|
||||||
|
vim.opt_local.list = false
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
-- automatically remove trailing whitespace on save file
|
-- automatically remove trailing whitespace on save file
|
||||||
create_cmd({"BufWritePre"}, {
|
create_cmd({"BufWritePre"}, {
|
||||||
desc = "Remove trailing whitespace when saving",
|
desc = "Remove trailing whitespace when saving",
|
||||||
|
|||||||
@@ -36,3 +36,67 @@ map("t", "<Esc><Esc>", "<C-\\><C-n>", { desc = "exit terminanl" })
|
|||||||
|
|
||||||
-- Pressing ESC removes search highlights
|
-- Pressing ESC removes search highlights
|
||||||
map("n", "<Esc>", "<Cmd>nohlsearch<Cr>")
|
map("n", "<Esc>", "<Cmd>nohlsearch<Cr>")
|
||||||
|
|
||||||
|
-- Smart buffer switch (to alternative, previous, or next) if possible
|
||||||
|
local function smart_buffer_switch(current)
|
||||||
|
local alternative = vim.fn.bufnr("#")
|
||||||
|
|
||||||
|
-- get all listed buffers
|
||||||
|
local buffers = vim.fn.getbufinfo({ buflisted = 1 })
|
||||||
|
|
||||||
|
-- find index of the current buffer
|
||||||
|
local current_index = nil
|
||||||
|
for index, buffer in ipairs(buffers) do
|
||||||
|
if buffer.bufnr == current then
|
||||||
|
current_index = i
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- try to switch to alternate buffer
|
||||||
|
if alternative > 0 and vim.fn.buflisted(alternative) == 1 and alternative ~= current then
|
||||||
|
vim.api.nvim_set_current_buf(alternative)
|
||||||
|
-- try to switch to previous buffer
|
||||||
|
elseif current_index and current_index > 1 then
|
||||||
|
vim.api.nvim_set_current_buf(buffers[current_index -1].bufnr)
|
||||||
|
-- try to switch to next buffer
|
||||||
|
elseif current_index and current_index < #buffers then
|
||||||
|
vim.api.nvim_set_current_buf(buffers[current_index + 1].bufnr)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function smart_buffer_delete()
|
||||||
|
local current = vim.api.nvim_get_current_buf()
|
||||||
|
smart_buffer_switch(current)
|
||||||
|
-- delete current buffer
|
||||||
|
vim.cmd(":confirm bdelete " .. current)
|
||||||
|
end
|
||||||
|
map("n", "<leader>bd", smart_buffer_delete, { desc = "Close Current Buffer" })
|
||||||
|
|
||||||
|
local function smart_buffer_wipeout()
|
||||||
|
local current = vim.api.nvim_get_current_buf()
|
||||||
|
smart_buffer_switch(current)
|
||||||
|
-- delete current buffer
|
||||||
|
vim.cmd(":confirm bwipeout " .. current)
|
||||||
|
end
|
||||||
|
map("n", "<leader>bw", smart_buffer_wipeout, { desc = "Wipeout Current Buffer" })
|
||||||
|
|
||||||
|
local function delete_other_buffers()
|
||||||
|
local current = vim.api.nvim_get_current_buf()
|
||||||
|
for _, buffer in ipairs(vim.api.nvim_list_bufs()) do
|
||||||
|
if buffer ~= current and vim.bo[buffer].buflisted and not vim.bo[buffer].modified then
|
||||||
|
vim.api.nvim_buf_delete(buffer, {})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
map("n", "<leader>bD", delete_other_buffers, { desc = "Close All Other Buffers" })
|
||||||
|
|
||||||
|
local function wipeout_other_buffers()
|
||||||
|
local current = vim.api.nvim_get_current_buf()
|
||||||
|
for _, buffer in ipairs(vim.api.nvim_list_bufs()) do
|
||||||
|
if buffer ~= current and vim.bo[buffer].buflisted and not vim.bo[buffer].modified then
|
||||||
|
vim.cmd("bwipeout " .. buffer)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
map("n", "<leader>bW", wipeout_other_buffers, { desc = "Wipeout All Other Buffers" })
|
||||||
|
|||||||
@@ -128,6 +128,28 @@ return {
|
|||||||
lualine_y = {},
|
lualine_y = {},
|
||||||
lualine_z = {},
|
lualine_z = {},
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
keys = {
|
||||||
|
{ "<leader>b1", "<Cmd>:LualineBuffersJump! 1<CR>", desc = "Show Buffer 1" },
|
||||||
|
{ "<leader>b2", "<Cmd>:LualineBuffersJump! 2<CR>", desc = "Show Buffer 2" },
|
||||||
|
{ "<leader>b3", "<Cmd>:LualineBuffersJump! 3<CR>", desc = "Show Buffer 3" },
|
||||||
|
{ "<leader>b4", "<Cmd>:LualineBuffersJump! 4<CR>", desc = "Show Buffer 4" },
|
||||||
|
{ "<leader>b5", "<Cmd>:LualineBuffersJump! 5<CR>", desc = "Show Buffer 5" },
|
||||||
|
{ "<leader>b6", "<Cmd>:LualineBuffersJump! 6<CR>", desc = "Show Buffer 6" },
|
||||||
|
{ "<leader>b7", "<Cmd>:LualineBuffersJump! 7<CR>", desc = "Show Buffer 7" },
|
||||||
|
{ "<leader>b8", "<Cmd>:LualineBuffersJump! 8<CR>", desc = "Show Buffer 8" },
|
||||||
|
{ "<leader>b9", "<Cmd>:LualineBuffersJump! 9<CR>", desc = "Show Buffer 9" },
|
||||||
|
{ "<leader>b0", "<Cmd>:LualineBuffersJump! 10<CR>", desc = "Show Buffer 10" },
|
||||||
|
{
|
||||||
|
"<leader>bb",
|
||||||
|
function()
|
||||||
|
local index = tonumber(vim.fn.input("Jump to Buffer: "))
|
||||||
|
if index then
|
||||||
|
vim.cmd("LualineBuffersJump! " .. index)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
desc = "Show Buffer ?"
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
--[[
|
||||||
|
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣴⣾⣷⣦⣄⡀
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣷⣦⣄⡀
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣦⣄⡀
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⠚⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠗⢀
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣤⣄⡉⠓⠦⣌⡙⠻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠟⢋⣡⠴⠚⢉⣠⣤⣀
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣤⣶⣿⣿⣿⣿⣿⣷⣦⣄⡉⠓⠦⣌⡙⠻⢿⣿⣿⣿⣿⣿⣿⡿⠟⢋⣡⠴⠚⢉⣠⣴⣾⣿⣿⣿⣿⣿⣶⣤
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠐⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣿⣿⣷⣦⣄⡉⠓⠦⣌⡙⠻⠟⢋⣡⠴⠚⢉⣠⣴⣾⣿⣿⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⠂
|
||||||
|
⠀⠀⠀⠀⢀⣠⣴⣆⡈⠻⢿⣿⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣿⣿⣷⣦⣄⡉⠃⠘⢉⣠⣴⣾⣿⣿⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⣿⡿⠟⢁⣰⣦⣄⡀
|
||||||
|
⠀⠀⠐⠾⣿⣿⣿⣿⣿⣷⣦⣌⡙⠻⢿⣿⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣿⣿⣷⣾⣿⣿⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⣿⡿⠟⢋⣡⣴⣾⣿⣿⣿⣿⣿⠷⠂
|
||||||
|
⠀⢸⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣌⡙⠻⢿⣿⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⣿⡿⠟⢋⣡⣴⣾⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⡇
|
||||||
|
⠀⢸⣿⣿⣿⣿⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣌⡙⠻⢿⣿⣷⣦⣄⡉⠛⠿⠿⠛⢉⣠⣴⣾⣿⡿⠟⢋⣡⣴⣾⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⣿⣿⣿⣿⡇
|
||||||
|
⠀⠀⠉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣌⡙⠻⢿⣿⣷⡆⢰⣾⣿⡿⠟⢋⣡⣴⣾⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⣿⣿⣿⣿⣿⠿⠛⠉
|
||||||
|
⠀⠀⠀⠀⠀⠀⠉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣌⡙⠃⠘⢋⣡⣴⣾⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⣿⣿⣿⣿⣿⠿⠛⠉
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣷⣾⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⣿⣿⣿⣿⣿⠿⠛⠉
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⣿⣿⣿⣿⣿⠿⠛⠉
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣄⡉⢉⣠⣴⣾⣿⣿⣿⣿⣿⠿⠛⠉
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠿⣿⣿⣿⣿⡇⢸⣿⣿⣿⣿⠿⠛⠉
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠿⡇⢸⠿⠛⠉
|
||||||
|
|
||||||
|
__ _ _
|
||||||
|
/ _|___ ___| |_ __ _ ___| | __
|
||||||
|
| ||_ /____/ __| __/ _` |/ __| |/ /
|
||||||
|
| _/ /_____\__ \ || (_| | (__| <
|
||||||
|
|_|/___| |___/\__\__,_|\___|_|\_\
|
||||||
|
|
||||||
|
Neovim 0.12 configuration
|
||||||
|
(c) Frank Zechert 2026
|
||||||
|
]]
|
||||||
|
|
||||||
|
return {
|
||||||
|
{
|
||||||
|
"folke/which-key.nvim",
|
||||||
|
dependencies = {
|
||||||
|
{ "nvim-mini/mini.icons" },
|
||||||
|
{ "nvim-tree/nvim-web-devicons" },
|
||||||
|
},
|
||||||
|
event = "VeryLazy",
|
||||||
|
opts = {
|
||||||
|
preset = "modern",
|
||||||
|
spec = {
|
||||||
|
{ "<leader>b", group = "Buffers" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
keys = {
|
||||||
|
{
|
||||||
|
"<leader>?",
|
||||||
|
function()
|
||||||
|
require("which-key").show({ global = false })
|
||||||
|
end,
|
||||||
|
desc = "Buffer Local Keymaps"
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user