splitted which key configuration in their respective plugin files

This commit is contained in:
aminnairi
2023-12-02 23:51:23 +01:00
parent 333f80533c
commit 38cf4d903a
5 changed files with 153 additions and 143 deletions
@@ -7,4 +7,37 @@ return {
skip_confirmation = true, skip_confirmation = true,
border = "rounded", border = "rounded",
}, },
config = function()
local whichKey = require("which-key")
whichKey.register({
["<leader>v"] = {
name = "Visit link",
v = {
function()
require("link-visitor").visit()
end,
"Visit",
},
l = {
function()
require("link-visitor").link_under_cursor()
end,
"Under cursor",
},
n = {
function()
require("link-visitor").link_near_cursor()
end,
"Near cursor",
},
N = {
function()
require("link-visitor").link_nearest()
end,
"Near cursor",
},
},
})
end
} }
@@ -19,89 +19,89 @@ return {
["<leader>l"] = { ["<leader>l"] = {
name = "LSP", name = "LSP",
d = { d = {
name = "Diagnostic", name = "LSP Diagnostic",
o = { o = {
function() function()
vim.diagnostic.open_float() vim.diagnostic.open_float()
end, end,
"Open", "Open LSP diagnostic",
}, },
p = { p = {
function() function()
vim.diagnostic.goto_prev() vim.diagnostic.goto_prev()
end, end,
"Previous", "Previous LSP diagnostic",
}, },
n = { n = {
function() function()
vim.diagnostic.goto_next() vim.diagnostic.goto_next()
end, end,
"Next", "Next LSP diagnostic",
}, },
}, },
b = { b = {
name = "File", name = "LSP Buffer",
d = { D = {
function() function()
vim.lsp.buf.declaration() vim.lsp.buf.declaration()
end, end,
"Declaration", "Go to symbol declaration",
buffer = ev.buf, buffer = ev.buf,
}, },
D = { d = {
function() function()
vim.lsp.buf.definition() vim.lsp.buf.definition()
end, end,
"Definition", "Go to symbol definition",
buffer = ev.buf, buffer = ev.buf,
}, },
h = { h = {
function() function()
vim.lsp.buf.hover() vim.lsp.buf.hover()
end, end,
"Hover", "Hover symbol documentation",
buffer = ev.buf, buffer = ev.buf,
}, },
i = { i = {
function() function()
vim.lsp.buf.implementation() vim.lsp.buf.implementation()
end, end,
"Implementation", "Go to symbol implementation",
buffer = ev.buf, buffer = ev.buf,
}, },
s = { s = {
function() function()
vim.lsp.buf.signature_help() vim.lsp.buf.signature_help()
end, end,
"Signature", "Go to symbol signature",
buffer = ev.buf, buffer = ev.buf,
}, },
t = { t = {
function() function()
vim.lsp.buf.type_definition() vim.lsp.buf.type_definition()
end, end,
"Type definition", "Go to symbol type definition",
buffer = ev.buf, buffer = ev.buf,
}, },
r = { r = {
function() function()
vim.lsp.buf.rename() vim.lsp.buf.rename()
end, end,
"Rename", "Rename symbol",
buffer = ev.buf, buffer = ev.buf,
}, },
c = { c = {
function() function()
vim.lsp.buf.code_action() vim.lsp.buf.code_action()
end, end,
"Code action", "LSP code action",
buffer = ev.buf, buffer = ev.buf,
}, },
R = { R = {
function() function()
vim.lsp.buf.references() vim.lsp.buf.references()
end, end,
"References", "Go to symbol deferences",
buffer = ev.buf, buffer = ev.buf,
}, },
f = { f = {
@@ -110,7 +110,7 @@ return {
async = true, async = true,
}) })
end, end,
"Format", "Format file",
buffer = ev.buf, buffer = ev.buf,
}, },
}, },
@@ -18,5 +18,37 @@ return {
dotfiles = false, dotfiles = false,
}, },
}) })
local whichKey = require("which-key")
whichKey.register({
["<leader>n"] = {
name = "NvimTree",
t = {
function()
require("nvim-tree.api").tree.toggle()
end,
"Toggle NvimTree",
},
f = {
function()
require("nvim-tree.api").tree.focus()
end,
"Focus NvimTree",
},
e = {
function()
require("nvim-tree.api").tree.expand_all()
end,
"Expand NvimTree",
},
c = {
function()
require("nvim-tree.api").tree.collapse_all()
end,
"Collapse NvimTree",
},
},
})
end, end,
} }
@@ -5,5 +5,76 @@ return {
}, },
config = function() config = function()
require("telescope").setup({}) require("telescope").setup({})
local whichKey = require("which-key")
whichKey.register({
["<leader>t"] = {
name = "Telescope",
t = {
function()
require("telescope.builtin").treesitter()
end,
"Explore the Abstract Syntax Tree",
},
f = {
function()
require("telescope.builtin").find_files()
end,
"Find files",
},
w = {
function()
require("telescope.builtin").live_grep()
end,
"Find words",
},
c = {
function()
require("telescope.builtin").colorscheme()
end,
"Find color schemes",
},
g = {
function()
require("telescope.builtin").git_files()
end,
"Find git files",
},
l = {
name = "LSP",
e = {
function()
require("telescope.builtin").diagnostics()
end,
"List diagnostics for all open buffers",
},
r = {
function()
require("telescope.builtin").lsp_references()
end,
"List all references for the word under the cursor",
},
i = {
function()
require("telescope.builtin").lsp_implementation()
end,
"Go to the implementation of the word under the cursor",
},
d = {
function()
require("telescope.builtin").lsp_definition()
end,
"Go to the definition of the word under the cursor",
},
t = {
function()
require("telescope.builtin").lsp_type_definition()
end,
"Go to the type definition of the word under the cursor",
},
},
},
})
end, end,
} }
@@ -5,130 +5,4 @@ return {
vim.o.timeout = true vim.o.timeout = true
vim.o.timeoutlen = 0 vim.o.timeoutlen = 0
end, end,
config = function()
local whichKey = require("which-key")
whichKey.register({
["<leader>n"] = {
name = "NvimTree",
t = {
function()
require("nvim-tree.api").tree.toggle()
end,
"Toggle",
},
f = {
function()
require("nvim-tree.api").tree.focus()
end,
"Focus",
},
e = {
function()
require("nvim-tree.api").tree.expand_all()
end,
"Expand",
},
c = {
function()
require("nvim-tree.api").tree.collapse_all()
end,
"Collapse",
},
},
["<leader>t"] = {
name = "Telescope",
t = {
function()
require("telescope.builtin").treesitter()
end,
"Explore the Abstract Syntax Tree",
},
f = {
function()
require("telescope.builtin").find_files()
end,
"Find files",
},
w = {
function()
require("telescope.builtin").live_grep()
end,
"Find words",
},
c = {
function()
require("telescope.builtin").colorscheme()
end,
"Find color schemes",
},
g = {
function()
require("telescope.builtin").git_files()
end,
"Find git files",
},
l = {
name = "LSP",
e = {
function()
require("telescope.builtin").diagnostics()
end,
"List diagnostics for all open buffers",
},
r = {
function()
require("telescope.builtin").lsp_references()
end,
"List all references for the word under the cursor",
},
i = {
function()
require("telescope.builtin").lsp_implementation()
end,
"Go to the implementation of the word under the cursor",
},
d = {
function()
require("telescope.builtin").lsp_definition()
end,
"Go to the definition of the word under the cursor",
},
t = {
function()
require("telescope.builtin").lsp_type_definition()
end,
"Go to the type definition of the word under the cursor",
},
},
},
["<leader>v"] = {
name = "Visit link",
v = {
function()
require("link-visitor").visit()
end,
"Visit",
},
l = {
function()
require("link-visitor").link_under_cursor()
end,
"Under cursor",
},
n = {
function()
require("link-visitor").link_near_cursor()
end,
"Near cursor",
},
N = {
function()
require("link-visitor").link_nearest()
end,
"Near cursor",
},
},
})
end,
} }