feat: telescope hotkeys for various lsp workspace symbol types

keys:
    <leader>pw -> all symbols
    <leader>pwf -> functions
    <leader>pwv -> variables
    <leader>pws -> structs
    <leader>pwC -> constants
    <leader>pwc -> classes
    <leader>pwe -> enums
This commit is contained in:
2024-06-01 08:58:26 +02:00
parent 7bb6b6d4ff
commit 580af3bfbd
2 changed files with 165 additions and 93 deletions

View File

@@ -13,29 +13,29 @@
"dressing.nvim": { "branch": "master", "commit": "3c38ac861e1b8d4077ff46a779cde17330b29f3a" },
"flutter-tools.nvim": { "branch": "main", "commit": "990a1349c29f7d474a0cd51355aba773ccc9deea" },
"harpoon": { "branch": "harpoon2", "commit": "0378a6c428a0bed6a2781d459d7943843f374bce" },
"lazy.nvim": { "branch": "main", "commit": "24fa2a97085ca8a7220b5b078916f81e316036fd" },
"lazy.nvim": { "branch": "main", "commit": "eab487c2520f0fe9e54eb5e3ea0606e20512492e" },
"lspkind.nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" },
"lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "a4caa0d083aab56f6cd5acf2d42331b74614a585" },
"mason.nvim": { "branch": "main", "commit": "49ff59aded1047a773670651cfa40e76e63c6377" },
"mason.nvim": { "branch": "main", "commit": "0fb4e56837f13b81a972fcc0554be1327b39061e" },
"mini.diff": { "branch": "main", "commit": "d357afcb7b9614b91bd96115e637841fda20418b" },
"mini.indentscope": { "branch": "main", "commit": "cf07f19e718ebb0bcc5b00999083ce11c37b8d40" },
"mini.surround": { "branch": "main", "commit": "a1b590cc3b676512de507328d6bbab5e43794720" },
"neogen": { "branch": "main", "commit": "6de0add4805165317ab7d3d36b5cef48b1b865f3" },
"nvim-cmp": { "branch": "main", "commit": "5260e5e8ecadaf13e6b82cf867a909f54e15fd07" },
"nvim-lightbulb": { "branch": "master", "commit": "8f00b89dd1b1dbde16872bee5fbcee2e58c9b8e9" },
"nvim-lspconfig": { "branch": "master", "commit": "7cb90cf656139dc59cf86206946ec85571671b5b" },
"nvim-lspconfig": { "branch": "master", "commit": "710a8fa7379db32199545f30ea01dd8446b9302f" },
"nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" },
"nvim-tree-docs": { "branch": "master", "commit": "5db023d783da1e55339e5e25caaf72a59597e626" },
"nvim-treesitter": { "branch": "master", "commit": "f770df9c8cd56c05b878cdf35115ad872c822bc0" },
"nvim-treesitter": { "branch": "master", "commit": "f9773e4a5e0dbeda0d6f8a78d7d61eb802b6d0e1" },
"nvim-ts-context-commentstring": { "branch": "main", "commit": "cb064386e667def1d241317deed9fd1b38f0dc2e" },
"nvim-web-devicons": { "branch": "master", "commit": "b77921fdc44833c994fdb389d658ccbce5490c16" },
"plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" },
"telescope.nvim": { "branch": "master", "commit": "dfa230be84a044e7f546a6c2b0a403c739732b86" },
"todo-comments.nvim": { "branch": "main", "commit": "e1549807066947818113a7d7ed48f637e49620d3" },
"trouble.nvim": { "branch": "main", "commit": "bda8de4205f06c3939b8b59e4da1f3713d04ea05" },
"trouble.nvim": { "branch": "main", "commit": "d7f69ff5638cf1864cabac54ade1b1694adfe085" },
"undotree": { "branch": "master", "commit": "56c684a805fe948936cda0d1b19505b84ad7e065" },
"vim-dadbod": { "branch": "master", "commit": "fb30422b7bee7e2fa4205a4d226f01477f4fc593" },
"vim-dadbod": { "branch": "master", "commit": "7888cb7164d69783d3dce4e0283decd26b82538b" },
"vim-dadbod-completion": { "branch": "master", "commit": "5d5ad196fcde223509d7dabbade0148f7884c5e3" },
"vim-dadbod-ui": { "branch": "master", "commit": "0dc68d9225a70d42f8645049482e090c1a8dce25" },
"vim-fugitive": { "branch": "master", "commit": "4f59455d2388e113bd510e85b310d15b9228ca0d" },

View File

@@ -1,93 +1,165 @@
return {
{
"nvim-telescope/telescope.nvim",
cmd = "Telescope",
dependencies = { "nvim-lua/plenary.nvim" },
opts = {
defaults = {
layout_strategy = "horizontal",
layout_config = {
horizontal = {
prompt_position = "bottom",
preview_width = 0.55,
results_width = 0.8,
},
vertical = {
mirror = false,
},
width = 0.87,
height = 0.80,
preview_cutoff = 120,
},
borderchars = require("409.ui").telescope_border,
prompt_prefix = "",
color_devicons = true,
},
},
keys = {
{
"<leader>pf",
":Telescope find_files<CR>",
desc = "Find files"
},
{
"<C-p>",
":Telescope git_files<CR>",
desc = "Find files (git)"
},
{
"<leader>pt",
":TodoTelescope<CR>",
desc = "Find TODOs"
},
{
"<leader>ps",
function()
local status, result = pcall(function()
return vim.fn.input("Grep > ")
end)
--
-- prevent keyboard interrupt error
if not status then
return
end
{
"nvim-telescope/telescope.nvim",
cmd = "Telescope",
dependencies = { "nvim-lua/plenary.nvim" },
opts = {
defaults = {
layout_strategy = "horizontal",
layout_config = {
horizontal = {
prompt_position = "bottom",
preview_width = 0.55,
results_width = 0.8,
},
vertical = {
mirror = false,
},
width = 0.87,
height = 0.80,
preview_cutoff = 120,
},
borderchars = require("409.ui").telescope_border,
prompt_prefix = "",
color_devicons = true,
},
},
keys = {
{
"<leader>pf",
":Telescope find_files<CR>",
desc = "Find files",
},
{
"<leader>pw",
":Telescope lsp_dynamic_workspace_symbols<CR>",
desc = "Find symbols (LSP)",
},
{
"<leader>pwf",
function()
require("telescope.builtin").lsp_dynamic_workspace_symbols({
symbols = "function",
})
end,
desc = "Find functions (LSP)",
},
{
"<leader>pwv",
function()
require("telescope.builtin").lsp_dynamic_workspace_symbols({
prompt_title = "Find variables (LSP)",
symbols = "variable",
})
end,
desc = "Find variables (LSP)",
},
{
"<leader>pws",
function()
require("telescope.builtin").lsp_dynamic_workspace_symbols({
prompt_title = "Find structs (LSP)",
symbols = "struct",
})
end,
desc = "Find structs (LSP)",
},
{
"<leader>pwC",
function()
require("telescope.builtin").lsp_dynamic_workspace_symbols({
prompt_title = "Find constants (LSP)",
symbols = "constant",
})
end,
desc = "Find constants (LSP)",
},
{
"<leader>pwc",
function()
require("telescope.builtin").lsp_dynamic_workspace_symbols({
prompt_title = "Find classes (LSP)",
symbols = "class",
})
end,
desc = "Find classes (LSP)",
},
{
"<leader>pwe",
function()
require("telescope.builtin").lsp_dynamic_workspace_symbols({
prompt_title = "Find enums (LSP)",
symbols = "enum",
})
end,
desc = "Find enums (LSP)",
},
{
"<C-p>",
":Telescope git_files<CR>",
desc = "Find files (git)",
},
{
"<leader>pt",
":TodoTelescope<CR>",
desc = "Find TODOs",
},
{
"<leader>ps",
function()
local status, result = pcall(function()
return vim.fn.input("Grep > ")
end)
--
-- prevent keyboard interrupt error
if not status then
return
end
require("telescope.builtin").grep_string({ search = result })
end,
desc = "Grep (root dir)"
},
{
"<leader>pl",
function()
require("telescope.builtin").live_grep()
end,
desc = "Live grep (root dir)"
},
{
"<C-b>",
":Telescope buffers<CR>",
desc = "Find buffers"
},
},
config = function()
vim.api.nvim_set_hl(0, "TelescopeSelection", { link = "Visual" })
end
},
{
"ThePrimeagen/harpoon",
branch = "harpoon2",
dependencies = { "nvim-lua/plenary.nvim" },
config = function()
local harpoon = require("harpoon")
require("telescope.builtin").grep_string({ search = result })
end,
desc = "Grep (root dir)",
},
{
"<leader>pl",
function()
require("telescope.builtin").live_grep()
end,
desc = "Live grep (root dir)",
},
{
"<C-b>",
":Telescope buffers<CR>",
desc = "Find buffers",
},
},
config = function(plugin, opts)
require("telescope").setup(opts)
harpoon.setup()
vim.api.nvim_set_hl(0, "TelescopeSelection", { link = "Visual" })
end,
},
{
"ThePrimeagen/harpoon",
branch = "harpoon2",
dependencies = { "nvim-lua/plenary.nvim" },
config = function()
local harpoon = require("harpoon")
vim.keymap.set("n", "<leader>a", function() harpoon:list():add() end)
vim.keymap.set("n", "<C-e>", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end)
harpoon.setup()
for i = 1, 9, 1 do
vim.keymap.set("n", string.format("<leader>%s", i), function() harpoon:list():select(i) end)
end
end
},
vim.keymap.set("n", "<leader>a", function()
harpoon:list():add()
end)
vim.keymap.set("n", "<C-e>", function()
harpoon.ui:toggle_quick_menu(harpoon:list())
end)
for i = 1, 9, 1 do
vim.keymap.set("n", string.format("<leader>%s", i), function()
harpoon:list():select(i)
end)
end
end,
},
}