From baa309eb4b6b8b107f48365c290b1f254f78280a Mon Sep 17 00:00:00 2001 From: Anish Lakhwara Date: Sun, 5 Oct 2025 20:51:20 -0700 Subject: [PATCH] some small nvim changes --- flake.lock | 191 +++++++++++++++++++++++++++++++++ flake.nix | 9 +- home/profiles/nvim/default.nix | 117 ++++++++++++++++++++ 3 files changed, 316 insertions(+), 1 deletion(-) diff --git a/flake.lock b/flake.lock index 5034bb7b..7d1edbb5 100644 --- a/flake.lock +++ b/flake.lock @@ -299,6 +299,20 @@ "type": "github" } }, + "flake-compat_4": { + "flake": false, + "locked": { + "lastModified": 1751685974, + "narHash": "sha256-NKw96t+BgHIYzHUjkTK95FqYRVKB8DHpVhefWSz/kTw=", + "rev": "549f2762aebeff29a2e5ece7a7dc0f955281a1d1", + "type": "tarball", + "url": "https://git.lix.systems/api/v1/repos/lix-project/flake-compat/archive/549f2762aebeff29a2e5ece7a7dc0f955281a1d1.tar.gz?rev=549f2762aebeff29a2e5ece7a7dc0f955281a1d1" + }, + "original": { + "type": "tarball", + "url": "https://git.lix.systems/lix-project/flake-compat/archive/main.tar.gz" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" @@ -417,6 +431,24 @@ "type": "github" } }, + "flake-utils_5": { + "inputs": { + "systems": "systems_5" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "gitignore": { "inputs": { "nixpkgs": [ @@ -440,6 +472,28 @@ "type": "github" } }, + "gomod2nix": { + "inputs": { + "flake-utils": "flake-utils_5", + "nixpkgs": [ + "tangled", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1754078208, + "narHash": "sha256-YVoIFDCDpYuU3riaDEJ3xiGdPOtsx4sR5eTzHTytPV8=", + "owner": "nix-community", + "repo": "gomod2nix", + "rev": "7f963246a71626c7fc70b431a315c4388a0c95cf", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "gomod2nix", + "type": "github" + } + }, "grasp": { "inputs": { "flake-utils": "flake-utils_4", @@ -567,6 +621,72 @@ "type": "github" } }, + "htmx-src": { + "flake": false, + "locked": { + "narHash": "sha256-nm6avZuEBg67SSyyZUhjpXVNstHHgUxrtBHqJgowU08=", + "type": "file", + "url": "https://unpkg.com/htmx.org@2.0.4/dist/htmx.min.js" + }, + "original": { + "type": "file", + "url": "https://unpkg.com/htmx.org@2.0.4/dist/htmx.min.js" + } + }, + "htmx-ws-src": { + "flake": false, + "locked": { + "narHash": "sha256-2fg6KyEJoO24q0fQqbz9RMaYNPQrMwpZh29tkSqdqGY=", + "type": "file", + "url": "https://cdn.jsdelivr.net/npm/htmx-ext-ws@2.0.2" + }, + "original": { + "type": "file", + "url": "https://cdn.jsdelivr.net/npm/htmx-ext-ws@2.0.2" + } + }, + "ibm-plex-mono-src": { + "flake": false, + "locked": { + "lastModified": 1731402384, + "narHash": "sha256-OwUmrPfEehLDz0fl2ChYLK8FQM2p0G1+EMrGsYEq+6g=", + "type": "tarball", + "url": "https://github.com/IBM/plex/releases/download/@ibm/plex-mono@1.1.0/ibm-plex-mono.zip" + }, + "original": { + "type": "tarball", + "url": "https://github.com/IBM/plex/releases/download/@ibm/plex-mono@1.1.0/ibm-plex-mono.zip" + } + }, + "indigo": { + "flake": false, + "locked": { + "lastModified": 1753693716, + "narHash": "sha256-DMIKnCJRODQXEHUxA+7mLzRALmnZhkkbHlFT2rCQYrE=", + "owner": "oppiliappan", + "repo": "indigo", + "rev": "5f170569da9360f57add450a278d73538092d8ca", + "type": "github" + }, + "original": { + "owner": "oppiliappan", + "repo": "indigo", + "type": "github" + } + }, + "inter-fonts-src": { + "flake": false, + "locked": { + "lastModified": 1731687360, + "narHash": "sha256-5vdKKvHAeZi6igrfpbOdhZlDX2/5+UvzlnCQV6DdqoQ=", + "type": "tarball", + "url": "https://github.com/rsms/inter/releases/download/v4.1/Inter-4.1.zip" + }, + "original": { + "type": "tarball", + "url": "https://github.com/rsms/inter/releases/download/v4.1/Inter-4.1.zip" + } + }, "jovian": { "inputs": { "nix-github-actions": "nix-github-actions", @@ -604,6 +724,19 @@ "type": "github" } }, + "lucide-src": { + "flake": false, + "locked": { + "lastModified": 1754044466, + "narHash": "sha256-+exBR2OToB1iv7ZQI2S4B0lXA/QRvC9n6U99UxGpJGs=", + "type": "tarball", + "url": "https://github.com/lucide-icons/lucide/releases/download/0.536.0/lucide-icons-0.536.0.zip" + }, + "original": { + "type": "tarball", + "url": "https://github.com/lucide-icons/lucide/releases/download/0.536.0/lucide-icons-0.536.0.zip" + } + }, "mk-shell-bin": { "locked": { "lastModified": 1677004959, @@ -980,6 +1113,7 @@ "nur": "nur", "poonam": "poonam", "rust-overlay": "rust-overlay", + "tangled": "tangled", "tidalcycles": "tidalcycles", "unstable": "unstable", "vimwikicli": "vimwikicli" @@ -1022,6 +1156,19 @@ "type": "github" } }, + "sqlite-lib-src": { + "flake": false, + "locked": { + "lastModified": 1706631843, + "narHash": "sha256-bJoMjirsBjm2Qk9KPiy3yV3+8b/POlYe76/FQbciHro=", + "type": "tarball", + "url": "https://sqlite.org/2024/sqlite-amalgamation-3450100.zip" + }, + "original": { + "type": "tarball", + "url": "https://sqlite.org/2024/sqlite-amalgamation-3450100.zip" + } + }, "superdirt-src": { "flake": false, "locked": { @@ -1098,6 +1245,50 @@ "type": "github" } }, + "systems_5": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "tangled": { + "inputs": { + "flake-compat": "flake-compat_4", + "gomod2nix": "gomod2nix", + "htmx-src": "htmx-src", + "htmx-ws-src": "htmx-ws-src", + "ibm-plex-mono-src": "ibm-plex-mono-src", + "indigo": "indigo", + "inter-fonts-src": "inter-fonts-src", + "lucide-src": "lucide-src", + "nixpkgs": [ + "nixpkgs" + ], + "sqlite-lib-src": "sqlite-lib-src" + }, + "locked": { + "lastModified": 1759559279, + "narHash": "sha256-gA0mh9Fx2uou2v75RMA6qUvWB3Z74Asc6pRjiojwaRo=", + "ref": "refs/heads/master", + "rev": "5ecd54b31547ac169a3b15d6034a67179f22aa33", + "revCount": 1486, + "type": "git", + "url": "https://tangled.org/@tangled.org/core" + }, + "original": { + "type": "git", + "url": "https://tangled.org/@tangled.org/core" + } + }, "tidal-src": { "flake": false, "locked": { diff --git a/flake.nix b/flake.nix index ced56e29..2cb9d3d3 100644 --- a/flake.nix +++ b/flake.nix @@ -65,6 +65,12 @@ inputs.nixpkgs.follows = "unstable"; }; + # Tangled (atproto tools) + tangled = { + url = "git+https://tangled.org/@tangled.org/core"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + # Others nur.url = "github:nix-community/NUR"; rust-overlay = { @@ -89,7 +95,7 @@ outputs = { self, nixpkgs, unstable, nixos-hardware, home-manager, deploy-rs , agenix, disko, basant, grasp, nix-matrix-appservices, nur, tidalcycles , rust-overlay, vimwikicli, autohide-tdrop, darwin, nix-homebrew, homebrew-bundle - , homebrew-core, homebrew-cask, jovian, ... }@inputs: + , homebrew-core, homebrew-cask, jovian, tangled, ... }@inputs: let forAllSystems = nixpkgs.lib.genAttrs [ "aarch64-linux" @@ -147,6 +153,7 @@ # ]; overlays = [ agenix.overlays.default + tangled.overlays.default # atproto tools only on lite deployments self.overlays.additions self.overlays.modifications tidalcycles.overlays.default # needed for nvim which comes pre-installed lol diff --git a/home/profiles/nvim/default.nix b/home/profiles/nvim/default.nix index e34501d6..8a2c51b5 100644 --- a/home/profiles/nvim/default.nix +++ b/home/profiles/nvim/default.nix @@ -228,6 +228,7 @@ in nnoremap fb Telescope buffers nnoremap fh Telescope help_tags nnoremap ft Telescope tags + nnoremap fr lua KitaabRecent() " exit normal mode in terminal :tnoremap @@ -975,6 +976,110 @@ in vim.keymap.set('n', '', 'resize +2', {silent = true}) vim.keymap.set('n', '', 'vertical resize +2', {silent = true}) + -- Kitaab recent files (only date-based files, sorted reverse) + function KitaabRecent() + local pickers = require('telescope.pickers') + local finders = require('telescope.finders') + local conf = require('telescope.config').values + + -- Use current working directory + local kitaab_path = vim.fn.getcwd() + + -- Get all files (depth 1, exclude directories) + local files = vim.fn.readdir(kitaab_path, function(name) + return vim.fn.isdirectory(kitaab_path .. '/' .. name) == 0 + end) + + -- Filter to only date-based files (starting with digit) + local date_files = {} + for _, filename in ipairs(files) do + if filename:match('^%d') then + table.insert(date_files, filename) + end + end + + -- Sort in reverse (most recent first) + table.sort(date_files, function(a, b) return a > b end) + + pickers.new({}, { + prompt_title = 'Kitaab Recent', + finder = finders.new_table({ + results = date_files, + entry_maker = function(entry) + return { + value = kitaab_path .. '/' .. entry, + display = entry, + ordinal = entry, + path = kitaab_path .. '/' .. entry, + } + end + }), + previewer = conf.file_previewer({}), + sorter = conf.generic_sorter({}), + }):find() + end + + -- Setup amp.nvim + require('amp').setup({ + auto_start = true, + log_level = "info" + }) + + -- Amp commands + vim.api.nvim_create_user_command("AmpSend", function(opts) + local message = opts.args + if message == "" then + print("Please provide a message to send") + return + end + local amp_message = require("amp.message") + amp_message.send_message(message) + end, { + nargs = "*", + desc = "Send a message to Amp", + }) + + vim.api.nvim_create_user_command("AmpSendBuffer", function(opts) + local buf = vim.api.nvim_get_current_buf() + local lines = vim.api.nvim_buf_get_lines(buf, 0, -1, false) + local content = table.concat(lines, "\n") + local amp_message = require("amp.message") + amp_message.send_message(content) + end, { + nargs = "?", + desc = "Send current buffer contents to Amp", + }) + + vim.api.nvim_create_user_command("AmpPromptSelection", function(opts) + local lines = vim.api.nvim_buf_get_lines(0, opts.line1 - 1, opts.line2, false) + local text = table.concat(lines, "\n") + local amp_message = require("amp.message") + amp_message.send_to_prompt(text) + end, { + range = true, + desc = "Add selected text to Amp prompt", + }) + + vim.api.nvim_create_user_command("AmpPromptRef", function(opts) + local bufname = vim.api.nvim_buf_get_name(0) + if bufname == "" then + print("Current buffer has no filename") + return + end + local relative_path = vim.fn.fnamemodify(bufname, ":.") + local ref = "@" .. relative_path + if opts.line1 ~= opts.line2 then + ref = ref .. "#L" .. opts.line1 .. "-" .. opts.line2 + elseif opts.line1 > 1 then + ref = ref .. "#L" .. opts.line1 + end + local amp_message = require("amp.message") + amp_message.send_to_prompt(ref) + end, { + range = true, + desc = "Add file reference (with selection) to Amp prompt", + }) + EOF ''; @@ -1093,6 +1198,17 @@ in yuck-vim nvim-parinfer # vim-processing + + # amp.nvim for Sourcegraph Amp integration + (pkgs.vimUtils.buildVimPlugin { + name = "amp-nvim"; + src = pkgs.fetchFromGitHub { + owner = "sourcegraph"; + repo = "amp.nvim"; + rev = "main"; + sha256 = "1n6d8nbakyg6yiq8mhhrvmsp9z0zb8cb67820jsg3wl6vqd1vwv5"; + }; + }) ]; withPython3 = true; extraPython3Packages = pkgs: with pkgs; [ tasklib six packaging ]; @@ -1100,3 +1216,4 @@ in }; } +