fixed luasnip keybindings; made ai plugins an option
This commit is contained in:
parent
9cf6e96c73
commit
4ad80df1eb
7 changed files with 159 additions and 79 deletions
|
@ -3,6 +3,12 @@
|
|||
options.nixvim-config = {
|
||||
enable = lib.mkEnableOption "Enable nixvim-config";
|
||||
|
||||
enable-ai = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = "Enable ai plugins";
|
||||
};
|
||||
|
||||
enable-startify = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
|
|
|
@ -1,64 +1,119 @@
|
|||
{ ... }:
|
||||
{ config, ... }:
|
||||
{
|
||||
programs.nixvim.plugins.avante = {
|
||||
enable = true;
|
||||
programs.nixvim.plugins = if config.nixvim-config.enable-ai then {
|
||||
## required dependencies
|
||||
dressing.enable = true; # this is archived and may break in the future
|
||||
nui.enable = true;
|
||||
|
||||
settings = {
|
||||
provider = "copilot";
|
||||
## optional dependencies
|
||||
cmp.enable = true;
|
||||
copilot-lua.enable = true;
|
||||
fzf-lua.enable = true;
|
||||
mini.enable = true;
|
||||
telescope.enable = true;
|
||||
web-devicons.enable = true;
|
||||
|
||||
claude = {
|
||||
api_key_name = "<api_key_name>";
|
||||
};
|
||||
openai = {
|
||||
api_key_name = "<api_key_name>";
|
||||
};
|
||||
avante = {
|
||||
enable = true;
|
||||
|
||||
vendors = {
|
||||
ollama = {
|
||||
api_key_name = "";
|
||||
endpoint = "http://localhost:11434/v1";
|
||||
model = "hf.co/unsloth/DeepSeek-R1-Distill-Qwen-1.5B-GGUF";
|
||||
temperature = "0.6";
|
||||
parse_curl_args.__raw = ''
|
||||
function(opts, code_opts)
|
||||
return {
|
||||
url = opts.endpoint .. "/chat/completions",
|
||||
headers = {
|
||||
["Accept"] = "application/json",
|
||||
["Content-Type"] = "application/json",
|
||||
["x-api-key"] = "ollama",
|
||||
},
|
||||
body = {
|
||||
model = opts.model,
|
||||
messages = require("avante.providers").copilot.parse_messages(code_opts),
|
||||
max_tokens = opts.max_tokens,
|
||||
stream = true,
|
||||
},
|
||||
}
|
||||
end'';
|
||||
parse_response_data.__raw = ''
|
||||
function(data_stream, event_state, opts)
|
||||
require("avante.providers").openai.parse_response(data_stream, event_state, opts)
|
||||
end'';
|
||||
};
|
||||
};
|
||||
settings = {
|
||||
provider = "copilot";
|
||||
|
||||
mappings = {
|
||||
ask = "<leader>ca";
|
||||
edit = "<leader>ce";
|
||||
refresh = "<leader>cr";
|
||||
focus = "<leader>cf";
|
||||
toggle = {
|
||||
default = "<leader>ct";
|
||||
debug = "<leader>cd";
|
||||
hint = "<leader>ch";
|
||||
suggestion = "<leader>cs";
|
||||
repomap = "<leader>cR";
|
||||
};
|
||||
files = {
|
||||
add_current = "<leader>cc";
|
||||
auto_include = true; # Automatically include relevant files
|
||||
max_files = 50; # Maximum number of files to include in context
|
||||
max_size_kb = 1000; # Maximum total size of files in KB
|
||||
|
||||
# Define which files to include/exclude
|
||||
include = [
|
||||
"*.lua"
|
||||
"*.nix"
|
||||
"*.rs"
|
||||
"*.ts"
|
||||
"*.js"
|
||||
"*.jsx"
|
||||
"*.tsx"
|
||||
# Add more patterns as needed
|
||||
];
|
||||
|
||||
exclude = [
|
||||
"node_modules/**"
|
||||
"dist/**"
|
||||
".git/**"
|
||||
# Add more patterns to exclude
|
||||
];
|
||||
};
|
||||
|
||||
claude = {
|
||||
api_key_name = "<api_key_name>";
|
||||
};
|
||||
openai = {
|
||||
api_key_name = "<api_key_name>";
|
||||
};
|
||||
|
||||
vendors = {
|
||||
ollama = {
|
||||
api_key_name = "";
|
||||
endpoint = "http://localhost:11434/v1";
|
||||
model = "hf.co/unsloth/DeepSeek-R1-Distill-Qwen-1.5B-GGUF";
|
||||
temperature = "0.6";
|
||||
parse_curl_args.__raw = ''
|
||||
function(opts, code_opts)
|
||||
return {
|
||||
url = opts.endpoint .. "/chat/completions",
|
||||
headers = {
|
||||
["Accept"] = "application/json",
|
||||
["Content-Type"] = "application/json",
|
||||
["x-api-key"] = "ollama",
|
||||
},
|
||||
body = {
|
||||
model = opts.model,
|
||||
messages = require("avante.providers").copilot.parse_messages(code_opts),
|
||||
max_tokens = opts.max_tokens,
|
||||
stream = true,
|
||||
},
|
||||
}
|
||||
end'';
|
||||
parse_response_data.__raw = ''
|
||||
function(data_stream, event_state, opts)
|
||||
require("avante.providers").openai.parse_response(data_stream, event_state, opts)
|
||||
end'';
|
||||
};
|
||||
};
|
||||
|
||||
## Default keybindings:
|
||||
# <leader>aa - ask
|
||||
# <leader>ae - edit
|
||||
# <leader>ar - refresh
|
||||
# <leader>af - focus
|
||||
# co - choose ours
|
||||
# ct - choose theirs
|
||||
# ca - choose all theirs
|
||||
# c0 - choose none
|
||||
# cb - choose both
|
||||
# cc - choose cursor
|
||||
# ]x - previous conflict
|
||||
# [x - next conflict
|
||||
# [[ - previous code block
|
||||
# ]] - next code block
|
||||
|
||||
# mappings = {
|
||||
# ask = "<leader>ca";
|
||||
# edit = "<leader>ce";
|
||||
# refresh = "<leader>cr";
|
||||
# focus = "<leader>cf";
|
||||
# toggle = {
|
||||
# default = "<leader>ct";
|
||||
# debug = "<leader>cd";
|
||||
# hint = "<leader>ch";
|
||||
# suggestion = "<leader>cs";
|
||||
# repomap = "<leader>cR";
|
||||
# };
|
||||
# files = {
|
||||
# add_current = "<leader>cc";
|
||||
# };
|
||||
# };
|
||||
};
|
||||
};
|
||||
};
|
||||
} else {};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ ... }:
|
||||
{ config, ... }:
|
||||
{
|
||||
programs.nixvim = {
|
||||
plugins = {
|
||||
|
@ -42,6 +42,19 @@
|
|||
option.get_bufnrs.__raw = "vim.api.nvim_list_bufs";
|
||||
keywordLength = 3;
|
||||
}
|
||||
] ++ (if config.nixvim-config.enable-ai then [
|
||||
{ name = "codecompanion"; }
|
||||
{ name = "copilot"; }
|
||||
] else []) ++ [
|
||||
{
|
||||
name = "path"; # file system paths
|
||||
keywordLength = 3;
|
||||
}
|
||||
{
|
||||
name = "luasnip"; # snippets
|
||||
keywordLength = 3;
|
||||
}
|
||||
{ name = "cmdline"; }
|
||||
{ name = "codecompanion"; }
|
||||
{ name = "copilot"; }
|
||||
{
|
||||
|
@ -157,6 +170,7 @@
|
|||
"<S-Tab>" = "cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true })";
|
||||
"<C-l>" = ''
|
||||
cmp.mapping(function()
|
||||
local luasnip = require('luasnip')
|
||||
if luasnip.expand_or_locally_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
end
|
||||
|
@ -164,6 +178,7 @@
|
|||
'';
|
||||
"<C-h>" = ''
|
||||
cmp.mapping(function()
|
||||
local luasnip = require('luasnip')
|
||||
if luasnip.locally_jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{ pkgs, ... }:
|
||||
{ config, pkgs, ... }:
|
||||
{
|
||||
programs.nixvim = {
|
||||
keymaps = [
|
||||
keymaps = if config.nixvim-config.enable-ai then [
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<c-c>";
|
||||
|
@ -12,10 +12,10 @@
|
|||
key = ",c";
|
||||
action = ":CodeCompanionChat Toggle<CR>";
|
||||
}
|
||||
];
|
||||
] else [];
|
||||
|
||||
plugins.codecompanion = {
|
||||
enable = true;
|
||||
enable = config.nixvim-config.enable-ai;
|
||||
|
||||
settings = {
|
||||
adapters = {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
{ ... }:
|
||||
{ config, ... }:
|
||||
{
|
||||
programs.nixvim = {
|
||||
plugins.copilot-lua = {
|
||||
enable = true;
|
||||
enable = config.nixvim-config.enable-ai;
|
||||
|
||||
settings = {
|
||||
suggestion.enabled = false;
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
|
||||
programs.nixvim.plugins = {
|
||||
comment.enable = true;
|
||||
## needed by avante. already archived, so may need to migrate to snacks
|
||||
dressing.enable = true;
|
||||
fugitive.enable = true;
|
||||
gitsigns.enable = true;
|
||||
lightline.enable = false;
|
||||
|
@ -40,6 +42,8 @@
|
|||
top_down = false;
|
||||
};
|
||||
};
|
||||
## needed by avante.
|
||||
nui.enable = true;
|
||||
nvim-autopairs.enable = true;
|
||||
nvim-bqf.enable = true;
|
||||
nvim-lightbulb.enable = true;
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
{ ... }:
|
||||
{
|
||||
programs.nixvim = {
|
||||
# keymaps = [
|
||||
# {
|
||||
# mode = "i";
|
||||
# key = "<c-c>";
|
||||
# action.__raw = ''function() require("luasnip.extras.select_choice")() end'';
|
||||
# options.desc = "Search";
|
||||
# }
|
||||
# ];
|
||||
keymaps = [
|
||||
{
|
||||
mode = "i";
|
||||
key = "<c-b>";
|
||||
action.__raw = ''function() require("luasnip.extras.select_choice")() end'';
|
||||
options.desc = "Search";
|
||||
}
|
||||
];
|
||||
|
||||
plugins.luasnip = {
|
||||
enable = true;
|
||||
|
@ -25,16 +25,16 @@
|
|||
updateevents = ["TextChanged" "TextChangedI"];
|
||||
region_check_events = "CursorHold";
|
||||
delete_check_events = "InsertLeave";
|
||||
# ext_opts.__raw = ''
|
||||
# {
|
||||
# [require('luasnip.util.types').choiceNode] = {
|
||||
# active = {
|
||||
# virt_text = { { 'choice <c-c>', 'Comment' } },
|
||||
# hl_mode = 'combine',
|
||||
# },
|
||||
# },
|
||||
# }
|
||||
# '';
|
||||
ext_opts.__raw = ''
|
||||
{
|
||||
[require('luasnip.util.types').choiceNode] = {
|
||||
active = {
|
||||
virt_text = { { 'choice <c-b>', 'Comment' } },
|
||||
hl_mode = 'combine',
|
||||
},
|
||||
},
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue