aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/config/codecompanion-save.lua145
-rw-r--r--lua/pi/completition/init.lua5
-rw-r--r--lua/plugins/cmp-ai.lua59
-rw-r--r--lua/plugins/codecompanion.lua41
-rw-r--r--lua/plugins/codeium.lua11
-rw-r--r--lua/plugins/copilot-chat.lua7
-rw-r--r--lua/plugins/treesitter.lua1
-rw-r--r--lua/plugins/vimtex.lua13
8 files changed, 145 insertions, 137 deletions
diff --git a/lua/config/codecompanion-save.lua b/lua/config/codecompanion-save.lua
index 46f2d94..1659b22 100644
--- a/lua/config/codecompanion-save.lua
+++ b/lua/config/codecompanion-save.lua
@@ -1,60 +1,99 @@
--- add 2 commands:
--- CodeCompanionSave [space delimited args]
--- CodeCompanionLoad
--- Save will save current chat in a md file named 'space-delimited-args.md'
--- Load will use a telescope filepicker to open a previously saved chat
-
--- create a folder to store our chats
-local Path = require("plenary.path")
-local data_path = vim.fn.stdpath("data")
-local save_folder = Path:new(data_path, "cc_saves")
-if not save_folder:exists() then
- save_folder:mkdir({ parents = true })
+local copilot_fn = function()
+ local copilot_config = {
+
+ schema = {
+ model = {
+ default = "claude-3.5-sonnet",
+ },
+ },
+ }
+ return require("codecompanion.adapters").extend("copilot", copilot_config)
+end
+
+local supported_adapters = {
+ copilot = copilot_fn,
+}
+local function save_path()
+ local Path = require("plenary.path")
+ local p = Path:new(vim.fn.stdpath("data") .. "/cc_saves")
+ p:mkdir({ parents = true })
+ return p
end
--- telescope picker for our saved chats
+--- Load a saved codecompanion.nvim chat file into a new CodeCompanion chat buffer.
+--- Usage: CodeCompanionLoad
vim.api.nvim_create_user_command("CodeCompanionLoad", function()
- local t_builtin = require("telescope.builtin")
- local t_actions = require("telescope.actions")
- local t_action_state = require("telescope.actions.state")
-
- local function start_picker()
- t_builtin.find_files({
- prompt_title = "Saved CodeCompanion Chats | <c-d>: delete",
- cwd = save_folder:absolute(),
- attach_mappings = function(_, map)
- map("i", "<c-d>", function(prompt_bufnr)
- local selection = t_action_state.get_selected_entry()
- local filepath = selection.path or selection.filename
- os.remove(filepath)
- t_actions.close(prompt_bufnr)
- start_picker()
- end)
- return true
- end,
- })
- end
- start_picker()
+ local fzf = require("fzf-lua")
+
+ local function select_adapter(filepath)
+ local adapters = vim.tbl_keys(supported_adapters)
+
+ fzf.fzf_exec(adapters, {
+ prompt = "Select CodeCompanion Adapter> ",
+ actions = {
+ ["default"] = function(selected)
+ local adapter = selected[1]
+ -- Open new CodeCompanion chat with selected adapter
+ vim.cmd("CodeCompanionChat " .. adapter)
+
+ -- Read contents of saved chat file
+ local lines = vim.fn.readfile(filepath)
+
+ -- Get the current buffer (which should be the new CodeCompanion chat)
+ local current_buf = vim.api.nvim_get_current_buf()
+
+ -- Paste contents into the new chat buffer
+ vim.api.nvim_buf_set_lines(current_buf, 0, -1, false, lines)
+ end,
+ },
+ })
+ end
+
+ local function start_picker()
+ local files = vim.fn.glob(save_path() .. "/*", false, true)
+
+ fzf.fzf_exec(files, {
+ prompt = "Saved CodeCompanion Chats | <c-r>: remove >",
+ previewer = "builtin",
+ actions = {
+ ["default"] = function(selected)
+ if #selected > 0 then
+ local filepath = selected[1]
+ select_adapter(filepath)
+ end
+ end,
+ ["ctrl-r"] = function(selected)
+ if #selected > 0 then
+ local filepath = selected[1]
+ os.remove(filepath)
+ -- Refresh the picker
+ start_picker()
+ end
+ end,
+ },
+ })
+ end
+
+ start_picker()
end, {})
--- save current chat, `CodeCompanionSave foo bar baz` will save as 'foo-bar-baz.md'
+--- Save the current codecompanion.nvim chat buffer to a file in the save_folder.
+--- Usage: CodeCompanionSave <filename>.md
+---@param opts table
vim.api.nvim_create_user_command("CodeCompanionSave", function(opts)
- local codecompanion = require("codecompanion")
- local success, chat = pcall(function()
- return codecompanion.buf_get_chat(0)
- end)
- if not success or chat == nil then
- vim.notify(
- "CodeCompanionSave should only be called from CodeCompanion chat buffers",
- vim.log.levels.ERROR
- )
- return
- end
- if #opts.fargs == 0 then
- vim.notify("CodeCompanionSave requires at least 1 arg to make a file name", vim.log.levels.ERROR)
- end
- local save_name = table.concat(opts.fargs, "-") .. ".md"
- local save_path = Path:new(save_folder, save_name)
- local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false)
- save_path:write(table.concat(lines, "\n"), "w")
+ local codecompanion = require("codecompanion")
+ local success, chat = pcall(function()
+ return codecompanion.buf_get_chat(0)
+ end)
+ if not success or chat == nil then
+ vim.notify("CodeCompanionSave should only be called from CodeCompanion chat buffers", vim.log.levels.ERROR)
+ return
+ end
+ if #opts.fargs == 0 then
+ vim.notify("CodeCompanionSave requires at least 1 arg to make a file name", vim.log.levels.ERROR)
+ end
+ local save_name = table.concat(opts.fargs, "-") .. ".md"
+ local save_file = save_path():joinpath(save_name)
+ local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false)
+ save_file:write(table.concat(lines, "\n"), "w")
end, { nargs = "*" })
diff --git a/lua/pi/completition/init.lua b/lua/pi/completition/init.lua
index 9ac1216..72671ff 100644
--- a/lua/pi/completition/init.lua
+++ b/lua/pi/completition/init.lua
@@ -60,8 +60,9 @@ cmp.setup {
{ name = "nvim_lsp" },
{ name = "path" },
{ name = "luasnip" },
- { name = "copilot" },
- { name = "codeium" },
+ { name = "codecompanion" },
+ { name = 'vimtex', },
+ -- { name = "codeium" },
-- { name = 'cmp_ai' },
{
name = "html-css",
diff --git a/lua/plugins/cmp-ai.lua b/lua/plugins/cmp-ai.lua
deleted file mode 100644
index 5431187..0000000
--- a/lua/plugins/cmp-ai.lua
+++ /dev/null
@@ -1,59 +0,0 @@
-return {
- "ElvisClaros/cmp-ai",
- dependencies = "nvim-lua/plenary.nvim",
- config = function()
- local cmp_ai = require "cmp_ai.config"
- cmp_ai:setup {
- max_lines = 10,
- provider = "LlamaCPP",
- provider_options = {
- model = "null",
- },
- notify = false,
- notify_callback = function(msg)
- vim.notify(msg)
- end,
- run_on_every_keystroke = true,
- ignored_file_types = {
- -- default is not to ignore
- -- uncomment to ignore in lua:
- -- lua = true
- },
- }
-
- -- cmp_ai:setup {
- -- max_lines = 10,
- -- provider = "Ollama",
- -- provider_options = {
- -- model = "tinyllama:1.1b",
- -- },
- -- notify = false,
- -- notify_callback = function(msg)
- -- vim.notify(msg)
- -- end,
- -- run_on_every_keystroke = true,
- -- ignored_file_types = {
- -- -- default is not to ignore
- -- -- uncomment to ignore in lua:
- -- -- lua = true
- -- },
- -- }
- -- cmp_ai:setup {
- -- max_lines = 10,
- -- provider = "OpenAI",
- -- provider_options = {
- -- model = "gpt-4",
- -- },
- -- notify = true,
- -- notify_callback = function(msg)
- -- vim.notify(msg)
- -- end,
- -- run_on_every_keystroke = true,
- -- ignored_file_types = {
- -- -- default is not to ignore
- -- -- uncomment to ignore in lua:
- -- -- lua = true
- -- },
- -- }
- end,
-}
diff --git a/lua/plugins/codecompanion.lua b/lua/plugins/codecompanion.lua
index 324f4d2..7fe6114 100644
--- a/lua/plugins/codecompanion.lua
+++ b/lua/plugins/codecompanion.lua
@@ -1,10 +1,6 @@
local IS_DEV = false
return {
{
- "nvim-treesitter/nvim-treesitter",
- opts = { ensure_installed = { "yaml", "markdown" } },
- },
- {
dir = IS_DEV and "~/Projects/research/codecompanion.nvim" or nil,
"olimorris/codecompanion.nvim",
dependencies = {
@@ -85,7 +81,7 @@ return {
env = {
api_key = "cmd:echo $OPENAI_API_KEY",
chat_url = "/v1/chat/completions",
- url = "http://127.0.0.1:8080",
+ url = "http://127.0.0.1:8012",
},
headers = {
["Content-Type"] = "application/json",
@@ -106,10 +102,43 @@ return {
},
})
end,
+ deepseek = function()
+ return require("codecompanion.adapters").extend("deepseek", {
+ env = {
+ api_key = "cmd:echo $OPENAI_API_KEY",
+ chat_url = "/v1/chat/completions",
+ url = "http://127.0.0.1:8000",
+ },
+ headers = {
+ ["Content-Type"] = "application/json",
+ },
+ schema = {
+ model = {
+ default = function()
+ return "davinci"
+ end,
+ },
+ },
+ })
+ end,
+ azure_openai = function()
+ return require("codecompanion.adapters").extend("azure_openai", {
+ env = {
+ api_key = "cmd:echo $AZ_DS_API_KEY",
+ endpoint = "https://DeepSeek-R1-nphob.eastus2.models.ai.azure.com",
+ },
+ schema = {
+ model = {
+ default = "DeepSeek-R1-nphob",
+ },
+ },
+ })
+ end,
},
+
strategies = {
chat = {
- adapter = "copilot",
+ adapter = "openai_compatible",
-- roles = { llm = " Copilot Chat", user = "IT Man" },
},
inline = { adapter = "copilot" },
diff --git a/lua/plugins/codeium.lua b/lua/plugins/codeium.lua
deleted file mode 100644
index 2de0def..0000000
--- a/lua/plugins/codeium.lua
+++ /dev/null
@@ -1,11 +0,0 @@
-return {
- "Exafunction/codeium.nvim",
- dependencies = {
- "nvim-lua/plenary.nvim",
- "hrsh7th/nvim-cmp",
- },
- config = function()
- require("codeium").setup({
- })
- end
-}
diff --git a/lua/plugins/copilot-chat.lua b/lua/plugins/copilot-chat.lua
index d389d2f..9262258 100644
--- a/lua/plugins/copilot-chat.lua
+++ b/lua/plugins/copilot-chat.lua
@@ -21,12 +21,8 @@ local prompts = {
return {
{
- "nvim-treesitter/nvim-treesitter",
- opts = { ensure_installed = { "diff", "markdown" } },
- },
- {
- dir = IS_DEV and "~/research/CopilotChat.nvim" or nil,
"CopilotC-Nvim/CopilotChat.nvim",
+ build = "make tiktoken", -- Only on MacOS or Linux
-- version = "v3.3.0",
dependencies = {
{ "nvim-lua/plenary.nvim" },
@@ -38,7 +34,6 @@ return {
},
},
opts = {
- model = 'claude-3.5-sonnet',
-- question_header = "## User ",
-- answer_header = "## Copilot ",
-- error_header = "## Error ",
diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua
index 363f081..80f98cf 100644
--- a/lua/plugins/treesitter.lua
+++ b/lua/plugins/treesitter.lua
@@ -44,6 +44,7 @@ return {
"luadoc",
"markdown",
"markdown_inline",
+ "typst",
"nix",
"org",
"php",
diff --git a/lua/plugins/vimtex.lua b/lua/plugins/vimtex.lua
new file mode 100644
index 0000000..588b848
--- /dev/null
+++ b/lua/plugins/vimtex.lua
@@ -0,0 +1,13 @@
+return {
+ {
+ "lervag/vimtex",
+ init = function()
+ vim.g.vimtex_view_method = "zathura" -- Integración con el visor PDF
+ vim.g.vimtex_compiler_method = "latexmk" -- Compilación automática
+ vim.g.vimtex_quickfix_mode = 0 -- Desactiva la ventana de quickfix automática
+ end,
+ },
+ {
+ "micangl/cmp-vimtex",
+ },
+}