From ede76d2bc2a78569fe2e3b2442155e9ec43924f7 Mon Sep 17 00:00:00 2001 From: Patrick Stevens <3138005+Smaug123@users.noreply.github.com> Date: Tue, 6 Aug 2024 20:14:01 +0100 Subject: [PATCH] Update flake (breaks ;; in which-key) (#67) --- flake.lock | 44 ++++++------ home-manager/home.nix | 6 ++ home-manager/nvim/dotnet.lua | 2 +- home-manager/nvim/init.lua | 96 +++++++++++++-------------- home-manager/nvim/lean.lua | 24 +++---- home-manager/nvim/lspconfig.lua | 82 +++++++++++------------ home-manager/nvim/nvim-dap-python.lua | 16 ++--- home-manager/nvim/nvim-dap.lua | 63 +++++++++--------- home-manager/nvim/python.lua | 14 ++-- home-manager/nvim/tokyonight.lua | 3 + home-manager/nvim/venv-selector.lua | 23 +++---- home-manager/nvim/which-key.lua | 48 -------------- 12 files changed, 181 insertions(+), 240 deletions(-) diff --git a/flake.lock b/flake.lock index b125383..c1a8097 100644 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1718588737, - "narHash": "sha256-06acqoMEYtc+/w5gWiIIuUFfdtdOBKlp1qrC/InRiBY=", + "lastModified": 1722469787, + "narHash": "sha256-P20oAmbgXHl1E77TXPXiAj1Ntycc1mf7fZMI7X13VYw=", "owner": "tpwrules", "repo": "nixos-apple-silicon", - "rev": "b0a2376f6c164a0af963d47386c064cc6fdcd5ea", + "rev": "8a665fee82901878edaeb8ee120296a979db2dd2", "type": "github" }, "original": { @@ -27,11 +27,11 @@ ] }, "locked": { - "lastModified": 1720599442, - "narHash": "sha256-jdm+sKVbBXoyrxcHbVaV0htlpq2iFR+eJw3Xe/DPcDo=", + "lastModified": 1722609272, + "narHash": "sha256-Kkb+ULEHVmk07AX+OhwyofFxBDpw+2WvsXguUS2m6e4=", "owner": "lnl7", "repo": "nix-darwin", - "rev": "cf297a8d248db6a455b60133f6c0029c04ebe50e", + "rev": "f7142b8024d6b70c66fd646e1d099d3aa5bfec49", "type": "github" }, "original": { @@ -50,11 +50,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1720686070, - "narHash": "sha256-zn6PPb38Z4+fJuDRGGN81XERkvxalXN4CtkRrQnrb7c=", + "lastModified": 1722874856, + "narHash": "sha256-h5I4R1iC7DT9osViQQRjxjwGbrJN7e2Ex5fYBSKc5SM=", "owner": "nix-community", "repo": "emacs-overlay", - "rev": "497bb499753986ce2ca3b7359532e7147cfb7f30", + "rev": "cd006b0c4505ce610b8d6b67f6b4e92e9bd794e9", "type": "github" }, "original": { @@ -121,11 +121,11 @@ ] }, "locked": { - "lastModified": 1720646128, - "narHash": "sha256-BivO5yIQukDlJL+1875Sqf3GuOPxZDdA48dYDi3PkL8=", + "lastModified": 1722630065, + "narHash": "sha256-QfM/9BMRkCmgWzrPDK+KbgJOUlSJnfX4OvsUupEUZvA=", "owner": "nix-community", "repo": "home-manager", - "rev": "c085b984ff2808bf322f375b10fea5a415a9c43d", + "rev": "afc892db74d65042031a093adb6010c4c3378422", "type": "github" }, "original": { @@ -148,27 +148,27 @@ }, "nixpkgs": { "locked": { - "lastModified": 1718318537, - "narHash": "sha256-4Zu0RYRcAY/VWuu6awwq4opuiD//ahpc2aFHg2CWqFY=", + "lastModified": 1722185531, + "narHash": "sha256-veKR07psFoJjINLC8RK4DiLniGGMgF3QMlS4tb74S6k=", "owner": "nixos", "repo": "nixpkgs", - "rev": "e9ee548d90ff586a6471b4ae80ae9cfcbceb3420", + "rev": "52ec9ac3b12395ad677e8b62106f0b98c1f8569d", "type": "github" }, "original": { "owner": "nixos", + "ref": "nixos-unstable", "repo": "nixpkgs", - "rev": "e9ee548d90ff586a6471b4ae80ae9cfcbceb3420", "type": "github" } }, "nixpkgs-stable": { "locked": { - "lastModified": 1720553833, - "narHash": "sha256-IXMiHQMtdShDXcBW95ctA+m5Oq2kLxnBt7WlMxvDQXA=", + "lastModified": 1722651103, + "narHash": "sha256-IRiJA0NVAoyaZeKZluwfb2DoTpBAj+FLI0KfybBeDU0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "249fbde2a178a2ea2638b65b9ecebd531b338cf9", + "rev": "a633d89c6dc9a2a8aae11813a62d7c58b2c0cc51", "type": "github" }, "original": { @@ -180,11 +180,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1720594544, - "narHash": "sha256-w6dlBUQYvS65f0Z33TvkcAj7ITr4NFqhF5ywss5T5bU=", + "lastModified": 1722730825, + "narHash": "sha256-X6U+w8qFBuGPCYrZzc9mpN34aRjQ8604MonpBUkj908=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "aa9461550594533c29866d42f861b6ff079a7fb6", + "rev": "f3834de3782b82bfc666abf664f946d0e7d1f116", "type": "github" }, "original": { diff --git a/home-manager/home.nix b/home-manager/home.nix index 014c2fc..3634aea 100644 --- a/home-manager/home.nix +++ b/home-manager/home.nix @@ -129,6 +129,12 @@ in { enable = true; plugins = [ + { + plugin = nixpkgs.vimPlugins.nvim-web-devicons; + } + { + plugin = nixpkgs.vimPlugins.mini-nvim; + } { plugin = nixpkgs.vimPlugins.nvim-lightbulb; type = "lua"; diff --git a/home-manager/nvim/dotnet.lua b/home-manager/nvim/dotnet.lua index 0824b09..ed1b30b 100644 --- a/home-manager/nvim/dotnet.lua +++ b/home-manager/nvim/dotnet.lua @@ -73,7 +73,7 @@ function RegisterSolution(sln_path) end local whichkey = require("which-key") - whichkey.register({ + whichkey.add({ s = { name = ".NET solution", b = { BuildDotNetSolution, "Build .NET solution" }, diff --git a/home-manager/nvim/init.lua b/home-manager/nvim/init.lua index d399a7b..d68942b 100644 --- a/home-manager/nvim/init.lua +++ b/home-manager/nvim/init.lua @@ -169,8 +169,6 @@ function DisplayAllMappingsWithTelescope() local function accumulate(tree) tree:walk(function(node) - -- Note: we could (if desired) view all groups, because the `node.mapping` table looks like this: - -- { prefix = "g", group = true, keys = {...}} if node.mapping then local mapping = node.mapping if not mapping.group then @@ -224,69 +222,65 @@ function ToggleSpell() vim.cmd("setlocal spell!") end -whichkey.register({ - [vim.api.nvim_get_var("maplocalleader")] = { - DisplayAllMappingsWithTelescope, - "View all mappings", +whichkey.add({ + { + "", + function() + require("which-key").show({ global = false }) + end, + desc = "View all mappings", }, - m = { - p = { MarkdownPreview, "Preview Markdown in Lynx" }, - d = { RemoveCarriageReturn, "Delete carriage returns from file" }, - }, - ["j"] = { - FormatJson, - "Auto-format JSON", - }, -}, { prefix = vim.api.nvim_get_var("maplocalleader") }) -whichkey.register({ - g = { + { "mp", MarkdownPreview, desc = "Preview Markdown in Lynx" }, + { "md", RemoveCarriageReturn, desc = "Delete carriage returns from file" }, + { "j", FormatJson, desc = "Auto-format JSON" }, +}) +whichkey.add({ + { + "g", function() require("telescope.builtin").grep_string() end, - "Find instances of text under cursor", + desc = "Find instances of text under cursor", }, - h = { - name = "Find historical...", - f = { - function() - require("telescope.builtin").oldfiles() - end, - "List previously open files", - }, - c = { - function() - require("telescope.builtin").command_history() - end, - "List previously run commands", - }, - s = { - function() - require("telescope.builtin").search_history() - end, - "List previously run searches", - }, + { "h", desc = "Find historical..." }, + { + "hf", + function() + require("telescope.builtin").oldfiles() + end, + desc = "List previously open files", }, - m = { + { + "hc", + function() + require("telescope.builtin").command_history() + end, + desc = "List previously run commands", + }, + { + "hs", + function() + require("telescope.builtin").search_history() + end, + desc = "List previously run searches", + }, + { + "m", function() require("telescope.builtin").marks() end, - "List marks", + desc = "List marks", }, - ["cd"] = { - ChangeToCurrentDirectory, - "Switch CWD to the directory of the open buffer", - }, - ["ss"] = { - ToggleSpell, - "Toggle spell-checker on or off", - }, - [vim.api.nvim_get_var("mapleader")] = { + { "cd", ChangeToCurrentDirectory, desc = "Switch CWD to the directory of the open buffer" }, + { "ss", ToggleSpell, desc = "Toggle spell-checker on or off" }, + { + "", function() require("telescope.builtin").find_files() end, - "Find files by name", + desc = "Find files by name", }, -}, { prefix = vim.api.nvim_get_var("mapleader") }) +}) vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { pattern = { "Directory.Build.props", "*.fsproj", "*.csproj" }, diff --git a/home-manager/nvim/lean.lua b/home-manager/nvim/lean.lua index 667e9ba..b74c961 100644 --- a/home-manager/nvim/lean.lua +++ b/home-manager/nvim/lean.lua @@ -2,16 +2,16 @@ require("lspconfig")["leanls"].setup({}) require("lean").setup({}) -require("which-key").register({ - l = { - i = { "LeanInfoviewToggle", "Toggle Lean info view" }, - p = { "LeanInfoviewPinTogglePause", "Pause Lean info view" }, - s = { "LeanSorryFill", "Fill open goals with sorry" }, - w = { "LeanInfoviewEnableWidgets", "Enable Lean widgets" }, - W = { "LeanInfoviewDisableWidgets", "Disable Lean widgets" }, - ["?"] = { - "LeanAbbreviationsReverseLookup", - "Show what Lean abbreviation produces the symbol under the cursor", - }, +require("which-key").add({ + { "l", desc = "Lean" }, + { "li", "LeanInfoviewToggle", desc = "Toggle Lean info view" }, + { "lp", "LeanInfoviewPinTogglePause", desc = "Pause Lean info view" }, + { "ls", "LeanSorryFill", desc = "Fill open goals with sorry" }, + { "lw", "LeanInfoviewEnableWidgets", desc = "Enable Lean widgets" }, + { "lW", "LeanInfoviewDisableWidgets", desc = "Disable Lean widgets" }, + { + "l?", + "LeanAbbreviationsReverseLookup", + desc = "Show what Lean abbreviation produces the symbol under the cursor", }, -}, { prefix = vim.api.nvim_get_var("maplocalleader") }) +}) diff --git a/home-manager/nvim/lspconfig.lua b/home-manager/nvim/lspconfig.lua index 2d84efd..06b4447 100644 --- a/home-manager/nvim/lspconfig.lua +++ b/home-manager/nvim/lspconfig.lua @@ -118,15 +118,13 @@ end do local whichkey_status, whichkey = pcall(require, "which-key") if whichkey_status then - whichkey.register({ - l = { - name = "loclist-related commands", - p = { vim.diagnostic.goto_prev, "Go to previous entry in loclist" }, - n = { vim.diagnostic.goto_next, "Go to next entry in loclist" }, - l = { ToggleLocList, "Toggle loclist" }, - f = { vim.diagnostic.open_float, "Open current loclist entry in floating window" }, - }, - }, { prefix = vim.api.nvim_get_var("mapleader") }) + whichkey.add({ + { "l", desc = "loclist-related commands" }, + { "lp", vim.diagnostic.goto_prev, desc = "Go to previous entry in loclist" }, + { "ln", vim.diagnostic.goto_next, desc = "Go to next entry in loclist" }, + { "ll", ToggleLocList, desc = "Toggle loclist" }, + { "lf", vim.diagnostic.open_float, desc = "Open current loclist entry in floating window" }, + }) else vim.keymap.set("n", "lp", vim.diagnostic.goto_prev) vim.keymap.set("n", "ln", vim.diagnostic.goto_next) @@ -146,48 +144,44 @@ vim.api.nvim_create_autocmd("LspAttach", { -- Buffer local mappings. -- See `:help vim.lsp.*` for documentation on any of the below functions - whichkey.register({ - g = { - name = "Go-to related commands", - D = { vim.lsp.buf.declaration, "Go to declaration" }, - d = { vim.lsp.buf.definition, "Go to definition" }, - i = { vim.lsp.buf.implementation, "Go to implementation" }, - r = { - function() - require("telescope.builtin").lsp_references() - end, - "Find references", - }, + whichkey.add({ + { "g", desc = "Go-to related commands" }, + { "gD", vim.lsp.buf.declaration, desc = "Go to declaration" }, + { "gd", vim.lsp.buf.definition, desc = "Go to definition" }, + { "gi", vim.lsp.buf.implementation, desc = "Go to implementation" }, + { + "gr", + function() + require("telescope.builtin").lsp_references() + end, + desc = "Find references", }, - K = { vim.lsp.buf.hover, "Display information about symbol under cursor" }, + { "gK", vim.lsp.buf.hover, desc = "Display information about symbol under cursor" }, }) - whichkey.register({ - [""] = { vim.lsp.buf.signature_help, "Display signature information about symbol under cursor" }, + whichkey.add({ + { "", vim.lsp.buf.signature_help, desc = "Display signature information about symbol under cursor" }, }) - whichkey.register({ - w = { - a = { vim.lsp.buf.add_workspace_folder, "Add a path to the workspace folders list" }, - r = { vim.lsp.buf.add_workspace_folder, "Remove a path from the workspace folders list" }, - l = { - function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, - "Show the workspace folders list", - }, + whichkey.add({ + { "w", desc = "Workspace-related commands" }, + { "wa", vim.lsp.buf.add_workspace_folder, desc = "Add a path to the workspace folders list" }, + { "wr", vim.lsp.buf.add_workspace_folder, desc = "Remove a path from the workspace folders list" }, + { + "wl", + function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, + desc = "Show the workspace folders list", }, - f = { + { + "f", function() vim.lsp.buf.format({ async = true }) end, - "Autoformat", + desc = "Autoformat", }, - c = { - a = { vim.lsp.buf.code_action, "Select a code action" }, - }, - r = { - n = { vim.lsp.buf.rename, "Rename variable" }, - }, - D = { vim.lsp.buf.type_definition, "Go to type definition" }, - }, { prefix = vim.api.nvim_get_var("mapleader") }) + { "ca", vim.lsp.buf.code_action, desc = "Select a code action" }, + { "rn", vim.lsp.buf.rename, desc = "Rename variable" }, + { "D", vim.lsp.buf.type_definition, desc = "Go to type definition" }, + }) end, }) diff --git a/home-manager/nvim/nvim-dap-python.lua b/home-manager/nvim/nvim-dap-python.lua index 79f524a..898dce1 100644 --- a/home-manager/nvim/nvim-dap-python.lua +++ b/home-manager/nvim/nvim-dap-python.lua @@ -2,14 +2,10 @@ require("dap-python").setup("%PYTHONENV%/bin/python") do local whichkey = require("which-key") - whichkey.register({ - ["pd"] = { - "Debugger-related commands", - t = { - "Tests", - f = { require("dap-python").test_class, "Run Python tests in the current file" }, - c = { require("dap-python").test_method, "Run the Python test under the cursor" }, - }, - }, - }, { prefix = vim.api.nvim_get_var("maplocalleader") }) + whichkey.add({ + { "pd", desc = "Debugger-related commands" }, + { "pdt", desc = "Tests" }, + { "pdtf", require("dap-python").test_class, desc = "Run Python tests in the current file" }, + { "pdtc", require("dap-python").test_method, desc = "Run the Python test under the cursor" }, + }) end diff --git a/home-manager/nvim/nvim-dap.lua b/home-manager/nvim/nvim-dap.lua index 49da93d..630ac31 100644 --- a/home-manager/nvim/nvim-dap.lua +++ b/home-manager/nvim/nvim-dap.lua @@ -30,37 +30,36 @@ dap.configurations.cs = { do local whichkey = require("which-key") - whichkey.register({ - d = { - name = "Debugger-related commands", - o = { dap.step_over, "Step over" }, - i = { dap.step_into, "Step into" }, - c = { dap.continue, "Continue" }, - C = { dap.run_last, "Run with last debug configuration" }, - b = { dap.toggle_breakpoint, "Toggle breakpoint" }, - r = { dap.repl.open, "Open debug repl" }, - v = { - name = "Commands to view debugger state", - v = { - function() - dap_ui.hover() - end, - "View value of expression under cursor", - }, - s = { - function() - dap_ui.sidebar(dap_ui.scopes).open() - end, - "View values of all variables in all scopes", - }, - f = { - function() - dap_ui.sidebar(dap_ui.frames).open() - end, - "View stack frames", - }, - }, - t = { dap.terminate, "Terminate/stop/end debug session" }, + whichkey.add({ + { "d", desc = "Debugger-related commands" }, + { "do", dap.step_over, desc = "Step over" }, + { "di", dap.step_into, desc = "Step into" }, + { "dc", dap.continue, desc = "Continue" }, + { "dC", dap.run_last, desc = "Run with last debug configuration" }, + { "db", dap.toggle_breakpoint, desc = "Toggle breakpoint" }, + { "dr", dap.repl.open, desc = "Open debug repl" }, + { "dv", desc = "Commands to view debugger state" }, + { + "dvv", + function() + dap_ui.hover() + end, + desc = "View value of expression under cursor", }, - }, { prefix = vim.api.nvim_get_var("maplocalleader") }) + { + "dvs", + function() + dap_ui.sidebar(dap_ui.scopes).open() + end, + desc = "View values of all variables in all scopes", + }, + { + "dvf", + function() + dap_ui.sidebar(dap_ui.frames).open() + end, + desc = "View stack frames", + }, + { "dt", dap.terminate, desc = "Terminate/stop/end debug session" }, + }) end diff --git a/home-manager/nvim/python.lua b/home-manager/nvim/python.lua index a7be732..b38fbf9 100644 --- a/home-manager/nvim/python.lua +++ b/home-manager/nvim/python.lua @@ -55,12 +55,10 @@ end do local whichkey = require("which-key") - whichkey.register({ - ["pt"] = { - "Run Python tests", - f = { RunPythonTestsInFile, "Run Python tests in the current file" }, - a = { RunAllPythonTests, "Run all Python tests" }, - c = { RunPythonTestAtCursor, "Run the Python test under the cursor" }, - }, - }, { prefix = vim.api.nvim_get_var("maplocalleader") }) + whichkey.add({ + { "pt", desc = "Run Python tests" }, + { "ptf", RunPythonTestsInFile, desc = "Run Python tests in the current file" }, + { "pta", RunAllPythonTests, desc = "Run all Python tests" }, + { "ptc", RunPythonTestAtCursor, desc = "Run the Python test under the cursor" }, + }) end diff --git a/home-manager/nvim/tokyonight.lua b/home-manager/nvim/tokyonight.lua index 229ff32..761a794 100644 --- a/home-manager/nvim/tokyonight.lua +++ b/home-manager/nvim/tokyonight.lua @@ -1,5 +1,8 @@ require("tokyonight").setup({ style = "night", + on_colors = function(colors) + colors.border = "#565f89" + end, }) vim.cmd([[colorscheme tokyonight]]) diff --git a/home-manager/nvim/venv-selector.lua b/home-manager/nvim/venv-selector.lua index 3205606..d1f76e4 100644 --- a/home-manager/nvim/venv-selector.lua +++ b/home-manager/nvim/venv-selector.lua @@ -84,17 +84,16 @@ end do local whichkey = require("which-key") - whichkey.register({ - ["pv"] = { - name = "Python virtual environment-related commands", - c = { CreateVenv, "Create virtual environment" }, - l = { SelectVenv, "Load virtual environment" }, - o = { - function() - vim.cmd("VenvSelect") - end, - "Choose (override) new virtual environment", - }, + whichkey.add({ + { "pv", desc = "Python virtual environment-related commands" }, + { "pvc", CreateVenv, desc = "Create virtual environment" }, + { "pvl", SelectVenv, desc = "Load virtual environment" }, + { + "pvo", + function() + vim.cmd("VenvSelect") + end, + desc = "Choose (override) new virtual environment", }, - }, { prefix = vim.api.nvim_get_var("maplocalleader") }) + }) end diff --git a/home-manager/nvim/which-key.lua b/home-manager/nvim/which-key.lua index c94e855..77e55e7 100644 --- a/home-manager/nvim/which-key.lua +++ b/home-manager/nvim/which-key.lua @@ -18,67 +18,19 @@ require("which-key").setup({ g = true, -- bindings for prefixed with g }, }, - -- add operators that will trigger motion and text object completion - -- to enable all native operators, set the preset / operators plugin above - operators = { gc = "Comments" }, - key_labels = { - -- override the label used to display some keys. It doesn't effect WK in any other way. - -- For example: - -- [""] = "SPC", - -- [""] = "RET", - -- [""] = "TAB", - }, - motions = { - count = true, - }, icons = { breadcrumb = "»", -- symbol used in the command line area that shows your active key combo separator = "➜", -- symbol used between a key and it's label group = "+", -- symbol prepended to a group }, - popup_mappings = { - scroll_down = "", -- binding to scroll down inside the popup - scroll_up = "", -- binding to scroll up inside the popup - }, - window = { - border = "none", -- none, single, double, shadow - position = "bottom", -- bottom, top - margin = { 1, 0, 1, 0 }, -- extra window margin [top, right, bottom, left]. When between 0 and 1, will be treated as a percentage of the screen size. - padding = { 1, 2, 1, 2 }, -- extra window padding [top, right, bottom, left] - winblend = 0, -- value between 0-100 0 for fully opaque and 100 for fully transparent - zindex = 1000, -- positive value to position WhichKey above other floating windows. - }, layout = { height = { min = 4, max = 25 }, -- min and max height of the columns width = { min = 20, max = 50 }, -- min and max width of the columns spacing = 3, -- spacing between columns align = "left", -- align columns left, center or right }, - ignore_missing = false, -- enable this to hide mappings for which you didn't specify a label - hidden = { "", "", "", "", "^:", "^ ", "^call ", "^lua " }, -- hide mapping boilerplate show_help = true, -- show a help message in the command line for using WhichKey show_keys = true, -- show the currently pressed key and its label as a message in the command line - triggers = "auto", -- automatically setup triggers - -- triggers = {""} -- or specifiy a list manually - -- list of triggers, where WhichKey should not wait for timeoutlen and show immediately - triggers_nowait = { - -- marks - "`", - "'", - "g`", - "g'", - -- registers - '"', - "", - -- spelling - "z=", - }, - triggers_blacklist = { - -- list of mode / prefixes that should never be hooked by WhichKey - -- this is mostly relevant for keymaps that start with a native binding - i = { "j", "k" }, - v = { "j", "k" }, - }, -- disable the WhichKey popup for certain buf types and file types. -- Disabled by default for Telescope disable = {