Add keybindings and binding descriptions

This commit is contained in:
Alexander Gehrke 2023-09-08 11:14:20 +02:00
parent cc13b9bbdb
commit daa9394fd5
3 changed files with 73 additions and 70 deletions

View file

@ -14,6 +14,7 @@
"gitsigns.nvim": { "branch": "main", "commit": "d8590288417fef2430f85bc8b312fae8b1cf2c40" },
"gitv": { "branch": "master", "commit": "a73599c34202709eaa7da78f4fe32b97c6ef83f8" },
"hledger-vim": { "branch": "master", "commit": "165eb483a10fd610bd9cad5d5246e457bf5fe285" },
"hover.nvim": { "branch": "main", "commit": "c366d1b0f9d6612d25681d3fea0f9ea46fa54f4d" },
"indent-blankline.nvim": { "branch": "master", "commit": "9637670896b68805430e2f72cf5d16be5b97a22a" },
"lazy.nvim": { "branch": "main", "commit": "2a9354c7d2368d78cbd5575a51a2af5bd8a6ad01" },
"lsp-colors.nvim": { "branch": "main", "commit": "2bbe7541747fd339bdd8923fc45631a09bb4f1e5" },

View file

@ -1,53 +1,54 @@
--Plug 'nvim-telescope/telescope.nvim'
--Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' }
--Plug 'gbrlsnchs/telescope-lsp-handlers.nvim'
--Plug 'nvim-telescope/telescope-ui-select.nvim'
return {
"nvim-telescope/telescope.nvim",
dependencies = {
{'nvim-telescope/telescope-fzf-native.nvim',
build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build',
},
'gbrlsnchs/telescope-lsp-handlers.nvim',
--Plug { 'do': 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' }
"nvim-telescope/telescope.nvim",
dependencies = {
{
'nvim-telescope/telescope-fzf-native.nvim',
build =
'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build',
},
cmd = "Telescope",
version = false,
keys = {
{',ff', require("telescope.builtin").fd, desc = "Find files"},
{',fg', require("telescope.builtin").git_files, desc = "Find files (git)"},
{',gs', require("telescope.builtin").git_status, desc = "Git status"},
{',s', require("telescope.builtin").lsp_dynamic_workspace_symbols, desc = "Symbols"},
{'g/', require("telescope.builtin").live_grep, desc = "Live grep"},
{'<C-/>', require("telescope.builtin").current_buffer_fuzzy_find, desc = "Fuzzy find"},
{'<leader>*', require("telescope.builtin").grep_string, desc = "Find at cursor"},
{'gb', require("telescope.builtin").buffers},
{ "<leader>:", require("telescope.builtin").command_history, desc = "Command History" },
{ "<leader>;", require("telescope.builtin").commands, desc = "Commands" },
'gbrlsnchs/telescope-lsp-handlers.nvim',
},
cmd = "Telescope",
version = false,
keys = function()
local builtin = require("telescope.builtin")
local utils = require("telescope.utils")
return {
{ ',,', function() builtin.fd { cwd = utils.buffer_dir() } end, desc = "Find files in current file's dir" },
{ ',ff', builtin.fd, desc = "Find files" },
{ ',fg', builtin.git_files, desc = "Find files (git)" },
{ ',gs', builtin.git_status, desc = "Git status" },
{ ',s', builtin.lsp_dynamic_workspace_symbols, desc = "Symbols" },
{ 'g/', builtin.live_grep, desc = "Live grep" },
{ '<C-/>', builtin.current_buffer_fuzzy_find, desc = "Fuzzy find" },
{ '<leader>*', builtin.grep_string, desc = "Find at cursor" },
{ 'gb', builtin.buffers, desc = "Switch buffer" },
{ "<leader>:", builtin.command_history, desc = "Command History" },
{ "<leader>;", builtin.commands, desc = "Commands" },
}
end,
opts = {
defaults = {
prompt_prefix = "",
selection_caret = "",
},
opts = {
defaults = {
prompt_prefix = "",
selection_caret = "",
extensions = {
fzf = {
fuzzy = true, -- false will only do exact matching
override_generic_sorter = true, -- override the generic sorter
override_file_sorter = true, -- override the file sorter
case_mode = "smart_case", -- or "ignore_case" or "respect_case"
-- the default case_mode is "smart_case"
},
extensions = {
fzf = {
fuzzy = true, -- false will only do exact matching
override_generic_sorter = true, -- override the generic sorter
override_file_sorter = true, -- override the file sorter
case_mode = "smart_case", -- or "ignore_case" or "respect_case"
-- the default case_mode is "smart_case"
},
["ui-select"] = {
require("telescope.themes").get_dropdown { }
},
["ui-select"] = {
require("telescope.themes").get_dropdown {}
},
},
config = function(_, opts)
local telescope = require('telescope')
telescope.setup(opts)
telescope.load_extension('fzf')
telescope.load_extension('ui-select')
end,
}
},
config = function(_, opts)
local telescope = require('telescope')
telescope.setup(opts)
telescope.load_extension('fzf')
telescope.load_extension('ui-select')
end,
}

View file

@ -8,34 +8,35 @@ local on_attach = function(args)
-- Mappings.
local opts = { silent = true, buffer = bufnr }
local loud = { buffer = bufnr }
local desc = function(text) return { silent = true, buffer = bufnr, desc = text} end
local map = vim.keymap.set
-- See `:help vim.lsp.*` for documentation on any of the below functions
map("n", "<leader>dr", function() require("dap").repl.toggle() end, { silent = true })
map('n', 'gD', vim.lsp.buf.declaration, opts)
map('n', 'gd', vim.lsp.buf.definition, opts)
map('n', 'gi', vim.lsp.buf.implementation, opts)
map('n', '<C-k>', vim.lsp.buf.signature_help, opts)
map('n', '<Leader>D', vim.lsp.buf.type_definition, opts)
map('n', '<Leader>rn', vim.lsp.buf.rename, opts)
map('n', '<M-x>', vim.lsp.buf.code_action, loud)
map('n', '<M-s>', vim.lsp.codelens.run, loud)
map('n', 'gr', vim.lsp.buf.references, opts)
map('n', '<M-e>', vim.diagnostic.open_float, opts)
map('n', '[d', vim.diagnostic.goto_prev, opts)
map('n', ']d', vim.diagnostic.goto_next, opts)
map('n', '<M-q>', vim.diagnostic.setloclist, opts)
map("n", "<Leader>f", function() vim.lsp.buf.format { async = true } end, opts)
map("n", "<leader>dc", function() require("dap").continue() end, opts)
map("n", "<leader>dK", function() require("dap.ui.widgets").hover() end, opts)
map("n", "<leader>dt", function() require("dap").toggle_breakpoint() end, opts)
map("n", "<leader>dso", function() require("dap").step_over() end, opts)
map("n", "<leader>dsi", function() require("dap").step_into() end, opts)
map("n", "<leader>dl", function() require("dap").run_last() end, opts)
map('n', 'gD', vim.lsp.buf.declaration, desc("Go to declaration"))
map('n', 'gd', vim.lsp.buf.definition, desc("Go to definition"))
map('n', 'gi', vim.lsp.buf.implementation, desc("Go to implementation"))
map('n', '<C-k>', vim.lsp.buf.signature_help, desc("Show signature help"))
map('n', '<Leader>D', vim.lsp.buf.type_definition, desc("Go to type definition"))
map('n', '<Leader>rn', vim.lsp.buf.rename, desc("Rename"))
map('n', '<M-x>', vim.lsp.buf.code_action, desc("Code action"))
map('n', '<M-s>', vim.lsp.codelens.run, desc("Run code lens"))
map('n', 'gr', vim.lsp.buf.references, desc("Go to references"))
map('n', '<M-e>', vim.diagnostic.open_float, desc("Open diagnostics"))
map('n', '[d', vim.diagnostic.goto_prev, desc("Go to previous diagnostic"))
map('n', '[d', vim.diagnostic.goto_prev, desc("Go to next diagnostic"))
map('n', '<M-q>', vim.diagnostic.setloclist, desc("Add buffer diagnostics to location list"))
map("n", "<Leader>f", function() vim.lsp.buf.format { async = true } end, desc("Format buffer"))
map("n", "<leader>dc", function() require("dap").continue() end, desc("Debug: Continue"))
map("n", "<leader>dK", function() require("dap.ui.widgets").hover() end, desc("Debug: Hover"))
map("n", "<leader>dt", function() require("dap").toggle_breakpoint() end, desc("Debug: Toggle breakpoint"))
map("n", "<leader>dso", function() require("dap").step_over() end, desc("Debug: Step over"))
map("n", "<leader>dsi", function() require("dap").step_into() end, desc("Debug: Step into"))
map("n", "<leader>dl", function() require("dap").run_last() end, desc("Debug: Run last"))
map("n", "<leader>aa", vim.diagnostic.setqflist, opts)
map("n", "<leader>aw", function() vim.diagnostic.setqflist({ severity = "W" }) end, opts)
map("n", "<leader>ae", function() vim.diagnostic.setqflist({ severity = "E" }) end, opts)
map("n", "<leader>aa", vim.diagnostic.setqflist, desc("Add all diagnostics to quickfix list"))
map("n", "<leader>aw", function() vim.diagnostic.setqflist({ severity = "W" }) end, desc("Add all warnings to quickfix list"))
map("n", "<leader>ae", function() vim.diagnostic.setqflist({ severity = "E" }) end, desc("Add all errors to quickfix list"))
vim.cmd [[autocmd CursorHoldI * silent! lua vim.lsp.buf.signature_help()]]
vim.cmd [[autocmd CursorHold * lua vim.diagnostic.open_float({max_width = 100, focusable = false})]]