Skip to content

Commit 8f1de34

Browse files
committed
codecompanion.nvim in vibe sandbox
1 parent 5008920 commit 8f1de34

File tree

3 files changed

+84
-29
lines changed

3 files changed

+84
-29
lines changed

nix/vibe.nix

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{pkgs ? import <nixpkgs> {}}: let
2+
unst = import ./nixpkgs-unstable.nix;
23
nixpak = import ./nixpak.nix;
34
mkNixPak = nixpak.lib.nixpak {
45
inherit (pkgs) lib;
@@ -20,8 +21,13 @@
2021
nix
2122
direnv
2223
nix-direnv
24+
unst.gemini-cli
2325
];
2426
};
27+
passwd = pkgs.writeTextFile {
28+
name = "passwd";
29+
text = "vibe:x:1000:1000:vibe:/tmp:/bin/sh";
30+
};
2531
sandbox = mkNixPak {
2632
config = {sloth, ...}: {
2733
app.package = app;
@@ -44,6 +50,7 @@
4450
"/usr/bin/env"
4551
"/run/current-system/sw/bin/bash"
4652
"/run/current-system/sw/bin/less"
53+
[(toString passwd) "/etc/passwd"]
4754
(sloth.concat' sloth.homeDir "/.bashrc")
4855
(sloth.concat' sloth.homeDir "/.bash_profile")
4956
(sloth.concat' sloth.homeDir "/.config/tmux")

pub/vi/nix/default.nix

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ in
5656
customRC =
5757
''
5858
set runtimepath+=${vi-src}
59-
let $PATH.=':${silver-searcher}/bin:${nodejs}/bin:${less}/bin:${lesspipeWrapper}/bin:${python311Packages.grip}/bin:${xdg-utils}/bin:${git}/bin:${jre8}/bin'
59+
let $PATH.=':${silver-searcher}/bin:${nodejs}/bin:${less}/bin:${lesspipeWrapper}/bin:${python311Packages.grip}/bin:${xdg-utils}/bin:${git}/bin:${jre8}/bin:${stylua}/bin'
6060
let g:vimBackground = '${vimBackground}'
6161
let g:vimColorScheme = '${vimColorScheme}'
6262
let g:languagetool_jar='${olds.languagetool}/share/languagetool-commandline.jar'
@@ -108,7 +108,10 @@ in
108108
]
109109
++ (
110110
if ai
111-
then [unst.vimPlugins.minuet-ai-nvim]
111+
then [
112+
unst.vimPlugins.minuet-ai-nvim
113+
unst.vimPlugins.codecompanion-nvim
114+
]
112115
else []
113116
);
114117
opt = [

pub/vi/vimrc.lua

Lines changed: 72 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,79 @@
11
local ok, avante_lib = pcall(require, "avante_lib")
22
if ok then
3-
avante_lib.load()
4-
require("avante").setup({provider = "gemini"})
3+
avante_lib.load()
4+
require("avante").setup({ provider = "gemini-cli" })
5+
end
6+
7+
local ok, codecompanion = pcall(require, "codecompanion")
8+
if ok then
9+
codecompanion.setup({
10+
strategies = {
11+
chat = {
12+
adapter = "gemini_cli",
13+
opts = {
14+
completion_provider = "coc",
15+
},
16+
},
17+
inline = {
18+
adapter = "gemini_cli",
19+
},
20+
cmd = {
21+
adapter = "gemini_cli",
22+
},
23+
},
24+
adapters = {
25+
acp = {
26+
gemini_cli = function()
27+
return require("codecompanion.adapters").extend("gemini_cli", {
28+
defaults = {
29+
auth_method = "gemini-api-key",
30+
mcpServers = {},
31+
timeout = 20000, -- 20 seconds
32+
},
33+
})
34+
end,
35+
},
36+
},
37+
})
38+
vim.keymap.set("n", "<leader>zz", "<CMD>CodeCompanionChat Toggle<CR>", {
39+
desc = "ai: ch[a]t",
40+
})
41+
vim.keymap.set("n", "<leader>zx", "<CMD>CodeCompanionActions<CR>", {
42+
desc = "ai: action[s]",
43+
})
44+
vim.keymap.set("n", "<leader>zc", "<CMD>CodeCompanionCmd<CR>", {
45+
desc = "ai: cm[d]",
46+
})
47+
vim.keymap.set({ "n", "v" }, "<leader>zv", "<CMD>CodeCompanion<CR>", {
48+
desc = "ai: [f]ile write with diff",
49+
})
550
end
651

752
local ok, minuet = pcall(require, "minuet")
853
if ok then
9-
minuet.setup({
10-
provider = "gemini",
11-
provider_options = {
12-
gemini = {
13-
model = 'gemini-2.5-flash-lite'
14-
}
15-
},
16-
virtualtext = {
17-
auto_trigger_ft = {},
18-
keymap = {
19-
-- accept whole completion
20-
accept = '<M-y>',
21-
-- accept one line
22-
accept_line = '<M-l>',
23-
-- accept n lines (prompts for number)
24-
-- e.g. "A-z 2 CR" will accept 2 lines
25-
accept_n_lines = '<M-z>',
26-
-- Cycle to prev completion item, or manually invoke completion
27-
prev = '<M-p>',
28-
-- Cycle to next completion item, or manually invoke completion
29-
next = '<M-n>',
30-
dismiss = '<M-e>',
31-
},
32-
}
33-
})
54+
minuet.setup({
55+
provider = "gemini",
56+
provider_options = {
57+
gemini = {
58+
model = "gemini-2.5-flash-lite",
59+
},
60+
},
61+
virtualtext = {
62+
auto_trigger_ft = {},
63+
keymap = {
64+
-- accept whole completion
65+
accept = "<M-y>",
66+
-- accept one line
67+
accept_line = "<M-l>",
68+
-- accept n lines (prompts for number)
69+
-- e.g. "A-z 2 CR" will accept 2 lines
70+
accept_n_lines = "<M-z>",
71+
-- Cycle to prev completion item, or manually invoke completion
72+
prev = "<M-p>",
73+
-- Cycle to next completion item, or manually invoke completion
74+
next = "<M-n>",
75+
dismiss = "<M-e>",
76+
},
77+
},
78+
})
3479
end

0 commit comments

Comments
 (0)