Compare commits
2 commits
46c13deee7
...
aab1848b02
Author | SHA1 | Date | |
---|---|---|---|
aab1848b02 | |||
d2044e7747 |
3 changed files with 108 additions and 67 deletions
36
flake.lock
36
flake.lock
|
@ -116,11 +116,11 @@
|
||||||
"zig": "zig"
|
"zig": "zig"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1735508351,
|
"lastModified": 1735535921,
|
||||||
"narHash": "sha256-hrmauluOxnJlvc49WeclJdoz24Nb7c/WHhyLGkmpde8=",
|
"narHash": "sha256-cfsHww91bRA2Frni54+blIGZGU9/269vaWzeGcNRNN0=",
|
||||||
"owner": "ghostty-org",
|
"owner": "ghostty-org",
|
||||||
"repo": "ghostty",
|
"repo": "ghostty",
|
||||||
"rev": "b3925b83ae4b24b02a9b268e88dffcf1af25734b",
|
"rev": "87bd0bb744d6a1c45022aa39f21219d0b6ff3261",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -246,11 +246,11 @@
|
||||||
"treefmt-nix": "treefmt-nix"
|
"treefmt-nix": "treefmt-nix"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1735463474,
|
"lastModified": 1735517129,
|
||||||
"narHash": "sha256-QTw0q1dJnoFygq9aiwjrXsX5cZEwruVzPz3VKg8KemQ=",
|
"narHash": "sha256-ibHgAkr8OXAP8MRBo4Z7AIaVdOHywGR2J8R50vZCQjI=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "neovim-nightly-overlay",
|
"repo": "neovim-nightly-overlay",
|
||||||
"rev": "3d6e49088eae842b6c0556fba66cfb14123f0d59",
|
"rev": "fd381a5a19f553c2466dc437fb94fcf799d77e82",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -262,11 +262,11 @@
|
||||||
"neovim-src": {
|
"neovim-src": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1735384850,
|
"lastModified": 1735489459,
|
||||||
"narHash": "sha256-e1KLj+283Znt14U9DkKw+zPqShe0AkFPGpT44BhZ9KU=",
|
"narHash": "sha256-PMeWazyxGxpA6UeVrWH/ur8WuqliGxXlRjTTQdMiYVc=",
|
||||||
"owner": "neovim",
|
"owner": "neovim",
|
||||||
"repo": "neovim",
|
"repo": "neovim",
|
||||||
"rev": "2b07b14eacf3197754c63f42f9c880e85960eef2",
|
"rev": "e4bc8b5967d22840c1e52c97acab0f77107cd48c",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -309,11 +309,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs-stable_2": {
|
"nixpkgs-stable_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1735264675,
|
"lastModified": 1735412871,
|
||||||
"narHash": "sha256-MgdXpeX2GuJbtlBrH9EdsUeWl/yXEubyvxM1G+yO4Ak=",
|
"narHash": "sha256-Qoz0ow6jDGUIBHxduc7Y1cjYFS71tvEGJV5Src/mj98=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "d49da4c08359e3c39c4e27c74ac7ac9b70085966",
|
"rev": "9f94733f93e4fe6e82f516efae007096e4ab5a21",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -341,11 +341,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs-unstable_2": {
|
"nixpkgs-unstable_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1735268880,
|
"lastModified": 1735523292,
|
||||||
"narHash": "sha256-7QEFnKkzD13SPxs+UFR5bUFN2fRw+GlL0am72ZjNre4=",
|
"narHash": "sha256-opBsbR/nrGxiiF6XzlVluiHYb6yN/hEwv+lBWTy9xoM=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "7cc0bff31a3a705d3ac4fdceb030a17239412210",
|
"rev": "6d97d419e5a9b36e6293887a89a078cf85f5a61b",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -357,11 +357,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs_2": {
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1735291276,
|
"lastModified": 1735471104,
|
||||||
"narHash": "sha256-NYVcA06+blsLG6wpAbSPTCyLvxD/92Hy4vlY9WxFI1M=",
|
"narHash": "sha256-0q9NGQySwDQc7RhAV2ukfnu7Gxa5/ybJ2ANT8DQrQrs=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "634fd46801442d760e09493a794c4f15db2d0cbb",
|
"rev": "88195a94f390381c6afcdaa933c2f6ff93959cb4",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
@ -127,6 +127,7 @@ vim.keymap.set('n', '<Leader>f', "<cmd>Pick files_root<cr>", opts("Open file pic
|
||||||
vim.keymap.set('n', '<c-p>', "<Leader>f", { remap = true })
|
vim.keymap.set('n', '<c-p>', "<Leader>f", { remap = true })
|
||||||
vim.keymap.set('n', '<Leader>g', "<cmd>Pick oldfiles<cr>", opts("Open file picker history"))
|
vim.keymap.set('n', '<Leader>g', "<cmd>Pick oldfiles<cr>", opts("Open file picker history"))
|
||||||
vim.keymap.set("n", '<Leader>k', vim.lsp.buf.hover, opts("Show docs for item under cursor"))
|
vim.keymap.set("n", '<Leader>k', vim.lsp.buf.hover, opts("Show docs for item under cursor"))
|
||||||
|
vim.keymap.set('n', '<Leader>p', "<cmd>Pick projects<cr>", opts("Open projects picker"))
|
||||||
vim.keymap.set('n', '<Leader>q', require('mini.bufremove').delete, opts("Delete buffer"))
|
vim.keymap.set('n', '<Leader>q', require('mini.bufremove').delete, opts("Delete buffer"))
|
||||||
vim.keymap.set('n', '<Leader>s', "<cmd>Pick lsp scope='document_symbol'<cr>", opts("Open symbol picker"))
|
vim.keymap.set('n', '<Leader>s', "<cmd>Pick lsp scope='document_symbol'<cr>", opts("Open symbol picker"))
|
||||||
vim.keymap.set('n', '<Leader>S', "<cmd>Pick lsp scope='workspace_symbol'<cr>", opts("Open workspace symbol picker"))
|
vim.keymap.set('n', '<Leader>S', "<cmd>Pick lsp scope='workspace_symbol'<cr>", opts("Open workspace symbol picker"))
|
||||||
|
|
|
@ -64,6 +64,45 @@ require('mini.pick').setup({
|
||||||
config = picker_win_config,
|
config = picker_win_config,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
MiniPick.registry.projects = function(local_opts)
|
||||||
|
local root = vim.fn.expand("~/src")
|
||||||
|
|
||||||
|
local command = {
|
||||||
|
"fd",
|
||||||
|
"--max-depth=8",
|
||||||
|
"--one-file-system",
|
||||||
|
"--unrestricted",
|
||||||
|
"--full-path",
|
||||||
|
"/.jj/repo/store/type$|/.git/HEAD$",
|
||||||
|
root,
|
||||||
|
}
|
||||||
|
|
||||||
|
local postprocess = function(paths)
|
||||||
|
local result = {}
|
||||||
|
for _, path in ipairs(paths) do
|
||||||
|
path = path:gsub("%/.jj/repo/store/type$", "")
|
||||||
|
path = path:gsub("%/.git/HEAD$", "")
|
||||||
|
local item = {
|
||||||
|
path = path,
|
||||||
|
text = path:gsub("%" .. root .. "/", " "),
|
||||||
|
}
|
||||||
|
table.insert(result, item)
|
||||||
|
end
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
local choose = function(item)
|
||||||
|
local_opts.cwd = item.path
|
||||||
|
vim.fn.chdir(item.path)
|
||||||
|
vim.schedule(function()
|
||||||
|
MiniPick.builtin.files(local_opts, { source = { cwd = item.path, tool = "rg" } })
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
return MiniPick.builtin.cli({ command = command, postprocess = postprocess }, { source = { choose = choose } })
|
||||||
|
end
|
||||||
|
|
||||||
MiniPick.registry.files_root = function(local_opts)
|
MiniPick.registry.files_root = function(local_opts)
|
||||||
local root_patterns = { ".jj", ".git" }
|
local root_patterns = { ".jj", ".git" }
|
||||||
local root_dir = vim.fs.dirname(vim.fs.find(root_patterns, { upward = true })[1])
|
local root_dir = vim.fs.dirname(vim.fs.find(root_patterns, { upward = true })[1])
|
||||||
|
@ -71,6 +110,7 @@ MiniPick.registry.files_root = function(local_opts)
|
||||||
local_opts.tool = "rg"
|
local_opts.tool = "rg"
|
||||||
return MiniPick.builtin.files(local_opts, { source = { cwd = root_dir, tool = "rg" } })
|
return MiniPick.builtin.files(local_opts, { source = { cwd = root_dir, tool = "rg" } })
|
||||||
end
|
end
|
||||||
|
|
||||||
MiniPick.registry.grep_live_root = function(local_opts)
|
MiniPick.registry.grep_live_root = function(local_opts)
|
||||||
local root_patterns = { ".jj", ".git" }
|
local root_patterns = { ".jj", ".git" }
|
||||||
local root_dir = vim.fs.dirname(vim.fs.find(root_patterns, { upward = true })[1])
|
local root_dir = vim.fs.dirname(vim.fs.find(root_patterns, { upward = true })[1])
|
||||||
|
@ -79,56 +119,56 @@ MiniPick.registry.grep_live_root = function(local_opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
require("mini.pick").registry.buffers = function(local_opts, opts)
|
require("mini.pick").registry.buffers = function(local_opts, opts)
|
||||||
local_opts = vim.tbl_deep_extend(
|
local_opts = vim.tbl_deep_extend(
|
||||||
"force",
|
"force",
|
||||||
{ sort_lastused = false, sort_mru = true, include_current = true, include_unlisted = false },
|
{ sort_lastused = false, sort_mru = true, include_current = true, include_unlisted = false },
|
||||||
local_opts or {}
|
local_opts or {}
|
||||||
)
|
)
|
||||||
local buffers_output = vim.api.nvim_exec("buffers" .. (local_opts.include_unlisted and "!" or ""), true)
|
local buffers_output = vim.api.nvim_exec("buffers" .. (local_opts.include_unlisted and "!" or ""), true)
|
||||||
local cur_buf_id, include_current = vim.api.nvim_get_current_buf(), local_opts.include_current
|
local cur_buf_id, include_current = vim.api.nvim_get_current_buf(), local_opts.include_current
|
||||||
local items = {}
|
local items = {}
|
||||||
local default_selection_idx = 1
|
local default_selection_idx = 1
|
||||||
for _, l in ipairs(vim.split(buffers_output, "\n")) do
|
for _, l in ipairs(vim.split(buffers_output, "\n")) do
|
||||||
local buf_str, name = l:match("^%s*%d+"), l:match('"(.*)"')
|
local buf_str, name = l:match("^%s*%d+"), l:match('"(.*)"')
|
||||||
local buf_id = tonumber(buf_str)
|
local buf_id = tonumber(buf_str)
|
||||||
local flag = buf_id == vim.fn.bufnr("") and "%" or (buf_id == vim.fn.bufnr("#") and "#" or " ")
|
local flag = buf_id == vim.fn.bufnr("") and "%" or (buf_id == vim.fn.bufnr("#") and "#" or " ")
|
||||||
local item = { text = name, bufnr = buf_id, flag = flag }
|
local item = { text = name, bufnr = buf_id, flag = flag }
|
||||||
if buf_id ~= cur_buf_id or include_current then
|
if buf_id ~= cur_buf_id or include_current then
|
||||||
if local_opts.sort_lastused and not local_opts.ignore_current_buffer and flag == "#" then
|
if local_opts.sort_lastused and not local_opts.ignore_current_buffer and flag == "#" then
|
||||||
default_selection_idx = 2
|
default_selection_idx = 2
|
||||||
end
|
end
|
||||||
if local_opts.sort_lastused and (flag == "#" or flag == "%") then
|
if local_opts.sort_lastused and (flag == "#" or flag == "%") then
|
||||||
local idx = ((items[1] ~= nil and items[1].flag == "%") and 2 or 1)
|
local idx = ((items[1] ~= nil and items[1].flag == "%") and 2 or 1)
|
||||||
table.insert(items, idx, item)
|
table.insert(items, idx, item)
|
||||||
else
|
else
|
||||||
table.insert(items, item)
|
table.insert(items, item)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if local_opts.sort_mru then
|
if local_opts.sort_mru then
|
||||||
table.sort(items, function(a, b)
|
table.sort(items, function(a, b)
|
||||||
return vim.fn.getbufinfo(a.bufnr)[1].lastused > vim.fn.getbufinfo(b.bufnr)[1].lastused
|
return vim.fn.getbufinfo(a.bufnr)[1].lastused > vim.fn.getbufinfo(b.bufnr)[1].lastused
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
local show = function(buf_id, items, query)
|
local show = function(buf_id, items, query)
|
||||||
require("mini.pick").default_show(buf_id, items, query, { show_icons = true })
|
require("mini.pick").default_show(buf_id, items, query, { show_icons = true })
|
||||||
end
|
end
|
||||||
local default_opts = { source = { name = "Buffers", show = show } }
|
local default_opts = { source = { name = "Buffers", show = show } }
|
||||||
opts = vim.tbl_deep_extend("force", default_opts, opts or {}, { source = { items = items } })
|
opts = vim.tbl_deep_extend("force", default_opts, opts or {}, { source = { items = items } })
|
||||||
if default_selection_idx > 1 then
|
if default_selection_idx > 1 then
|
||||||
vim.api.nvim_create_autocmd("User", {
|
vim.api.nvim_create_autocmd("User", {
|
||||||
pattern = "MiniPickStart",
|
pattern = "MiniPickStart",
|
||||||
once = true,
|
once = true,
|
||||||
callback = function()
|
callback = function()
|
||||||
local mappings = require("mini.pick").get_picker_opts().mappings
|
local mappings = require("mini.pick").get_picker_opts().mappings
|
||||||
local keys = vim.fn["repeat"](mappings.move_down, default_selection_idx - 1)
|
local keys = vim.fn["repeat"](mappings.move_down, default_selection_idx - 1)
|
||||||
vim.api.nvim_input(vim.api.nvim_replace_termcodes(keys, true, true, true))
|
vim.api.nvim_input(vim.api.nvim_replace_termcodes(keys, true, true, true))
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
return require("mini.pick").start(opts)
|
return require("mini.pick").start(opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
local miniclue = require('mini.clue')
|
local miniclue = require('mini.clue')
|
||||||
miniclue.setup({ -- cute prompts about bindings
|
miniclue.setup({ -- cute prompts about bindings
|
||||||
|
|
Loading…
Reference in a new issue