Compare commits

...

2 commits

Author SHA1 Message Date
aab1848b02
nix update 2024-12-30 09:44:34 +01:00
d2044e7747
nvim: implement projects picker 2024-12-30 09:43:26 +01:00
3 changed files with 108 additions and 67 deletions

View file

@ -116,11 +116,11 @@
"zig": "zig"
},
"locked": {
"lastModified": 1735508351,
"narHash": "sha256-hrmauluOxnJlvc49WeclJdoz24Nb7c/WHhyLGkmpde8=",
"lastModified": 1735535921,
"narHash": "sha256-cfsHww91bRA2Frni54+blIGZGU9/269vaWzeGcNRNN0=",
"owner": "ghostty-org",
"repo": "ghostty",
"rev": "b3925b83ae4b24b02a9b268e88dffcf1af25734b",
"rev": "87bd0bb744d6a1c45022aa39f21219d0b6ff3261",
"type": "github"
},
"original": {
@ -246,11 +246,11 @@
"treefmt-nix": "treefmt-nix"
},
"locked": {
"lastModified": 1735463474,
"narHash": "sha256-QTw0q1dJnoFygq9aiwjrXsX5cZEwruVzPz3VKg8KemQ=",
"lastModified": 1735517129,
"narHash": "sha256-ibHgAkr8OXAP8MRBo4Z7AIaVdOHywGR2J8R50vZCQjI=",
"owner": "nix-community",
"repo": "neovim-nightly-overlay",
"rev": "3d6e49088eae842b6c0556fba66cfb14123f0d59",
"rev": "fd381a5a19f553c2466dc437fb94fcf799d77e82",
"type": "github"
},
"original": {
@ -262,11 +262,11 @@
"neovim-src": {
"flake": false,
"locked": {
"lastModified": 1735384850,
"narHash": "sha256-e1KLj+283Znt14U9DkKw+zPqShe0AkFPGpT44BhZ9KU=",
"lastModified": 1735489459,
"narHash": "sha256-PMeWazyxGxpA6UeVrWH/ur8WuqliGxXlRjTTQdMiYVc=",
"owner": "neovim",
"repo": "neovim",
"rev": "2b07b14eacf3197754c63f42f9c880e85960eef2",
"rev": "e4bc8b5967d22840c1e52c97acab0f77107cd48c",
"type": "github"
},
"original": {
@ -309,11 +309,11 @@
},
"nixpkgs-stable_2": {
"locked": {
"lastModified": 1735264675,
"narHash": "sha256-MgdXpeX2GuJbtlBrH9EdsUeWl/yXEubyvxM1G+yO4Ak=",
"lastModified": 1735412871,
"narHash": "sha256-Qoz0ow6jDGUIBHxduc7Y1cjYFS71tvEGJV5Src/mj98=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "d49da4c08359e3c39c4e27c74ac7ac9b70085966",
"rev": "9f94733f93e4fe6e82f516efae007096e4ab5a21",
"type": "github"
},
"original": {
@ -341,11 +341,11 @@
},
"nixpkgs-unstable_2": {
"locked": {
"lastModified": 1735268880,
"narHash": "sha256-7QEFnKkzD13SPxs+UFR5bUFN2fRw+GlL0am72ZjNre4=",
"lastModified": 1735523292,
"narHash": "sha256-opBsbR/nrGxiiF6XzlVluiHYb6yN/hEwv+lBWTy9xoM=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "7cc0bff31a3a705d3ac4fdceb030a17239412210",
"rev": "6d97d419e5a9b36e6293887a89a078cf85f5a61b",
"type": "github"
},
"original": {
@ -357,11 +357,11 @@
},
"nixpkgs_2": {
"locked": {
"lastModified": 1735291276,
"narHash": "sha256-NYVcA06+blsLG6wpAbSPTCyLvxD/92Hy4vlY9WxFI1M=",
"lastModified": 1735471104,
"narHash": "sha256-0q9NGQySwDQc7RhAV2ukfnu7Gxa5/ybJ2ANT8DQrQrs=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "634fd46801442d760e09493a794c4f15db2d0cbb",
"rev": "88195a94f390381c6afcdaa933c2f6ff93959cb4",
"type": "github"
},
"original": {

View file

@ -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', '<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>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>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"))

View file

@ -64,6 +64,45 @@ require('mini.pick').setup({
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)
local root_patterns = { ".jj", ".git" }
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"
return MiniPick.builtin.files(local_opts, { source = { cwd = root_dir, tool = "rg" } })
end
MiniPick.registry.grep_live_root = function(local_opts)
local root_patterns = { ".jj", ".git" }
local root_dir = vim.fs.dirname(vim.fs.find(root_patterns, { upward = true })[1])
@ -128,7 +168,7 @@ require("mini.pick").registry.buffers = function(local_opts, opts)
})
end
return require("mini.pick").start(opts)
end
end
local miniclue = require('mini.clue')
miniclue.setup({ -- cute prompts about bindings