even more jj mini/snacks rice

This commit is contained in:
iofq 2025-06-21 04:13:57 -05:00
parent 83f9f90f1f
commit 75c09a73ff
No known key found for this signature in database
GPG key ID: ECF3B2DA38BF7183
15 changed files with 345 additions and 337 deletions

1
.gitignore vendored
View file

@ -2,3 +2,4 @@ result
*.AppImage *.AppImage
.direnv .direnv
.luarc.json .luarc.json
nvim/lazy*json

View file

@ -7,186 +7,195 @@
pkgs-wrapNeovim ? pkgs, pkgs-wrapNeovim ? pkgs,
}: }:
with lib; with lib;
{ {
# NVIM_APPNAME - Defaults to 'nvim' if not set. # NVIM_APPNAME - Defaults to 'nvim' if not set.
# If set to something else, this will also rename the binary. # If set to something else, this will also rename the binary.
appName ? null, appName ? null,
# The Neovim package to wrap # The Neovim package to wrap
neovim-unwrapped ? pkgs-wrapNeovim.neovim-unwrapped, neovim-unwrapped ? pkgs-wrapNeovim.neovim-unwrapped,
plugins ? [], # List of plugins plugins ? [ ], # List of plugins
# List of dev plugins (will be bootstrapped) - useful for plugin developers # List of dev plugins (will be bootstrapped) - useful for plugin developers
# { name = <plugin-name>; url = <git-url>; } # { name = <plugin-name>; url = <git-url>; }
devPlugins ? [], devPlugins ? [ ],
# Regexes for config files to ignore, relative to the nvim directory. # Regexes for config files to ignore, relative to the nvim directory.
# e.g. [ "^plugin/neogit.lua" "^ftplugin/.*.lua" ] # e.g. [ "^plugin/neogit.lua" "^ftplugin/.*.lua" ]
ignoreConfigRegexes ? [], ignoreConfigRegexes ? [ ],
extraPackages ? [], # Extra runtime dependencies (e.g. ripgrep, ...) extraPackages ? [ ], # Extra runtime dependencies (e.g. ripgrep, ...)
# The below arguments can typically be left as their defaults # The below arguments can typically be left as their defaults
# Additional lua packages (not plugins), e.g. from luarocks.org. # Additional lua packages (not plugins), e.g. from luarocks.org.
# e.g. p: [p.jsregexp] # e.g. p: [p.jsregexp]
extraLuaPackages ? p: [], extraLuaPackages ? p: [ ],
extraPython3Packages ? p: [], # Additional python 3 packages extraPython3Packages ? p: [ ], # Additional python 3 packages
withPython3 ? false, # Build Neovim with Python 3 support? withPython3 ? false, # Build Neovim with Python 3 support?
withRuby ? false, # Build Neovim with Ruby support? withRuby ? false, # Build Neovim with Ruby support?
withNodeJs ? false, # Build Neovim with NodeJS support? withNodeJs ? false, # Build Neovim with NodeJS support?
withSqlite ? true, # Add sqlite? This is a dependency for some plugins withSqlite ? true, # Add sqlite? This is a dependency for some plugins
# You probably don't want to create vi or vim aliases # You probably don't want to create vi or vim aliases
# if the appName is something different than "nvim" # if the appName is something different than "nvim"
viAlias ? appName == "nvim", # Add a "vi" binary to the build output as an alias? viAlias ? appName == "nvim", # Add a "vi" binary to the build output as an alias?
vimAlias ? appName == "nvim", # Add a "vim" binary to the build output as an alias? vimAlias ? appName == "nvim", # Add a "vim" binary to the build output as an alias?
wrapRc ? true, wrapRc ? true,
}: let }:
# This is the structure of a plugin definition. let
# Each plugin in the `plugins` argument list can also be defined as this attrset # This is the structure of a plugin definition.
defaultPlugin = { # Each plugin in the `plugins` argument list can also be defined as this attrset
plugin = null; # e.g. nvim-lspconfig defaultPlugin = {
config = null; # plugin config plugin = null; # e.g. nvim-lspconfig
# If `optional` is set to `false`, the plugin is installed in the 'start' packpath config = null; # plugin config
# set to `true`, it is installed in the 'opt' packpath, and can be lazy loaded with # If `optional` is set to `false`, the plugin is installed in the 'start' packpath
# ':packadd! {plugin-name} # set to `true`, it is installed in the 'opt' packpath, and can be lazy loaded with
optional = false; # ':packadd! {plugin-name}
runtime = {}; optional = false;
}; runtime = { };
};
externalPackages = extraPackages ++ (optionals withSqlite [pkgs.sqlite]); externalPackages = extraPackages ++ (optionals withSqlite [ pkgs.sqlite ]);
# Map all plugins to an attrset { plugin = <plugin>; config = <config>; optional = <tf>; ... } # Map all plugins to an attrset { plugin = <plugin>; config = <config>; optional = <tf>; ... }
normalizedPlugins = map (x: normalizedPlugins = map (x: defaultPlugin // (if x ? plugin then x else { plugin = x; })) plugins;
defaultPlugin
// (
if x ? plugin
then x
else {plugin = x;}
))
plugins;
# This nixpkgs util function creates an attrset # This nixpkgs util function creates an attrset
# that pkgs.wrapNeovimUnstable uses to configure the Neovim build. # that pkgs.wrapNeovimUnstable uses to configure the Neovim build.
neovimConfig = pkgs-wrapNeovim.neovimUtils.makeNeovimConfig { neovimConfig = pkgs-wrapNeovim.neovimUtils.makeNeovimConfig {
inherit extraPython3Packages withPython3 withRuby withNodeJs viAlias vimAlias; inherit
plugins = normalizedPlugins; extraPython3Packages
}; withPython3
withRuby
withNodeJs
viAlias
vimAlias
;
plugins = normalizedPlugins;
};
packDir = pkgs.neovimUtils.packDir({ packDir = pkgs.neovimUtils.packDir {
myNeovimPackages = pkgs.neovimUtils.normalizedPluginsToVimPackage normalizedPlugins; myNeovimPackages = pkgs.neovimUtils.normalizedPluginsToVimPackage normalizedPlugins;
}); };
# This uses the ignoreConfigRegexes list to filter # This uses the ignoreConfigRegexes list to filter
# the nvim directory # the nvim directory
nvimRtpSrc = let nvimRtpSrc =
let
src = ../nvim; src = ../nvim;
in in
lib.cleanSourceWith { lib.cleanSourceWith {
inherit src; inherit src;
name = "nvim-rtp-src"; name = "nvim-rtp-src";
filter = path: tyoe: let filter =
path: tyoe:
let
srcPrefix = toString src + "/"; srcPrefix = toString src + "/";
relPath = lib.removePrefix srcPrefix (toString path); relPath = lib.removePrefix srcPrefix (toString path);
in in
lib.all (regex: builtins.match regex relPath == null) ignoreConfigRegexes; lib.all (regex: builtins.match regex relPath == null) ignoreConfigRegexes;
};
# Split runtimepath into 3 directories:
# - lua, to be prepended to the rtp at the beginning of init.lua
# - nvim, containing plugin, ftplugin, ... subdirectories
# - after, to be sourced last in the startup initialization
# See also: https://neovim.io/doc/user/starting.html
nvimRtp = stdenv.mkDerivation {
name = "nvim-rtp";
src = nvimRtpSrc;
buildPhase = ''
mkdir -p $out/lua
mkdir -p $out/ftplugin
'';
installPhase = ''
cp -r lua $out/
rm -r lua
cp -r ftplugin $out/
rm -r ftplugin
'';
}; };
# The final init.lua content that we pass to the Neovim wrapper. # Split runtimepath into 3 directories:
# It wraps the user init.lua, prepends the lua lib directory to the RTP # - lua, to be prepended to the rtp at the beginning of init.lua
# and prepends the nvim and after directory to the RTP # - nvim, containing plugin, ftplugin, ... subdirectories
initLua = '' # - after, to be sourced last in the startup initialization
vim.opt.rtp:prepend('${nvimRtp}') # See also: https://neovim.io/doc/user/starting.html
LAZY_OPTS = { nvimRtp = stdenv.mkDerivation {
performance = { name = "nvim-rtp";
reset_packpath = false, src = nvimRtpSrc;
rtp = {
reset = false, buildPhase = ''
disabled_plugins = { mkdir -p $out/lua
"netrwPlugin", mkdir -p $out/ftplugin
"tutor", '';
},
installPhase = ''
cp -r lua $out/
rm -r lua
cp -r ftplugin $out/
rm -r ftplugin
'';
};
# The final init.lua content that we pass to the Neovim wrapper.
# It wraps the user init.lua, prepends the lua lib directory to the RTP
# and prepends the nvim and after directory to the RTP
initLua =
''
LAZY_OPTS = {
performance = {
reset_packpath = true,
rtp = {
disabled_plugins = {
"netrwPlugin",
"tutor",
}, },
}, },
dev = { },
path = "${packDir}/pack/myNeovimPackages/start", dev = {
patterns = {""}, path = "${packDir}/pack/myNeovimPackages/start",
}, patterns = {""},
checker = { },
enabled = false, checker = {
}, enabled = false,
install = { missing = false, }, },
spec = {{ import = "plugins" }}, install = { missing = false, },
} spec = {{ import = "plugins" }},
'' + (builtins.readFile ../nvim/init.lua); }
vim.opt.rtp:prepend('${nvimRtp}')
''
+ (builtins.readFile ../nvim/init.lua);
# Add arguments to the Neovim wrapper script # Add arguments to the Neovim wrapper script
extraMakeWrapperArgs = builtins.concatStringsSep " " ( extraMakeWrapperArgs = builtins.concatStringsSep " " (
# Set the NVIM_APPNAME environment variable # Set the NVIM_APPNAME environment variable
(optional (appName != "nvim" && appName != null && appName != "") (optional (
''--set NVIM_APPNAME "${appName}"'') appName != "nvim" && appName != null && appName != ""
# Add external packages to the PATH ) ''--set NVIM_APPNAME "${appName}"'')
++ (optional (externalPackages != []) # Add external packages to the PATH
''--prefix PATH : "${makeBinPath externalPackages}"'') ++ (optional (externalPackages != [ ]) ''--prefix PATH : "${makeBinPath externalPackages}"'')
# Set the LIBSQLITE_CLIB_PATH if sqlite is enabled # Set the LIBSQLITE_CLIB_PATH if sqlite is enabled
++ (optional withSqlite ++ (optional withSqlite ''--set LIBSQLITE_CLIB_PATH "${pkgs.sqlite.out}/lib/libsqlite3.so"'')
''--set LIBSQLITE_CLIB_PATH "${pkgs.sqlite.out}/lib/libsqlite3.so"'') # Set the LIBSQLITE environment variable if sqlite is enabled
# Set the LIBSQLITE environment variable if sqlite is enabled ++ (optional withSqlite ''--set LIBSQLITE "${pkgs.sqlite.out}/lib/libsqlite3.so"'')
++ (optional withSqlite );
''--set LIBSQLITE "${pkgs.sqlite.out}/lib/libsqlite3.so"'')
);
luaPackages = neovim-unwrapped.lua.pkgs; luaPackages = neovim-unwrapped.lua.pkgs;
resolvedExtraLuaPackages = extraLuaPackages luaPackages; resolvedExtraLuaPackages = extraLuaPackages luaPackages;
# Native Lua libraries # Native Lua libraries
extraMakeWrapperLuaCArgs = extraMakeWrapperLuaCArgs =
optionalString (resolvedExtraLuaPackages != []) optionalString (resolvedExtraLuaPackages != [ ])
''--suffix LUA_CPATH ";" "${concatMapStringsSep ";" luaPackages.getLuaCPath resolvedExtraLuaPackages}"''; ''--suffix LUA_CPATH ";" "${
concatMapStringsSep ";" luaPackages.getLuaCPath resolvedExtraLuaPackages
}"'';
# Lua libraries # Lua libraries
extraMakeWrapperLuaArgs = extraMakeWrapperLuaArgs =
optionalString (resolvedExtraLuaPackages != []) optionalString (resolvedExtraLuaPackages != [ ])
''--suffix LUA_PATH ";" "${concatMapStringsSep ";" luaPackages.getLuaPath resolvedExtraLuaPackages}"''; ''--suffix LUA_PATH ";" "${
concatMapStringsSep ";" luaPackages.getLuaPath resolvedExtraLuaPackages
}"'';
# wrapNeovimUnstable is the nixpkgs utility function for building a Neovim derivation. # wrapNeovimUnstable is the nixpkgs utility function for building a Neovim derivation.
neovim-wrapped = pkgs-wrapNeovim.wrapNeovimUnstable neovim-unwrapped (neovimConfig neovim-wrapped = pkgs-wrapNeovim.wrapNeovimUnstable neovim-unwrapped (
// { neovimConfig
luaRcContent = initLua; // {
wrapperArgs = luaRcContent = initLua;
escapeShellArgs neovimConfig.wrapperArgs wrapperArgs =
+ " " escapeShellArgs neovimConfig.wrapperArgs
+ extraMakeWrapperArgs + " "
+ " " + extraMakeWrapperArgs
+ extraMakeWrapperLuaCArgs + " "
+ " " + extraMakeWrapperLuaCArgs
+ extraMakeWrapperLuaArgs; + " "
wrapRc = wrapRc; + extraMakeWrapperLuaArgs;
}); wrapRc = wrapRc;
}
);
isCustomAppName = appName != null && appName != "nvim"; isCustomAppName = appName != null && appName != "nvim";
in in
neovim-wrapped.overrideAttrs (oa: { neovim-wrapped.overrideAttrs (oa: {
buildPhase = buildPhase =
oa.buildPhase oa.buildPhase
# If a custom NVIM_APPNAME has been set, rename the `nvim` binary # If a custom NVIM_APPNAME has been set, rename the `nvim` binary
+ lib.optionalString isCustomAppName '' + lib.optionalString isCustomAppName ''
mv $out/bin/nvim $out/bin/${lib.escapeShellArg appName} mv $out/bin/nvim $out/bin/${lib.escapeShellArg appName}
''; '';
}) })

View file

@ -22,6 +22,7 @@ with final.pkgs.lib; let
diffview-nvim diffview-nvim
eyeliner-nvim eyeliner-nvim
friendly-snippets friendly-snippets
fzf-vim
lazy-nvim lazy-nvim
mini-nvim-git mini-nvim-git
nightfox-nvim nightfox-nvim
@ -34,11 +35,8 @@ with final.pkgs.lib; let
oil-nvim oil-nvim
refactoring-nvim refactoring-nvim
render-markdown-nvim render-markdown-nvim
scope-nvim
snacks-nvim snacks-nvim
trouble-nvim trouble-nvim
treewalker-nvim
yanky-nvim
]; ];
basePackages = with pkgs; [ basePackages = with pkgs; [

View file

@ -1 +0,0 @@
vim.opt.tabstop = 4

View file

@ -28,5 +28,6 @@ if not LAZY_OPTS then
}, },
} }
end end
vim.cmd('packadd cfilter')
require('lazy').setup(LAZY_OPTS) require('lazy').setup(LAZY_OPTS)
require('config') require('config')

View file

@ -1,26 +0,0 @@
{
"blink-copilot": { "branch": "main", "commit": "bdc45bbbed2ec252b3a29f4adecf031e157b5573" },
"blink-ripgrep.nvim": { "branch": "main", "commit": "0a2c3c1ce8c3c56e7490cae835a981d5dbeb472c" },
"blink.cmp": { "branch": "main", "commit": "4f38ce99a472932d5776337f08f7a8180f1f571a" },
"conform.nvim": { "branch": "master", "commit": "372fc521f8421b7830ea6db4d6ea3bae1c77548c" },
"copilot.lua": { "branch": "master", "commit": "a5c390f8d8e85b501b22dcb2f30e0cbbd69d5ff0" },
"diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" },
"eyeliner.nvim": { "branch": "main", "commit": "8f197eb30cecdf4c2cc9988a5eecc6bc34c0c7d6" },
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
"mini.nvim": { "branch": "main", "commit": "ee23e1abc206efc6d6cce19ec8c0a3da7a897035" },
"nightfox.nvim": { "branch": "main", "commit": "ba47d4b4c5ec308718641ba7402c143836f35aa9" },
"nvim-bqf": { "branch": "main", "commit": "9cbec7cf8ad2a902a0a41241ad16c3489620321b" },
"nvim-lint": { "branch": "master", "commit": "9dfb77ef6c5092a19502883c02dc5a02ec648729" },
"nvim-lspconfig": { "branch": "master", "commit": "1b801f68d09e70e59e6dd967b663b6d84ee3e87d" },
"nvim-treesitter": { "branch": "master", "commit": "94ea4f436d2b59c80f02e293466c374584f03b8c" },
"nvim-treesitter-context": { "branch": "master", "commit": "6daca3ad780f045550b820f262002f35175a6c04" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "ed373482db797bbf71bdff37a15c7555a84dce47" },
"oil.nvim": { "branch": "master", "commit": "685cdb4ffa74473d75a1b97451f8654ceeab0f4a" },
"refactoring.nvim": { "branch": "master", "commit": "2be7ea3f10b7e59658f5abf6dffc50b5d61964d6" },
"render-markdown.nvim": { "branch": "main", "commit": "b2d857c848c2c27440c8e5efc8e49a9b5bcf13c6" },
"scope.nvim": { "branch": "main", "commit": "3fc963e75f88990a9467ff72b8eea667a69c30a2" },
"snacks.nvim": { "branch": "main", "commit": "bc0630e43be5699bb94dadc302c0d21615421d93" },
"treewalker.nvim": { "branch": "main", "commit": "34bf0a6044e0b5e3d93b7012ae7bdf457de91ba1" },
"trouble.nvim": { "branch": "main", "commit": "85bedb7eb7fa331a2ccbecb9202d8abba64d37b3" },
"yanky.nvim": { "branch": "main", "commit": "04775cc6e10ef038c397c407bc17f00a2f52b378" }
}

View file

@ -2,7 +2,7 @@ vim.opt.autowrite = true
vim.opt.backspace = 'indent,eol,start' vim.opt.backspace = 'indent,eol,start'
vim.opt.confirm = true vim.opt.confirm = true
vim.opt.completeopt = { 'menu', 'menuone', 'noselect' } vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
vim.opt.cmdheight = 0 vim.opt.cmdheight = 1
vim.opt.diffopt = 'internal,filler,closeoff,inline:char' vim.opt.diffopt = 'internal,filler,closeoff,inline:char'
vim.opt.expandtab = true -- insert tabs as spaces vim.opt.expandtab = true -- insert tabs as spaces
vim.opt.inccommand = 'split' -- incremental live completion vim.opt.inccommand = 'split' -- incremental live completion
@ -28,7 +28,7 @@ end, { silent = true, desc = 'toggle tabstop' })
-- autocmd -- autocmd
---------------------------------------- ----------------------------------------
local undopath = '~/.local/share/nvim/undo' local undopath = vim.fn.stdpath('data') .. 'undo'
vim.api.nvim_create_autocmd('VimEnter', { vim.api.nvim_create_autocmd('VimEnter', {
command = 'silent !mkdir -p ' .. undopath, command = 'silent !mkdir -p ' .. undopath,
group = vim.api.nvim_create_augroup('Init', {}), group = vim.api.nvim_create_augroup('Init', {}),

View file

@ -7,6 +7,9 @@ return {
'fang2hou/blink-copilot', 'fang2hou/blink-copilot',
}, },
opts = { opts = {
enabled = function()
return not vim.tbl_contains({ 'snacks_picker_input', 'oil' }, vim.bo.filetype)
end,
fuzzy = { fuzzy = {
sorts = { sorts = {
'exact', 'exact',

View file

@ -10,7 +10,7 @@ end
JJ.jj_start_watching_tree_state = function(buf_id, path) JJ.jj_start_watching_tree_state = function(buf_id, path)
local stdout = vim.loop.new_pipe() local stdout = vim.loop.new_pipe()
local args = { 'workspace', 'root' } local args = { 'workspace', 'root', '--ignore-working-copy' }
local spawn_opts = { local spawn_opts = {
args = args, args = args,
cwd = vim.fn.fnamemodify(path, ':h'), cwd = vim.fn.fnamemodify(path, ':h'),
@ -86,7 +86,7 @@ JJ.jj_set_ref_text = vim.schedule_wrap(function(buf_id)
-- Set -- Set
local stdout = vim.loop.new_pipe() local stdout = vim.loop.new_pipe()
local spawn_opts = { local spawn_opts = {
args = { 'file', 'show', '-r', '@-', './' .. basename }, args = { 'file', 'show', '--ignore-working-copy', '-r', '@-', './' .. basename },
cwd = cwd, cwd = cwd,
stdio = { nil, stdout, nil }, stdio = { nil, stdout, nil },
} }

View file

@ -0,0 +1,48 @@
local M = {}
M.load = function()
local jj_root = vim.system({ 'jj', 'workspace', 'root' }):wait()
local sessions = require('mini.sessions')
if jj_root.code ~= 0 then
return
end
local result = vim
.system({
'jj',
'log',
'-r',
'latest(heads(::@ & bookmarks()))',
'--template',
'bookmarks',
'--no-pager',
'--no-graph',
})
:wait()
local branch = vim.trim(string.gsub(result.stdout, '[\n*]', ''))
local root = vim.trim(string.gsub(jj_root.stdout, '\n', ''))
local jj_sesh = string.gsub(string.format('jj:%s:%s', root, branch), '[./]', '-')
if jj_sesh ~= '' then
vim.opt.shadafile = vim.fn.stdpath('data') .. '/myshada/' .. jj_sesh .. '.shada'
for name, _ in pairs(sessions.detected) do
if name == jj_sesh then
vim.ui.select({
'No',
'Yes',
}, { prompt = 'Session found at ' .. jj_sesh .. ', load it?' }, function(c)
if c == 'Yes' then
-- load session (buffers, etc) as well as shada (marks)
sessions.read(jj_sesh)
vim.cmd('rshada')
vim.notify('loaded jj session: ' .. jj_sesh)
end
end)
return
end
end
vim.cmd('wshada')
sessions.write(jj_sesh)
end
end
return M

View file

@ -23,7 +23,7 @@ function M.status()
file = string.match(text, '{.-=>%s*(.-)}') file = string.match(text, '{.-=>%s*(.-)}')
end end
local diff = vim.fn.system('jj diff ' .. file .. ' --no-pager --stat --git') local diff = vim.fn.system('jj diff ' .. file .. ' --ignore-working-copy --no-pager --stat --git')
table.insert(files, { table.insert(files, {
text = text, text = text,
file = file, file = file,
@ -56,77 +56,64 @@ function M.status()
end end
function M.revs() function M.revs()
local function jj_new() local function jj_new(picker, item)
return function(picker, item) picker:close()
picker:close() if item then
if item then if not item.rev then
if not item.rev then Snacks.notify.warn('No branch or commit found', { title = 'Snacks Picker' })
Snacks.notify.warn('No branch or commit found', { title = 'Snacks Picker' }) return
return
end
local cmd = { 'jj', 'new', '-r', item.rev }
Snacks.picker.util.cmd(cmd, function()
Snacks.notify('Checking out revision: ' .. item.rev, { title = 'Snacks Picker' })
vim.cmd.checktime()
end, { cwd = item.cwd })
end end
local cmd = { 'jj', 'new', '-r', item.rev }
Snacks.picker.util.cmd(cmd, function()
Snacks.notify('Checking out revision: ' .. item.rev, { title = 'Snacks Picker' })
vim.cmd.checktime()
end, { cwd = item.cwd })
end end
end end
local function jj_rev_cmd(rev) local function jj_rev_cmd(ctx)
if rev ~= nil then if ctx.item.rev then
return vim.fn.system { 'jj', 'show', '--git', '-r', rev } Snacks.picker.preview.cmd({ 'jj', 'show', '--ignore-working-copy', '--git', '-r', ctx.item.rev }, ctx)
else else
ctx.preview:reset()
return 'No preview available.' return 'No preview available.'
end end
end end
local function jj_log(revset) local function jj_log(revset)
if revset == nil then if revset == nil then
revset = '-r @' revset = '-r "ancestors(@,25)"'
else else
revset = '-r ' .. revset revset = '-r ' .. revset
end end
local status_raw = vim.fn.system( local status_raw = vim.fn.system(
'jj log ' 'jj log --ignore-working-copy '
.. revset .. revset
.. ..
' --template \'if(root, format_root_commit(self), label(if(current_working_copy, "working_copy"), concat( format_short_commit_header(self) ++ " ", separate(" ", if(empty, label("empty", "(empty)")), if(description, description.first_line(), label(if(empty, "empty"), description_placeholder),),) ++ "\n",),))\'' ' --template \'if(root, format_root_commit(self), label(if(current_working_copy, "working_copy"), concat(separate(" ", self.change_id().shortest(8), self.bookmarks()), " | ", if(empty, label("empty", "(empty)")), if(description, description.first_line(), label(if(empty, "empty"), description_placeholder),),) ++ "\n",),)\''
) )
local lines = {} local lines = {}
for line in status_raw:gmatch('[^\r\n]+') do for line in status_raw:gmatch('[^\r\n]+') do
local sign, rev, description = string.match(line, '(.)%s*(%a+)(.*)') local sign, rev = string.match(line, '(.)%s(%a+)%s.*')
table.insert(lines, { table.insert(lines, {
text = line, text = line,
file = line,
sign = sign, sign = sign,
rev = rev, rev = rev,
hl = 'SnacksPickerGitMsg',
description = description,
diff = jj_rev_cmd(rev),
}) })
end end
return lines return lines
end end
local lines = jj_log('::@')
Snacks.picker.pick { Snacks.picker.pick {
source = 'jj_revs', source = 'jj_revs',
items = lines, layout = 'ivy',
format = 'text', format = 'text',
title = 'jj log', title = 'jj log',
confirm = jj_new(), items = jj_log(),
preview = function(ctx) confirm = jj_new,
if ctx.item.file then preview = jj_rev_cmd,
Snacks.picker.preview.diff(ctx)
else
ctx.preview:reset()
ctx.preview:set_title('No rev found')
end
end,
} }
end end

View file

@ -41,7 +41,6 @@ return {
{ {
'echasnovski/mini.nvim', 'echasnovski/mini.nvim',
lazy = false, lazy = false,
dependencies = { 'folke/snacks.nvim' },
keys = { keys = {
{ {
'<leader>gp', '<leader>gp',
@ -52,7 +51,7 @@ return {
desc = 'git diff overlay', desc = 'git diff overlay',
}, },
{ {
'<leader>gd', '<leader>go',
function() function()
return MiniGit.show_at_cursor() return MiniGit.show_at_cursor()
end, end,
@ -61,7 +60,7 @@ return {
}, },
{ {
'<leader>gb', '<leader>gb',
'<Cmd>vertical Git blame -- %<CR>', '<Cmd>Git blame -- %<CR>',
noremap = true, noremap = true,
desc = 'git blame', desc = 'git blame',
}, },
@ -72,12 +71,12 @@ return {
desc = 'git command', desc = 'git command',
}, },
{ {
'S', '<leader>fs',
function() function()
MiniJump2d.start { spotter = MiniJump2d.gen_spotter.vimpattern() } require('plugins.lib.session_jj').load()
end, end,
noremap = true, noremap = true,
desc = 'mini jump', desc = 'mini session select',
}, },
}, },
config = function() config = function()
@ -91,18 +90,17 @@ return {
active = function() active = function()
local mode, mode_hl = MiniStatusline.section_mode {} local mode, mode_hl = MiniStatusline.section_mode {}
local filename = MiniStatusline.section_filename { trunc_width = 140 } local filename = MiniStatusline.section_filename { trunc_width = 140 }
local diff = MiniStatusline.section_diff { trunc_width = 75, icon = '' }
local diagnostics = MiniStatusline.section_diagnostics { trunc_width = 75 } local diagnostics = MiniStatusline.section_diagnostics { trunc_width = 75 }
local lsp = MiniStatusline.section_lsp { trunc_width = 75 } local lsp = MiniStatusline.section_lsp { trunc_width = 75 }
local search = MiniStatusline.section_searchcount { trunc_width = 75 } local search = MiniStatusline.section_searchcount { trunc_width = 75 }
return MiniStatusline.combine_groups { return MiniStatusline.combine_groups {
'%<', -- Mark general truncate point '%<', -- Mark general truncate point
{ hl = 'MiniStatuslineFilename', strings = { '' } }, -- { hl = 'MiniStatuslineFilename', strings = { filename } },
'%=', -- End left alignment '%=', -- End left alignment
{ hl = 'MiniStatusDevinfo', strings = { diagnostics, lsp } }, { hl = 'MiniStatuslineDevinfo', strings = { rec, diagnostics, lsp } },
{ hl = 'MiniStatuslineFilename', strings = { search } }, { hl = 'MiniStatuslineDevinfo', strings = { search } },
{ hl = mode_hl, strings = { mode } }, { hl = mode_hl, strings = { mode } },
} }
end, end,
inactive = function() inactive = function()
@ -118,24 +116,28 @@ return {
require('mini.align').setup() require('mini.align').setup()
require('mini.bracketed').setup() require('mini.bracketed').setup()
require('mini.icons').setup() require('mini.icons').setup()
require('mini.jump2d').setup { require('mini.git').setup()
view = { n_steps_ahead = 1, dim = true }, require('mini.surround').setup()
require('mini.splitjoin').setup { detect = { separator = '[,;\n]' } }
local sessions = require('mini.sessions')
sessions.setup {
file = '',
autowrite = true,
verbose = {
write = false,
},
} }
require('mini.git').setup { command = { split = 'vertical' } } if #vim.fn.argv() == 0 then
-- Bind both windows so that they scroll together require('plugins.lib.session_jj').load()
local align_blame = function(au_data)
if au_data.data.git_subcommand ~= 'blame' then
return
end
local win_src = au_data.data.win_source
vim.wo.wrap = false
vim.fn.winrestview { topline = vim.fn.line('w0', win_src) }
vim.api.nvim_win_set_cursor(0, { vim.fn.line('.', win_src), 0 })
vim.wo[win_src].scrollbind, vim.wo.scrollbind = true, true
end end
local au_opts = { pattern = 'MiniGitCommandSplit', callback = align_blame } local jump = require('mini.jump2d')
vim.api.nvim_create_autocmd('User', au_opts) jump.setup {
view = { n_steps_ahead = 1, dim = true },
spotter = jump.gen_spotter.vimpattern(),
}
setup_pairs { setup_pairs {
modes = { insert = true, command = true, terminal = false }, modes = { insert = true, command = true, terminal = false },
skip_next = [=[[%w%%%'%[%"%.%`%$]]=], skip_next = [=[[%w%%%'%[%"%.%`%$]]=],
@ -144,10 +146,7 @@ return {
markdown = true, markdown = true,
} }
require('mini.surround').setup() local jj = require('plugins.lib.minidiff_jj')
require('mini.splitjoin').setup { detect = { separator = '[,;\n]' } }
local jj = require('nvim.lua.plugins.lib.minidiff_jj')
local diff = require('mini.diff') local diff = require('mini.diff')
diff.setup { diff.setup {
options = { wrap_goto = true }, options = { wrap_goto = true },
@ -178,14 +177,6 @@ return {
miniclue.gen_clues.registers(), miniclue.gen_clues.registers(),
miniclue.gen_clues.windows(), miniclue.gen_clues.windows(),
miniclue.gen_clues.z(), miniclue.gen_clues.z(),
{ mode = 'n', keys = '<Leader>wj', postkeys = '<Leader>w', desc = 'TS Down' },
{ mode = 'n', keys = '<Leader>wk', postkeys = '<Leader>w', desc = 'TS Up' },
{ mode = 'n', keys = '<Leader>wh', postkeys = '<Leader>w', desc = 'TS Left' },
{ mode = 'n', keys = '<Leader>wl', postkeys = '<Leader>w', desc = 'TS Right' },
{ mode = 'n', keys = '<Leader>w<C-J>', postkeys = '<Leader>w', desc = 'Swap TS Down' },
{ mode = 'n', keys = '<Leader>w<C-K>', postkeys = '<Leader>w', desc = 'Swap TS Up' },
{ mode = 'n', keys = '<Leader>w<C-H>', postkeys = '<Leader>w', desc = 'Swap TS Left' },
{ mode = 'n', keys = '<Leader>w<C-L>', postkeys = '<Leader>w', desc = 'Swap TS Right' },
}, },
} }

View file

@ -20,7 +20,7 @@ return {
function() function()
require('oil').toggle_float() require('oil').toggle_float()
end, end,
{ noremap = true, silent = true }, { noremap = true, silent = true, desc = 'oil' },
}, },
}, },
}, },
@ -32,7 +32,6 @@ return {
vim.api.nvim_set_hl(0, 'EyelinerSecondary', { underline = true, bold = true }) vim.api.nvim_set_hl(0, 'EyelinerSecondary', { underline = true, bold = true })
end, end,
}, },
{ 'tiagovla/scope.nvim', event = 'VeryLazy', config = true },
{ {
'MeanderingProgrammer/render-markdown.nvim', 'MeanderingProgrammer/render-markdown.nvim',
event = 'VeryLazy', event = 'VeryLazy',
@ -68,7 +67,14 @@ return {
{ '<leader>nb', vim.cmd.DiffviewOpen, noremap = true, desc = 'diffview open' }, { '<leader>nb', vim.cmd.DiffviewOpen, noremap = true, desc = 'diffview open' },
{ {
'<leader>nh', '<leader>nh',
vim.cmd.DiffviewFileHistory, '<cmd>DiffviewFileHistory %<cr>',
mode = { 'n', 'v' },
noremap = true,
desc = 'diffview history',
},
{
'<leader>nH',
'<cmd>DiffviewFileHistory<cr>',
mode = { 'n', 'v' }, mode = { 'n', 'v' },
noremap = true, noremap = true,
desc = 'diffview history', desc = 'diffview history',
@ -105,30 +111,6 @@ return {
vim.api.nvim_set_hl(0, 'BlinkCmpGhostText', { link = 'String' }) vim.api.nvim_set_hl(0, 'BlinkCmpGhostText', { link = 'String' })
end, end,
}, },
{
'gbprod/yanky.nvim',
opts = {
ring = {
storage = 'memory',
},
picker = {
select = {
action = require('yanky.picker').actions.set_register('+'),
},
},
},
keys = {
{ 'y', '<Plug>(YankyYank)', mode = { 'n', 'x' } },
{
'<leader>fp',
'<cmd>YankyRingHistory<cr>',
mode = { 'n', 'x' },
noremap = true,
silent = true,
desc = 'Pick history (yanky.nvim)',
},
},
},
{ {
'ThePrimeagen/refactoring.nvim', 'ThePrimeagen/refactoring.nvim',
event = 'VeryLazy', event = 'VeryLazy',
@ -144,5 +126,14 @@ return {
}, },
}, },
}, },
{ 'kevinhwang91/nvim-bqf', event = 'VeryLazy', config = true }, {
'kevinhwang91/nvim-bqf',
event = 'VeryLazy',
opts = {
auto_resize_height = true,
preview = {
winblend = 0,
},
},
},
} }

View file

@ -1,7 +1,9 @@
return { return {
{ {
'folke/snacks.nvim', 'folke/snacks.nvim',
dependencies = { 'folke/trouble.nvim' }, dependencies = {
'folke/trouble.nvim',
},
lazy = false, lazy = false,
priority = 1000, priority = 1000,
opts = { opts = {
@ -10,7 +12,6 @@ return {
dim = { enabled = true }, dim = { enabled = true },
quickfile = { enabled = true }, quickfile = { enabled = true },
notifier = { enabled = true }, notifier = { enabled = true },
scope = { enabled = true },
terminal = { enabled = true }, terminal = { enabled = true },
indent = { enabled = true }, indent = { enabled = true },
input = { enabled = true }, input = { enabled = true },
@ -135,15 +136,6 @@ return {
noremap = true, noremap = true,
desc = 'snacks explorer', desc = 'snacks explorer',
}, },
{
'<leader>fE',
function()
Snacks.explorer.reveal()
end,
noremap = true,
silent = true,
desc = 'snacks explorer open current file',
},
{ {
'<leader>fg', '<leader>fg',
function() function()
@ -180,15 +172,6 @@ return {
silent = true, silent = true,
desc = 'See all pickers', desc = 'See all pickers',
}, },
{
"<leader>f'",
function()
Snacks.picker.marks()
end,
noremap = true,
silent = true,
desc = 'Pick marks',
},
{ {
'<leader>fu', '<leader>fu',
function() function()
@ -235,18 +218,54 @@ return {
desc = 'pick notifications', desc = 'pick notifications',
}, },
{ {
'<leader>fj', '<leader>fm',
function() function()
require('nvim.lua.plugins.lib.snacks_jj').status() vim.cmd.delmarks { args = { '0-9' } }
Snacks.picker.pick {
finder = 'vim_marks',
format = 'file',
['local'] = false,
global = true,
actions = {
markdel = function(picker)
for _, item in ipairs(picker:selected()) do
vim.cmd.delmarks { args = { item.label } }
end
vim.cmd('wshada')
picker.list:set_selected()
picker.list:set_target()
picker:find()
end,
},
win = {
input = {
keys = {
['<c-x>'] = { 'markdel', mode = { 'n', 'i' } },
},
},
list = {
keys = { ['dd'] = 'markdel' },
},
},
}
end,
noremap = true,
silent = true,
desc = 'pick global marks',
},
{
'<leader>jf',
function()
require('plugins.lib.snacks_jj').status()
end, end,
noremap = true, noremap = true,
silent = true, silent = true,
desc = 'pick notifications', desc = 'pick notifications',
}, },
{ {
'<leader>fr', '<leader>jj',
function() function()
require('nvim.lua.plugins.lib.snacks_jj').revs() require('plugins.lib.snacks_jj').revs()
end, end,
noremap = true, noremap = true,
silent = true, silent = true,

View file

@ -11,19 +11,6 @@ return {
}, },
}, },
'nvim-treesitter/nvim-treesitter-textobjects', 'nvim-treesitter/nvim-treesitter-textobjects',
{
'aaronik/treewalker.nvim',
keys = {
{ '<leader>wj', '<cmd>Treewalker Down<cr>', silent = true, desc = 'Down (Treewalker)' },
{ '<leader>wk', '<cmd>Treewalker Up<cr>', silent = true, desc = 'Up (Treewalker)' },
{ '<leader>wh', '<cmd>Treewalker Left<cr>', silent = true, desc = 'Left (Treewalker)' },
{ '<leader>wl', '<cmd>Treewalker Right<cr>', silent = true, desc = 'Right (Treewalker)' },
{ '<leader>w<C-J>', '<cmd>Treewalker SwapDown<cr>', silent = true, desc = 'SwapDown (Treewalker)' },
{ '<leader>w<C-K>', '<cmd>Treewalker SwapUp<cr>', silent = true, desc = 'SwapUp (Treewalker)' },
{ '<leader>w<C-H>', '<cmd>Treewalker SwapLeft<cr>', silent = true, desc = 'SwapLeft (Treewalker)' },
{ '<leader>w<C-L>', '<cmd>Treewalker SwapRight<cr>', silent = true, desc = 'SwapRight (Treewalker)' },
},
},
}, },
config = function() config = function()
require('nvim-treesitter.configs').setup { require('nvim-treesitter.configs').setup {