diff --git a/flake.lock b/flake.lock index 5999137..3653bb4 100644 --- a/flake.lock +++ b/flake.lock @@ -1,6 +1,320 @@ { "nodes": { - "root": {} + "devshell": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1735644329, + "narHash": "sha256-tO3HrHriyLvipc4xr+Ewtdlo7wM1OjXNjlWRgmM7peY=", + "owner": "numtide", + "repo": "devshell", + "rev": "f7795ede5b02664b57035b3b757876703e2c3eac", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "flake-compat": { + "locked": { + "lastModified": 1733328505, + "narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=", + "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", + "revCount": 69, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.1.0/01948eb7-9cba-704f-bbf3-3fa956735b52/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1738453229, + "narHash": "sha256-7H9XgNiGLKN1G1CgRh0vUL4AheZSYzPm+zmZ7vxbJdo=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "32ea77a06711b758da0ad9bd6a844c5740a87abd", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "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" + } + }, + "git-hooks": { + "inputs": { + "flake-compat": [ + "nixvim", + "flake-compat" + ], + "gitignore": "gitignore", + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1737465171, + "narHash": "sha256-R10v2hoJRLq8jcL4syVFag7nIGE7m13qO48wRIukWNg=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "9364dc02281ce2d37a1f55b6e51f7c0f65a75f17", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "nixvim", + "git-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1738878603, + "narHash": "sha256-fmhq8B3MvQLawLbMO+LWLcdC2ftLMmwSk+P29icJ3tE=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "433799271274c9f2ab520a49527ebfe2992dcfbd", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "ixx": { + "inputs": { + "flake-utils": [ + "nixvim", + "nuschtosSearch", + "flake-utils" + ], + "nixpkgs": [ + "nixvim", + "nuschtosSearch", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1729958008, + "narHash": "sha256-EiOq8jF4Z/zQe0QYVc3+qSKxRK//CFHMB84aYrYGwEs=", + "owner": "NuschtOS", + "repo": "ixx", + "rev": "9fd01aad037f345350eab2cd45e1946cc66da4eb", + "type": "github" + }, + "original": { + "owner": "NuschtOS", + "ref": "v0.0.6", + "repo": "ixx", + "type": "github" + } + }, + "nix-darwin": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1738743987, + "narHash": "sha256-O3bnAfsObto6l2tQOmQlrO6Z2kD6yKwOWfs7pA0CpOc=", + "owner": "lnl7", + "repo": "nix-darwin", + "rev": "ae406c04577ff9a64087018c79b4fdc02468c87c", + "type": "github" + }, + "original": { + "owner": "lnl7", + "repo": "nix-darwin", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1740126099, + "narHash": "sha256-ozoOtE2hGsqh4XkTJFsrTkNxkRgShxpQxDynaPZUGxk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "32fb99ba93fea2798be0e997ea331dd78167f814", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1738797219, + "narHash": "sha256-KRwX9Z1XavpgeSDVM/THdFd6uH8rNm/6R+7kIbGa+2s=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "1da52dd49a127ad74486b135898da2cef8c62665", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixvim": { + "inputs": { + "devshell": "devshell", + "flake-compat": "flake-compat", + "flake-parts": "flake-parts", + "git-hooks": "git-hooks", + "home-manager": "home-manager", + "nix-darwin": "nix-darwin", + "nixpkgs": "nixpkgs_2", + "nuschtosSearch": "nuschtosSearch", + "treefmt-nix": "treefmt-nix" + }, + "locked": { + "lastModified": 1739902813, + "narHash": "sha256-BgOQcKKz7VNvSHIbBllHisv32HvF3W3ALF9sdnC++V8=", + "owner": "nix-community", + "repo": "nixvim", + "rev": "0ab9947137cd034ec64eb5cd9ede94e53af21f50", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixvim", + "type": "github" + } + }, + "nuschtosSearch": { + "inputs": { + "flake-utils": "flake-utils", + "ixx": "ixx", + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1738508923, + "narHash": "sha256-4DaDrQDAIxlWhTjH6h/+xfG05jt3qDZrZE/7zDLQaS4=", + "owner": "NuschtOS", + "repo": "search", + "rev": "86e2038290859006e05ca7201425ea5b5de4aecb", + "type": "github" + }, + "original": { + "owner": "NuschtOS", + "repo": "search", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "nixvim": "nixvim" + } + }, + "systems": { + "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": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1738680491, + "narHash": "sha256-8X7tR3kFGkE7WEF5EXVkt4apgaN85oHZdoTGutCFs6I=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "64dbb922d51a42c0ced6a7668ca008dded61c483", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + } }, "root": "root", "version": 7 diff --git a/flake.nix b/flake.nix index 9b96b84..0ce1dd7 100644 --- a/flake.nix +++ b/flake.nix @@ -6,7 +6,6 @@ nixvim = { url = "github:nix-community/nixvim"; - inputs.nixpkgs.follows = "nixpkgs"; }; }; diff --git a/plugins/avante-custom.nix b/plugins/avante-custom.nix new file mode 100644 index 0000000..e096cf8 --- /dev/null +++ b/plugins/avante-custom.nix @@ -0,0 +1,72 @@ +{ config, pkgs,... }: +{ + programs.nixvim = if config.nixvim-config.enable-ai then { + extraPlugins = [ + pkgs.vimPlugins.avante-nvim + # (pkgs.vimUtils.buildVimPlugin { + # name = "avante"; + # src = pkgs.fetchFromGitHub { + # owner = "yetone"; + # repo = "avante.nvim"; + # rev = "v0.0.19"; + # hash = "sha256-/WvkMsyhaYa3TLOg6QBVz1dvHO4vr1PdeSF7zVIOUcY="; + # }; + # }) + ]; + + # Use "post" to make sure dependencies are loaded first + extraConfigLuaPost = '' + -- MunifTanjim/nui.nvim + -- stevearc/dressing.nvim + -- nvim-lua/plenary.nvim + + require('nui').setup({}); + require('dressing').setup({}); + require('plenary').setup({}); + require('avante_lib').load() + require('avante').setup ({ + provider = "copilot", + + claude = { + api_key_name = "", + }, + openai = { + api_key_name = "", + }, + + files = { + auto_include = true, -- Automatically include relevant files + max_files = 50, ---------------- Maximum number of files to include in context + max_size_kb = 1000, -- Maximum total size of files in KB + + -- Define which files to include/exclude + include = { + "*.lua", + "*.nix", + "*.rs", + "*.ts", + "*.js", + "*.jsx", + "*.tsx", + -- Add more patterns as needed + }, + + exclude = { + "node_modules/**", + "dist/**", + ".git/**", + }, + }, + + web_search_engine = { + provider = "tavily", -- tavily, serpapi, searchapi, google, kagi + }, + + -- depends on docker + rag_service = { + enable = true, -- requires OPENAI_API_KEY to be set + }, + }) + ''; + } else {}; +} diff --git a/plugins/avante.nix b/plugins/avante.nix index 1afa8d3..cd3a319 100644 --- a/plugins/avante.nix +++ b/plugins/avante.nix @@ -18,6 +18,10 @@ settings = { provider = "copilot"; + cursor_applying_provider = "copilot"; + behaviour = { + enable_cursor_planning_mode = true; + }; files = { auto_include = true; # Automatically include relevant files diff --git a/plugins/default.nix b/plugins/default.nix index 3c02465..98b9ed2 100644 --- a/plugins/default.nix +++ b/plugins/default.nix @@ -1,7 +1,8 @@ -{ config, ... }: +{ config, pkgs, ... }: { imports = [ ./avante.nix + # ./avante-custom.nix ./bash.nix # ./blink-cmp.nix # ./blink-cmp-copilot.nix @@ -19,61 +20,65 @@ ./lazydev.nix ./lsp.nix ./luasnip.nix + # ./mini.nix + # ./mini-files.nix ./nvim-tree.nix + ./startify.nix ./telescope.nix ./treesitter.nix ./vim-signify.nix ]; - programs.nixvim.plugins = { - comment.enable = true; - ## needed by avante. already archived, so may need to migrate to snacks - dressing.enable = true; - fugitive.enable = true; - gitsigns.enable = true; - lightline.enable = false; - lualine.enable = true; - nix.enable = true; - noice.enable = true; - ## disable, very annoying as notifications block content and - ## are part of the buffer rotation - notify = { - enable = false; - settings = { - top_down = false; + programs.nixvim = { + plugins = { + comment.enable = true; + ## needed by avante. already archived, so may need to migrate to snacks + dressing.enable = true; + fugitive.enable = true; + gitsigns.enable = true; + lightline.enable = false; + lualine.enable = true; + nix.enable = true; + noice.enable = true; + ## disable, very annoying as notifications block content and + ## are part of the buffer rotation + notify = { + enable = false; + settings = { + top_down = false; + }; }; + ## needed by avante. + nui.enable = true; + nvim-autopairs.enable = true; + nvim-bqf.enable = true; + nvim-lightbulb.enable = true; + # config = '' + # lua << EOF + # require('nvim-lightbulb').setup({ + # float = { + # -- "true" causes "invalid buffer id" error + # enabled = false, + # }, + # autocmd = { + # enabled = true, + # }, + # }) + # EOF + # ''; + # oil.enable = true; + rainbow-delimiters.enable = true; + render-markdown.enable = true; + sleuth.enable = true; + tmux-navigator.enable = true; + treesitter-context.enable = true; + trouble.enable = true; + ts-autotag.enable = true; + # ## Needed for telescope, nvim-tree, trouble, diffview, bufferline, and other plugins + # ## Only on unstable at the moment + web-devicons.enable = true; + which-key.enable = true; + yanky.enable = true; }; - ## needed by avante. - nui.enable = true; - nvim-autopairs.enable = true; - nvim-bqf.enable = true; - nvim-lightbulb.enable = true; - # config = '' - # lua << EOF - # require('nvim-lightbulb').setup({ - # float = { - # -- "true" causes "invalid buffer id" error - # enabled = false, - # }, - # autocmd = { - # enabled = true, - # }, - # }) - # EOF - # ''; - - oil.enable = true; - rainbow-delimiters.enable = true; - sleuth.enable = true; - startify.enable = config.nixvim-config.enable-startify; - tmux-navigator.enable = true; - treesitter-context.enable = true; - trouble.enable = true; - ts-autotag.enable = true; - # ## Needed for telescope, nvim-tree, trouble, diffview, bufferline, and other plugins - # ## Only on unstable at the moment - web-devicons.enable = true; - which-key.enable = true; - yanky.enable = true; }; } diff --git a/plugins/indent-blankline.nix b/plugins/indent-blankline.nix index d847e70..2b085fd 100644 --- a/plugins/indent-blankline.nix +++ b/plugins/indent-blankline.nix @@ -4,26 +4,37 @@ indent-blankline = { enable = true; luaConfig.post = '' + vim.g.indent_blankline_filetype_exclude = { + 'checkhealth', + 'dashboard', + 'help', + 'lspinfo', + 'neogitstatus', + 'packer', + 'startify', + "", + } + local highlight = { - "RainbowRed", - "RainbowYellow", - "RainbowBlue", - "RainbowOrange", - "RainbowGreen", - "RainbowViolet", - "RainbowCyan", + "RainbowRed", + "RainbowYellow", + "RainbowBlue", + "RainbowOrange", + "RainbowGreen", + "RainbowViolet", + "RainbowCyan", } local hooks = require "ibl.hooks" -- create the highlight groups in the highlight setup hook, so they are reset -- every time the colorscheme changes hooks.register(hooks.type.HIGHLIGHT_SETUP, function() - vim.api.nvim_set_hl(0, "RainbowRed", { fg = "#E06C75" }) - vim.api.nvim_set_hl(0, "RainbowYellow", { fg = "#E5C07B" }) - vim.api.nvim_set_hl(0, "RainbowBlue", { fg = "#61AFEF" }) - vim.api.nvim_set_hl(0, "RainbowOrange", { fg = "#D19A66" }) - vim.api.nvim_set_hl(0, "RainbowGreen", { fg = "#98C379" }) - vim.api.nvim_set_hl(0, "RainbowViolet", { fg = "#C678DD" }) - vim.api.nvim_set_hl(0, "RainbowCyan", { fg = "#56B6C2" }) + vim.api.nvim_set_hl(0, "RainbowRed", { fg = "#E06C75" }) + vim.api.nvim_set_hl(0, "RainbowYellow", { fg = "#E5C07B" }) + vim.api.nvim_set_hl(0, "RainbowBlue", { fg = "#61AFEF" }) + vim.api.nvim_set_hl(0, "RainbowOrange", { fg = "#D19A66" }) + vim.api.nvim_set_hl(0, "RainbowGreen", { fg = "#98C379" }) + vim.api.nvim_set_hl(0, "RainbowViolet", { fg = "#C678DD" }) + vim.api.nvim_set_hl(0, "RainbowCyan", { fg = "#56B6C2" }) end) vim.g.rainbow_delimiters = { highlight = highlight } diff --git a/plugins/mini-files.nix b/plugins/mini-files.nix new file mode 100644 index 0000000..358790f --- /dev/null +++ b/plugins/mini-files.nix @@ -0,0 +1,72 @@ +{ pkgs,... }: +{ + programs.nixvim = { + extraPlugins = [ + pkgs.vimPlugins.mini-files + ]; + + extraFiles = { + "lua/treeutils-mini.lua" = { + source = ./treeutils-mini.lua; + }; + }; + + extraConfigLua = '' + require('mini.files').setup({ + }); + + function _G.mini_files_open_current_buffer() + local MiniFiles = require("mini.files") + local _ = MiniFiles.close() + or MiniFiles.open(vim.api.nvim_buf_get_name(0), false) + vim.defer_fn(function() + MiniFiles.reveal_cwd() + end, 30) + end + + function _G.mini_files_toggle() + local MiniFiles = require("mini.files") + local _ = MiniFiles.close() + or MiniFiles.open() + end + + function _G.launch_find_files_wrapped() + -- Try custom function first + local handled = require('treeutils-mini').launch_find_files() + + if handled == "default" then + -- If custom function didn't handle it, execute default behavior + local default_key = vim.api.nvim_replace_termcodes('', true, true, true) + vim.api.nvim_feedkeys(default_key, 'n', false) + end + end + ''; + keymaps = [ + ## Go to current buffer's file in nvim-tree + { + mode = [ "n" ]; + key = ",n"; + action = "lua mini_files_open_current_buffer()"; + } + ## Toggle nvim-tree visibility + { + mode = [ "n" ]; + key = ",m"; + action = "lua mini_files_toggle()"; + } + ## Search current path + { + mode = [ "n" ]; + key = ""; + action = "lua launch_find_files_wrapped()"; + options = { noremap = true; }; + } + { + mode = [ "n" ]; + key = ""; + action = "lua require('treeutils-mini').launch_live_grep()"; + options = { noremap = true; }; + } + ]; + }; +} diff --git a/plugins/mini.nix b/plugins/mini.nix new file mode 100644 index 0000000..487ce79 --- /dev/null +++ b/plugins/mini.nix @@ -0,0 +1,75 @@ +{ ... }: +{ + programs.nixvim = { + plugins.mini = { + enable = true; + modules = { + ai = { + n_lines = 50; + search_method = "cover_or_next"; + }; + ## Already handled by another plugin + # comment = { + # mappings = { + # comment = "/"; + # comment_line = "/"; + # comment_visual = "/"; + # textobject = "/"; + # }; + # }; + diff = { + view = { + style = "sign"; + }; + }; + starter = { + content_hooks = { + "__unkeyed-1.adding_bullet" = { + __raw = "require('mini.starter').gen_hook.adding_bullet()"; + }; + "__unkeyed-2.indexing" = { + __raw = "require('mini.starter').gen_hook.indexing('all', { 'Builtin actions' })"; + }; + "__unkeyed-3.padding" = { + __raw = "require('mini.starter').gen_hook.aligning('center', 'center')"; + }; + }; + evaluate_single = true; + header = '' + _______ ____ ____.___ _____ + \ \ ____ ___\ \ / /| | / \ + / | \_/ __ \/ _ \ Y / | |/ \ / \ + / | \ ___( <_> ) / | / Y \ + \____|__ /\___ >____/ \___/ |___\____|__ / + \/ \/ \/ + ''; + items = { + "__unkeyed-1.buildtin_actions" = { + __raw = "require('mini.starter').sections.builtin_actions()"; + }; + "__unkeyed-2.recent_files_current_directory" = { + __raw = "require('mini.starter').sections.recent_files(10, false)"; + }; + "__unkeyed-3.recent_files" = { + __raw = "require('mini.starter').sections.recent_files(10, true)"; + }; + # "__unkeyed-4.sessions" = { + # __raw = "require('mini.starter').sections.sessions(5, true)"; + # }; + }; + }; + surround = { + mappings = { + add = "gsa"; + delete = "gsd"; + find = "gsf"; + find_left = "gsF"; + highlight = "gsh"; + replace = "gsr"; + update_n_lines = "gsn"; + }; + }; + }; + }; + }; +} diff --git a/plugins/startify.nix b/plugins/startify.nix new file mode 100644 index 0000000..f7be3a8 --- /dev/null +++ b/plugins/startify.nix @@ -0,0 +1,18 @@ +{ config, ... }: +{ + programs.nixvim = { + plugins.startify = { + enable = true; + settings = { + custom_header = if config.nixvim-config.enable-startify then null else [ + ''. _______ ____ ____.___ _____'' + ''. \ \ ____ ___\ \ / /| | / \'' + ''. / | \_/ __ \/ _ \ Y / | |/ \ / \'' + ''. / | \ ___( <_> ) / | / Y \'' + ''. \____|__ /\___ >____/ \___/ |___\____|__ /'' + ''. \/ \/ \/'' + ]; + }; + }; + }; +} diff --git a/plugins/treeutils-mini.lua b/plugins/treeutils-mini.lua new file mode 100644 index 0000000..abbdd0c --- /dev/null +++ b/plugins/treeutils-mini.lua @@ -0,0 +1,55 @@ +local MiniFiles = require("mini.files") +local actions = require'telescope.actions' +local action_state = require'telescope.actions.state' +local M = {} + +local view_selection = function(prompt_bufnr, map) + actions.select_default:replace(function() + actions.close(prompt_bufnr) + local selection = action_state.get_selected_entry() + local filename = selection.filename + if (filename == nil) then + filename = selection[1] + end + -- openfile.fn('preview', filename) + end) + return true +end + +function M.launch_live_grep(opts) + return M.launch_telescope("live_grep", opts) +end + +function M.launch_find_files(opts) + return M.launch_telescope("find_files", opts, { active_only_in_tree = true }) +end + +function M.launch_telescope(func_name, opts, internal_opts) + internal_opts = internal_opts or {} + local buffname = vim.fn.bufname() + if (internal_opts.active_only_in_tree) then + -- Make sure this is being called in NvimTree + if (string.sub(buffname, 1, string.len('NvimTree')) ~= 'NvimTree') then + return "default" + end + end + + local telescope_status_ok, _ = pcall(require, "telescope") + if not telescope_status_ok then + return + end + local node = MiniFiles.get_latest_path() + if (node == nil) then + -- Tree is probably not open + return + end + local is_folder = node.fs_stat and node.fs_stat.type == 'directory' or false + local basedir = is_folder and node.absolute_path or vim.fn.fnamemodify(node.absolute_path, ":h") + opts = opts or {} + opts.cwd = basedir + opts.search_dirs = { basedir } + opts.attach_mappings = view_selection + return require("telescope.builtin")[func_name](opts) +end + +return M