add which-key

This commit is contained in:
2025-05-12 23:41:48 +02:00
parent bf0056358b
commit 90beed3354
11 changed files with 121 additions and 126 deletions

View File

@@ -8,16 +8,15 @@ vim.opt.relativenumber = false
vim.opt.number = true vim.opt.number = true
local builtin = require("telescope.builtin") local builtin = require("telescope.builtin")
vim.keymap.set("n", "<leader>ff", builtin.find_files, {}) vim.keymap.set("n", "<leader>ff", builtin.find_files, { desc = "Find files" })
vim.keymap.set("n", "<leader>fg", builtin.live_grep, {}) vim.keymap.set("n", "<leader>fg", builtin.live_grep, { desc = "Live grep files" })
vim.keymap.set("n", "<leader>fb", builtin.buffers, {}) vim.keymap.set("n", "<leader>fb", builtin.buffers, { desc = "Find buffers" })
vim.keymap.set("n", "<leader>fh", builtin.help_tags, {}) vim.keymap.set("n", "<leader>fh", builtin.help_tags, { desc = "Help tags" })
vim.keymap.set("n", "<leader>F", function() vim.keymap.set("n", "<leader>F", function()
require("conform").format({ async = true }) require("conform").format({ async = true })
end, {}) end, { desc = "Format file" })
vim.keymap.set("n", "<leader>n", ":BufferLineCycleNext<CR>", {})
vim.keymap.set("n", "<leader>b", ":BufferLineCyclePrev<CR>", {})
vim.keymap.set("n", "<leader>q", ":bd<CR>", {})
vim.keymap.set("n", "<leader>n", ":BufferLineCycleNext<CR>", { desc = "Go to the next buffer" })
vim.keymap.set("n", "<leader>b", ":BufferLineCyclePrev<CR>", { desc = "Go to the previous buffer" })
vim.keymap.set("n", "<leader>q", ":bd<CR>", { desc = "Close current buffer" })

View File

@@ -1,17 +1,17 @@
-- Bootstrap lazy.nvim -- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git" local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({ vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" }, { "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" }, { out, "WarningMsg" },
{ "\nPress any key to exit..." }, { "\nPress any key to exit..." },
}, true, {}) }, true, {})
vim.fn.getchar() vim.fn.getchar()
os.exit(1) os.exit(1)
end end
end end
vim.opt.rtp:prepend(lazypath) vim.opt.rtp:prepend(lazypath)
@@ -23,14 +23,13 @@ vim.g.maplocalleader = "\\"
-- Setup lazy.nvim -- Setup lazy.nvim
require("lazy").setup({ require("lazy").setup({
spec = { spec = {
-- import your plugins -- import your plugins
{ import = "plugins" }, { import = "plugins" },
}, },
-- Configure any other settings here. See the documentation for more details. -- Configure any other settings here. See the documentation for more details.
-- colorscheme that will be used when installing plugins. -- colorscheme that will be used when installing plugins.
install = { colorscheme = { "catppuccin-mocha" } }, install = { colorscheme = { "catppuccin-mocha" } },
-- automatically check for plugin updates -- automatically check for plugin updates
checker = { enabled = true }, checker = { enabled = true },
}) })

View File

@@ -1,54 +1,53 @@
return { return {
'saghen/blink.cmp', "saghen/blink.cmp",
-- optional: provides snippets for the snippet source -- optional: provides snippets for the snippet source
--dependencies = { 'rafamadriz/friendly-snippets' }, --dependencies = { 'rafamadriz/friendly-snippets' },
-- use a release tag to download pre-built binaries -- use a release tag to download pre-built binaries
version = '1.*', version = "1.*",
-- AND/OR build from source, requires nightly: https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust -- AND/OR build from source, requires nightly: https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust
-- build = 'cargo build --release', -- build = 'cargo build --release',
-- If you use nix, you can build from source using latest nightly rust with: -- If you use nix, you can build from source using latest nightly rust with:
-- build = 'nix run .#build-plugin', -- build = 'nix run .#build-plugin',
---@module 'blink.cmp' ---@module 'blink.cmp'
---@type blink.cmp.Config ---@type blink.cmp.Config
opts = { opts = {
-- 'default' (recommended) for mappings similar to built-in completions (C-y to accept) -- 'default' (recommended) for mappings similar to built-in completions (C-y to accept)
-- 'super-tab' for mappings similar to vscode (tab to accept) -- 'super-tab' for mappings similar to vscode (tab to accept)
-- 'enter' for enter to accept -- 'enter' for enter to accept
-- 'none' for no mappings -- 'none' for no mappings
-- --
-- All presets have the following mappings: -- All presets have the following mappings:
-- C-space: Open menu or open docs if already open -- C-space: Open menu or open docs if already open
-- C-n/C-p or Up/Down: Select next/previous item -- C-n/C-p or Up/Down: Select next/previous item
-- C-e: Hide menu -- C-e: Hide menu
-- C-k: Toggle signature help (if signature.enabled = true) -- C-k: Toggle signature help (if signature.enabled = true)
-- --
-- See :h blink-cmp-config-keymap for defining your own keymap -- See :h blink-cmp-config-keymap for defining your own keymap
keymap = { preset = 'super-tab' }, keymap = { preset = "super-tab" },
appearance = { appearance = {
-- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font' -- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
-- Adjusts spacing to ensure icons are aligned -- Adjusts spacing to ensure icons are aligned
nerd_font_variant = 'mono' nerd_font_variant = "mono",
}, },
-- (Default) Only show the documentation popup when manually triggered -- (Default) Only show the documentation popup when manually triggered
completion = { documentation = { auto_show = false } }, completion = { documentation = { auto_show = false } },
-- Default list of enabled providers defined so that you can extend it -- Default list of enabled providers defined so that you can extend it
-- elsewhere in your config, without redefining it, due to `opts_extend` -- elsewhere in your config, without redefining it, due to `opts_extend`
sources = { sources = {
default = { 'lsp', 'path', 'snippets', 'buffer' }, default = { "lsp", "path", "snippets", "buffer" },
}, },
-- (Default) Rust fuzzy matcher for typo resistance and significantly better performance -- (Default) Rust fuzzy matcher for typo resistance and significantly better performance
-- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation, -- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation,
-- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"` -- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"`
-- --
-- See the fuzzy documentation for more information -- See the fuzzy documentation for more information
fuzzy = { implementation = "prefer_rust_with_warning" } fuzzy = { implementation = "prefer_rust_with_warning" },
}, },
opts_extend = { "sources.default" } opts_extend = { "sources.default" },
} }

View File

@@ -13,7 +13,6 @@ return {
buffer_close_icon = "X", buffer_close_icon = "X",
modified_icon = "U", modified_icon = "U",
} },
} },
} }

View File

@@ -6,4 +6,3 @@ return {
vim.cmd([[colorscheme catppuccin-macchiato]]) vim.cmd([[colorscheme catppuccin-macchiato]])
end, end,
} }

View File

@@ -3,7 +3,8 @@ return {
opts = { opts = {
formatters_by_ft = { formatters_by_ft = {
python = { "black" }, python = { "black" },
c = { "clang-format" } c = { "clang-format" },
lua = { "stylua" },
}, },
}, },
} }

View File

@@ -1,21 +1,18 @@
return { return {
'neovim/nvim-lspconfig', "neovim/nvim-lspconfig",
dependencies = { 'saghen/blink.cmp' }, dependencies = { "saghen/blink.cmp" },
opts = {
-- example using `opts` for defining servers servers = {
opts = { clangd = {},
servers = { },
clangd = {}, },
} config = function(_, opts)
}, local lspconfig = require("lspconfig")
config = function(_, opts) for server, config in pairs(opts.servers) do
local lspconfig = require('lspconfig') -- passing config.capabilities to blink.cmp merges with the capabilities in your
for server, config in pairs(opts.servers) do -- `opts[server].capabilities, if you've defined it
-- passing config.capabilities to blink.cmp merges with the capabilities in your config.capabilities = require("blink.cmp").get_lsp_capabilities(config.capabilities)
-- `opts[server].capabilities, if you've defined it lspconfig[server].setup(config)
config.capabilities = require('blink.cmp').get_lsp_capabilities(config.capabilities) end
lspconfig[server].setup(config) end,
end
end
} }

View File

@@ -1,15 +1,14 @@
return { return {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
build = ":TSUpdate", build = ":TSUpdate",
config = function () config = function()
local configs = require("nvim-treesitter.configs") local configs = require("nvim-treesitter.configs")
configs.setup({ configs.setup({
ensure_installed = { "c", "lua", "vim", "vimdoc" }, ensure_installed = { "c", "lua", "vim", "vimdoc" },
sync_install = false, sync_install = false,
highlight = { enable = true }, highlight = { enable = true },
indent = { enable = true }, indent = { enable = true },
}) })
end end,
} }

View File

@@ -1,5 +1,5 @@
return { return {
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
tag = "0.1.8", tag = "0.1.8",
dependencies = { "nvim-lua/plenary.nvim" } dependencies = { "nvim-lua/plenary.nvim" },
} }

View File

@@ -0,0 +1,10 @@
return {
"folke/which-key.nvim",
event = "VeryLazy",
opts = {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
},
keys = {},
}

View File

@@ -7,19 +7,12 @@ My personal dotfiles!
## Requirements ## Requirements
- [ripgrep](https://github.com/BurntSushi/ripgrep) - [ripgrep](https://github.com/BurntSushi/ripgrep)
- clangd - clangd
- stylua
- Optional
## Installation ## Installation
Just copy the folders under `.config` in your `$HOME/.config/`. Just copy the folders under `.config` in your `$HOME/.config/`.
## Keybindings ## Keybindings
The leader key is the `Space`. The leader key is the `Space`. Press it to show all the keybindings.
`<leader>ff` - Find files
`<leader>fg` - Live grep
`<leader>fb` - Show buffers
`<leader>fh` - Help tags
`<leader>F` - Format file (only works with C files)
`<leader>q` - Quit buffer
`<leader>n` - Next buffer
`<ledaer>b` - Previous buffer