Update flake (breaks ;; in which-key) (#67)

This commit is contained in:
Patrick Stevens
2024-08-06 20:14:01 +01:00
committed by GitHub
parent 19e8024a13
commit ede76d2bc2
12 changed files with 181 additions and 240 deletions

View File

@@ -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";

View File

@@ -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" },

View File

@@ -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({
{
"<localleader><localleader>",
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 = {
{ "<localleader>mp", MarkdownPreview, desc = "Preview Markdown in Lynx" },
{ "<localleader>md", RemoveCarriageReturn, desc = "Delete carriage returns from file" },
{ "<localleader>j", FormatJson, desc = "Auto-format JSON" },
})
whichkey.add({
{
"<leader>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",
},
{ "<leader>h", desc = "Find historical..." },
{
"<leader>hf",
function()
require("telescope.builtin").oldfiles()
end,
desc = "List previously open files",
},
m = {
{
"<leader>hc",
function()
require("telescope.builtin").command_history()
end,
desc = "List previously run commands",
},
{
"<leader>hs",
function()
require("telescope.builtin").search_history()
end,
desc = "List previously run searches",
},
{
"<leader>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")] = {
{ "<leader>cd", ChangeToCurrentDirectory, desc = "Switch CWD to the directory of the open buffer" },
{ "<leader>ss", ToggleSpell, desc = "Toggle spell-checker on or off" },
{
"<leader><leader>",
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" },

View File

@@ -2,16 +2,16 @@ require("lspconfig")["leanls"].setup({})
require("lean").setup({})
require("which-key").register({
l = {
i = { "<Cmd>LeanInfoviewToggle<CR>", "Toggle Lean info view" },
p = { "<Cmd>LeanInfoviewPinTogglePause<CR>", "Pause Lean info view" },
s = { "<Cmd>LeanSorryFill<CR>", "Fill open goals with sorry" },
w = { "<Cmd>LeanInfoviewEnableWidgets<CR>", "Enable Lean widgets" },
W = { "<Cmd>LeanInfoviewDisableWidgets<CR>", "Disable Lean widgets" },
["?"] = {
"<Cmd>LeanAbbreviationsReverseLookup<CR>",
"Show what Lean abbreviation produces the symbol under the cursor",
},
require("which-key").add({
{ "<localleader>l", desc = "Lean" },
{ "<localleader>li", "<Cmd>LeanInfoviewToggle<CR>", desc = "Toggle Lean info view" },
{ "<localleader>lp", "<Cmd>LeanInfoviewPinTogglePause<CR>", desc = "Pause Lean info view" },
{ "<localleader>ls", "<Cmd>LeanSorryFill<CR>", desc = "Fill open goals with sorry" },
{ "<localleader>lw", "<Cmd>LeanInfoviewEnableWidgets<CR>", desc = "Enable Lean widgets" },
{ "<localleader>lW", "<Cmd>LeanInfoviewDisableWidgets<CR>", desc = "Disable Lean widgets" },
{
"<localleader>l?",
"<Cmd>LeanAbbreviationsReverseLookup<CR>",
desc = "Show what Lean abbreviation produces the symbol under the cursor",
},
}, { prefix = vim.api.nvim_get_var("maplocalleader") })
})

View File

@@ -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({
{ "<leader>l", desc = "loclist-related commands" },
{ "<leader>lp", vim.diagnostic.goto_prev, desc = "Go to previous entry in loclist" },
{ "<leader>ln", vim.diagnostic.goto_next, desc = "Go to next entry in loclist" },
{ "<leader>ll", ToggleLocList, desc = "Toggle loclist" },
{ "<leader>lf", vim.diagnostic.open_float, desc = "Open current loclist entry in floating window" },
})
else
vim.keymap.set("n", "<leader>lp", vim.diagnostic.goto_prev)
vim.keymap.set("n", "<leader>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({
["<C-k>"] = { vim.lsp.buf.signature_help, "Display signature information about symbol under cursor" },
whichkey.add({
{ "<C-k>", 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({
{ "<leader>w", desc = "Workspace-related commands" },
{ "<leader>wa", vim.lsp.buf.add_workspace_folder, desc = "Add a path to the workspace folders list" },
{ "<leader>wr", vim.lsp.buf.add_workspace_folder, desc = "Remove a path from the workspace folders list" },
{
"<leader>wl",
function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end,
desc = "Show the workspace folders list",
},
f = {
{
"<leader>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") })
{ "<leader>ca", vim.lsp.buf.code_action, desc = "Select a code action" },
{ "<leader>rn", vim.lsp.buf.rename, desc = "Rename variable" },
{ "<leader>D", vim.lsp.buf.type_definition, desc = "Go to type definition" },
})
end,
})

View File

@@ -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({
{ "<localleader>pd", desc = "Debugger-related commands" },
{ "<localleader>pdt", desc = "Tests" },
{ "<localleader>pdtf", require("dap-python").test_class, desc = "Run Python tests in the current file" },
{ "<localleader>pdtc", require("dap-python").test_method, desc = "Run the Python test under the cursor" },
})
end

View File

@@ -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({
{ "<localleader>d", desc = "Debugger-related commands" },
{ "<localleader>do", dap.step_over, desc = "Step over" },
{ "<localleader>di", dap.step_into, desc = "Step into" },
{ "<localleader>dc", dap.continue, desc = "Continue" },
{ "<localleader>dC", dap.run_last, desc = "Run with last debug configuration" },
{ "<localleader>db", dap.toggle_breakpoint, desc = "Toggle breakpoint" },
{ "<localleader>dr", dap.repl.open, desc = "Open debug repl" },
{ "<localleader>dv", desc = "Commands to view debugger state" },
{
"<localleader>dvv",
function()
dap_ui.hover()
end,
desc = "View value of expression under cursor",
},
}, { prefix = vim.api.nvim_get_var("maplocalleader") })
{
"<localleader>dvs",
function()
dap_ui.sidebar(dap_ui.scopes).open()
end,
desc = "View values of all variables in all scopes",
},
{
"<localleader>dvf",
function()
dap_ui.sidebar(dap_ui.frames).open()
end,
desc = "View stack frames",
},
{ "<localleader>dt", dap.terminate, desc = "Terminate/stop/end debug session" },
})
end

View File

@@ -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({
{ "<localleader>pt", desc = "Run Python tests" },
{ "<localleader>ptf", RunPythonTestsInFile, desc = "Run Python tests in the current file" },
{ "<localleader>pta", RunAllPythonTests, desc = "Run all Python tests" },
{ "<localleader>ptc", RunPythonTestAtCursor, desc = "Run the Python test under the cursor" },
})
end

View File

@@ -1,5 +1,8 @@
require("tokyonight").setup({
style = "night",
on_colors = function(colors)
colors.border = "#565f89"
end,
})
vim.cmd([[colorscheme tokyonight]])

View File

@@ -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({
{ "<localleader>pv", desc = "Python virtual environment-related commands" },
{ "<localleader>pvc", CreateVenv, desc = "Create virtual environment" },
{ "<localleader>pvl", SelectVenv, desc = "Load virtual environment" },
{
"<localleader>pvo",
function()
vim.cmd("VenvSelect")
end,
desc = "Choose (override) new virtual environment",
},
}, { prefix = vim.api.nvim_get_var("maplocalleader") })
})
end

View File

@@ -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:
-- ["<space>"] = "SPC",
-- ["<cr>"] = "RET",
-- ["<tab>"] = "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 = "<c-d>", -- binding to scroll down inside the popup
scroll_up = "<c-u>", -- 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 = { "<silent>", "<cmd>", "<Cmd>", "<CR>", "^:", "^ ", "^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 = {"<leader>"} -- or specifiy a list manually
-- list of triggers, where WhichKey should not wait for timeoutlen and show immediately
triggers_nowait = {
-- marks
"`",
"'",
"g`",
"g'",
-- registers
'"',
"<c-r>",
-- 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 = {