updates to code completion, gen-ai functionality, and nvim-tree

This commit is contained in:
Ellis Rahhal 2025-02-15 20:45:53 -08:00
parent 0c6dab5310
commit a68c97c516
6 changed files with 215 additions and 161 deletions

View file

@ -1,7 +1,25 @@
{ ... }:
{
programs.nixvim = {
plugins.cmp = {
plugins = {
cmp-cmdline.enable = true;
cmp-git.enable = true;
cmp-npm.enable = true;
cmp-path.enable = true;
cmp-rg.enable = true;
cmp-tmux.enable = true;
cmp-treesitter.enable = true;
cmp-zsh.enable = true;
cmp_yanky.enable = true;
copilot-cmp = {
enable = true;
settings = {
event = ["InsertEnter" "LspAttach"]; # When to trigger Copilot
fix_pairs = true; # Fix parentheses/brackets completion
};
};
cmp = {
enable = true;
autoEnableSources = true;
settings = {
@ -24,7 +42,7 @@
option.get_bufnrs.__raw = "vim.api.nvim_list_bufs";
keywordLength = 3;
}
# { name = "copilot"; } # enable/disable copilot
{ name = "copilot"; }
{
name = "path"; # file system paths
keywordLength = 3;
@ -154,4 +172,5 @@
};
};
};
};
}

View file

@ -1,7 +1,20 @@
{ pkgs, ... }:
{
programs.nixvim.plugins = {
codecompanion = {
programs.nixvim = {
keymaps = [
{
mode = [ "n" ];
key = "<c-c>";
action = ":CodeCompanionActions<CR>";
}
{
mode = [ "n" ];
key = ",c";
action = ":CodeCompanionChat Toggle<CR>";
}
];
plugins.codecompanion = {
enable = true;
settings = {

View file

@ -26,13 +26,7 @@
gitsigns.enable = true;
indent-blankline.enable = true;
lightline.enable = false;
lsp-signature.enable = true;
# config = ''
# lua << EOF
# require("lsp_signature").setup()
# EOF
# '';
# lsp-signature.enable = true;
lualine.enable = true;
nix.enable = true;
noice.enable = true;
@ -58,6 +52,7 @@
# EOF
# '';
oil.enable = true;
rainbow-delimiters.enable = true;
sleuth.enable = true;
treesitter.enable = false;
@ -67,5 +62,6 @@
# ## Only on unstable at the moment
web-devicons.enable = true;
which-key.enable = true;
yanky.enable = true;
};
}

View file

@ -1,6 +1,15 @@
{ ... }:
{
programs.nixvim = {
# keymaps = [
# {
# mode = "i";
# key = "<c-c>";
# action.__raw = ''function() require("luasnip.extras.select_choice")() end'';
# options.desc = "Search";
# }
# ];
plugins.luasnip = {
enable = true;
@ -28,14 +37,5 @@
# '';
};
};
# keymaps = [
# {
# mode = "i";
# key = "<c-c>";
# action.__raw = ''function() require("luasnip.extras.select_choice")() end'';
# options.desc = "Search";
# }
# ];
};
}

View file

@ -8,6 +8,19 @@
};
};
extraConfigLua = ''
function _G.launch_find_files_wrapped()
-- Try custom function first
local handled = require('treeutils').launch_find_files()
if handled == "default" then
-- If custom function didn't handle it, execute default behavior
local default_key = vim.api.nvim_replace_termcodes('<c-f>', true, true, true)
vim.api.nvim_feedkeys(default_key, 'n', false)
end
end
'';
keymaps = [
## Go to current buffer's file in nvim-tree
{
@ -25,7 +38,7 @@
{
mode = [ "n" ];
key = "<c-f>";
action = "<cmd>lua require('treeutils').launch_find_files()<CR>";
action = "<cmd>lua launch_find_files_wrapped()<CR>";
options = { noremap = true; };
}
{

View file

@ -22,15 +22,28 @@ function M.launch_live_grep(opts)
end
function M.launch_find_files(opts)
return M.launch_telescope("find_files", opts)
return M.launch_telescope("find_files", opts, { active_only_in_tree = true })
end
function M.launch_telescope(func_name, opts, internal_opts)
internal_opts = internal_opts or {}
local buffname = vim.fn.bufname()
if (internal_opts.active_only_in_tree) then
-- Make sure this is being called in NvimTree
if (string.sub(buffname, 1, string.len('NvimTree')) ~= 'NvimTree') then
return "default"
end
end
function M.launch_telescope(func_name, opts)
local telescope_status_ok, _ = pcall(require, "telescope")
if not telescope_status_ok then
return
end
local node = api.tree.get_node_under_cursor()
if (node == nil) then
-- Tree is probably not open
return
end
local is_folder = node.fs_stat and node.fs_stat.type == 'directory' or false
local basedir = is_folder and node.absolute_path or vim.fn.fnamemodify(node.absolute_path, ":h")
if (node.name == '..' and TreeExplorer ~= nil) then