Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more codecompanion config #120

Merged
merged 8 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/nvim/config/lazy-lock.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"CopilotChat.nvim": { "branch": "main", "commit": "e4cb1fc27e0def7571e5329f522a79e9555a5502" },
"LazyVim": { "branch": "main", "commit": "2bea40c447b72e54ffb2d5cddc98d7798990796f" },
"LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" },
"SchemaStore.nvim": { "branch": "main", "commit": "5be212138af55d3dcae9d77b5b14f63634243e3d" },
Expand All @@ -8,6 +7,7 @@
"blink.cmp": { "branch": "main", "commit": "1cc3b1a908fbcfd15451c4772759549724f38524" },
"bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" },
"catppuccin": { "branch": "main", "commit": "f67b886d65a029f12ffa298701fb8f1efd89295d" },
"codecompanion.nvim": { "branch": "main", "commit": "2051d2707efb281b147dd883b42b23ad5bd4ed14" },
"conform.nvim": { "branch": "master", "commit": "f8d743ce333bedc47821de2cd4d23c43856ecbe5" },
"copilot.lua": { "branch": "master", "commit": "f8d8d872bb319f640d5177dad5fbf01f7a16d7d0" },
"crates.nvim": { "branch": "main", "commit": "bd35b13e94a292ee6e32c351e05ca2202dc9f070" },
Expand Down Expand Up @@ -50,7 +50,6 @@
"nvim-treesitter-context": { "branch": "master", "commit": "bece284c5322ddf6946fa4bdc383a2bc033269d7" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "ad8f0a472148c3e0ae9851e26a722ee4e29b1595" },
"nvim-ts-autotag": { "branch": "main", "commit": "1cca23c9da708047922d3895a71032bc0449c52d" },
"oatmeal.nvim": { "branch": "master", "commit": "c8cdd0a182cf77f88ea5fa4703229ddb3f47c1f7" },
"one-small-step-for-vimkind": { "branch": "main", "commit": "b9def31568d20b16f7da9479a4174d165046fe8a" },
"open-browser.vim": { "branch": "master", "commit": "7d4c1d8198e889d513a030b5a83faa07606bac27" },
"persistence.nvim": { "branch": "main", "commit": "f6aad7dde7fcf54148ccfc5f622c6d5badd0cc3d" },
Expand Down
3 changes: 1 addition & 2 deletions packages/nvim/config/lazyvim.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"extras": [
"lazyvim.plugins.extras.ai.copilot",
"lazyvim.plugins.extras.ai.copilot-chat",
"lazyvim.plugins.extras.dap.core",
"lazyvim.plugins.extras.dap.nlua",
"lazyvim.plugins.extras.editor.fzf",
Expand All @@ -19,7 +18,7 @@
"lazyvim.plugins.extras.lang.yaml",
"lazyvim.plugins.extras.test.core",
"lazyvim.plugins.extras.util.mini-hipatterns",
"plugins.extras.ai.oatmeal",
"plugins.extras.ai.codecompanion",
"plugins.extras.d2.lang",
"plugins.extras.dap.keymaps",
"plugins.extras.editor.fzf",
Expand Down
14 changes: 7 additions & 7 deletions packages/nvim/config/lua/config/autocmds.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
group = ft_group,
callback = function()
-- TODO: need to configure null-ls to pass `--parser=json` to prettier for this buffer (or like, always?)
vim.bo.filetype = 'json'
vim.bo.filetype = "json"
end,
})

vim.api.nvim_create_autocmd({ "BufRead" }, {
pattern = { ".swcrc" },
pattern = { ".swcrc" },
group = ft_group,
callback = function()
-- TODO: need to configure null-ls to pass `--parser=json` to prettier for this buffer (or like, always?)
Expand All @@ -47,7 +47,7 @@ vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
})

vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
pattern = ".lazy.lua",
pattern = { ".lazy.lua", "**/nvim/config/lua/plugins/**/*.lua" },
group = ft_group,
callback = function()
require("luasnip").filetype_extend("lua", { "lazyvim" })
Expand All @@ -58,7 +58,7 @@ vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
pattern = ".markdownlintrc",
group = ft_group,
callback = function()
vim.bo.filetype = 'json'
vim.bo.filetype = "json"
end,
})

Expand Down Expand Up @@ -90,23 +90,23 @@ vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
pattern = "vite.config.ts",
group = ft_group,
callback = function()
require('luasnip').filetype_extend('typescript', { 'vite-config' })
require("luasnip").filetype_extend("typescript", { "vite-config" })
end,
})

vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
pattern = "*_spec.lua",
group = ft_group,
callback = function()
require('luasnip').filetype_extend('lua', { 'plenary' })
require("luasnip").filetype_extend("lua", { "plenary" })
end,
})

vim.api.nvim_create_autocmd("FileType", {
group = ft_group,
pattern = { "typescriptreact" },
callback = function()
require('luasnip').filetype_extend('typescriptreact', { 'typescript' })
require("luasnip").filetype_extend("typescriptreact", { "typescript" })
end,
})

Expand Down
6 changes: 3 additions & 3 deletions packages/nvim/config/lua/plugins/coding.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local function __dirname()
return dirname, filename
end

---@module 'lazyvim.types'
---@module 'lazy.types'
---@type LazyPluginSpec[]
return {
{
Expand Down Expand Up @@ -96,8 +96,8 @@ return {
["<m-y>"] = { "select_and_accept" },
["<m-j>"] = { "select_next" },
["<m-k>"] = { "select_prev" },
["<c-j>"] = { "snippet_forward" },
["<c-k>"] = { "snippet_backward" },
["<c-k>"] = { "snippet_forward" },
["<c-j>"] = { "snippet_backward" },
},
snippets = {
preset = "luasnip",
Expand Down
143 changes: 143 additions & 0 deletions packages/nvim/config/lua/plugins/extras/ai/codecompanion.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
local LualineCodeCompanionSpinner = require("lualine.component"):extend()
local spinner_symbols = {
"⠋",
"⠙",
"⠹",
"⠸",
"⠼",
"⠴",
"⠦",
"⠧",
"⠇",
"⠏",
}

function LualineCodeCompanionSpinner:init(options)
LualineCodeCompanionSpinner.super.init(self, options)
self.spinner_index = 1

local group = vim.api.nvim_create_augroup("CodeCompanionHooks", {})

vim.api.nvim_create_autocmd({ "User" }, {
pattern = "CodeCompanionRequest*",
group = group,
callback = function(request)
if request.match == "CodeCompanionRequestStarted" then
self.processing = true
elseif request.match == "CodeCompanionRequestFinished" then
self.processing = false
end
end,
})
end

-- Function that runs every time statusline is updated
function LualineCodeCompanionSpinner:update_status()
if self.processing then
self.spinner_index = (self.spinner_index % #spinner_symbols) + 1
return [[CodeCompanion ]] .. spinner_symbols[self.spinner_index]
else
return nil
end
end

---@module 'lazy.types'
---@type LazyPluginSpec[]
return {
{
"olimorris/codecompanion.nvim",
cmd = { "CodeCompanion", "CodeCompanionActions", "CodeCompanionChat", "CodeCompanionCmd" },

keys = {
{ "<leader>a", "", desc = "+ai", mode = { "n", "v" } },
{
"<leader>aA",
"<cmd>CodeCompanionActions<cr>",
mode = { "n", "v" },
desc = "Prompt Actions (CodeCompanion)",
},
{ "<leader>aa", "<cmd>CodeCompanionChat Toggle<cr>", mode = { "n", "v" }, desc = "Toggle (CodeCompanion)" },
{ "<leader>ac", "<cmd>CodeCompanionChat Add<cr>", mode = "v", desc = "Add code to CodeCompanion" },
{
"<leader>ap",
"<cmd>CodeCompanion<cr>",
mode = "n",
desc = "Inline prompt (CodeCompanion)",
},
},

opts = {
adapters = {
anthropic = function()
return require("codecompanion.adapters").extend("anthropic", {
env = { api_key = "AI_CLAUDE_CODE_COMPANION_KEY" },
})
end,

openai = function()
return require("codecompanion.adapters").extend("openai", {
env = { api_key = "AI_OPENAI_CODE_COMPANION_KEY" },
})
end,

copilot = {
model = "claude-3.5-sonnet",
},
},

strategies = {
chat = {
adapter = "anthropic",
-- keymaps = {},
},
inline = { adapter = "anthropic" },
agent = { adapter = "anthropic" },
},

-- see <https://codecompanion.olimorris.dev/configuration/chat-buffer.html#layout>
display = {
chat = {
window = {
position = "right",
},
},
},

-- see <https://codecompanion.olimorris.dev/configuration/action-palette.html>
-- action_palette = {
-- opts = {
-- show_default_actions = false,
-- show_default_prompt_library = false,
-- }
-- }

-- logs in $HOME/.local/state/nvim/codecompanion.log
-- log_level = "TRACE", -- TRACE|DEBUG|ERROR|INFO
},
},

{
"nvim-lualine/lualine.nvim",
opts = {
sections = {
lualine_y = {
{ LualineCodeCompanionSpinner },
{ "progress", separator = " ", padding = { left = 1, right = 0 } },
{ "location", padding = { left = 0, right = 1 } },
},
},
},
},

{
"saghen/blink.cmp",
optional = true,
opts = {
sources = {
per_filetype = {
codecompanion = { "codecompanion" },
},
},
},
},
}
3 changes: 2 additions & 1 deletion packages/nvim/config/lua/plugins/extras/ai/oatmeal.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-- see https://github.com/dustinblackman/oatmeal.nvim#lazy-nvim
---@type LazySpec[]
---@module 'lazy.types'
---@type LazyPluginSpec[]
return {
{
"dustinblackman/oatmeal.nvim",
Expand Down
36 changes: 2 additions & 34 deletions packages/nvim/config/lua/plugins/ui.lua
Original file line number Diff line number Diff line change
@@ -1,39 +1,8 @@
vim.g.debug_messages = false

---@module 'lazy.types'
---@type LazyPluginSpec[]
return {
-- active indent guide and indent text objects
{
"echasnovski/mini.indentscope",
opts = {
draw = {
-- don't animate the indent scope highlighting
delay = 0,
},
},
},

-- Disable this growl/toast distraction
-- use show notifications; show-last notification instead
{
"rcarriga/nvim-notify",
enabled = false,
keys = {
{
"<leader>un",
false,
},
},
opts = {
timeout = 3000,
max_height = function()
return math.floor(vim.o.lines * 0.75)
end,
max_width = function()
return math.floor(vim.o.columns * 0.75)
end,
},
},

{
"folke/which-key.nvim",
event = "VeryLazy",
Expand Down Expand Up @@ -74,7 +43,6 @@ return {
end,
},

-- bufferline
{
"akinsho/bufferline.nvim",
event = "VeryLazy",
Expand Down
10 changes: 9 additions & 1 deletion packages/nvim/config/snippets/lazyvim.snippets
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@ snippet java:default "default java lazyvim setup"
enabled = false,
}
}


snippet specs "empty lazyspecs"
---@module 'lazy.types'
---@type LazyPluginSpec[]
return {
{
"${0:gh-repo}"
}
}
Loading