From 8ea1f67f0705acb5963c02b0189d54ee40727d8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jalil=20David=20Salam=C3=A9=20Messina?= Date: Sat, 2 Mar 2024 20:49:44 +0100 Subject: [PATCH] fix(nvim): Translate mappings to nixvim --- nvim/default.nix | 2 +- nvim/mappings.nix | 200 +++++++++++++++++++++++++++++----------------- 2 files changed, 129 insertions(+), 73 deletions(-) diff --git a/nvim/default.nix b/nvim/default.nix index 7178a6c..cea576e 100644 --- a/nvim/default.nix +++ b/nvim/default.nix @@ -38,8 +38,8 @@ in # Enable local configuration :h 'exrc' options.exrc = true; # safe since nvim 0.9 plugins = import ./plugins; - mappings = import ./mappings.nix; augroups = import ./augroups.nix; + keymaps = import ./mappings.nix; extraPlugins = (with pkgs.vimExtraPlugins; [ dressing-nvim diff --git a/nvim/mappings.nix b/nvim/mappings.nix index df41583..1c1f4b1 100644 --- a/nvim/mappings.nix +++ b/nvim/mappings.nix @@ -1,91 +1,147 @@ -{ +[ # Quickfix - normal."qo" = { - action = "'Copen'"; - desc = "Quickfix Open"; - }; - normal."qq" = { - action = "'cclose'"; - desc = "Quickfix Quit"; - }; - normal."qj" = { - action = "'cnext'"; - desc = "Quickfix next [J]"; - }; - normal."qk" = { - action = "'cprev'"; - desc = "Quickfix previous [K]"; - }; + { + mode = "n"; + key = "qo"; + action = "Copen"; + options.desc = "Quickfix Open"; + } + { + mode = "n"; + key = "qq"; + action = "cclose"; + options.desc = "Quickfix Quit"; + } + { + mode = "n"; + key = "qj"; + action = "cnext"; + options.desc = "Quickfix next [J]"; + } + { + mode = "n"; + key = "qk"; + action = "cprev"; + options.desc = "Quickfix previous [K]"; + } # Open or create file - normal."gf" = { - action = "'e '"; - desc = "Go to File"; - }; + { + mode = "n"; + key = "gf"; + action = "e "; + options.desc = "Go to File"; + } # Keep Selection when indenting - visualOnly.">" = { - action = "'>gv'"; - desc = "Indent Selection"; - }; - visualOnly."<" = { - action = "'dj" = { + { + mode = "n"; + key = "dj"; action = "vim.diagnostic.goto_next"; - desc = "Diagnostics next [J]"; - }; - normal."dk" = { + lua = true; + options.desc = "Diagnostics next [J]"; + } + { + mode = "n"; + key = "dk"; action = "vim.diagnostic.goto_prev"; - desc = "Diagnostics previous [K]"; - }; - normal."xx" = { + lua = true; + options.desc = "Diagnostics previous [K]"; + } + { + mode = "n"; + key = "xx"; action = "require('trouble').toggle"; - desc = "Toggle trouble"; - }; - normal."xw" = { + lua = true; + options.desc = "Toggle trouble"; + } + { + mode = "n"; + key = "xw"; action = "function() require('trouble').toggle('workspace_diagnostics') end"; - desc = "Toggle Workspace trouble"; - }; - normal."xd" = { + lua = true; + options.desc = "Toggle Workspace trouble"; + } + { + mode = "n"; + key = "xd"; action = "function() require('trouble').toggle('document_diagnostics') end"; - desc = "Toggle Document trouble"; - }; - normal."xq" = { + lua = true; + options.desc = "Toggle Document trouble"; + } + { + mode = "n"; + key = "xq"; action = "function() require('trouble').toggle('quickfix') end"; - desc = "Toggle Quickfix trouble"; - }; - normal."xl" = { + lua = true; + options.desc = "Toggle Quickfix trouble"; + } + { + mode = "n"; + key = "xl"; action = "function() require('trouble').toggle('loclist') end"; - desc = "Toggle Loclist trouble"; - }; - normal."gR" = { + lua = true; + options.desc = "Toggle Loclist trouble"; + } + { + mode = "n"; + key = "gR"; action = "function() require('trouble').toggle('lsp_references') end"; - desc = "Toggle lsp References trouble"; - }; + lua = true; + options.desc = "Toggle lsp References trouble"; + } # Telescope - normal."ff" = { + { + mode = "n"; + key = "ff"; action = "require('telescope.builtin').find_files"; - desc = "Find Files"; - }; - normal."fg" = { + lua = true; + options.desc = "Find Files"; + } + { + mode = "n"; + key = "fg"; action = "require('telescope.builtin').live_grep"; - desc = "Find Grep"; - }; - normal."fh" = { + lua = true; + options.desc = "Find Grep"; + } + { + mode = "n"; + key = "fh"; action = "require('telescope.builtin').help_tags"; - desc = "Find Help"; - }; - normal."fb" = { + lua = true; + options.desc = "Find Help"; + } + { + mode = "n"; + key = "fb"; action = "require('telescope.builtin').buffers"; - desc = "Find Buffer"; - }; - normal."fd" = { + lua = true; + options.desc = "Find Buffer"; + } + { + mode = "n"; + key = "fd"; action = "require('telescope.builtin').diagnostics"; - desc = "Find Diagnostics"; - }; - normal."fq" = { + lua = true; + options.desc = "Find Diagnostics"; + } + { + mode = "n"; + key = "fq"; action = "require('telescope.builtin').quickfix"; - desc = "Find Quickfix"; - }; -} + lua = true; + options.desc = "Find Quickfix"; + } +]