From 615c53c8fb982b85988ea3aa52772ba6c9c71650 Mon Sep 17 00:00:00 2001 From: "RingOfStorms (Joshua Bell)" Date: Thu, 14 Nov 2024 13:40:28 -0600 Subject: [PATCH] avante and remote sshfs --- flake.lock | 51 +++++++++++++++++++ flake.nix | 63 +++++++++++++++++++++-- lua/_disabled/avante.lua | 36 -------------- lua/plugins/avante.lua | 80 ++++++++++++++++++++++++++++++ lua/plugins/cmp_autocompletion.lua | 12 ++--- lua/plugins/remote-sshfs.lua | 17 +++++++ 6 files changed, 210 insertions(+), 49 deletions(-) delete mode 100644 lua/_disabled/avante.lua create mode 100644 lua/plugins/avante.lua create mode 100644 lua/plugins/remote-sshfs.lua diff --git a/flake.lock b/flake.lock index a2a4cdf..431a1e7 100644 --- a/flake.lock +++ b/flake.lock @@ -528,6 +528,22 @@ "type": "github" } }, + "nvim_plugin-nosduco/remote-sshfs.nvim": { + "flake": false, + "locked": { + "lastModified": 1724901856, + "narHash": "sha256-vFEIISxhTIGSl9LzDYHuEIkjLGkU0y5XhfWI/i5DgN4=", + "owner": "nosduco", + "repo": "remote-sshfs.nvim", + "rev": "03f6c40c4032eeb1ab91368e06db9c3f3a97a75d", + "type": "github" + }, + "original": { + "owner": "nosduco", + "repo": "remote-sshfs.nvim", + "type": "github" + } + }, "nvim_plugin-nvim-lua/plenary.nvim": { "flake": false, "locked": { @@ -800,6 +816,22 @@ "type": "github" } }, + "nvim_plugin-stevearc/dressing.nvim": { + "flake": false, + "locked": { + "lastModified": 1731521499, + "narHash": "sha256-O0sdxU+ZQnclnnC5IfBpgqlMxjsJKlmPYQYPP+S3cn8=", + "owner": "stevearc", + "repo": "dressing.nvim", + "rev": "fc78a3ca96f4db9f8893bb7e2fd9823e0780451b", + "type": "github" + }, + "original": { + "owner": "stevearc", + "repo": "dressing.nvim", + "type": "github" + } + }, "nvim_plugin-tpope/vim-sleuth": { "flake": false, "locked": { @@ -864,6 +896,22 @@ "type": "github" } }, + "nvim_plugin-yetone/avante.nvim": { + "flake": false, + "locked": { + "lastModified": 1731602098, + "narHash": "sha256-pWgJO4v6nUjO9rkTzPKO8pXNwAC372LE6cqv7P9Wfxg=", + "owner": "yetone", + "repo": "avante.nvim", + "rev": "839a8ee25a84f813545440c4c798edd25bfd68a9", + "type": "github" + }, + "original": { + "owner": "yetone", + "repo": "avante.nvim", + "type": "github" + } + }, "nvim_plugin-zbirenbaum/copilot-cmp": { "flake": false, "locked": { @@ -931,6 +979,7 @@ "nvim_plugin-mfussenegger/nvim-lint": "nvim_plugin-mfussenegger/nvim-lint", "nvim_plugin-mrcjkb/rustaceanvim": "nvim_plugin-mrcjkb/rustaceanvim", "nvim_plugin-neovim/nvim-lspconfig": "nvim_plugin-neovim/nvim-lspconfig", + "nvim_plugin-nosduco/remote-sshfs.nvim": "nvim_plugin-nosduco/remote-sshfs.nvim", "nvim_plugin-nvim-lua/plenary.nvim": "nvim_plugin-nvim-lua/plenary.nvim", "nvim_plugin-nvim-lualine/lualine.nvim": "nvim_plugin-nvim-lualine/lualine.nvim", "nvim_plugin-nvim-telescope/telescope-file-browser.nvim": "nvim_plugin-nvim-telescope/telescope-file-browser.nvim", @@ -948,10 +997,12 @@ "nvim_plugin-saadparwaiz1/cmp_luasnip": "nvim_plugin-saadparwaiz1/cmp_luasnip", "nvim_plugin-sindrets/diffview.nvim": "nvim_plugin-sindrets/diffview.nvim", "nvim_plugin-stevearc/conform.nvim": "nvim_plugin-stevearc/conform.nvim", + "nvim_plugin-stevearc/dressing.nvim": "nvim_plugin-stevearc/dressing.nvim", "nvim_plugin-tpope/vim-sleuth": "nvim_plugin-tpope/vim-sleuth", "nvim_plugin-tpope/vim-surround": "nvim_plugin-tpope/vim-surround", "nvim_plugin-uga-rosa/ccc.nvim": "nvim_plugin-uga-rosa/ccc.nvim", "nvim_plugin-windwp/nvim-ts-autotag": "nvim_plugin-windwp/nvim-ts-autotag", + "nvim_plugin-yetone/avante.nvim": "nvim_plugin-yetone/avante.nvim", "nvim_plugin-zbirenbaum/copilot-cmp": "nvim_plugin-zbirenbaum/copilot-cmp", "nvim_plugin-zbirenbaum/copilot.lua": "nvim_plugin-zbirenbaum/copilot.lua", "rust-overlay": "rust-overlay" diff --git a/flake.nix b/flake.nix index f0d59ca..9aa5ab3 100644 --- a/flake.nix +++ b/flake.nix @@ -108,10 +108,10 @@ "nvim_plugin-zbirenbaum/copilot.lua".flake = false; "nvim_plugin-CopilotC-Nvim/CopilotChat.nvim".url = "github:CopilotC-Nvim/CopilotChat.nvim"; "nvim_plugin-CopilotC-Nvim/CopilotChat.nvim".flake = false; - # "nvim_plugin-yetone/avante.nvim".url = "github:yetone/avante.nvim"; - # "nvim_plugin-yetone/avante.nvim".flake = false; - # "nvim_plugin-stevearc/dressing.nvim".url = "github:stevearc/dressing.nvim"; - # "nvim_plugin-stevearc/dressing.nvim".flake = false; + "nvim_plugin-yetone/avante.nvim".url = "github:yetone/avante.nvim"; + "nvim_plugin-yetone/avante.nvim".flake = false; + "nvim_plugin-stevearc/dressing.nvim".url = "github:stevearc/dressing.nvim"; + "nvim_plugin-stevearc/dressing.nvim".flake = false; "nvim_plugin-folke/neodev.nvim".url = "github:folke/neodev.nvim"; "nvim_plugin-folke/neodev.nvim".flake = false; "nvim_plugin-mrcjkb/rustaceanvim".url = "github:mrcjkb/rustaceanvim"; @@ -124,6 +124,8 @@ "nvim_plugin-rafamadriz/friendly-snippets".flake = false; "nvim_plugin-ron/ron.vim".url = "github:ron-rs/ron.vim"; "nvim_plugin-ron/ron.vim".flake = false; + "nvim_plugin-nosduco/remote-sshfs.nvim".url = "github:nosduco/remote-sshfs.nvim"; + "nvim_plugin-nosduco/remote-sshfs.nvim".flake = false; }; outputs = { @@ -165,6 +167,44 @@ "nvim_plugin-nvim-treesitter/nvim-treesitter" = nvim-treesitter.withAllGrammars; }; + avante-nvim-lib = pkgs.rustPlatform.buildRustPackage { + pname = "avante-nvim-lib"; + version = "0.0.0"; + src = inputs."nvim_plugin-yetone/avante.nvim"; + + buildFeatures = [ "luajit" ]; + doCheck = false; + cargoLock = { + lockFile = inputs."nvim_plugin-yetone/avante.nvim" + "/Cargo.lock"; + allowBuiltinFetchGit = true; + }; + + nativeBuildInputs = with pkgs; [ + pkg-config + ]; + + buildInputs = with pkgs; [ + openssl.dev + ]; + env = { + OPENSSL_NO_VENDOR = "1"; + OPENSSL_LIB_DIR = "${pkgs.openssl.out}/lib"; + OPENSSL_INCLUDE_DIR = "${pkgs.openssl.dev}/include"; + OPENSSL_DIR = "${pkgs.openssl.dev}"; + }; + postInstall = '' + # mv $out/lib/libavante_repo_map.so $out/lib/avante_repo_map.so + for f in $out/lib/lib*; do + mv "$f" "$out/lib/''${f##*/lib}" + done + ''; + meta = { + description = "Avante nvim libraries"; + homepage = "https://github.com/yetone/avante.nvim"; + license = pkgs.lib.licenses.asl20; + }; + }; + # This will be how we put any nix related stuff into our lua config luaNixGlobal = "NIX=" @@ -182,6 +222,7 @@ (builtins.filter (n: builtins.substring 0 12 n == "nvim_plugin-") (builtins.attrNames inputs)); }); + # These are appended at the start of the path so that they take precedence over local install tools runtimeDependencies = with pkgs; [ # tools ripgrep # search @@ -190,9 +231,11 @@ tree-sitter glow # markdown renderer curl # http requests - # nodePackages.cspell TODO + sshfs # remote dev for nosduco/remote-sshfs.nvim + # nodePackages.cspell TODO check out `typos` rust checker instead? ]; + # These are appended at the end of the PATH so any local installed tools will take precedence defaultRuntimeDependencies = with pkgs; [ # linters markdownlint-cli @@ -261,6 +304,16 @@ "--set" "LAZY" "${lazyPath}" + # Link avante libraries + "--prefix" + "LD_LIBRARY_PATH" + ":" + "${avante-nvim-lib}/lib" + # Add Lua C modules path + "--prefix" + "LUA_CPATH" + ";" + "${avante-nvim-lib}/lib/?.so" # Don't use default directories to not collide with another neovim config # All things at runtime should be deletable since we are using nix to handle downloads and bins # so I've chosen to put everything into the local state directory. diff --git a/lua/_disabled/avante.lua b/lua/_disabled/avante.lua deleted file mode 100644 index afecc88..0000000 --- a/lua/_disabled/avante.lua +++ /dev/null @@ -1,36 +0,0 @@ -return { - "yetone/avante.nvim", - dependencies = { - "nvim-treesitter/nvim-treesitter", - "stevearc/dressing.nvim", - "nvim-lua/plenary.nvim", - "MunifTanjim/nui.nvim", - --- The below dependencies are optional, - -- { - -- -- support for image pasting - -- "HakonHarnes/img-clip.nvim", - -- event = "VeryLazy", - -- opts = { - -- -- recommended settings - -- default = { - -- embed_image_as_base64 = false, - -- prompt_for_file_name = false, - -- drag_and_drop = { - -- insert_mode = true, - -- }, - -- -- required for Windows users - -- use_absolute_path = true, - -- }, - -- }, - -- }, - }, - event = "VeryLazy", - lazy = false, - opts = { - provider = "claude", - }, - config = function(_, opts) - require("avante_lib").load() - require("avante").setup(opts) - end, -} diff --git a/lua/plugins/avante.lua b/lua/plugins/avante.lua new file mode 100644 index 0000000..f933fed --- /dev/null +++ b/lua/plugins/avante.lua @@ -0,0 +1,80 @@ +return { + -- cond = false, + "yetone/avante.nvim", + dependencies = { + "nvim-treesitter/nvim-treesitter", + "stevearc/dressing.nvim", + "nvim-lua/plenary.nvim", + "MunifTanjim/nui.nvim", + --- The below dependencies are optional, + -- { + -- -- support for image pasting + -- "HakonHarnes/img-clip.nvim", + -- event = "VeryLazy", + -- opts = { + -- -- recommended settings + -- default = { + -- embed_image_as_base64 = false, + -- prompt_for_file_name = false, + -- drag_and_drop = { + -- insert_mode = true, + -- }, + -- -- required for Windows users + -- use_absolute_path = true, + -- }, + -- }, + -- }, + }, + event = "VeryLazy", + build = function() + -- TODO does this actually work? I still dont have full non nix support tested for this config. + if not NIX then + vim.cmd("make") + end + end, + lazy = false, + opts = { + provider = "claude", + behavior = { + -- auto_suggestions = true, -- Experimental stage + auto_set_keymaps = false, + support_paste_from_clipboard = true, + }, + }, + config = function(_, opts) + require("avante_lib").load() + require("avante").setup(opts) + end, + keys = { + { + "c", + "AvanteToggle", + desc = "Avante - Toggle Chat", + mode = { "n", "v", "x" }, + }, + { + "r", + "AvanteRefresh", + desc = "Avante - Refresh", + mode = { "n", "v", "x" }, + }, + { + "f", + "AvanteFocus", + desc = "CopilotChat - Quick chat", + mode = { "n", "v", "x" }, + }, + { + "e", + "AvanteEdit", + desc = "Avante - Edit Selection", + mode = { "v", "x" }, + }, + { + "e", + "ggVGAvanteEdit", + desc = "Avante - Edit File", + mode = { "n" }, + }, + }, +} diff --git a/lua/plugins/cmp_autocompletion.lua b/lua/plugins/cmp_autocompletion.lua index d9acf2a..bec84ad 100644 --- a/lua/plugins/cmp_autocompletion.lua +++ b/lua/plugins/cmp_autocompletion.lua @@ -50,9 +50,8 @@ return { }, }, keys = { - -- Show help actions with telescope { - "h", + "ch", function() local actions = require("CopilotChat.actions") require("CopilotChat.integrations.telescope").pick(actions.help_actions()) @@ -60,9 +59,8 @@ return { desc = "CopilotChat - Help actions", mode = { "n", "v", "x" }, }, - -- Show prompts actions with telescope { - "p", + "cp", function() local actions = require("CopilotChat.actions") require("CopilotChat.integrations.telescope").pick(actions.prompt_actions()) @@ -70,9 +68,8 @@ return { desc = "CopilotChat - Prompt actions", mode = { "n", "v", "x" }, }, - -- Quick chat with Copilot { - "q", + "cq", function() local input = vim.fn.input("Quick Chat: ") if input ~= "" then @@ -82,9 +79,8 @@ return { desc = "CopilotChat - Quick chat", mode = { "n", "v", "x" }, }, - -- Quick chat with Copilot { - "c", + "cc", function() require("CopilotChat").toggle() end, diff --git a/lua/plugins/remote-sshfs.lua b/lua/plugins/remote-sshfs.lua new file mode 100644 index 0000000..ae93bcf --- /dev/null +++ b/lua/plugins/remote-sshfs.lua @@ -0,0 +1,17 @@ +return { + "nosduco/remote-sshfs.nvim", + cmd = { + "RemoteSshfs", + "RemoteSSHFSConnect", + "RemoteSSHFSDisconnect", + "RemoteSSHFSEdit", + "RemoteSSHFSFindFiles", + "RemoteSSHFSLiveGrep", + }, + dependencies = { "nvim-telescope/telescope.nvim" }, + opts = {}, + config = function(_, opts) + require("remote-sshfs").setup(opts) + require("telescope").load_extension("remote-sshfs") + end, +}