diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 36b3551..4c6ddd7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - package_name: ["nvim-min"] + package_name: ["nvim"] steps: - uses: actions/checkout@v3 - uses: DeterminateSystems/nix-installer-action@main diff --git a/README.md b/README.md index 29a9c20..223d62a 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ ## Usage Try it out! ```bash -nix run "github:iofq/nvim.nix" #nvim-min +nix run "github:iofq/nvim.nix" #nvim ``` Or use in a flake: diff --git a/flake.lock b/flake.lock index f7bb4eb..3513204 100644 --- a/flake.lock +++ b/flake.lock @@ -6,11 +6,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1760745932, - "narHash": "sha256-Z9idyP9kiKxC10VL0vHnxcBwrkpNtBrC+Zxl9mQbCj8=", + "lastModified": 1761202123, + "narHash": "sha256-ULrZW4b8SKRvPpJPt8/jkqqc/blQiIWUriNWVXA33so=", "owner": "iofq", "repo": "dart.nvim", - "rev": "26b476f2113143329637a27d4e52ce9772bcae5b", + "rev": "71421e7ef5aee8267e24dc562fdd07a83bda192e", "type": "github" }, "original": { @@ -93,11 +93,11 @@ ] }, "locked": { - "lastModified": 1760813311, - "narHash": "sha256-lbHQ7FXGzt6/IygWvJ1lCq+Txcut3xYYd6VIpF1ojkg=", + "lastModified": 1760948891, + "narHash": "sha256-TmWcdiUUaWk8J4lpjzu4gCGxWY6/Ok7mOK4fIFfBuU4=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "4e627ac2e1b8f1de7f5090064242de9a259dbbc8", + "rev": "864599284fc7c0ba6357ed89ed5e2cd5040f0c04", "type": "github" }, "original": { @@ -267,11 +267,11 @@ ] }, "locked": { - "lastModified": 1758022363, - "narHash": "sha256-ENUhCRWgSX4ni751HieNuQoq06dJvApV/Nm89kh+/A0=", + "lastModified": 1761230615, + "narHash": "sha256-pLE7U5gOtlA/2wbKCsVRYf5DqMQ5TWBCrCfZGytDDeo=", "owner": "hercules-ci", "repo": "hercules-ci-effects", - "rev": "1a3667d33e247ad35ca250698d63f49a5453d824", + "rev": "7db2b867219a26781437d840ce457b75b7645154", "type": "github" }, "original": { @@ -309,11 +309,11 @@ "treefmt-nix": "treefmt-nix" }, "locked": { - "lastModified": 1760832323, - "narHash": "sha256-THAk4qzBOsp03bDBYK9Ek3mQEvl2g8Fea0QhpCoEzfs=", + "lastModified": 1761437965, + "narHash": "sha256-X4SNeOXdFkE7Gt+waO5ck3TqfqWskqJHxt1WIu3nnUQ=", "owner": "nix-community", "repo": "neovim-nightly-overlay", - "rev": "3c9432813e5528a13075f5493da6ff9ef249ad1d", + "rev": "21595d9f79b5da0eef177dcfdd84ca981ac253a9", "type": "github" }, "original": { @@ -325,11 +325,11 @@ "neovim-src": { "flake": false, "locked": { - "lastModified": 1760810839, - "narHash": "sha256-VYkZdjjMOYsugoSydDDWE/1l79swm4zc4NJl1Z0brjA=", + "lastModified": 1761434579, + "narHash": "sha256-S+YmbP/bPETjKk6B/tlh+jwIH7K7iPoXyHLLwTqVOhk=", "owner": "neovim", "repo": "neovim", - "rev": "be73c35943f85e7835c3a0fc89bddaeba944db29", + "rev": "a121ede1bfee2704c26159124f8f61f96c6aa136", "type": "github" }, "original": { @@ -383,11 +383,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1760913523, - "narHash": "sha256-Il5+67iRA3xp0cIErILj4VwEJ2ICrDrvTAHEmBsZJKQ=", + "lastModified": 1761497392, + "narHash": "sha256-aK+BZgnXKktKD1DFAJoB+8KD9L8sf/dmiOa2bShlhlk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "6a3b08503e9cab108f9f0ec27065c5854655662a", + "rev": "887b4accbb94043a752c086c2aae6c6b365f7b3f", "type": "github" }, "original": { @@ -399,11 +399,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1760524057, - "narHash": "sha256-EVAqOteLBFmd7pKkb0+FIUyzTF61VKi7YmvP1tw4nEw=", + "lastModified": 1761114652, + "narHash": "sha256-f/QCJM/YhrV/lavyCVz8iU3rlZun6d+dAiC3H+CDle4=", "owner": "nixos", "repo": "nixpkgs", - "rev": "544961dfcce86422ba200ed9a0b00dd4b1486ec5", + "rev": "01f116e4df6a15f4ccdffb1bcd41096869fb385c", "type": "github" }, "original": { @@ -416,11 +416,11 @@ "nvim-treesitter": { "flake": false, "locked": { - "lastModified": 1760866486, - "narHash": "sha256-ZeNCXy6+I18N+Nu2sKnEk2otVEb8V3tKhL8Jq95wS5k=", + "lastModified": 1761385693, + "narHash": "sha256-/SGikTPEMxI7rcfGvuJlNZs73/wZiQx14QX9xlfsTv0=", "owner": "nvim-treesitter", "repo": "nvim-treesitter", - "rev": "71bf1665f804d46f7e4b24ad7ffc11f6ea5b271a", + "rev": "98fe644cb3b5ba390d1bc3f89299f93c70020803", "type": "github" }, "original": { @@ -437,11 +437,11 @@ "nvim-treesitter-textobjects": "nvim-treesitter-textobjects" }, "locked": { - "lastModified": 1760906917, - "narHash": "sha256-WJScDX0q/+PCRpvBSlJfV01kwvu9WCk5YDpzW2Zswj8=", + "lastModified": 1761496664, + "narHash": "sha256-xTQUiJu0jJNSEHEv4La1HbaFokup0eWr67Kqf/wDENA=", "owner": "iofq", "repo": "nvim-treesitter-main", - "rev": "420c14c0523d65c6c7ce943e8f2fb896eff950e3", + "rev": "834d66648bb7a96a2ad11d53a33f2d9b13766447", "type": "github" }, "original": { @@ -515,11 +515,11 @@ ] }, "locked": { - "lastModified": 1760802554, - "narHash": "sha256-5YkOYOCF8/XNw89/ABKFB0c/P78U2EVuKRDGTql6+kA=", + "lastModified": 1761311587, + "narHash": "sha256-Msq86cR5SjozQGCnC6H8C+0cD4rnx91BPltZ9KK613Y=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "296ebf0c3668ebceb3b0bfee55298f112b4b5754", + "rev": "2eddae033e4e74bf581c2d1dfa101f9033dbd2dc", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index a9cc1ad..e5890fa 100644 --- a/flake.nix +++ b/flake.nix @@ -73,7 +73,6 @@ packages = rec { default = nvim; nvim = pkgs.nvim-pkg; - nvim-min = pkgs.nvim-min-pkg; }; devShells = { default = shell; diff --git a/nix/neovim-overlay.nix b/nix/neovim-overlay.nix index 430c345..efc75a1 100644 --- a/nix/neovim-overlay.nix +++ b/nix/neovim-overlay.nix @@ -17,41 +17,18 @@ let nvim-treesitter nvim-treesitter-textobjects quicker-nvim - refactoring-nvim render-markdown-nvim snacks-nvim ]; - basePackages = with prev; [ + packages = with prev; [ ripgrep fd ]; - # Extra packages that should be included on nixos but don't need to be bundled - extraPackages = with prev; [ - # linters - yamllint - jq - hadolint - nixfmt - shellcheck - golangci-lint - - # LSPs - gopls - lua-language-server - nixd - basedpyright - ]; in { nvim-pkg = mkNeovim { - inherit plugins; - packages = basePackages ++ extraPackages; - }; - - nvim-min-pkg = mkNeovim { - inherit plugins; - packages = basePackages; + inherit plugins packages; }; nvim-luarc-json = final.mk-luarc-json { diff --git a/nvim/after/lua/iofq/snacks_jj.lua b/nvim/after/lua/iofq/snacks_jj.lua index aae14fa..a9c78fe 100644 --- a/nvim/after/lua/iofq/snacks_jj.lua +++ b/nvim/after/lua/iofq/snacks_jj.lua @@ -62,6 +62,21 @@ function M.file_history(filename) end end + local function confirm(picker, item) + picker:close() + local cmd = string.format('jj show --git -r %s', item.rev) + local out = vim.fn.systemlist(cmd) + + local bufnr = vim.api.nvim_create_buf(false, true) + vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, out) + vim.bo[bufnr].bufhidden = 'wipe' + vim.bo[bufnr].buftype = 'nofile' + vim.bo[bufnr].filetype = 'diff' + vim.keymap.set('n', 'q', vim.cmd.bdelete, { buffer = bufnr, noremap = true }) + + vim.api.nvim_set_current_buf(bufnr) + end + local function get_history(f) local status_raw = vim.fn.system( 'jj log --ignore-working-copy --no-graph' @@ -85,6 +100,7 @@ function M.file_history(filename) title = 'jj file history for ' .. filename, items = get_history(filename), preview = preview, + confirm = confirm, } end return M diff --git a/nvim/after/plugin/autocmd.lua b/nvim/after/plugin/autocmd.lua index 81cb335..7e8e994 100644 --- a/nvim/after/plugin/autocmd.lua +++ b/nvim/after/plugin/autocmd.lua @@ -48,7 +48,7 @@ cmd('FileType', { local ns = vim.api.nvim_create_namespace('nvim.difftool.hl') vim.api.nvim_buf_clear_namespace(event.buf, ns, 0, -1) for i, item in ipairs(qf) do - local path = vim.fn.fnamemodify(item.user_data.right, ':t') + local path = vim.fn.fnamemodify(item.user_data.right, ':.') local hl = 'Added' if exec('git diff --quiet -- %s', path) ~= 0 @@ -98,6 +98,45 @@ cmd('BufWinEnter', { vim.cmd(string.format('%dcopen', math.min(10, #items))) end) end + + local function get_hunks(bufnr) + local conf_start = vim.fn.search('^<<<<<<<', 'bc') + local base_start = vim.fn.search('^|||||||', 'W') + local base_end = vim.fn.search('^=======', 'W') + local conf_end = vim.fn.search('^>>>>>>>', 'W') + + local left = vim.api.nvim_buf_get_lines(bufnr, conf_start, base_start - 1, false) + local right = vim.api.nvim_buf_get_lines(bufnr, base_end, conf_end - 1, false) + + return { + start = conf_start, + stop = conf_end, + left = left, + right = right, + } + end + + local function apply_hunk(hunks, first) + local result = {} + if first == -1 then -- left first + vim.list_extend(result, hunks.left) + vim.list_extend(result, hunks.right) + else + vim.list_extend(result, hunks.right) + vim.list_extend(result, hunks.left) + end + + -- apply hunk in place + vim.api.nvim_buf_set_lines(0, hunks.start - 1, hunks.stop, false, result) + end + + -- "combine" mappings ala vscode's merge editor + vim.keymap.set('n', 'dl', function() + apply_hunk(get_hunks(event.buf), -1) + end, { buffer = event.buf }) + vim.keymap.set('n', 'dr', function() + apply_hunk(get_hunks(event.buf), 1) + end, { buffer = event.buf }) end, }) diff --git a/nvim/after/plugin/mini.lua b/nvim/after/plugin/mini.lua index c60ec00..76b5fe9 100644 --- a/nvim/after/plugin/mini.lua +++ b/nvim/after/plugin/mini.lua @@ -18,9 +18,7 @@ vim.schedule(function() require('mini.git').setup() map('n', 'gb', 'Git blame -- %') - map('n', 'go', function() - return MiniGit.show_at_cursor() - end) + map('n', 'go', MiniGit.show_at_cursor) local jump = require('mini.jump2d') jump.setup { diff --git a/nvim/after/plugin/plugins.lua b/nvim/after/plugin/plugins.lua index 2d8e7c4..21c9339 100644 --- a/nvim/after/plugin/plugins.lua +++ b/nvim/after/plugin/plugins.lua @@ -3,12 +3,7 @@ local map = vim.keymap.set require('mini.basics').setup { mappings = { windows = true } } require('mini.icons').setup() -require('dart').setup { - tabline = { - icons = false, - label_marked_fg = 'cyan', - }, -} +require('dart').setup {} require('snacks').setup { bigfile = { enabled = true }, @@ -65,12 +60,6 @@ vim.schedule(function() require('nvim-treesitter-textobjects').setup() require('nvim-autopairs').setup() - require('refactoring').setup() - map('n', 'rr', require('refactoring').select_refactor) - map('n', 'rv', function() - require('refactoring').refactor('Inline Variable') - end) - require('quicker').setup() map('n', 'qf', function() require('quicker').toggle { max_height = 20 } @@ -82,7 +71,6 @@ vim.schedule(function() json = { 'jq' }, lua = { 'stylua' }, python = { 'ruff' }, - nix = { 'nixfmt' }, fish = { 'fish_indent' }, ['*'] = { 'trim_whitespace' }, }, @@ -128,7 +116,7 @@ vim.schedule(function() sources = { default = { 'lsp', 'path', 'snippets', 'ripgrep', 'buffer' }, providers = { - lsp = { fallbacks = {} }, -- include buffer even when LSP is active + lsp = { fallbacks = {}, async = true }, -- include buffer even when LSP is active path = { opts = { get_cwd = vim.fn.getcwd } }, -- use nvim pwd instead of current file pwd ripgrep = { module = 'blink-ripgrep',