require("commander").setup({ prompt_title = "Help | Keybindings", components = { "DESC", "KEYS", }, integration = { telescope = { enable = true, theme = require("telescope.themes").commander, }, }, }) local lspconfig = require("lspconfig") -- Use LspAttach autocommand to only map the following keys -- after the language server attaches to the current buffer local lsp_antach_done = false vim.api.nvim_create_autocmd("LspAttach", { group = vim.api.nvim_create_augroup("UserLspConfig", {}), callback = function(ev) -- Buffer local mappings. -- See `:help vim.lsp.*` for documentation on any of the below functions local opts = { buffer = ev.buf } require("commander").add({ { desc = "LSP Quickfix", cmd = function() vim.lsp.buf.code_action({ filter = function(a) return a.kind ~= "quickfix" or a.isPreferred end, apply = true, }) end, keys = { "n", "qf", opts }, }, { desc = "LSP Declaration", cmd = vim.lsp.buf.declaration, keys = { "n", "gD", opts } }, { desc = "LSP Definition", cmd = vim.lsp.buf.definition, keys = { "n", "gd", opts } }, { desc = "LSP Hover", cmd = vim.lsp.buf.hover, keys = { "n", "K", opts } }, { desc = "LSP Rename", cmd = vim.lsp.buf.rename, keys = { "n", "rn", opts } }, { desc = "LSP Implementation", cmd = vim.lsp.buf.implementation, keys = { "n", "gi", opts } }, { desc = "LSP Signature Help", cmd = vim.lsp.buf.signature_help, keys = { "n", "", opts } }, { desc = "LSP Code Action", cmd = vim.lsp.buf.code_action, keys = { "n", "ca", opts } }, { desc = "LSP Format", cmd = function() vim.lsp.buf.format({ async = true }) end, keys = { "n", "f", opts }, }, { desc = "LSP Diagnostics", cmd = function() require("trouble").toggle("document_diagnostics") end, keys = { "n", "d" }, }, { desc = "LSP Diagnostics whole workspace", cmd = function() require("trouble").toggle("workspace_diagnostics") end, keys = { "n", "dw" }, }, { desc = "LSP References", cmd = "Telescope lsp_references", keys = { "n", "gr" } }, { desc = "LSP Definitions", cmd = "Telescope lsp_definitions", keys = { "n", "fcde" } }, { desc = "LSP Document Symbols", cmd = "Telescope lsp_document_symbols", keys = { "n", "fcds" }, }, { desc = "LSP Workspace Symbols", cmd = "Telescope lsp_workspace_symbols", keys = { "n", "fcws" }, }, }, { show = not lsp_attach_done }) lsp_attach_done = true end, }) require("commander").add({ { desc = "Open Help", cmd = require("commander").show, keys = { "n", "h" }, }, { desc = "Search for files in git", cmd = "Telescope git_files", keys = { "n", "" }, }, { desc = "Search for files", cmd = "Telescope find_files", keys = { "n", "ff" } }, { desc = "Search for string", cmd = "Telescope live_grep", keys = { "n", "fg" } }, { desc = "Git Commits", cmd = "Telescope git_commits", keys = { "n", "fgc" } }, { desc = "Git Branches", cmd = "Telescope git_branches", keys = { "n", "fgb" } }, { desc = "Git Status", cmd = "Telescope git_status", keys = { "n", "fgs" } }, { desc = "Terraform Doc", cmd = "Telescope terraform_doc", keys = { "n", "ftf" } }, { desc = "Terraform Modules", cmd = "Telescope terraform_doc modules", keys = { "n", "ftm" } }, { desc = "Terraform AWS", cmd = "Telescope terraform_doc full_name=hashicorp/aws", keys = { "n", "ftfa" }, }, { desc = "Terraform Kubernetes", cmd = "Telescope terraform_doc full_name=hashicorp/kubernetes", keys = { "n", "ftfk" }, }, })