Neovim: update which-key configuration to v3

This commit is contained in:
Marko Korhonen 2024-07-13 15:49:55 +03:00
parent 165c1ee9ca
commit 44345df4a9
12 changed files with 95 additions and 87 deletions

View file

@ -104,6 +104,10 @@ return {
{ name = "buffer" },
{ name = "spell" },
{ name = "path" },
{
name = "lazydev",
group_index = 0, -- set group index to 0 to skip loading LuaLS completions
},
},
})

View file

@ -0,0 +1,22 @@
--- @type LazyPluginSpec
return {
"lewis6991/gitsigns.nvim",
config = true,
lazy = false,
keys = {
{
"[h",
function()
require("gitsigns").prev_hunk()
end,
desc = "Previous hunk",
},
{
"]h",
function()
require("gitsigns").next_hunk()
end,
desc = "Next hunk",
},
},
}

View file

@ -0,0 +1,15 @@
-- Neovim setup for init.lua and plugin development with full signature help, docs and completion for the nvim lua API.
--- @type LazyPluginSpec
return {
{
"folke/lazydev.nvim",
ft = "lua", -- only load on lua files
opts = {
library = {
-- See the configuration section for more details
-- Load luvit types when the `vim.uv` word is found
{ path = "luvit-meta/library", words = { "vim%.uv" } },
},
},
},
}

View file

@ -5,5 +5,8 @@ return {
config = function()
require("mini.surround").setup()
require("mini.comment").setup()
-- Recommended for which-key
require("mini.icons").setup()
end,
}

View file

@ -1,14 +0,0 @@
-- Neovim setup for init.lua and plugin development with full signature help, docs and completion for the nvim lua API.
return {
"folke/neodev.nvim",
--- @type LuaDevOptions
opts = {
override = function(root_dir, library)
local dotfiles_path = tostring(vim.fn.expand("~/git/dotfiles"))
if string.find(root_dir, dotfiles_path, 1, true) then
library.enabled = true
library.plugins = { "nvim-dap-ui" }
end
end,
},
}

View file

@ -2,7 +2,6 @@
--- @type LazyPluginSpec
return {
"kyazdani42/nvim-tree.lua",
lazy = false,
dependencies = { "kyazdani42/nvim-web-devicons" },
opts = {
diagnostics = {

View file

@ -2,19 +2,7 @@
--- @type LazyPluginSpec
return {
"luukvbaal/statuscol.nvim",
dependencies = {
{
"lewis6991/gitsigns.nvim",
config = true,
},
},
config = function()
local gitsigns = require("gitsigns")
require("which-key").register({
["["] = { h = { gitsigns.prev_hunk, "Previous hunk" } },
["]"] = { h = { gitsigns.next_hunk, "Next hunk" } },
})
local builtin = require("statuscol.builtin")
require("statuscol").setup({
relculright = true,

View file

@ -1,35 +1,20 @@
-- Display possible keybinds
-- Here I have also defined some generic keybinds
-- Plugin specific keybinds are set up in plugin configuration file
local function toggle_theme()
local current_theme = vim.fn.eval("&background")
if current_theme == "dark" then
vim.cmd("set background=light")
else
vim.cmd("set background=dark")
end
end
--- @type LazyPluginSpec
return {
"folke/which-key.nvim",
config = function()
local wk = require("which-key")
wk.setup()
wk.register({
h = { "<cmd>nohlsearch<cr>", "Turn off search highlight" },
b = { toggle_theme, "Toggle background between dark and light" },
co = { '<cmd>silent! execute "%bd|e#|bd#"<cr>', "Close other buffers" },
}, { prefix = "<leader>" })
wk.register({
["<Tab>"] = { "<cmd>bnext<cr>", "Next buffer" },
["<S-Tab>"] = { "<cmd>bprevious<cr>", "Previous buffer" },
require("which-key").add({
{ "<leader>", group = "Leader" },
{ "g", group = "Go to" },
})
-- Exit terminal insert mode with esc
vim.keymap.set("t", "<Esc>", "<C-\\><C-n>", {})
end,
keys = {
{
"<leader>?",
function()
require("which-key").show({ global = false })
end,
desc = "Buffer Local Keymaps (which-key)",
},
},
}