From ffc2d4c13daf8e09f4684a5f9d51928052f93ae2 Mon Sep 17 00:00:00 2001 From: Salar Rahmanian Date: Sun, 6 Oct 2024 22:48:48 -0700 Subject: [PATCH 1/4] replace gen.nvim with avante --- lua/plugins/avante.lua | 76 ++++++++++++++++++++++++++++++++++++++++++ lua/plugins/gen.lua | 48 -------------------------- 2 files changed, 76 insertions(+), 48 deletions(-) create mode 100644 lua/plugins/avante.lua delete mode 100644 lua/plugins/gen.lua diff --git a/lua/plugins/avante.lua b/lua/plugins/avante.lua new file mode 100644 index 0000000..cbee33a --- /dev/null +++ b/lua/plugins/avante.lua @@ -0,0 +1,76 @@ +return { + "yetone/avante.nvim", + event = "VeryLazy", + lazy = false, + version = false, -- set this if you want to always pull the latest change + opts = { + provider = "openai", + openai = { + api_key_name = "cmd:cat ~/.openai", + }, + provider = "ollama", + vendors = { + ---@type AvanteProvider + ollama = { + ["local"] = true, + endpoint = "127.0.0.1:11434/v1", + model = "codegemma", + parse_curl_args = function(opts, code_opts) + return { + url = opts.endpoint .. "/chat/completions", + headers = { + ["Accept"] = "application/json", + ["Content-Type"] = "application/json", + }, + body = { + model = opts.model, + messages = require("avante.providers").copilot.parse_message(code_opts), -- you can make your own message, but this is very advanced + max_tokens = 2048, + stream = true, + }, + } + end, + parse_response_data = function(data_stream, event_state, opts) + require("avante.providers").openai.parse_response(data_stream, event_state, opts) + end, + }, + }, + }, + }, + -- if you want to build from source then do `make BUILD_FROM_SOURCE=true` + build = "make", + -- build = "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false" -- for windows + dependencies = { + "nvim-treesitter/nvim-treesitter", + "stevearc/dressing.nvim", + "nvim-lua/plenary.nvim", + "MunifTanjim/nui.nvim", + --- The below dependencies are optional, + "nvim-tree/nvim-web-devicons", -- or echasnovski/mini.icons + { + -- 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, + }, + }, + }, + { + -- Make sure to set this up properly if you have lazy=true + "MeanderingProgrammer/render-markdown.nvim", + opts = { + file_types = { "markdown", "Avante" }, + }, + ft = { "markdown", "Avante" }, + }, + }, +} diff --git a/lua/plugins/gen.lua b/lua/plugins/gen.lua deleted file mode 100644 index 4a01257..0000000 --- a/lua/plugins/gen.lua +++ /dev/null @@ -1,48 +0,0 @@ -return { - "David-Kunz/gen.nvim", - lazy = true, - keys = { - { "ai", ":Gen", mode = { "n", "v" }, desc = "AI tools using Ollama" }, - { "aa", ":Gen Ask", mode = { "n", "v" }, desc = "[A]I [A]sk" }, - { - "am", - function() - require("gen").select_model() - end, - mode = { "n", "v" }, - desc = "Select [A]I [m]odel", - }, - }, - config = function() - require("gen").setup({ - { - model = "codellama", - host = "localhost", - port = "11434", - quit_map = "q", - retry_map = "", - init = function(options) - pcall(io.popen, "ollama serve > /dev/null 2>&1 &") - end, - command = function(options) - local body = { model = options.model, stream = true } - return "curl --silent --no-buffer -X POST http://" - .. options.host - .. ":" - .. options.port - .. "/api/chat -d $body" - end, - display_mode = "split", -- "split" or "float" - show_prompt = true, - show_model = true, - no_auto_close = false, - debug = false, - }, - }) - require("gen").prompts["Fix_Code"] = { - prompt = "Fix the following code. Only ouput the result in format ```$filetype\n...\n```:\n```$filetype\n$text\n```", - replace = true, - extract = "```$filetype\n(.-)```", - } - end, -} -- 2.46.1 From d184855eb2ff506a504efa6a23345f772d86f02b Mon Sep 17 00:00:00 2001 From: Salar Rahmanian Date: Sun, 6 Oct 2024 23:00:12 -0700 Subject: [PATCH 2/4] remove ollama --- lua/plugins/avante.lua | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/lua/plugins/avante.lua b/lua/plugins/avante.lua index cbee33a..e83cf4f 100644 --- a/lua/plugins/avante.lua +++ b/lua/plugins/avante.lua @@ -8,34 +8,6 @@ return { openai = { api_key_name = "cmd:cat ~/.openai", }, - provider = "ollama", - vendors = { - ---@type AvanteProvider - ollama = { - ["local"] = true, - endpoint = "127.0.0.1:11434/v1", - model = "codegemma", - parse_curl_args = function(opts, code_opts) - return { - url = opts.endpoint .. "/chat/completions", - headers = { - ["Accept"] = "application/json", - ["Content-Type"] = "application/json", - }, - body = { - model = opts.model, - messages = require("avante.providers").copilot.parse_message(code_opts), -- you can make your own message, but this is very advanced - max_tokens = 2048, - stream = true, - }, - } - end, - parse_response_data = function(data_stream, event_state, opts) - require("avante.providers").openai.parse_response(data_stream, event_state, opts) - end, - }, - }, - }, }, -- if you want to build from source then do `make BUILD_FROM_SOURCE=true` build = "make", -- 2.46.1 From c1825115587fe42f272bddb5510aa5b02426cfab Mon Sep 17 00:00:00 2001 From: Salar Rahmanian Date: Sun, 6 Oct 2024 23:00:23 -0700 Subject: [PATCH 3/4] treesitter and indent updates --- init.lua | 2 +- lua/plugins/treesitter.lua | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index 479f1b3..30f58ef 100644 --- a/init.lua +++ b/init.lua @@ -48,7 +48,7 @@ else vim.o.breakindent = true -- smart indenting - vim.o.smartindent = false + vim.o.smartindent = true -- Save undo history vim.o.undofile = true diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index cfc5538..4834476 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -4,7 +4,12 @@ return { -- build = function() -- pcall(require("nvim-treesitter.install").update({ with_sync = true })) -- end, - dependencies = { "nvim-treesitter/nvim-treesitter-textobjects", "nvim-treesitter/playground" }, + dependencies = { + "nvim-treesitter/nvim-treesitter-context", + "nvim-treesitter/nvim-treesitter-refactor", + "nvim-treesitter/nvim-treesitter-textobjects", + "nvim-treesitter/playground", + }, config = function() require("nvim-treesitter.configs").setup({ -- Add languages to be installed here that you want installed for treesitter @@ -58,7 +63,13 @@ return { auto_install = true, highlight = { enable = true }, - indent = { enable = true }, + indent = { + enable = true, + disable = { + "python", + "css", + }, + }, incremental_selection = { enable = true, keymaps = { -- 2.46.1 From 2776da83bb9f4635a41c84b00a96aba7b8979f22 Mon Sep 17 00:00:00 2001 From: Salar Rahmanian Date: Sun, 6 Oct 2024 23:03:04 -0700 Subject: [PATCH 4/4] update tab size for lua and nix --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 30f58ef..97c23c0 100644 --- a/init.lua +++ b/init.lua @@ -90,7 +90,7 @@ else -- sets the tab size for json files vim.api.nvim_create_autocmd("FileType", { - pattern = "json", + pattern = { "json", "lua", "nix" }, callback = function() vim.bo.tabstop = 2 vim.bo.shiftwidth = 2 -- 2.46.1