diff --git a/flake.lock b/flake.lock index 2685c3c..0530187 100644 --- a/flake.lock +++ b/flake.lock @@ -1,18 +1,19 @@ { "nodes": { "dart": { - "flake": false, + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + }, "locked": { - "lastModified": 1755657012, - "owner": "iofq", - "repo": "dart.nvim", - "rev": "c38b1e0d6daa47f8b9c58422e5a7ab57221810fd", - "type": "github" + "lastModified": 1758080529, + "narHash": "sha256-Sup4+HacL6Xe6mTk23N6sD4uXoU9dcoqRgc9Mu0oQ5E=", + "path": "/home/e/dev/dart.nvim", + "type": "path" }, "original": { - "owner": "iofq", - "repo": "dart.nvim", - "type": "github" + "path": "/home/e/dev/dart.nvim", + "type": "path" } }, "flake-compat": { @@ -89,11 +90,11 @@ ] }, "locked": { - "lastModified": 1754487366, - "narHash": "sha256-pHYj8gUBapuUzKV/kN/tR3Zvqc7o6gdFB9XKXIp1SQ8=", + "lastModified": 1756770412, + "narHash": "sha256-+uWLQZccFHwqpGqr2Yt5VsW/PbeJVTn9Dk6SHWhNRPw=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "af66ad14b28a127c5c0f3bbb298218fc63528a18", + "rev": "4524271976b625a4a605beefd893f270620fd751", "type": "github" }, "original": { @@ -102,27 +103,6 @@ "type": "github" } }, - "flake-parts_3": { - "inputs": { - "nixpkgs-lib": [ - "neovim-nightly-overlay", - "hercules-ci-effects", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1751413152, - "narHash": "sha256-Tyw1RjYEsp5scoigs1384gIg6e0GoBVjms4aXFfRssQ=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "77826244401ea9de6e3bac47c2db46005e1f30b5", - "type": "github" - }, - "original": { - "id": "flake-parts", - "type": "indirect" - } - }, "flake-utils": { "inputs": { "systems": "systems" @@ -140,6 +120,24 @@ "type": "github" } }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "gen-luarc": { "inputs": { "flake-parts": "flake-parts", @@ -150,10 +148,11 @@ ] }, "locked": { - "lastModified": 1754586557, + "lastModified": 1755304025, + "narHash": "sha256-xVKfjFwc0zMbLMjLTiHz+0llggkjs93SmHkhaa9S3M4=", "owner": "mrcjkb", "repo": "nix-gen-luarc-json", - "rev": "4b8d4da04808062e2b1ef0e7bcd0a03bcb93e043", + "rev": "1865b0ebb753ae5324d7381b1fa8c98c04ec7509", "type": "github" }, "original": { @@ -196,11 +195,11 @@ ] }, "locked": { - "lastModified": 1754416808, - "narHash": "sha256-c6yg0EQ9xVESx6HGDOCMcyRSjaTpNJP10ef+6fRcofA=", + "lastModified": 1758108966, + "narHash": "sha256-ytw7ROXaWZ7OfwHrQ9xvjpUWeGVm86pwnEd1QhzawIo=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "9c52372878df6911f9afc1e2a1391f55e4dfc864", + "rev": "54df955a695a84cd47d4a43e08e1feaf90b1fd9b", "type": "github" }, "original": { @@ -255,18 +254,21 @@ }, "hercules-ci-effects": { "inputs": { - "flake-parts": "flake-parts_3", + "flake-parts": [ + "neovim-nightly-overlay", + "flake-parts" + ], "nixpkgs": [ "neovim-nightly-overlay", "nixpkgs" ] }, "locked": { - "lastModified": 1752595130, - "narHash": "sha256-CNBgr4OZSuklGtNOa9CnTNo9+Xceqn/EDAC1Tc43fH8=", + "lastModified": 1758022363, + "narHash": "sha256-ENUhCRWgSX4ni751HieNuQoq06dJvApV/Nm89kh+/A0=", "owner": "hercules-ci", "repo": "hercules-ci-effects", - "rev": "5f2e09654b2e70ba643e41609d9f9b6640f22113", + "rev": "1a3667d33e247ad35ca250698d63f49a5453d824", "type": "github" }, "original": { @@ -298,14 +300,15 @@ "git-hooks": "git-hooks_2", "hercules-ci-effects": "hercules-ci-effects", "neovim-src": "neovim-src", - "nixpkgs": "nixpkgs", + "nixpkgs": "nixpkgs_2", "treefmt-nix": "treefmt-nix" }, "locked": { - "lastModified": 1754641381, + "lastModified": 1759277111, + "narHash": "sha256-SDLZMha2miaChOBGBkQJlTtk2kvcB7WIVVZ2l0/9byc=", "owner": "nix-community", "repo": "neovim-nightly-overlay", - "rev": "83aaf3085f808dec9ea1b5d16b216875a8081b37", + "rev": "b7b3632fab34541543373254c265da03c1d0f240", "type": "github" }, "original": { @@ -317,11 +320,11 @@ "neovim-src": { "flake": false, "locked": { - "lastModified": 1754610154, - "narHash": "sha256-ORfF40X4BGiFxnLNQbdsQbUTW4TkUHfPqyZWHaYL5NE=", + "lastModified": 1759210115, + "narHash": "sha256-oc1pPeoe8458X0r/Wum8CucVcJLlIp4mg+1HiOSVRgA=", "owner": "neovim", "repo": "neovim", - "rev": "038eb01b41b66379f75164507571497929f8847c", + "rev": "198c9e9bca7549cf7110be8c6f1df1c38d4e747f", "type": "github" }, "original": { @@ -332,16 +335,15 @@ }, "nixpkgs": { "locked": { - "lastModified": 1754393734, - "narHash": "sha256-fbnmAwTQkuXHKBlcL5Nq1sMAzd3GFqCOQgEQw6Hy0Ak=", + "lastModified": 1755660401, "owner": "NixOS", "repo": "nixpkgs", - "rev": "a683adc19ff5228af548c6539dbc3440509bfed3", + "rev": "5788de501b965d7413f2beaac10aeeb56f9a19a8", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixpkgs-unstable", + "ref": "master", "repo": "nixpkgs", "type": "github" } @@ -376,10 +378,27 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1754893210, + "lastModified": 1759070547, + "narHash": "sha256-JVZl8NaVRYb0+381nl7LvPE+A774/dRpif01FKLrYFQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "defc725219d1fb9b56662370e014012929e557af", + "rev": "647e5c14cbd5067f44ac86b74f014962df460840", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1759300078, + "narHash": "sha256-7G5fSMPNVwWNlFpZLwvKB8PUOaqPzFQbrtZ7RAzg2nw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "d48b56f4899ee1d5377291576284969c9e37acc2", "type": "github" }, "original": { @@ -389,13 +408,30 @@ "type": "github" } }, + "nixpkgs_4": { + "locked": { + "lastModified": 1759381078, + "narHash": "sha256-gTrEEp5gEspIcCOx9PD8kMaF1iEmfBcTbO0Jag2QhQs=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "7df7ff7d8e00218376575f0acdcc5d66741351ee", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "nvim-treesitter": { "flake": false, "locked": { - "lastModified": 1754640844, + "lastModified": 1759376029, + "narHash": "sha256-Cu6Wg9SKJpYAkp8DPAXe4Rf9OSSWW2wNdmCkYtl//fw=", "owner": "nvim-treesitter", "repo": "nvim-treesitter", - "rev": "9866036ec3c5db40700a9178494e0cfdcfe6ecfd", + "rev": "99bd52ba56a4b7c9a8cc50a6140180755e76fac6", "type": "github" }, "original": { @@ -405,13 +441,31 @@ "type": "github" } }, + "nvim-treesitter-main": { + "inputs": { + "nixpkgs": "nixpkgs_4", + "nvim-treesitter": "nvim-treesitter", + "nvim-treesitter-textobjects": "nvim-treesitter-textobjects" + }, + "locked": { + "lastModified": 1759555972, + "narHash": "sha256-vdIHsEjpZUdTYVzoJKsDsXjIlCyyIXMsBubg3dIp+cE=", + "path": "/home/e/dev/nvim-treesitter-main", + "type": "path" + }, + "original": { + "path": "/home/e/dev/nvim-treesitter-main", + "type": "path" + } + }, "nvim-treesitter-textobjects": { "flake": false, "locked": { - "lastModified": 1751128959, + "lastModified": 1756368113, + "narHash": "sha256-+KmOpRi4JAqm6UqYdtk80jwFrJhLCs0lZM/Liofq0R4=", "owner": "nvim-treesitter", "repo": "nvim-treesitter-textobjects", - "rev": "b54cec389e98c5b0babbe618773acec927437cab", + "rev": "1b2d85d3de6114c4bcea89ffb2cd1ce9e3a19931", "type": "github" }, "original": { @@ -424,12 +478,11 @@ "root": { "inputs": { "dart": "dart", - "flake-utils": "flake-utils", + "flake-utils": "flake-utils_2", "gen-luarc": "gen-luarc", "neovim-nightly-overlay": "neovim-nightly-overlay", - "nixpkgs": "nixpkgs_2", - "nvim-treesitter": "nvim-treesitter", - "nvim-treesitter-textobjects": "nvim-treesitter-textobjects" + "nixpkgs": "nixpkgs_3", + "nvim-treesitter-main": "nvim-treesitter-main" } }, "systems": { @@ -447,6 +500,21 @@ "type": "github" } }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "treefmt-nix": { "inputs": { "nixpkgs": [ @@ -455,11 +523,11 @@ ] }, "locked": { - "lastModified": 1754492133, - "narHash": "sha256-B+3g9+76KlGe34Yk9za8AF3RL+lnbHXkLiVHLjYVOAc=", + "lastModified": 1758728421, + "narHash": "sha256-ySNJ008muQAds2JemiyrWYbwbG+V7S5wg3ZVKGHSFu8=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "1298185c05a56bff66383a20be0b41a307f52228", + "rev": "5eda4ee8121f97b218f7cc73f5172098d458f1d1", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 07d80b6..3224f5f 100644 --- a/flake.nix +++ b/flake.nix @@ -10,16 +10,10 @@ inputs.nixpkgs.follows = "nixpkgs"; }; dart = { - url = "github:iofq/dart.nvim"; - flake = false; + url = "path:/home/e/dev/dart.nvim"; }; - nvim-treesitter = { - url = "github:nvim-treesitter/nvim-treesitter/main"; - flake = false; - }; - nvim-treesitter-textobjects = { - url = "github:nvim-treesitter/nvim-treesitter-textobjects/main"; - flake = false; + nvim-treesitter-main = { + url = "path:/home/e/dev/nvim-treesitter-main"; }; # Add bleeding-edge plugins here. # They can be updated with `nix flake update` (make sure to commit the generated flake.lock) @@ -39,7 +33,6 @@ systems = builtins.attrNames nixpkgs.legacyPackages; # This is where the Neovim derivation is built. - plugin-overlay = import ./nix/plugin-overlay.nix { inherit inputs; }; neovim-overlay = import ./nix/neovim-overlay.nix { inherit inputs; }; in flake-utils.lib.eachSystem systems ( @@ -50,7 +43,7 @@ config.allowUnfree = true; overlays = [ inputs.neovim-nightly-overlay.overlays.default - plugin-overlay + inputs.nvim-treesitter-main.overlays.default neovim-overlay # This adds a function can be used to generate a .luarc.json # containing the Neovim API all plugins in the workspace directory. @@ -88,6 +81,6 @@ } ) // { - overlays.default = final: prev: (plugin-overlay final prev) // (neovim-overlay final prev); + overlays.default = final: prev: (neovim-overlay final prev); }; } diff --git a/nix/neovim-overlay.nix b/nix/neovim-overlay.nix index 204e118..d79bef6 100644 --- a/nix/neovim-overlay.nix +++ b/nix/neovim-overlay.nix @@ -4,6 +4,7 @@ final: prev: with final.pkgs.lib; let mkNeovim = prev.callPackage ./mkNeovim.nix { pkgs-wrapNeovim = prev; }; + dart-nvim = inputs.dart.packages.x86_64-linux.default; plugins = with final.vimPlugins; [ blink-cmp @@ -11,18 +12,13 @@ let conform-nvim dart-nvim diffview-nvim - eyeliner-nvim - friendly-snippets lazy-nvim mini-nvim - nvim-autopairs nvim-lint nvim-lspconfig nvim-treesitter.withAllGrammars - nvim-treesitter-context nvim-treesitter-textobjects quicker-nvim - refactoring-nvim render-markdown-nvim snacks-nvim ]; diff --git a/nix/plugin-overlay.nix b/nix/plugin-overlay.nix deleted file mode 100644 index 9a51a54..0000000 --- a/nix/plugin-overlay.nix +++ /dev/null @@ -1,29 +0,0 @@ -{ inputs, ... }: -final: prev: -let - mkNvimPlugin = - src: pname: - prev.vimUtils.buildVimPlugin { - inherit pname src; - version = src.lastModifiedDate; - }; -in -{ - vimPlugins = prev.vimPlugins.extend ( - final': prev': { - dart-nvim = mkNvimPlugin inputs.dart "dart.nvim"; - nvim-treesitter-textobjects = mkNvimPlugin inputs.nvim-treesitter-textobjects "nvim-treesitter-textobjects"; - nvim-treesitter = prev'.nvim-treesitter.overrideAttrs (old: rec { - src = inputs.nvim-treesitter; - name = "${old.pname}-${src.rev}"; - postPatch = ""; - # ensure runtime queries get linked to RTP (:TSInstall does this too) - buildPhase = " - mkdir -p $out/queries - cp -a $src/runtime/queries/* $out/queries - "; - nvimSkipModules = [ "nvim-treesitter._meta.parsers" ]; - }); - } - ); -} diff --git a/nvim/colors/iofq.lua b/nvim/colors/iofq.lua index be525d8..7d80403 100644 --- a/nvim/colors/iofq.lua +++ b/nvim/colors/iofq.lua @@ -626,7 +626,7 @@ hi(0, 'SpellLocal', { sp = '#5a93aa', undercurl = true }) hi(0, 'SpellRare', { sp = '#5a93aa', undercurl = true }) hi(0, 'Statement', { fg = '#ad5c7c' }) hi(0, 'StatusLine', { bg = 'none' }) -hi(0, 'StatusLineNC', { bg = 'none' }) +hi(0, 'StatusLineNC', { bg = 'none', fg = "grey" }) hi(0, 'String', { fg = '#7aa4a1' }) hi(0, 'Substitute', { bg = '#e85c51', fg = '#152528' }) hi(0, 'SymbolOutlineConnector', { link = 'Conceal' }) diff --git a/nvim/lua/config/autocmd.lua b/nvim/lua/config/autocmd.lua index 0ccfabd..e5cfb89 100644 --- a/nvim/lua/config/autocmd.lua +++ b/nvim/lua/config/autocmd.lua @@ -1,10 +1,3 @@ --- create undopath -local undopath = vim.fn.stdpath('data') .. 'undo' -vim.api.nvim_create_autocmd('VimEnter', { - command = 'silent !mkdir -p ' .. undopath, - group = vim.api.nvim_create_augroup('Init', {}), -}) - -- open :h in buffers vim.api.nvim_create_autocmd('BufWinEnter', { pattern = '*', @@ -17,26 +10,6 @@ vim.api.nvim_create_autocmd('BufWinEnter', { end, }) --- Allow basic deletion in qflist -vim.api.nvim_create_autocmd({ 'FileType' }, { - pattern = 'qf', - callback = function() - vim.keymap.set({ 'n', 'i' }, 'dd', function() - local ln = vim.fn.line('.') - local qf = vim.fn.getqflist() - if #qf == 0 then - return - end - table.remove(qf, ln) - vim.fn.setqflist(qf, 'r') - vim.cmd('copen') - -- move cursor to stay at same index (or up one if at EOF) - vim.api.nvim_win_set_cursor(vim.fn.win_getid(), { ln < #qf and ln or math.max(ln - 1, 1), 0 }) - require('quicker').refresh() - end, { buffer = true }) - end, -}) - -- resize splits if window got resized vim.api.nvim_create_autocmd({ 'VimResized' }, { group = vim.api.nvim_create_augroup('resize_splits', { clear = true }), @@ -61,51 +34,26 @@ vim.api.nvim_create_autocmd({ 'FocusGained', 'TermClose', 'TermLeave' }, { vim.api.nvim_create_autocmd('FileType', { callback = function(event) local bufnr = event.buf - local filetype = vim.api.nvim_get_option_value('filetype', { buf = bufnr }) - - if filetype == '' then - return - end - - local parser_name = vim.treesitter.language.get_lang(filetype) - if not parser_name then - return - end - local parser_installed = pcall(vim.treesitter.get_parser, bufnr, parser_name) - if not parser_installed then - return - end - - local function map(lhs, rhs, opts) - if lhs == '' then - return - end - opts = vim.tbl_deep_extend('force', { silent = true }, opts or {}) - vim.keymap.set({ 'v', 'n' }, lhs, rhs, opts) - end vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" - vim.treesitter.start() + pcall(vim.treesitter.start, bufnr) - map('[c', function() - require('treesitter-context').go_to_context(vim.v.count1) - end, { buffer = bufnr, desc = 'jump to TS context' }) - map(']f', function() + vim.keymap.set({'v','n'}, ']f', function() require('nvim-treesitter-textobjects.move').goto_next_start('@function.outer', 'textobjects') end, { buffer = bufnr, desc = 'next function def' }) - map('[f', function() + vim.keymap.set({'v','n'}, '[f', function() require('nvim-treesitter-textobjects.move').goto_previous_start('@function.outer', 'textobjects') end, { buffer = bufnr, desc = 'prev function def' }) - map(']a', function() + vim.keymap.set({'v','n'}, ']a', function() require('nvim-treesitter-textobjects.move').goto_next_start('@parameter.inner', 'textobjects') end, { buffer = bufnr, desc = 'next param def' }) - map('[a', function() + vim.keymap.set({'v','n'}, '[a', function() require('nvim-treesitter-textobjects.move').goto_previous_start('@parameter.inner', 'textobjects') end, { buffer = bufnr, desc = 'prev param def' }) - map('a]', function() + vim.keymap.set({'v','n'}, 'a]', function() require('nvim-treesitter-textobjects.swap').swap_next('@parameter.inner') end, { buffer = bufnr, desc = 'swap next arg' }) - map('a[', function() + vim.keymap.set({'v','n'}, 'a[', function() require('nvim-treesitter-textobjects.swap').swap_previous('@parameter.inner') end, { buffer = bufnr, desc = 'swap prev arg' }) end, diff --git a/nvim/lua/plugins/lib/minidiff_jj.lua b/nvim/lua/plugins/lib/minidiff_jj.lua index d5b93d8..0294773 100644 --- a/nvim/lua/plugins/lib/minidiff_jj.lua +++ b/nvim/lua/plugins/lib/minidiff_jj.lua @@ -4,18 +4,12 @@ local M = { } M.get_buf_realpath = function(buf_id) - return vim.loop.fs_realpath(vim.api.nvim_buf_get_name(buf_id)) or '' + local path = vim.loop.fs_realpath(vim.api.nvim_buf_get_name(buf_id)) or '' + local cwd, basename = vim.fn.fnamemodify(path, ':h'), vim.fn.fnamemodify(path, ':t') + return path, cwd, basename end M.jj_start_watching_tree_state = function(buf_id, path) - local stdout = vim.loop.new_pipe() - local args = { 'workspace', 'root', '--ignore-working-copy' } - local spawn_opts = { - args = args, - cwd = vim.fn.fnamemodify(path, ':h'), - stdio = { nil, stdout, nil }, - } - local on_not_in_jj = vim.schedule_wrap(function() if not vim.api.nvim_buf_is_valid(buf_id) then M.cache[buf_id] = nil @@ -25,105 +19,57 @@ M.jj_start_watching_tree_state = function(buf_id, path) M.cache[buf_id] = {} end) - local process, stdout_feed = nil, {} - local on_exit = function(exit_code) - process:close() + vim.system( + { 'jj', 'workspace', 'root', '--ignore-working-copy' }, + {cwd = vim.fn.fnamemodify(path, ':h')}, + function(obj) + if obj.code ~= 0 then + return on_not_in_jj() + end - -- Watch index only if there was no error retrieving path to it - if exit_code ~= 0 or stdout_feed[1] == nil then - return on_not_in_jj() + -- Set up index watching + local root = obj.stdout:gsub('\n+$', '') .. '/.jj/working_copy/tree_state' + local buf_fs_event = vim.loop.new_fs_event() + + buf_fs_event:start(root, { stat = true }, function() + M.jj_set_ref_text(buf_id) + end) + M.cache[buf_id] = { fs_event = buf_fs_event } + + -- Set reference text immediately + M.jj_set_ref_text(buf_id) end - - -- Set up index watching - local jj_dir_path = table.concat(stdout_feed, ''):gsub('\n+$', '') .. '/.jj/working_copy' - M.jj_setup_tree_state_watch(buf_id, jj_dir_path) - - -- Set reference text immediately - M.jj_set_ref_text(buf_id) - end - - process = vim.loop.spawn('jj', spawn_opts, on_exit) - M.jj_read_stream(stdout, stdout_feed) + ) end -M.jj_setup_tree_state_watch = function(buf_id, jj_dir_path) - local buf_fs_event, timer = vim.loop.new_fs_event(), vim.loop.new_timer() - local buf_jj_set_ref_text = function() - M.jj_set_ref_text(buf_id) - end - - local watch_tree_state = function(_, filename, _) - if filename ~= 'tree_state' then - return - end - -- Debounce to not overload during incremental staging (like in script) - timer:stop() - timer:start(50, 0, buf_jj_set_ref_text) - end - buf_fs_event:start(jj_dir_path, { stat = true }, watch_tree_state) - - M.jj_invalidate_cache(M.cache[buf_id]) - M.cache[buf_id] = { fs_event = buf_fs_event, timer = timer } -end M.jj_set_ref_text = vim.schedule_wrap(function(buf_id) if not vim.api.nvim_buf_is_valid(buf_id) then return end - local buf_set_ref_text = vim.schedule_wrap(function(text) + local buf_set_ref_text = function(text) pcall(diff.set_ref_text, buf_id, text) - end) + end - -- NOTE: Do not cache buffer's name to react to its possible rename - local path = M.get_buf_realpath(buf_id) + -- react to possible rename + local path, cwd, basename = M.get_buf_realpath(buf_id) if path == '' then return buf_set_ref_text {} end - local cwd, basename = vim.fn.fnamemodify(path, ':h'), vim.fn.fnamemodify(path, ':t') - -- Set - local stdout = vim.loop.new_pipe() - local spawn_opts = { - args = { 'file', 'show', '--no-pager', '--ignore-working-copy', '-r', '@-', './' .. basename }, - cwd = cwd, - stdio = { nil, stdout, nil }, - } - - local process, stdout_feed = nil, {} - process = vim.loop.spawn('jj', spawn_opts, function(exit_code) - process:close() - - if exit_code ~= 0 or stdout_feed[1] == nil then - return buf_set_ref_text {} - end - - -- Set reference text accounting for possible 'crlf' end of line in index - local text = table.concat(stdout_feed, ''):gsub('\r\n', '\n') - buf_set_ref_text(text) - end) - - M.jj_read_stream(stdout, stdout_feed) + vim.system( + { 'jj', 'file', 'show', '--no-pager', '--ignore-working-copy', '-r', '@-', './' .. basename }, + { cwd = cwd }, + vim.schedule_wrap(function(obj) + if obj.code ~= 0 then return buf_set_ref_text {} end + buf_set_ref_text(obj.stdout:gsub('\r\n', '\n')) + end) + ) end) -M.jj_read_stream = function(stream, feed) - local callback = function(err, data) - if data ~= nil then - return table.insert(feed, data) - end - if err then - feed[1] = nil - end - stream:close() - end - stream:read_start(callback) -end - -M.jj_invalidate_cache = function(cache) - if cache == nil then - return - end - pcall(vim.loop.fs_event_stop, cache.fs_event) - pcall(vim.loop.timer_stop, cache.timer) +M.jj_invalidate_cache = function(buf_id) + pcall(vim.loop.fs_event_stop, M.cache[buf_id].fs_event) + M.cache[buf_id] = nil end M.gen_source = function() @@ -143,20 +89,15 @@ M.gen_source = function() end local detach = function(buf_id) - local cache = M.cache[buf_id] - M.cache[buf_id] = nil - M.jj_invalidate_cache(cache) + M.jj_invalidate_cache(buf_id) end - local apply_hunks = function(_, _) - -- staging does not apply for jj - end return { name = 'jj', attach = attach, detach = detach, - apply_hunks = apply_hunks, + apply_hunks = function(_, _) end -- staging does not apply for jj } end return M diff --git a/nvim/lua/plugins/lib/session_jj.lua b/nvim/lua/plugins/lib/session_jj.lua index 5e81803..ac21e3c 100644 --- a/nvim/lua/plugins/lib/session_jj.lua +++ b/nvim/lua/plugins/lib/session_jj.lua @@ -67,5 +67,4 @@ M.load = function() end end -_G.M = M return M diff --git a/nvim/lua/plugins/lib/snacks_jj.lua b/nvim/lua/plugins/lib/snacks_jj.lua index da442eb..cee860f 100644 --- a/nvim/lua/plugins/lib/snacks_jj.lua +++ b/nvim/lua/plugins/lib/snacks_jj.lua @@ -55,67 +55,4 @@ function M.status() } end -function M.revs() - local function jj_new(picker, item) - picker:close() - if item then - if not item.rev then - vim.notify.warn('No branch or commit found', { title = 'Snacks Picker' }) - return - end - local cmd = { 'jj', 'new', '-r', item.rev } - Snacks.picker.util.cmd(cmd, function() - vim.notify('Checking out revision: ' .. item.rev, { title = 'Snacks Picker' }) - vim.cmd.checktime() - require('plugins.lib.session_jj').load() - end, { cwd = item.cwd }) - end - end - - local function jj_rev_cmd(ctx) - if ctx.item.rev then - Snacks.picker.preview.cmd({ 'jj', 'show', '--ignore-working-copy', '--git', '-r', ctx.item.rev }, ctx) - else - ctx.preview:reset() - return 'No preview available.' - end - end - - local function jj_log(revset) - if revset == nil then - revset = '-r "ancestors(@,25)"' - else - revset = '-r ' .. revset - end - local status_raw = vim.fn.system( - 'jj log --ignore-working-copy ' - .. revset - .. - ' --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 = {} - - for line in status_raw:gmatch('[^\r\n]+') do - local sign, rev = string.match(line, '(.)%s(%a+)%s.*') - table.insert(lines, { - text = line, - sign = sign, - rev = rev, - }) - end - - return lines - end - - Snacks.picker.pick { - source = 'jj_revs', - layout = 'ivy', - format = 'text', - title = 'jj log', - items = jj_log(), - confirm = jj_new, - preview = jj_rev_cmd, - } -end - return M diff --git a/nvim/lua/plugins/mini.lua b/nvim/lua/plugins/mini.lua index 136521a..a0b78ff 100644 --- a/nvim/lua/plugins/mini.lua +++ b/nvim/lua/plugins/mini.lua @@ -1,6 +1,6 @@ return { { - 'echasnovski/mini.nvim', + 'nvim-mini/mini.nvim', lazy = false, keys = { { @@ -24,37 +24,23 @@ return { 'Git blame -- %', desc = 'git blame', }, - { - 'gg', - ':Git ', - desc = 'git command', - }, }, config = function() require('mini.basics').setup { mappings = { windows = true } } + require('mini.icons').setup() vim.schedule(function() local ai = require('mini.ai') - local extra_ai = require('mini.extra').gen_ai_spec ai.setup { n_lines = 300, custom_textobjects = { - i = extra_ai.indent(), - g = extra_ai.buffer(), - l = extra_ai.line(), + i = require('mini.extra').gen_ai_spec.indent(), u = ai.gen_spec.function_call(), a = ai.gen_spec.treesitter { a = '@parameter.outer', i = '@parameter.inner' }, - k = ai.gen_spec.treesitter { a = '@assignment.lhs', i = '@assignment.lhs' }, - v = ai.gen_spec.treesitter { a = '@assignment.rhs', i = '@assignment.rhs' }, f = ai.gen_spec.treesitter { a = '@function.outer', i = '@function.inner' }, - o = ai.gen_spec.treesitter { - a = { '@block.outer', '@conditional.outer', '@loop.outer' }, - i = { '@block.inner', '@conditional.inner', '@loop.inner' }, - }, }, } require('mini.align').setup() - require('mini.bracketed').setup { file = { suffix = 'm' } } - require('mini.icons').setup() + require('mini.pairs').setup() require('mini.git').setup() require('mini.surround').setup() require('mini.splitjoin').setup { detect = { separator = '[,;\n]' } } @@ -111,7 +97,7 @@ return { clues = { miniclue.gen_clues.g(), miniclue.gen_clues.marks(), - miniclue.gen_clues.registers(), + miniclue.gen_clues.registers({show_contents = true}), miniclue.gen_clues.windows(), miniclue.gen_clues.z(), }, @@ -153,10 +139,6 @@ return { Snacks.rename.on_rename_file(event.data.from, event.data.to) end, }) - - local multi = require('mini.keymap').map_multistep - multi({ 'i', 's' }, '', { 'blink_accept', 'vimsnippet_next', 'increase_indent' }) - multi({ 'i', 's' }, '', { 'vimsnippet_prev', 'decrease_indent' }) end) end, }, diff --git a/nvim/lua/plugins/misc.lua b/nvim/lua/plugins/misc.lua index 7dacf20..d880b74 100644 --- a/nvim/lua/plugins/misc.lua +++ b/nvim/lua/plugins/misc.lua @@ -3,12 +3,10 @@ return { 'iofq/dart.nvim', lazy = false, priority = 1001, - config = true, - }, - { - 'windwp/nvim-autopairs', - event = 'VeryLazy', - config = true, + dependencies = 'nvim-mini/mini.nvim', + opts = { + label_marked_fg = 'cyan' + }, }, { 'nvim-treesitter/nvim-treesitter', @@ -20,20 +18,8 @@ return { branch = 'main', config = true, }, - { - 'nvim-treesitter/nvim-treesitter-context', - opts = { - max_lines = 5, - min_window_height = 50, - }, - }, }, }, - { - 'jinh0/eyeliner.nvim', - event = 'VeryLazy', - config = true, - }, { 'MeanderingProgrammer/render-markdown.nvim', event = 'VeryLazy', @@ -86,21 +72,6 @@ return { }, }, }, - { - 'ThePrimeagen/refactoring.nvim', - event = 'VeryLazy', - config = true, - keys = { - { 'rv', 'Refactor inline_vardd', mode = { 'n', 'x' } }, - { - 'rr', - function() - require('refactoring').select_refactor { prefer_ex_cmd = true } - end, - mode = { 'n', 'x' }, - }, - }, - }, { 'stevearc/quicker.nvim', event = 'VeryLazy', diff --git a/nvim/lua/plugins/snacks.lua b/nvim/lua/plugins/snacks.lua index d6dd0b2..1fc4baa 100644 --- a/nvim/lua/plugins/snacks.lua +++ b/nvim/lua/plugins/snacks.lua @@ -13,9 +13,6 @@ return { notification = { wo = { wrap = true }, }, - terminal = { - border = 'rounded', - }, }, terminal = { enabled = true }, indent = { enabled = true }, @@ -88,13 +85,6 @@ return { end, desc = 'Fuzzy find smart', }, - { - 'fe', - function() - Snacks.explorer() - end, - desc = 'snacks explorer', - }, { 'ff', function() @@ -151,13 +141,6 @@ return { end, desc = 'Fuzzy find buffers', }, - { - 'fn', - function() - Snacks.picker.notifications() - end, - desc = 'pick notifications', - }, { 'gO', function() @@ -179,13 +162,6 @@ return { end, desc = 'pick notifications', }, - { - 'jj', - function() - require('plugins.lib.snacks_jj').revs() - end, - desc = 'pick notifications', - }, }, }, }