From a641d4fafea93316430f175b66c653ad811c1437 Mon Sep 17 00:00:00 2001 From: Zhongheng Liu Date: Sat, 2 Nov 2024 11:17:38 +0200 Subject: [PATCH] feat: add rust error explanation binding --- home-manager/stvnliu/nixvim/custom/binds.nix | 8 + home-manager/stvnliu/nixvim/default.nix | 232 ++++++++++--------- nixos/configuration.nix | 1 + nixos/ly.nix | 9 + 4 files changed, 135 insertions(+), 115 deletions(-) create mode 100644 home-manager/stvnliu/nixvim/custom/binds.nix create mode 100644 nixos/ly.nix diff --git a/home-manager/stvnliu/nixvim/custom/binds.nix b/home-manager/stvnliu/nixvim/custom/binds.nix new file mode 100644 index 0000000..63e9262 --- /dev/null +++ b/home-manager/stvnliu/nixvim/custom/binds.nix @@ -0,0 +1,8 @@ +[ + { + mode = "n"; + key = "ree"; + action = "RustLsp explainError"; + options.desc = "Explain this Rust error (custom)"; + } +] diff --git a/home-manager/stvnliu/nixvim/default.nix b/home-manager/stvnliu/nixvim/default.nix index 4373b54..afe1179 100644 --- a/home-manager/stvnliu/nixvim/default.nix +++ b/home-manager/stvnliu/nixvim/default.nix @@ -26,125 +26,127 @@ defaultEditor = true; globals.mapleader = " "; colorschemes.gruvbox = {enable = true;}; - keymaps = [ - # Global - # Default mode is "" which means normal-visual-op - { - mode = "n"; - key = "bg"; - action = "TransparentToggle"; - options.desc = "Toggle background transparency"; - } - { - key = ""; - action = "NvimTreeToggle"; - options.desc = "Toggle NvimTree"; - } + keymaps = + [ + # Global + # Default mode is "" which means normal-visual-op + { + mode = "n"; + key = "bg"; + action = "TransparentToggle"; + options.desc = "Toggle background transparency"; + } + { + key = ""; + action = "NvimTreeToggle"; + options.desc = "Toggle NvimTree"; + } - # File - { - mode = "n"; - key = "f"; - action = "+find/file"; - } - { - # Format file - key = "fm"; - action = "lua vim.lsp.buf.format()"; - options.desc = "Format the current buffer"; - } + # File + { + mode = "n"; + key = "f"; + action = "+find/file"; + } + { + # Format file + key = "fm"; + action = "lua vim.lsp.buf.format()"; + options.desc = "Format the current buffer"; + } - # Git - { - mode = "n"; - key = "g"; - action = "+git"; - } - { - mode = "n"; - key = "gt"; - action = "+toggles"; - } - { - key = "gtb"; - action = "Gitsigns toggle_current_line_blame"; - options.desc = "Gitsigns current line blame"; - } - { - key = "gtd"; - action = "Gitsigns toggle_deleted"; - options.desc = "Gitsigns deleted"; - } - { - key = "gd"; - action = "Gitsigns diffthis"; - options.desc = "Gitsigns diff this buffer"; - } + # Git + { + mode = "n"; + key = "g"; + action = "+git"; + } + { + mode = "n"; + key = "gt"; + action = "+toggles"; + } + { + key = "gtb"; + action = "Gitsigns toggle_current_line_blame"; + options.desc = "Gitsigns current line blame"; + } + { + key = "gtd"; + action = "Gitsigns toggle_deleted"; + options.desc = "Gitsigns deleted"; + } + { + key = "gd"; + action = "Gitsigns diffthis"; + options.desc = "Gitsigns diff this buffer"; + } - # Tabs - { - mode = "n"; - key = "t"; - action = "+tab"; - } - { - mode = "n"; - key = "tn"; - action = "tabnew"; - options.desc = "Create new tab"; - } - { - mode = "n"; - key = "td"; - action = "tabclose"; - options.desc = "Close tab"; - } - { - mode = "n"; - key = "ts"; - action = "tabnext"; - options.desc = "Go to the sub-sequent tab"; - } - { - mode = "n"; - key = "tp"; - action = "tabprevious"; - options.desc = "Go to the previous tab"; - } + # Tabs + { + mode = "n"; + key = "t"; + action = "+tab"; + } + { + mode = "n"; + key = "tn"; + action = "tabnew"; + options.desc = "Create new tab"; + } + { + mode = "n"; + key = "td"; + action = "tabclose"; + options.desc = "Close tab"; + } + { + mode = "n"; + key = "ts"; + action = "tabnext"; + options.desc = "Go to the sub-sequent tab"; + } + { + mode = "n"; + key = "tp"; + action = "tabprevious"; + options.desc = "Go to the previous tab"; + } - # Terminal - { - # Escape terminal mode using ESC - mode = "t"; - key = ""; - action = ""; - options.desc = "Escape terminal mode"; - } + # Terminal + { + # Escape terminal mode using ESC + mode = "t"; + key = ""; + action = ""; + options.desc = "Escape terminal mode"; + } - # Trouble - { - mode = "n"; - key = "d"; - action = "+diagnostics/debug"; - } - { - key = "dt"; - action = "TroubleToggle"; - options.desc = "Toggle trouble"; - } + # Trouble + { + mode = "n"; + key = "d"; + action = "+diagnostics/debug"; + } + { + key = "dt"; + action = "TroubleToggle"; + options.desc = "Toggle trouble"; + } - # Rust - { - mode = "n"; - key = "r"; - action = "+rust"; - } - { - # Start standalone rust-analyzer (fixes issues when opening files from nvim tree) - mode = "n"; - key = "rs"; - action = "RustStartStandaloneServerForBuffer"; - options.desc = "Start standalone rust-analyzer"; - } - ]; + # Rust + { + mode = "n"; + key = "r"; + action = "+rust"; + } + { + # Start standalone rust-analyzer (fixes issues when opening files from nvim tree) + mode = "n"; + key = "rs"; + action = "RustStartStandaloneServerForBuffer"; + options.desc = "Start standalone rust-analyzer"; + } + ] + ++ (import ./custom/binds.nix); } diff --git a/nixos/configuration.nix b/nixos/configuration.nix index d4c1dff..82cd0bc 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -10,6 +10,7 @@ imports = [ ../common/variables.nix ./greetd.nix + #./ly.nix ./bootloader.nix ./nvidia.nix ./fonts.nix diff --git a/nixos/ly.nix b/nixos/ly.nix new file mode 100644 index 0000000..20482d0 --- /dev/null +++ b/nixos/ly.nix @@ -0,0 +1,9 @@ +{ + pkgs, + config, + ... +}: { + services.displayManager.ly = { + enable = true; + }; +}