codecompanion

This commit is contained in:
2025-02-13 15:05:43 -08:00
parent 239756d583
commit 97110bcaad
7 changed files with 245 additions and 252 deletions

View File

@@ -0,0 +1,15 @@
require("codecompanion").setup({
strategies = {
chat = {
adapter = "copilot",
},
inline = {
adapter = "copilot",
},
},
display = {
action_palette = {
provider = "telescope"
}
}
})

View File

@@ -1,52 +1,103 @@
require('lualine').setup {
options = {
icons_enabled = true,
theme = 'codedark',
-- theme = 'dracula',
-- theme = 'horizon',
-- theme = 'onedark',
component_separators = { left = '', right = '' },
section_separators = { left = '', right = ''},
disabled_filetypes = {},
always_divide_middle = true,
},
sections = {
lualine_a = { 'mode' },
lualine_b = { 'branch', 'diff' },
lualine_c = { 'filename' },
lualine_x = {
{
'diagnostics',
'fileformat',
symbols = {
unix = '', -- e712
dos = '', -- e70f
mac = '', -- e711
}
}, 'encoding', 'fileformat', { 'filetype', colored = true, icon_only = false } },
lualine_y = { 'progress' },
lualine_z = { 'location' }
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {
{
'filename',
file_status = true, -- Displays file status (readonly status, modified status)
path = 0, -- 0: Just the filename
shorting_target = 40, -- Shortens path to leave 40 spaces in the window
symbols = {
modified = '[+]', -- Text to show when the file is modified.
readonly = '[-]', -- Text to show when the file is non-modifiable or readonly.
unnamed = '[No Name]', -- Text to show for unnamed buffers.
}
},
},
lualine_x = { 'location' },
lualine_y = {},
lualine_z = {}
},
tabline = {},
extensions = { 'quickfix', 'fzf', 'nvim-tree', 'symbols-outline', 'fugitive' }
local M = require("lualine.component"):extend()
M.processing = false
M.spinner_index = 1
local spinner_symbols = {
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
}
local spinner_symbols_len = 10
-- Initializer
function M:init(options)
M.super.init(self, options)
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 M:update_status()
if self.processing then
self.spinner_index = (self.spinner_index % spinner_symbols_len) + 1
return spinner_symbols[self.spinner_index]
else
return nil
end
end
require('lualine').setup {
options = {
icons_enabled = true,
theme = 'codedark',
-- theme = 'dracula',
-- theme = 'horizon',
-- theme = 'onedark',
component_separators = { left = '', right = '' },
section_separators = { left = '', right = '' },
disabled_filetypes = {},
always_divide_middle = true,
},
sections = {
lualine_a = { 'mode' },
lualine_b = { 'branch', 'diff' },
lualine_c = { 'filename', M },
lualine_x = {
{
'diagnostics',
'fileformat',
symbols = {
unix = '', -- e712
dos = '', -- e70f
mac = '', -- e711
}
}, 'encoding', 'fileformat', { 'filetype', colored = true, icon_only = false } },
lualine_y = { 'progress' },
lualine_z = { 'location' }
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {
{
'filename',
file_status = true, -- Displays file status (readonly status, modified status)
path = 0, -- 0: Just the filename
shorting_target = 40, -- Shortens path to leave 40 spaces in the window
symbols = {
modified = '[+]', -- Text to show when the file is modified.
readonly = '[-]', -- Text to show when the file is non-modifiable or readonly.
unnamed = '[No Name]', -- Text to show for unnamed buffers.
}
},
M
},
lualine_x = { 'location' },
lualine_y = {},
lualine_z = {}
},
tabline = {},
extensions = { 'quickfix', 'fzf', 'nvim-tree', 'symbols-outline', 'fugitive' }
}
-- return M

View File

@@ -157,7 +157,9 @@ cmp.setup({
-- })
},
sources = cmp.config.sources({
{ name = "copilot", group_index = 2 }, { name = "path", group_index = 2 },
{ name = "copilot", group_index = 2 },
{ name = "codecompanion", group_index = 2 },
{ name = "path", group_index = 2 },
{ name = 'nvim_lsp', group_index = 2 },
{ name = 'nvim_lsp_signature_help', group_index = 2 },
{ name = 'nvim_lsp_document_symbol', group_index = 2 },
@@ -183,8 +185,11 @@ cmp.setup({
priority_weight = 2,
comparators = {
require("copilot_cmp.comparators").prioritize,
cmp.config.compare.offset,
cmp.config.compare.exact,
require("copilot_cmp.comparators").score,
require("copilot_cmp.comparators").recently_used,
cmp.config.compare.locality,
require("copilot_cmp.comparators").kind,
require("copilot_cmp.comparators").sort_text,
require("copilot_cmp.comparators").length,
@@ -223,37 +228,37 @@ for _, lsp in ipairs(servers) do
lspconfig[lsp].setup {
on_attach = require("lsp-format").on_attach,
on_init = function(client)
if client.workspace_folders then
local path = client.workspace_folders[1].name
if path ~= vim.fn.stdpath('config') and (vim.loop.fs_stat(path..'/.luarc.json') or vim.loop.fs_stat(path..'/.luarc.jsonc')) then
return
if client.workspace_folders then
local path = client.workspace_folders[1].name
if path ~= vim.fn.stdpath('config') and (vim.loop.fs_stat(path .. '/.luarc.json') or vim.loop.fs_stat(path .. '/.luarc.jsonc')) then
return
end
end
end
client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, {
client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, {
runtime = {
-- Tell the language server which version of Lua you're using
-- (most likely LuaJIT in the case of Neovim)
version = 'LuaJIT'
-- Tell the language server which version of Lua you're using
-- (most likely LuaJIT in the case of Neovim)
version = 'LuaJIT'
},
-- Make the server aware of Neovim runtime files
workspace = {
checkThirdParty = false,
library = {
vim.env.VIMRUNTIME
-- Depending on the usage, you might want to add additional paths here.
-- "${3rd}/luv/library"
-- "${3rd}/busted/library",
}
-- or pull in all of 'runtimepath'. NOTE: this is a lot slower and will cause issues when working on your own configuration (see https://github.com/neovim/nvim-lspconfig/issues/3189)
-- library = vim.api.nvim_get_runtime_file("", true)
checkThirdParty = false,
library = {
vim.env.VIMRUNTIME
-- Depending on the usage, you might want to add additional paths here.
-- "${3rd}/luv/library"
-- "${3rd}/busted/library",
}
-- or pull in all of 'runtimepath'. NOTE: this is a lot slower and will cause issues when working on your own configuration (see https://github.com/neovim/nvim-lspconfig/issues/3189)
-- library = vim.api.nvim_get_runtime_file("", true)
}
})
})
end,
capabilities = capabilities,
callSnippet = "Replace",
settings = {
Lua = {}
}
capabilities = capabilities,
callSnippet = "Replace",
settings = {
Lua = {}
}
}
else
lspconfig[lsp].setup { on_attach = require("lsp-format").on_attach, capabilities = capabilities }
@@ -263,4 +268,4 @@ end
-- cmp.event:on("menu_opened",
-- function() vim.b.copilot_suggestion_hidden = true end)
-- cmp.event:on("menu_closed",
-- function() vim.b.copilot_suggestion_hidden = false end)
-- function() vim.b.copilot_suggestion_hidden = false end)