Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated configuration files for which-key version3 mapping spec changes #188

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lua/user/comment.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ local M = {

function M.config()
local wk = require "which-key"
wk.register {
["<leader>/"] = { "<Plug>(comment_toggle_linewise_current)", "Comment" },
wk.add {
{ "<leader>/", "<Plug>(comment_toggle_linewise_current)", desc = "Comment" },
}

wk.register {
["<leader>/"] = { "<Plug>(comment_toggle_linewise_visual)", "Comment", mode = "v" },
wk.add {
{ "<leader>/", "<Plug>(comment_toggle_linewise_visual)", desc = "Comment", mode = "v" },
}

vim.g.skip_ts_context_commentstring_module = true
Expand Down
26 changes: 10 additions & 16 deletions lua/user/gitsigns.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,16 @@ M.config = function()
local icons = require "user.icons"

local wk = require "which-key"
wk.register {
["<leader>gj"] = { "<cmd>lua require 'gitsigns'.next_hunk({navigation_message = false})<cr>", "Next Hunk" },
["<leader>gk"] = { "<cmd>lua require 'gitsigns'.prev_hunk({navigation_message = false})<cr>", "Prev Hunk" },
["<leader>gp"] = { "<cmd>lua require 'gitsigns'.preview_hunk()<cr>", "Preview Hunk" },
["<leader>gr"] = { "<cmd>lua require 'gitsigns'.reset_hunk()<cr>", "Reset Hunk" },
["<leader>gl"] = { "<cmd>lua require 'gitsigns'.blame_line()<cr>", "Blame" },
["<leader>gR"] = { "<cmd>lua require 'gitsigns'.reset_buffer()<cr>", "Reset Buffer" },
["<leader>gs"] = { "<cmd>lua require 'gitsigns'.stage_hunk()<cr>", "Stage Hunk" },
["<leader>gu"] = {
"<cmd>lua require 'gitsigns'.undo_stage_hunk()<cr>",
"Undo Stage Hunk",
},
["<leader>gd"] = {
"<cmd>Gitsigns diffthis HEAD<cr>",
"Git Diff",
},
wk.add {
{ "<leader>gj", "<cmd>lua require 'gitsigns'.next_hunk({navigation_message = false})<cr>", desc = "Next Hunk" },
{ "<leader>gk", "<cmd>lua require 'gitsigns'.prev_hunk({navigation_message = false})<cr>", desc = "Prev Hunk" },
{ "<leader>gp", "<cmd>lua require 'gitsigns'.preview_hunk()<cr>", desc = "Preview Hunk" },
{ "<leader>gr", "<cmd>lua require 'gitsigns'.reset_hunk()<cr>", desc = "Reset Hunk" },
{ "<leader>gl", "<cmd>lua require 'gitsigns'.blame_line()<cr>", desc = "Blame" },
{ "<leader>gR", "<cmd>lua require 'gitsigns'.reset_buffer()<cr>", desc = "Reset Buffer" },
{ "<leader>gs", "<cmd>lua require 'gitsigns'.stage_hunk()<cr>", desc = "Stage Hunk" },
{ "<leader>gu", "<cmd>lua require 'gitsigns'.undo_stage_hunk()<cr>", desc = "Undo Stage Hunk" },
{ "<leader>gd", "<cmd>Gitsigns diffthis HEAD<cr>", desc = "Git Diff" },
}

require("gitsigns").setup {
Expand Down
31 changes: 15 additions & 16 deletions lua/user/lspconfig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,25 @@ end

function M.config()
local wk = require "which-key"
wk.register {
["<leader>la"] = { "<cmd>lua vim.lsp.buf.code_action()<cr>", "Code Action" },
["<leader>lf"] = {
wk.add {
{ "<leader>la", "<cmd>lua vim.lsp.buf.code_action()<cr>", desc = "Code Action" },
{
"<leader>lf",
"<cmd>lua vim.lsp.buf.format({async = true, filter = function(client) return client.name ~= 'typescript-tools' end})<cr>",
"Format",
desc = "Format",
},
["<leader>li"] = { "<cmd>LspInfo<cr>", "Info" },
["<leader>lj"] = { "<cmd>lua vim.diagnostic.goto_next()<cr>", "Next Diagnostic" },
["<leader>lh"] = { "<cmd>lua require('user.lspconfig').toggle_inlay_hints()<cr>", "Hints" },
["<leader>lk"] = { "<cmd>lua vim.diagnostic.goto_prev()<cr>", "Prev Diagnostic" },
["<leader>ll"] = { "<cmd>lua vim.lsp.codelens.run()<cr>", "CodeLens Action" },
["<leader>lq"] = { "<cmd>lua vim.diagnostic.setloclist()<cr>", "Quickfix" },
["<leader>lr"] = { "<cmd>lua vim.lsp.buf.rename()<cr>", "Rename" },
{ "<leader>lh", "<cmd>lua require('user.lspconfig').toggle_inlay_hints()<cr>", desc = "Hints" },
{ "<leader>li", "<cmd>LspInfo<cr>", desc = "Info" },
{ "<leader>lj", "<cmd>lua vim.diagnostic.goto_next()<cr>", desc = "Next Diagnostic" },
{ "<leader>lk", "<cmd>lua vim.diagnostic.goto_prev()<cr>", desc = "Prev Diagnostic" },
{ "<leader>ll", "<cmd>lua vim.lsp.codelens.run()<cr>", desc = "CodeLens Action" },
{ "<leader>lq", "<cmd>lua vim.diagnostic.setloclist()<cr>", desc = "Quickfix" },
{ "<leader>lr", "<cmd>lua vim.lsp.buf.rename()<cr>", desc = "Rename" },
}

wk.register {
["<leader>la"] = {
name = "LSP",
a = { "<cmd>lua vim.lsp.buf.code_action()<cr>", "Code Action", mode = "v" },
},
wk.add {
{ "<leader>la", group = "LSP" },
{ "<leader>laa", "<cmd>lua vim.lsp.buf.code_action()<cr>", desc = "Code Action", mode = "v" },
}

local lspconfig = require "lspconfig"
Expand Down
4 changes: 2 additions & 2 deletions lua/user/neogit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ local M = {
function M.config()
local icons = require "user.icons"
local wk = require "which-key"
wk.register {
["<leader>gg"] = { "<cmd>Neogit<CR>", "Neogit" },
wk.add {
{ "<leader>gg", "<cmd>Neogit<CR>", desc = "Neogit" },
}

require("neogit").setup {
Expand Down
12 changes: 6 additions & 6 deletions lua/user/neotest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ local M = {

function M.config()
local wk = require "which-key"
wk.register {
["<leader>tt"] = { "<cmd>lua require'neotest'.run.run()<cr>", "Test Nearest" },
["<leader>tf"] = { "<cmd>lua require('neotest').run.run(vim.fn.expand('%'))<cr>", "Test File" },
["<leader>td"] = { "<cmd>lua require('neotest').run.run({strategy = 'dap'})<cr>", "Debug Test" },
["<leader>ts"] = { "<cmd>lua require('neotest').run.stop()<cr>", "Test Stop" },
["<leader>ta"] = { "<cmd>lua require('neotest').run.attach()<cr>", "Attach Test" },
wk.add {
{ "<leader>tt", "<cmd>lua require'neotest'.run.run()<cr>", desc = "Test Nearest" },
{ "<leader>tf", "<cmd>lua require('neotest').run.run(vim.fn.expand('%'))<cr>", desc = "Test File" },
{ "<leader>td", "<cmd>lua require('neotest').run.run({strategy = 'dap'})<cr>", desc = "Debug Test" },
{ "<leader>ts", "<cmd>lua require('neotest').run.stop()<cr>", desc = "Test Stop" },
{ "<leader>ta", "<cmd>lua require('neotest').run.attach()<cr>", desc = "Attach Test" },
}

---@diagnostic disable: missing-fields
Expand Down
4 changes: 2 additions & 2 deletions lua/user/nvimtree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ local M = {

function M.config()
local wk = require "which-key"
wk.register {
["<leader>e"] = { "<cmd>NvimTreeToggle<CR>", "Explorer" },
wk.add {
{ "<leader>e", "<cmd>NvimTreeToggle<CR>", desc = "Explorer" },
}

local icons = require "user.icons"
Expand Down
20 changes: 10 additions & 10 deletions lua/user/telescope.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ local M = {

function M.config()
local wk = require "which-key"
wk.register {
["<leader>bb"] = { "<cmd>Telescope buffers previewer=false<cr>", "Find" },
["<leader>fb"] = { "<cmd>Telescope git_branches<cr>", "Checkout branch" },
["<leader>fc"] = { "<cmd>Telescope colorscheme<cr>", "Colorscheme" },
["<leader>ff"] = { "<cmd>Telescope find_files<cr>", "Find files" },
["<leader>fp"] = { "<cmd>lua require('telescope').extensions.projects.projects()<cr>", "Projects" },
["<leader>ft"] = { "<cmd>Telescope live_grep<cr>", "Find Text" },
["<leader>fh"] = { "<cmd>Telescope help_tags<cr>", "Help" },
["<leader>fl"] = { "<cmd>Telescope resume<cr>", "Last Search" },
["<leader>fr"] = { "<cmd>Telescope oldfiles<cr>", "Recent File" },
wk.add {
{ "<leader>bb", "<cmd>Telescope buffers previewer=false<cr>", desc = "Find" },
{ "<leader>fb", "<cmd>Telescope git_branches<cr>", desc = "Checkout branch" },
{ "<leader>fc", "<cmd>Telescope colorscheme<cr>", desc = "Colorscheme" },
{ "<leader>ff", "<cmd>Telescope find_files<cr>", desc = "Find files" },
{ "<leader>fp", "<cmd>lua require('telescope').extensions.projects.projects()<cr>", desc = "Projects" },
{ "<leader>ft", "<cmd>Telescope live_grep<cr>", desc = "Find Text" },
{ "<leader>fh", "<cmd>Telescope help_tags<cr>", desc = "Help" },
{ "<leader>fl", "<cmd>Telescope resume<cr>", desc = "Last Search" },
{ "<leader>fr", "<cmd>Telescope oldfiles<cr>", desc = "Recent File" },
}

local icons = require "user.icons"
Expand Down
54 changes: 24 additions & 30 deletions lua/user/whichkey.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,32 @@ local M = {
}

function M.config()
local mappings = {
q = { "<cmd>confirm q<CR>", "Quit" },
h = { "<cmd>nohlsearch<CR>", "NOHL" },
[";"] = { "<cmd>tabnew | terminal<CR>", "Term" },
v = { "<cmd>vsplit<CR>", "Split" },
b = { name = "Buffers" },
d = { name = "Debug" },
f = { name = "Find" },
g = { name = "Git" },
l = { name = "LSP" },
p = { name = "Plugins" },
t = { name = "Test" },
a = {
name = "Tab",
n = { "<cmd>$tabnew<cr>", "New Empty Tab" },
N = { "<cmd>tabnew %<cr>", "New Tab" },
o = { "<cmd>tabonly<cr>", "Only" },
h = { "<cmd>-tabmove<cr>", "Move Left" },
l = { "<cmd>+tabmove<cr>", "Move Right" },
},
T = { name = "Treesitter" },
}

local which_key = require "which-key"
which_key.setup {
defaults = {
mode = "n",
prefix = "<leader>",
},
spec = {
{ "<leader>q", "<cmd>confirm q<CR>", desc = "Quit" },
{ "<leader>h", "<cmd>nohlsearch<CR>", desc = "NOHL" },
{ "<leader>;", "<cmd>tabnew | terminal<CR>", desc = "Term" },
{ "<leader>v", "<cmd>vsplit<CR>", desc = "Split" },
{ "<leader>b", group = "Buffers" },
{ "<leader>d", group = "Debug" },
{ "<leader>f", group = "Find" },
{ "<leader>g", group = "Git" },
{ "<leader>l", group = "LSP" },
{ "<leader>p", group = "Plugins" },
{ "<leader>t", group = "Test" },
{ "<leader>a", group = "Tab" },
{ "<leader>aN", "<cmd>tabnew %<cr>", desc = "New Tab" },
{ "<leader>ah", "<cmd>-tabmove<cr>", desc = "Move Left" },
{ "<leader>al", "<cmd>+tabmove<cr>", desc = "Move Right" },
{ "<leader>an", "<cmd>$tabnew<cr>", desc = "New Empty Tab" },
{ "<leader>ao", "<cmd>tabonly<cr>", desc = "Only" },
{ "<leader>T", group = "Treesitter" },
},
plugins = {
marks = true,
registers = true,
Expand Down Expand Up @@ -58,13 +59,6 @@ function M.config()
filetypes = { "TelescopePrompt" },
},
}

local opts = {
mode = "n", -- NORMAL mode
prefix = "<leader>",
}

which_key.register(mappings, opts)
end

return M