{ ... }: { programs.nixvim.globals.mapleader = " "; programs.nixvim.globals.maplocalleader = ","; programs.nixvim.keymaps = [ { key = "gl"; action = "lua vim.diagnostic.open_float()"; } { key = "u"; action = "UndotreeToggle"; } { key = "f"; action = "Telescope fd"; } { key = "g"; action = "Telescope live_grep"; } { key = "D"; action = "Telescope diagnostics"; } { key = "b"; action = "Telescope buffers"; } { key = "s"; action = "Telescope lsp_document_symbols"; } { key = "w"; action = ""; } { # Unbind F1 key = ""; action = ""; } ]; programs.nixvim.autoCmd = [ { desc = "LSP Actions"; event = "LspAttach"; callback = { __raw = '' function(event) local opts = { buffer = event.buf } -- these will be buffer-local keybindings -- because they only work if you have an active language server vim.keymap.set('n', 'K', 'lua vim.lsp.buf.hover()', opts) vim.keymap.set('n', 'gd', 'Telescope lsp_definitions', opts) vim.keymap.set('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) vim.keymap.set('n', 'gi', 'Telescope lsp_implementations', opts) vim.keymap.set('n', 'go', 'Telescope lsp_type_definitions', opts) vim.keymap.set('n', 'gr', 'Telescope lsp_references', opts) vim.keymap.set('n', 'gs', 'lua vim.lsp.buf.signature_help()', opts) vim.keymap.set('n', 'r', 'lua vim.lsp.buf.rename()', opts) vim.keymap.set({ 'n', 'x' }, '', 'lua vim.lsp.buf.format({async = true})', opts) -- vim.keymap.set('n', 'a', 'lua vim.lsp.buf.code_action()', opts) vim.keymap.set("n", "a", require("actions-preview").code_actions, opts) vim.keymap.set("n", "gh", "ClangdSwitchSourceHeader", opts) end ''; }; } ]; }