Switched to which key and added most of my old plugins

This commit is contained in:
Warwick New 2026-03-03 11:09:14 +00:00
parent 7ce708971d
commit a519bfa721
10 changed files with 279 additions and 32 deletions

View file

@ -1,17 +1,32 @@
{
"LuaSnip": { "branch": "master", "commit": "dae4f5aaa3574bd0c2b9dd20fb9542a02c10471c" },
"cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" },
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
"friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" },
"gruvbox.nvim": { "branch": "main", "commit": "561126520034a1dac2f78ab063db025d12555998" },
"indent-blankline.nvim": { "branch": "master", "commit": "d28a3f70721c79e3c5f6693057ae929f3d9c0a03" },
"lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" },
"lualine.nvim": { "branch": "master", "commit": "47f91c416daef12db467145e16bed5bbfe00add8" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "a324581a3c83fdacdb9804b79de1cbe00ce18550" },
"mason-nvim-dap.nvim": { "branch": "main", "commit": "9a10e096703966335bd5c46c8c875d5b0690dade" },
"mason.nvim": { "branch": "main", "commit": "44d1e90e1f66e077268191e3ee9d2ac97cc18e65" },
"mini.animate": { "branch": "main", "commit": "8814b56e282cd86635ce9a392ed56b6a85f59731" },
"mini.starter": { "branch": "main", "commit": "cdf909e5bda577e09c61fa6d9a36bb2a88dbc636" },
"neo-tree.nvim": { "branch": "v3.x", "commit": "9d6826582a3e8c84787bd7355df22a2812a1ad59" },
"nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" },
"nvim-autopairs": { "branch": "master", "commit": "59bce2eef357189c3305e25bc6dd2d138c1683f5" },
"nvim-cmp": { "branch": "main", "commit": "da88697d7f45d16852c6b2769dc52387d1ddc45f" },
"nvim-dap": { "branch": "master", "commit": "b516f20b487b0ac6a281e376dfac1d16b5040041" },
"nvim-dap-ui": { "branch": "master", "commit": "cf91d5e2d07c72903d052f5207511bf7ecdb7122" },
"nvim-lsp-file-operations": { "branch": "master", "commit": "b9c795d3973e8eec22706af14959bc60c579e771" },
"nvim-lspconfig": { "branch": "master", "commit": "ead0f5f342d8d323441e7d4b88f0fc436a81ad5f" },
"nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" },
"nvim-treesitter": { "branch": "main", "commit": "cb2cb74f3c3cbbcc17e79cada2060165d616d849" },
"nvim-web-devicons": { "branch": "master", "commit": "737cf6c657898d0c697311d79d361288a1343d50" },
"nvim-window-picker": { "branch": "main", "commit": "6382540b2ae5de6c793d4aa2e3fe6dbb518505ec" },
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
"telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" },
"telescope.nvim": { "branch": "master", "commit": "5255aa27c422de944791318024167ad5d40aad20" }
"telescope.nvim": { "branch": "master", "commit": "5255aa27c422de944791318024167ad5d40aad20" },
"toggleterm.nvim": { "branch": "main", "commit": "9a88eae817ef395952e08650b3283726786fb5fb" },
"which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" }
}

View file

@ -0,0 +1,45 @@
return {
{
"hrsh7th/cmp-nvim-lsp"
},
{
"L3MON4D3/LuaSnip",
dependencies = {
"saadparwaiz1/cmp_luasnip",
"rafamadriz/friendly-snippets",
},
},
{
"hrsh7th/nvim-cmp",
version = false,
config = function()
local cmp = require("cmp")
require("luasnip.loaders.from_vscode").lazy_load()
cmp.setup({
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
mapping = cmp.mapping.preset.insert({
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({ select = true }),
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "luasnip" }, -- For luasnip users.
}, {
{ name = "buffer" },
}),
})
end,
},
}

69
lua/plugins/dap.lua Normal file
View file

@ -0,0 +1,69 @@
return {
"rcarriga/nvim-dap-ui",
dependencies = {
"mfussenegger/nvim-dap",
"nvim-neotest/nvim-nio",
"jay-babu/mason-nvim-dap.nvim"
},
config = function()
local dap, dapui = require("dap"), require("dapui")
dapui.setup();
dap.listeners.before.attach.dapui_config = function()
dapui.open()
end
dap.listeners.before.launch.dapui_config = function()
dapui.open()
end
dap.listeners.before.event_terminated.dapui_config = function()
dapui.close()
end
dap.listeners.before.event_exited.dapui_config = function()
dapui.close()
end
-- C/C++/Rust (via gdb)
dap.adapters.gdb = {
type = "executable",
command = "gdb",
args = { "--interpreter=dap", "--eval-command", "set print pretty on" }
}
local c_conf = {
{
name = "Launch",
type = "gdb",
request = "launch",
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
cwd = "${workspaceFolder}",
stopAtBeginningOfMainSubprogram = false,
},
{
name = "Select and attach to process",
type = "gdb",
request = "attach",
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
pid = function()
local name = vim.fn.input('Executable name (filter): ')
return require("dap.utils").pick_process({ filter = name })
end,
cwd = '${workspaceFolder}'
},
{
name = 'Attach to gdbserver :1234',
type = 'gdb',
request = 'attach',
target = 'localhost:1234',
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
cwd = '${workspaceFolder}'
},
}
dap.configurations.c = c_conf
dap.configurations.cpp = c_conf
end
}

23
lua/plugins/git.lua Normal file
View file

@ -0,0 +1,23 @@
return {
"kdheepak/lazygit.nvim",
--cmd = {
-- "LazyGit",
-- "LazyGitConfig",
-- "LazyGitCurrentFile",
-- "LazyGitFilter",
-- "LazyGitFilterCurrentFile",
--},
dependencies = {
"nvim-lua/plenary.nvim",
"folke/which-key.nvim",
},
config = function()
require('which-key').add({
{ "<leader>g", group = "git" },
{ "<leader>gb", "<Cmd>Telescope git_branches<CR>", desc = "Branches" },
{ "<leader>gg", "<Cmd>Telescope git_commits<CR>", desc = "LazyGit" },
{ "<leader>gl", "<Cmd>LazyGit<CR>", desc = "Commits" },
{ "<leader>gs", "<Cmd>Telescope git_status<CR>", desc = "Status" },
})
end
}

View file

@ -5,6 +5,7 @@ return {
{ "mason-org/mason.nvim", opts = {} },
{
"neovim/nvim-lspconfig",
dependencies = "folke/which-key.nvim",
config = function()
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
@ -15,28 +16,27 @@ return {
-- Buffer local mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local opts = { buffer = ev.buf }
vim.keymap.set('n', '<leader>le', vim.diagnostic.open_float)
vim.keymap.set('n', '<leader>ln', vim.diagnostic.goto_next)
vim.keymap.set('n', '<leader>lN', vim.diagnostic.goto_prev)
vim.keymap.set('n', '<leader>lj', vim.diagnostic.setloclist)
require('which-key').add({
{ "<leader>l", group = "lsp" },
vim.keymap.set('n', '<leader>lD', vim.lsp.buf.declaration, opts)
vim.keymap.set('n', '<leader>ld', vim.lsp.buf.definition, opts)
vim.keymap.set('n', '<leader>lk', vim.lsp.buf.hover, opts)
vim.keymap.set('n', '<leader>li', vim.lsp.buf.implementation, opts)
--vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
--vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts)
--vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts)
--vim.keymap.set('n', '<space>wl', function()
-- print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
--end, opts)
vim.keymap.set('n', '<leader>lt', vim.lsp.buf.type_definition, opts)
vim.keymap.set('n', '<leader>lR', vim.lsp.buf.rename, opts)
vim.keymap.set({ 'n', 'v' }, '<leader>la', vim.lsp.buf.code_action, opts)
vim.keymap.set('n', '<leader>lr', vim.lsp.buf.references, opts)
vim.keymap.set('n', '<space>lf', function()
vim.lsp.buf.format { async = true }
end, opts)
{ '<leader>le', vim.diagnostic.open_float, desc = "Explanation" },
{ '<leader>ln', vim.diagnostic.goto_next, desc = "Next Issue" },
{ '<leader>lN', vim.diagnostic.goto_prev, desc = "Previous Issue" },
{ '<leader>lj', vim.diagnostic.setloclist, desc = "Diagnostic list" },
{ '<leader>lD', vim.lsp.buf.declaration, opts, desc = "Declaration" },
{ '<leader>ld', vim.lsp.buf.definition, opts, desc = "Definition" },
{ '<leader>lk', vim.lsp.buf.hover, opts, desc = "Hover" },
{ '<leader>li', vim.lsp.buf.implementation, opts, desc = "Implmentation" },
{ '<leader>lt', vim.lsp.buf.type_definition, opts, desc = "Type" },
{ '<leader>lR', vim.lsp.buf.rename, opts, desc = "Rename" },
{ '<leader>la', vim.lsp.buf.code_action, opts, desc = "Actions" },
{ '<leader>lr', vim.lsp.buf.references, opts, desc = "References" },
{ '<leader>lf', function()
vim.lsp.buf.format { async = true }
end, opts }
})
end,
})
end

View file

@ -13,10 +13,11 @@ return {
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-neo-tree/neo-tree.nvim", -- makes sure that this loads after Neo-tree.
"folke/which-key.nvim"
},
config = function()
require("lsp-file-operations").setup()
vim.keymap.set("n", "<leader>s", ':Neotree toggle<CR>')
require('which-key').add({ { "<leader>s", ':Neotree toggle<CR>' } })
end,
},
{

View file

@ -0,0 +1,47 @@
return {
{ "lukas-reineke/indent-blankline.nvim", main = "ibl", opts = {} },
{
'echasnovski/mini.animate',
version = false,
config = function()
local animate = require('mini.animate')
animate.setup({
scroll = { timing = animate.gen_timing.linear({ duration = 50, unit = 'total' }) },
cursor = { enable = false }
})
end
},
{
'echasnovski/mini.starter',
version = false,
config = function()
require('mini.starter').setup()
end
},
{
'windwp/nvim-autopairs',
event = "InsertEnter",
opts = {} -- this is equalent to setup({}) function
},
{
'akinsho/toggleterm.nvim',
config = function()
require("toggleterm").setup({
hide_numbers = true,
start_in_insert = true,
shell = vim.o.shell,
})
-- Get out of terminal!
function _G.set_terminal_keymaps()
local opts = { buffer = 0 }
vim.keymap.set('t', '<leader><esc>', [[<C-\><C-n>]], opts)
vim.keymap.set('t', '<C-w>', [[<C-\><C-n><C-w>]], opts)
end
vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()')
-- Open terminal keymap
vim.keymap.set('n', '<leader>t', ":ToggleTerm<CR>", { noremap = true, silent = true })
end
},
}

View file

@ -1,15 +1,22 @@
return {
{
'nvim-telescope/telescope.nvim',
dependencies = { "nvim-lua/plenary.nvim" },
dependencies = { "nvim-lua/plenary.nvim", "folke/which-key.nvim" },
opts = {},
config = function()
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
vim.keymap.set('n', '<leader>fo', builtin.oldfiles, {})
vim.keymap.set('n', '<leader>fg', builtin.live_grep, {})
vim.keymap.set('n', '<leader>fh', builtin.help_tags, {})
end
require('which-key').add({
{ "<leader>ff", builtin.find_files, desc = "Find" },
{ "<leader>fg", builtin.live_grep, desc = "Grep" },
{ "<leader>fh", builtin.help_tags, desc = "Help Tags" },
{ "<leader>fo", builtin.help_tags, desc = "Old Files" },
})
--vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
--vim.keymap.set('n', '<leader>fo', builtin.oldfiles, {})
--vim.keymap.set('n', '<leader>fg', builtin.live_grep, {})
--vim.keymap.set('n', '<leader>fh', builtin.help_tags, {})
end,
},
{
'nvim-telescope/telescope-ui-select.nvim',
@ -26,4 +33,3 @@ return {
end
}
}

41
lua/plugins/which-key.lua Normal file
View file

@ -0,0 +1,41 @@
return {
"folke/which-key.nvim",
lazy = false,
init = function()
vim.o.timeout = true
vim.o.timeoutlen = 0
local wk = require('which-key')
wk.setup({
hide_statusline = false,
default_keymap_settings = {
silent = true,
noremap = true,
},
default_mode = 'n',
})
-- Map window keys to leader w
vim.cmd [[nmap <leader>w <C-w>]]
wk.add({
{ "<leader>w", group = "window" },
{ "<leader>w+", desc = "Increase height" },
{ "<leader>w-", desc = "Decrease height" },
{ "<leader>w<", desc = "Decrease width" },
{ "<leader>w=", desc = "Equally high and wide" },
{ "<leader>w>", desc = "Increase width" },
{ "<leader>wT", desc = "Break out into a new tab" },
{ "<leader>wh", desc = "Go to the left window" },
{ "<leader>wj", desc = "Go to the down window" },
{ "<leader>wk", desc = "Go to the up window" },
{ "<leader>wl", desc = "Go to the right window" },
{ "<leader>wq", desc = "Quit a window" },
{ "<leader>ws", desc = "Split window" },
{ "<leader>wv", desc = "Split window vertically" },
{ "<leader>ww", desc = "Pick Window" },
{ "<leader>wx", desc = "Swap current with next" },
{ "<leader>w|", desc = "Max out the width" },
})
end
}