Rewrite keymap definition, add nvim-navbuddy

Move plugin-specific keymaps into init section of plugin definition
Add nvim-navbuddy for breadcrumbs navigation
Remove aerial as replaced by navbuddy
This commit is contained in:
Evie Litherland-Smith 2023-05-11 08:51:35 +01:00
parent d0ce2d2005
commit 9567908cb7
18 changed files with 92 additions and 162 deletions

View file

@ -1,8 +0,0 @@
return {
-- optionally use on_attach to set keymaps when aerial has attached to a buffer
on_attach = function(bufnr)
-- Jump forwards/backwards with '{' and '}'
vim.keymap.set("n", "{", "<cmd>AerialPrev<CR>", { buffer = bufnr })
vim.keymap.set("n", "}", "<cmd>AerialNext<CR>", { buffer = bufnr })
end,
}

View file

@ -21,4 +21,5 @@ vim.g.loaded_ruby_provider = 0
vim.g.loaded_perl_provider = 0 vim.g.loaded_perl_provider = 0
-- Keymaps -- Keymaps
require "config.keymaps" vim.keymap.set("i", "jk", "<esc>")
vim.keymap.set("n", "<leader>l", "<cmd>Lazy<CR>")

View file

@ -1,102 +0,0 @@
vim.keymap.set("i", "jk", "<esc>")
vim.keymap.set("n", "<leader>l", "<cmd>Lazy<CR>")
vim.keymap.set("n", "<leader>m", "<cmd>Mason<CR>")
vim.keymap.set("n", "<leader>s", "<cmd>Dashboard<CR>")
vim.keymap.set("n", "<leader>z", "<cmd>ZenMode<CR>")
vim.keymap.set("n", "<leader>gf", "<cmd>Neogit<CR>")
vim.keymap.set("n", "<leader>gg", "<cmd>Neogit kind=split<CR>")
vim.keymap.set("n", "<leader>cc", "<cmd>Neogit commit<CR>")
vim.keymap.set("n", "<leader>gp", "<cmd>Neogit kind=split pull<CR>")
vim.keymap.set("n", "<leader>gP", "<cmd>Neogit kind=split push<CR>")
vim.keymap.set("n", "<leader>tt", "<cmd>ToggleTerm direction=horizontal<CR>")
vim.keymap.set({ "n", "t" }, "<A-h>", "<CMD>NavigatorLeft<CR>")
vim.keymap.set({ "n", "t" }, "<A-l>", "<CMD>NavigatorRight<CR>")
vim.keymap.set({ "n", "t" }, "<A-k>", "<CMD>NavigatorUp<CR>")
vim.keymap.set({ "n", "t" }, "<A-j>", "<CMD>NavigatorDown<CR>")
vim.keymap.set({ "n", "t" }, "<A-p>", "<CMD>NavigatorPrevious<CR>")
-- Telescope
vim.keymap.set("n", "<leader>;", "<cmd>Telescope builtin<cr>")
vim.keymap.set("n", "<leader>ff", "<cmd>Telescope find_files<cr>")
vim.keymap.set("n", "<leader>fg", "<cmd>Telescope live_grep<cr>")
vim.keymap.set("n", "<leader>fb", "<cmd>Telescope buffers<cr>")
vim.keymap.set("n", "<leader>fl", "<cmd>Telescope lsp_document_symbols<cr>")
vim.keymap.set("n", "<leader>fe", "<cmd>Telescope diagnostics<cr>")
vim.keymap.set("n", "<leader>fs", "<cmd>Telescope treesitter<cr>")
vim.keymap.set("n", "<leader>fz", "<cmd>Telescope current_buffer_fuzzy_find<cr>")
vim.keymap.set("n", "<leader>fp", "<cmd>Telescope projects<cr>")
-- Hop
vim.keymap.set("n", "<leader>hw", "<cmd>HopWord<cr>")
vim.keymap.set("n", "<leader>hl", "<cmd>HopLine<cr>")
-- Neotree
vim.keymap.set("n", "<leader>nn", "<cmd>Neotree float reveal reveal_force_cwd<cr>")
vim.keymap.set("n", "<leader>nb", "<cmd>Neotree toggle show buffers right<cr>")
vim.keymap.set("n", "<leader>ns", "<cmd>Neotree float git_status<cr>")
-- Aerial
vim.keymap.set("n", "<leader>a", "<cmd>AerialToggle!<CR>")
-- Trouble
vim.keymap.set("n", "<leader>xx", "<cmd>TroubleToggle<cr>")
vim.keymap.set("n", "<leader>xw", "<cmd>TroubleToggle workspace_diagnostics<cr>")
vim.keymap.set("n", "<leader>xd", "<cmd>TroubleToggle document_diagnostics<cr>")
vim.keymap.set("n", "<leader>xq", "<cmd>TroubleToggle quickfix<cr>")
vim.keymap.set("n", "<leader>xl", "<cmd>TroubleToggle loclist<cr>")
-- nvim-test
vim.keymap.set("n", "<leader>ts", "<cmd>TestSuite<cr>")
vim.keymap.set("n", "<leader>tf", "<cmd>TestFile<cr>")
vim.keymap.set("n", "<leader>te", "<cmd>TestEdit<cr>")
vim.keymap.set("n", "<leader>tn", "<cmd>TestNearest<cr>")
vim.keymap.set("n", "<leader>tl", "<cmd>TestLast<cr>")
vim.keymap.set("n", "<leader>tv", "<cmd>TestVisit<cr>")
vim.keymap.set("n", "<leader>ti", "<cmd>TestInfo<cr>")
-- barbar
-- local map = vim.api.nvim_set_keymap
local map = vim.keymap.set
local opts = { noremap = true, silent = true }
-- Move to previous/next
map('n', '<A-,>', '<Cmd>BufferPrevious<CR>', opts)
map('n', '<A-.>', '<Cmd>BufferNext<CR>', opts)
-- Re-order to previous/next
map('n', '<A-<>', '<Cmd>BufferMovePrevious<CR>', opts)
map('n', '<A->>', '<Cmd>BufferMoveNext<CR>', opts)
-- Goto buffer in position...
map('n', '<A-1>', '<Cmd>BufferGoto 1<CR>', opts)
map('n', '<A-2>', '<Cmd>BufferGoto 2<CR>', opts)
map('n', '<A-3>', '<Cmd>BufferGoto 3<CR>', opts)
map('n', '<A-4>', '<Cmd>BufferGoto 4<CR>', opts)
map('n', '<A-5>', '<Cmd>BufferGoto 5<CR>', opts)
map('n', '<A-6>', '<Cmd>BufferGoto 6<CR>', opts)
map('n', '<A-7>', '<Cmd>BufferGoto 7<CR>', opts)
map('n', '<A-8>', '<Cmd>BufferGoto 8<CR>', opts)
map('n', '<A-9>', '<Cmd>BufferGoto 9<CR>', opts)
map('n', '<A-0>', '<Cmd>BufferLast<CR>', opts)
-- Pin/unpin buffer
map('n', '<A-p>', '<Cmd>BufferPin<CR>', opts)
-- Close buffer
map('n', '<A-c>', '<Cmd>BufferClose<CR>', opts)
map('n', '<A-C>', '<Cmd>BufferCloseAllButCurrentOrPinned<CR>', opts)
-- Wipeout buffer
-- :BufferWipeout
-- Close commands
-- :BufferCloseAllButCurrent
-- :BufferCloseAllButPinned
-- :BufferCloseAllButCurrentOrPinned
-- :BufferCloseBuffersLeft
-- :BufferCloseBuffersRight
-- Magic buffer-picking mode
map('n', '<C-p>', '<Cmd>BufferPick<CR>', opts)
-- Sort automatically by...
map('n', '<Space>bb', '<Cmd>BufferOrderByBufferNumber<CR>', opts)
map('n', '<Space>bd', '<Cmd>BufferOrderByDirectory<CR>', opts)
map('n', '<Space>bl', '<Cmd>BufferOrderByLanguage<CR>', opts)
map('n', '<Space>bw', '<Cmd>BufferOrderByWindowNumber<CR>', opts)
-- Other:
-- :BarbarEnable - enables barbar (enabled by default)
-- :BarbarDisable - very bad command, should never be used

View file

@ -30,7 +30,7 @@ return {
}, },
sections = { sections = {
lualine_a = { "mode" }, lualine_a = { "mode" },
lualine_b = { "filetype", { "branch", icon = "󰊢" }, "diff" }, lualine_b = { "filename", { "branch", icon = "󰊢" }, "diff" },
lualine_c = { lsp_progress, "diagnostics" }, lualine_c = { lsp_progress, "diagnostics" },
lualine_x = {}, lualine_x = {},
lualine_y = { "searchcount", "progress", "selectioncount" }, lualine_y = { "searchcount", "progress", "selectioncount" },
@ -38,7 +38,7 @@ return {
}, },
tabline = { tabline = {
lualine_a = {}, lualine_a = {},
lualine_b = { { "filetype", icon_only = true }, "fileformat", "encoding" }, lualine_b = { "filetype", "fileformat", "encoding" },
lualine_c = { "require('nvim-navic').get_location()" }, lualine_c = { "require('nvim-navic').get_location()" },
lualine_x = { { "windows", use_mode_colors = true } }, lualine_x = { { "windows", use_mode_colors = true } },
lualine_y = {}, lualine_y = {},

View file

@ -1,5 +1,9 @@
return { return {
disable_builtin_notifications = true,
kind = "floating", kind = "floating",
commit_popup = { kind = "floating" },
preview_buffer = { kind = "floating" },
popup = { kind = "floating" },
integrations = { integrations = {
diffview = true, diffview = true,
}, },

View file

@ -0,0 +1,4 @@
return {
icons = require("config.nvim-navic").icons,
window = { border = "rounded" },
}

View file

@ -19,6 +19,9 @@ local on_attach = function(client, bufnr)
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, bufopts) vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, bufopts)
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, bufopts) vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, bufopts)
vim.keymap.set("n", "<leader>i", require "lsp.formatting", bufopts) vim.keymap.set("n", "<leader>i", require "lsp.formatting", bufopts)
if client.server_capabilities.documentSymbolProvider then require("nvim-navic").attach(client, bufnr) end if client.server_capabilities.documentSymbolProvider then
require("nvim-navic").attach(client, bufnr)
require("nvim-navbuddy").attach(client, bufnr)
end
end end
return on_attach return on_attach

View file

@ -1,17 +0,0 @@
return {
"stevearc/aerial.nvim",
name = "aerial",
cmd = {
"AerialOpen",
"AerialOpenAll",
"AerialNext",
"AerialPrev",
"AerialGo",
"AerialInfo",
"AerialToggle",
},
config = function()
require("aerial").setup(require "config.aerial")
vim.keymap.set("n", "<leader>fa", "<cmd>Telescope aerial<cr>")
end,
}

View file

@ -1,5 +1,9 @@
return { return {
'phaazon/hop.nvim', "phaazon/hop.nvim",
cmd = { "HopWord", "HopLine" }, cmd = { "HopWord", "HopLine" },
init = function()
vim.keymap.set("n", "<leader>hw", "<cmd>HopWord<cr>")
vim.keymap.set("n", "<leader>hl", "<cmd>HopLine<cr>")
end,
config = true, config = true,
} }

View file

@ -17,6 +17,12 @@ return {
{ "mfussenegger/nvim-dap", lazy = true }, { "mfussenegger/nvim-dap", lazy = true },
{ "folke/neodev.nvim", dependencies = { "hrsh7th/nvim-cmp" }, lazy = true }, { "folke/neodev.nvim", dependencies = { "hrsh7th/nvim-cmp" }, lazy = true },
{ "SmiteshP/nvim-navic", lazy = true, config = true, opts = require "config.nvim-navic" }, { "SmiteshP/nvim-navic", lazy = true, config = true, opts = require "config.nvim-navic" },
{
"SmiteshP/nvim-navbuddy",
dependencies = { "SmiteshP/nvim-navic", "MunifTanjim/nui.nvim" },
config = true,
opts = require "config.nvim-navbuddy",
},
}, },
config = function() config = function()
require "lsp.config" require "lsp.config"

View file

@ -7,5 +7,12 @@ return {
"NavigatorRight", "NavigatorRight",
"NavigatorPrevious", "NavigatorPrevious",
}, },
config = function() require("Navigator").setup() end, init = function()
vim.keymap.set({ "n", "t" }, "<A-h>", "<CMD>NavigatorLeft<CR>")
vim.keymap.set({ "n", "t" }, "<A-l>", "<CMD>NavigatorRight<CR>")
vim.keymap.set({ "n", "t" }, "<A-k>", "<CMD>NavigatorUp<CR>")
vim.keymap.set({ "n", "t" }, "<A-j>", "<CMD>NavigatorDown<CR>")
vim.keymap.set({ "n", "t" }, "<A-p>", "<CMD>NavigatorPrevious<CR>")
end,
config = true,
} }

View file

@ -1,9 +1,16 @@
return { return {
"TimUntersberger/neogit", "TimUntersberger/neogit",
config = function() require("neogit").setup(require "config.neogit") end,
cmd = "Neogit",
dependencies = { dependencies = {
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",
"sindrets/diffview.nvim", "sindrets/diffview.nvim",
}, },
cmd = "Neogit",
init = function()
vim.keymap.set("n", "<leader>gg", "<cmd>Neogit<CR>")
vim.keymap.set("n", "<leader>cc", "<cmd>Neogit commit<CR>")
vim.keymap.set("n", "<leader>gp", "<cmd>Neogit pull<CR>")
vim.keymap.set("n", "<leader>gP", "<cmd>Neogit push<CR>")
end,
config = true,
opts = require "config.neogit",
} }

View file

@ -12,6 +12,10 @@ return {
vim.g.loaded_netrw = 1 vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1 vim.g.loaded_netrwPlugin = 1
vim.g.neo_tree_remove_legacy_commands = 1 vim.g.neo_tree_remove_legacy_commands = 1
vim.keymap.set("n", "<leader>nn", "<cmd>Neotree float reveal reveal_force_cwd<cr>")
vim.keymap.set("n", "<leader>nb", "<cmd>Neotree toggle show buffers right<cr>")
vim.keymap.set("n", "<leader>ns", "<cmd>Neotree float git_status<cr>")
end, end,
config = function() require("neo-tree").setup(require "config.neotree") end, config = true,
opts = require "config.neotree",
} }

View file

@ -9,5 +9,15 @@ return {
"TestInfo", "TestInfo",
"TestSuite", "TestSuite",
}, },
config = function() require("nvim-test").setup(require "config.nvim_test") end, init = function()
vim.keymap.set("n", "<leader>ts", "<cmd>TestSuite<cr>")
vim.keymap.set("n", "<leader>tf", "<cmd>TestFile<cr>")
vim.keymap.set("n", "<leader>te", "<cmd>TestEdit<cr>")
vim.keymap.set("n", "<leader>tn", "<cmd>TestNearest<cr>")
vim.keymap.set("n", "<leader>tl", "<cmd>TestLast<cr>")
vim.keymap.set("n", "<leader>tv", "<cmd>TestVisit<cr>")
vim.keymap.set("n", "<leader>ti", "<cmd>TestInfo<cr>")
end,
config = true,
otps = require "config.nvim_test",
} }

View file

@ -2,6 +2,17 @@ return {
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
branch = "0.1.x", branch = "0.1.x",
cmd = "Telescope", cmd = "Telescope",
init = function()
vim.keymap.set("n", "<leader>;", "<cmd>Telescope builtin<cr>")
vim.keymap.set("n", "<leader>ff", "<cmd>Telescope find_files<cr>")
vim.keymap.set("n", "<leader>fg", "<cmd>Telescope live_grep<cr>")
vim.keymap.set("n", "<leader>fb", "<cmd>Telescope buffers<cr>")
vim.keymap.set("n", "<leader>fl", "<cmd>Telescope lsp_document_symbols<cr>")
vim.keymap.set("n", "<leader>fe", "<cmd>Telescope diagnostics<cr>")
vim.keymap.set("n", "<leader>fs", "<cmd>Telescope treesitter<cr>")
vim.keymap.set("n", "<leader>fz", "<cmd>Telescope current_buffer_fuzzy_find<cr>")
vim.keymap.set("n", "<leader>fp", "<cmd>Telescope projects<cr>")
end,
config = function() config = function()
require("telescope").setup(require "config.telescope") require("telescope").setup(require "config.telescope")
require("telescope").load_extension "fzf" require("telescope").load_extension "fzf"
@ -16,30 +27,15 @@ return {
dependencies = { dependencies = {
{ {
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",
{ { "nvim-telescope/telescope-fzf-native.nvim", build = "make" },
"nvim-telescope/telescope-fzf-native.nvim", { "tsakirist/telescope-lazy.nvim", dependencies = { "folke/lazy.nvim" } },
build = "make", { "benfowler/telescope-luasnip.nvim", dependencies = { "L3MON4D3/LuaSnip" } },
},
{
"tsakirist/telescope-lazy.nvim",
dependencies = { "folke/lazy.nvim" },
},
{
"benfowler/telescope-luasnip.nvim",
dependencies = { "L3MON4D3/LuaSnip" },
},
{ {
"paopaol/telescope-git-diffs.nvim", "paopaol/telescope-git-diffs.nvim",
dependencies = { dependencies = { "nvim-lua/plenary.nvim", "sindrets/diffview.nvim" },
"nvim-lua/plenary.nvim",
"sindrets/diffview.nvim",
},
}, },
"FeiyouG/command_center.nvim", "FeiyouG/command_center.nvim",
{ { "barrett-ruth/telescope-http.nvim", dependencies = { "savq/paq-nvim" } },
"barrett-ruth/telescope-http.nvim",
dependencies = { "savq/paq-nvim" },
},
"aaronhallaert/advanced-git-search.nvim", "aaronhallaert/advanced-git-search.nvim",
}, },
}, },

View file

@ -1,6 +1,7 @@
return { return {
"akinsho/toggleterm.nvim", "akinsho/toggleterm.nvim",
version = "*", version = "*",
config = true,
cmd = { "ToggleTerm" }, cmd = { "ToggleTerm" },
init = function() vim.keymap.set("n", "<leader>tt", "<cmd>ToggleTerm direction=horizontal<CR>") end,
config = true,
} }

View file

@ -2,5 +2,13 @@ return {
"folke/trouble.nvim", "folke/trouble.nvim",
dependencies = "nvim-tree/nvim-web-devicons", dependencies = "nvim-tree/nvim-web-devicons",
cmd = "TroubleToggle", cmd = "TroubleToggle",
config = function() require("trouble").setup(require "config.trouble") end, init = function()
vim.keymap.set("n", "<leader>xx", "<cmd>TroubleToggle<cr>")
vim.keymap.set("n", "<leader>xw", "<cmd>TroubleToggle workspace_diagnostics<cr>")
vim.keymap.set("n", "<leader>xd", "<cmd>TroubleToggle document_diagnostics<cr>")
vim.keymap.set("n", "<leader>xq", "<cmd>TroubleToggle quickfix<cr>")
vim.keymap.set("n", "<leader>xl", "<cmd>TroubleToggle loclist<cr>")
end,
config = true,
opts = require "config.trouble",
} }

View file

@ -1,7 +1,9 @@
return { return {
"folke/zen-mode.nvim", "folke/zen-mode.nvim",
cmd = "ZenMode", cmd = { "ZenMode" },
config = function() require("zen-mode").setup(require "config.zen_mode") end, init = function() vim.keymap.set("n", "<leader>z", "<cmd>ZenMode<CR>") end,
config = true,
opts = require "config.zen_mode",
dependencies = { dependencies = {
"folke/twilight.nvim", "folke/twilight.nvim",
cmd = "Twilight", cmd = "Twilight",