vim.g.mapleader = " " local function smart_quit() local bufnr = vim.api.nvim_get_current_buf() local modified = vim.api.nvim_buf_get_option(bufnr, "modified") if modified then vim.ui.input({ prompt = "You have unsaved changes. Quit anyway? (y/n) ", }, function(input) if input == "y" then vim.cmd "q!" end end) else vim.cmd "q!" end end local function find_project_files() local _, builtin = pcall(require, "telescope.builtin") local ok = pcall(builtin.git_files) if not ok then builtin.find_files() end end local wk = require("which-key") wk.setup({}) wk.register({ [""] = { [";"] = { "Alpha", "Dashboard" }, ["w"] = { "w!", "Save" }, ["q"] = { "smart_quit()", "Quit" }, ["/"] = { "(comment_toggle_linewise_current)", "Comment toggle current line" }, ["c"] = { "BufferKill", "Close Buffer" }, ["f"] = { find_project_files, "Find File" }, ["h"] = { "nohlsearch", "No Highlight" }, ["t"] = { "TodoTelescope keywords=TODO,FIX", "Find TODO,FIX" }, b = { name = "Buffers", j = { "BufferLinePick", "Jump" }, f = { "Telescope buffers", "Find" }, b = { "BufferLineCyclePrev", "Previous" }, n = { "BufferLineCycleNext", "Next" }, -- w = { "BufferWipeout", "Wipeout" }, -- TODO: implement this for bufferline e = { "BufferLinePickClose", "Pick which buffer to close", }, h = { "BufferLineCloseLeft", "Close all to the left" }, l = { "BufferLineCloseRight", "Close all to the right", }, D = { "BufferLineSortByDirectory", "Sort by directory", }, L = { "BufferLineSortByExtension", "Sort by language", }, }, -- " Available Debug Adapters: -- " https://microsoft.github.io/debug-adapter-protocol/implementors/adapters/ -- " Adapter configuration and installation instructions: -- " https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation -- " Debug Adapter protocol: -- " https://microsoft.github.io/debug-adapter-protocol/ -- " Debugging g = { name = "Git", g = { Lazygit_toggle, "Lazygit" }, j = { "lua require 'gitsigns'.next_hunk({navigation_message = false})", "Next Hunk" }, k = { "lua require 'gitsigns'.prev_hunk({navigation_message = false})", "Prev Hunk" }, l = { "lua require 'gitsigns'.blame_line()", "Blame" }, p = { "lua require 'gitsigns'.preview_hunk()", "Preview Hunk" }, r = { "lua require 'gitsigns'.reset_hunk()", "Reset Hunk" }, R = { "lua require 'gitsigns'.reset_buffer()", "Reset Buffer" }, s = { "lua require 'gitsigns'.stage_hunk()", "Stage Hunk" }, u = { "lua require 'gitsigns'.undo_stage_hunk()", "Undo Stage Hunk", }, o = { "Telescope git_status", "Open changed file" }, b = { "Telescope git_branches", "Checkout branch" }, c = { "Telescope git_commits", "Checkout commit" }, C = { "Telescope git_bcommits", "Checkout commit(for current file)", }, d = { "Gitsigns diffthis HEAD", "Git Diff", }, }, l = { name = "LSP", a = { "lua vim.lsp.buf.code_action()", "Code Action" }, d = { "Telescope diagnostics bufnr=0 theme=get_ivy", "Buffer Diagnostics" }, w = { "Telescope diagnostics", "Diagnostics" }, -- f = { require("lvim.lsp.utils").format, "Format" }, i = { "LspInfo", "Info" }, I = { "Mason", "Mason Info" }, j = { vim.diagnostic.goto_next, "Next Diagnostic", }, k = { vim.diagnostic.goto_prev, "Prev Diagnostic", }, l = { vim.lsp.codelens.run, "CodeLens Action" }, q = { vim.diagnostic.setloclist, "Quickfix" }, r = { vim.lsp.buf.rename, "Rename" }, s = { "Telescope lsp_document_symbols", "Document Symbols" }, S = { "Telescope lsp_dynamic_workspace_symbols", "Workspace Symbols", }, e = { "Telescope quickfix", "Telescope Quickfix" }, }, a = { "lua require('telescope.builtin').lsp_code_actions()", "Code Actions" }, d = { "lua require('telescope.builtin').lsp_document_diagnostics()", "LSP Diagnostics" }, k = { "lua vim.lsp.buf.signature_help()", "Signature Help" }, P = { "lua require'telescope'.extensions.projects.projects{}", "Signature Help" }, } }) wk.register( { ["/"] = { "(comment_toggle_linewise_visual)", "Comment toggle linewise (visual)" }, }, { mode = "v", -- VISUAL mode prefix = "", buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings silent = true, -- use `silent` when creating keymaps noremap = true, -- use `noremap` when creating keymaps nowait = true, -- use `nowait` when creating keymaps } )