updates to code completion, gen-ai functionality, and nvim-tree
This commit is contained in:
parent
0c6dab5310
commit
a68c97c516
6 changed files with 215 additions and 161 deletions
299
plugins/cmp.nix
299
plugins/cmp.nix
|
@ -1,155 +1,174 @@
|
||||||
{ ... }:
|
{ ... }:
|
||||||
{
|
{
|
||||||
programs.nixvim = {
|
programs.nixvim = {
|
||||||
plugins.cmp = {
|
plugins = {
|
||||||
enable = true;
|
cmp-cmdline.enable = true;
|
||||||
autoEnableSources = true;
|
cmp-git.enable = true;
|
||||||
settings = {
|
cmp-npm.enable = true;
|
||||||
enabled.__raw = ''
|
cmp-path.enable = true;
|
||||||
function()
|
cmp-rg.enable = true;
|
||||||
local filetype = vim.api.nvim_buf_get_option(0, "filetype")
|
cmp-tmux.enable = true;
|
||||||
if filetype == "TelescopePrompt" then
|
cmp-treesitter.enable = true;
|
||||||
return false
|
cmp-zsh.enable = true;
|
||||||
end
|
cmp_yanky.enable = true;
|
||||||
return true
|
copilot-cmp = {
|
||||||
end
|
enable = true;
|
||||||
'';
|
settings = {
|
||||||
|
event = ["InsertEnter" "LspAttach"]; # When to trigger Copilot
|
||||||
sources = [
|
fix_pairs = true; # Fix parentheses/brackets completion
|
||||||
{ name = "nvim_lua"; }
|
|
||||||
{ name = "nvim_lsp"; }
|
|
||||||
{ name = "emoji"; }
|
|
||||||
{
|
|
||||||
name = "buffer"; # text within current buffer
|
|
||||||
option.get_bufnrs.__raw = "vim.api.nvim_list_bufs";
|
|
||||||
keywordLength = 3;
|
|
||||||
}
|
|
||||||
# { name = "copilot"; } # enable/disable copilot
|
|
||||||
{
|
|
||||||
name = "path"; # file system paths
|
|
||||||
keywordLength = 3;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
name = "luasnip"; # snippets
|
|
||||||
keywordLength = 3;
|
|
||||||
}
|
|
||||||
{ name = "cmdline"; }
|
|
||||||
];
|
|
||||||
|
|
||||||
formatting = {
|
|
||||||
fields = [ "kind" "abbr" "menu" ];
|
|
||||||
format = ''
|
|
||||||
function(entry, vim_item)
|
|
||||||
local kind_icons = {
|
|
||||||
Text = "",
|
|
||||||
Method = "",
|
|
||||||
Function = "",
|
|
||||||
Constructor = "",
|
|
||||||
Field = "",
|
|
||||||
Variable = "",
|
|
||||||
Class = "",
|
|
||||||
Interface = "",
|
|
||||||
Module = "",
|
|
||||||
Property = "",
|
|
||||||
Unit = "",
|
|
||||||
Value = "",
|
|
||||||
Enum = "",
|
|
||||||
Keyword = "",
|
|
||||||
Snippet = "",
|
|
||||||
Color = "",
|
|
||||||
File = "",
|
|
||||||
Reference = "",
|
|
||||||
Folder = "",
|
|
||||||
EnumMember = "",
|
|
||||||
Constant = "",
|
|
||||||
Struct = "",
|
|
||||||
Event = "",
|
|
||||||
Operator = "",
|
|
||||||
TypeParameter = "",
|
|
||||||
}
|
|
||||||
vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
|
|
||||||
vim_item.menu = ({
|
|
||||||
path = "[Path]",
|
|
||||||
nvim_lua = "[NVIM_LUA]",
|
|
||||||
nvim_lsp = "[LSP]",
|
|
||||||
luasnip = "[Snippet]",
|
|
||||||
buffer = "[Buffer]",
|
|
||||||
})[entry.source.name]
|
|
||||||
return vim_item
|
|
||||||
end
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
completion = {
|
|
||||||
completeopt = "menuone,noselect";
|
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
cmp = {
|
||||||
|
enable = true;
|
||||||
autoEnableSources = true;
|
autoEnableSources = true;
|
||||||
|
settings = {
|
||||||
experimental = { ghost_text = true; };
|
enabled.__raw = ''
|
||||||
|
function()
|
||||||
performance = {
|
local filetype = vim.api.nvim_buf_get_option(0, "filetype")
|
||||||
debounce = 60;
|
if filetype == "TelescopePrompt" then
|
||||||
fetchingTimeout = 200;
|
return false
|
||||||
maxViewEntries = 30;
|
end
|
||||||
};
|
return true
|
||||||
|
|
||||||
snippet = {
|
|
||||||
expand = ''
|
|
||||||
function(args)
|
|
||||||
require('luasnip').lsp_expand(args.body)
|
|
||||||
end
|
end
|
||||||
'';
|
'';
|
||||||
};
|
|
||||||
|
|
||||||
window = {
|
sources = [
|
||||||
completion = { border = "solid"; };
|
{ name = "nvim_lua"; }
|
||||||
documentation = { border = "solid"; };
|
{ name = "nvim_lsp"; }
|
||||||
};
|
{ name = "emoji"; }
|
||||||
|
{
|
||||||
|
name = "buffer"; # text within current buffer
|
||||||
|
option.get_bufnrs.__raw = "vim.api.nvim_list_bufs";
|
||||||
|
keywordLength = 3;
|
||||||
|
}
|
||||||
|
{ name = "copilot"; }
|
||||||
|
{
|
||||||
|
name = "path"; # file system paths
|
||||||
|
keywordLength = 3;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
name = "luasnip"; # snippets
|
||||||
|
keywordLength = 3;
|
||||||
|
}
|
||||||
|
{ name = "cmdline"; }
|
||||||
|
];
|
||||||
|
|
||||||
mapping = {
|
formatting = {
|
||||||
"<C-j>" = "cmp.mapping.select_next_item()";
|
fields = [ "kind" "abbr" "menu" ];
|
||||||
"<C-n>" = "cmp.mapping.select_next_item()";
|
format = ''
|
||||||
"<C-k>" = "cmp.mapping.select_prev_item()";
|
function(entry, vim_item)
|
||||||
"<C-p>" = "cmp.mapping.select_prev_item()";
|
local kind_icons = {
|
||||||
"<C-e>" = "cmp.mapping.abort()";
|
Text = "",
|
||||||
"<C-b>" = "cmp.mapping.scroll_docs(-4)";
|
Method = "",
|
||||||
"<C-f>" = "cmp.mapping.scroll_docs(4)";
|
Function = "",
|
||||||
"<C-c>" = "cmp.mapping.complete()";
|
Constructor = "",
|
||||||
"<Tab>" = "cmp.mapping.confirm({ select = false })";
|
Field = "",
|
||||||
# "<Tab>" = ''
|
Variable = "",
|
||||||
# cmp.mapping(function(fallback)
|
Class = "",
|
||||||
# -- local context = require("cmp.config.context")
|
Interface = "",
|
||||||
# -- local is_comment = context.in_treesitter_capture("comment") == true or context.in_syntax_group("Comment")
|
Module = "",
|
||||||
#
|
Property = "",
|
||||||
# local col = vim.fn.col('.') - 1
|
Unit = "",
|
||||||
# local line = vim.fn.getline('.')
|
Value = "",
|
||||||
# local char_under_cursor = string.sub(line, col, col)
|
Enum = "",
|
||||||
#
|
Keyword = "",
|
||||||
# if col == 0 or string.match(char_under_cursor, '%s') then
|
Snippet = "",
|
||||||
# fallback()
|
Color = "",
|
||||||
# elseif cmp.visible() then
|
File = "",
|
||||||
# cmp.confirm({ select = true })
|
Reference = "",
|
||||||
# else
|
Folder = "",
|
||||||
# fallback()
|
EnumMember = "",
|
||||||
# end
|
Constant = "",
|
||||||
# end, { "i", "s" })
|
Struct = "",
|
||||||
# '';
|
Event = "",
|
||||||
"<S-Tab>" = "cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true })";
|
Operator = "",
|
||||||
"<C-l>" = ''
|
TypeParameter = "",
|
||||||
cmp.mapping(function()
|
}
|
||||||
if luasnip.expand_or_locally_jumpable() then
|
vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
|
||||||
luasnip.expand_or_jump()
|
vim_item.menu = ({
|
||||||
|
path = "[Path]",
|
||||||
|
nvim_lua = "[NVIM_LUA]",
|
||||||
|
nvim_lsp = "[LSP]",
|
||||||
|
luasnip = "[Snippet]",
|
||||||
|
buffer = "[Buffer]",
|
||||||
|
})[entry.source.name]
|
||||||
|
return vim_item
|
||||||
end
|
end
|
||||||
end, { 'i', 's' })
|
'';
|
||||||
'';
|
};
|
||||||
"<C-h>" = ''
|
|
||||||
cmp.mapping(function()
|
completion = {
|
||||||
if luasnip.locally_jumpable(-1) then
|
completeopt = "menuone,noselect";
|
||||||
luasnip.jump(-1)
|
};
|
||||||
|
|
||||||
|
autoEnableSources = true;
|
||||||
|
|
||||||
|
experimental = { ghost_text = true; };
|
||||||
|
|
||||||
|
performance = {
|
||||||
|
debounce = 60;
|
||||||
|
fetchingTimeout = 200;
|
||||||
|
maxViewEntries = 30;
|
||||||
|
};
|
||||||
|
|
||||||
|
snippet = {
|
||||||
|
expand = ''
|
||||||
|
function(args)
|
||||||
|
require('luasnip').lsp_expand(args.body)
|
||||||
end
|
end
|
||||||
end, { 'i', 's' })
|
'';
|
||||||
'';
|
};
|
||||||
|
|
||||||
|
window = {
|
||||||
|
completion = { border = "solid"; };
|
||||||
|
documentation = { border = "solid"; };
|
||||||
|
};
|
||||||
|
|
||||||
|
mapping = {
|
||||||
|
"<C-j>" = "cmp.mapping.select_next_item()";
|
||||||
|
"<C-n>" = "cmp.mapping.select_next_item()";
|
||||||
|
"<C-k>" = "cmp.mapping.select_prev_item()";
|
||||||
|
"<C-p>" = "cmp.mapping.select_prev_item()";
|
||||||
|
"<C-e>" = "cmp.mapping.abort()";
|
||||||
|
"<C-b>" = "cmp.mapping.scroll_docs(-4)";
|
||||||
|
"<C-f>" = "cmp.mapping.scroll_docs(4)";
|
||||||
|
"<C-c>" = "cmp.mapping.complete()";
|
||||||
|
"<Tab>" = "cmp.mapping.confirm({ select = false })";
|
||||||
|
# "<Tab>" = ''
|
||||||
|
# cmp.mapping(function(fallback)
|
||||||
|
# -- local context = require("cmp.config.context")
|
||||||
|
# -- local is_comment = context.in_treesitter_capture("comment") == true or context.in_syntax_group("Comment")
|
||||||
|
#
|
||||||
|
# local col = vim.fn.col('.') - 1
|
||||||
|
# local line = vim.fn.getline('.')
|
||||||
|
# local char_under_cursor = string.sub(line, col, col)
|
||||||
|
#
|
||||||
|
# if col == 0 or string.match(char_under_cursor, '%s') then
|
||||||
|
# fallback()
|
||||||
|
# elseif cmp.visible() then
|
||||||
|
# cmp.confirm({ select = true })
|
||||||
|
# else
|
||||||
|
# fallback()
|
||||||
|
# end
|
||||||
|
# end, { "i", "s" })
|
||||||
|
# '';
|
||||||
|
"<S-Tab>" = "cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true })";
|
||||||
|
"<C-l>" = ''
|
||||||
|
cmp.mapping(function()
|
||||||
|
if luasnip.expand_or_locally_jumpable() then
|
||||||
|
luasnip.expand_or_jump()
|
||||||
|
end
|
||||||
|
end, { 'i', 's' })
|
||||||
|
'';
|
||||||
|
"<C-h>" = ''
|
||||||
|
cmp.mapping(function()
|
||||||
|
if luasnip.locally_jumpable(-1) then
|
||||||
|
luasnip.jump(-1)
|
||||||
|
end
|
||||||
|
end, { 'i', 's' })
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,20 @@
|
||||||
{ pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
{
|
{
|
||||||
programs.nixvim.plugins = {
|
programs.nixvim = {
|
||||||
codecompanion = {
|
keymaps = [
|
||||||
|
{
|
||||||
|
mode = [ "n" ];
|
||||||
|
key = "<c-c>";
|
||||||
|
action = ":CodeCompanionActions<CR>";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
mode = [ "n" ];
|
||||||
|
key = ",c";
|
||||||
|
action = ":CodeCompanionChat Toggle<CR>";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
plugins.codecompanion = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
settings = {
|
settings = {
|
||||||
|
|
|
@ -26,13 +26,7 @@
|
||||||
gitsigns.enable = true;
|
gitsigns.enable = true;
|
||||||
indent-blankline.enable = true;
|
indent-blankline.enable = true;
|
||||||
lightline.enable = false;
|
lightline.enable = false;
|
||||||
lsp-signature.enable = true;
|
# lsp-signature.enable = true;
|
||||||
# config = ''
|
|
||||||
# lua << EOF
|
|
||||||
# require("lsp_signature").setup()
|
|
||||||
# EOF
|
|
||||||
# '';
|
|
||||||
|
|
||||||
lualine.enable = true;
|
lualine.enable = true;
|
||||||
nix.enable = true;
|
nix.enable = true;
|
||||||
noice.enable = true;
|
noice.enable = true;
|
||||||
|
@ -58,6 +52,7 @@
|
||||||
# EOF
|
# EOF
|
||||||
# '';
|
# '';
|
||||||
|
|
||||||
|
oil.enable = true;
|
||||||
rainbow-delimiters.enable = true;
|
rainbow-delimiters.enable = true;
|
||||||
sleuth.enable = true;
|
sleuth.enable = true;
|
||||||
treesitter.enable = false;
|
treesitter.enable = false;
|
||||||
|
@ -67,5 +62,6 @@
|
||||||
# ## Only on unstable at the moment
|
# ## Only on unstable at the moment
|
||||||
web-devicons.enable = true;
|
web-devicons.enable = true;
|
||||||
which-key.enable = true;
|
which-key.enable = true;
|
||||||
|
yanky.enable = true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,15 @@
|
||||||
{ ... }:
|
{ ... }:
|
||||||
{
|
{
|
||||||
programs.nixvim = {
|
programs.nixvim = {
|
||||||
|
# keymaps = [
|
||||||
|
# {
|
||||||
|
# mode = "i";
|
||||||
|
# key = "<c-c>";
|
||||||
|
# action.__raw = ''function() require("luasnip.extras.select_choice")() end'';
|
||||||
|
# options.desc = "Search";
|
||||||
|
# }
|
||||||
|
# ];
|
||||||
|
|
||||||
plugins.luasnip = {
|
plugins.luasnip = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
|
@ -28,14 +37,5 @@
|
||||||
# '';
|
# '';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# keymaps = [
|
|
||||||
# {
|
|
||||||
# mode = "i";
|
|
||||||
# key = "<c-c>";
|
|
||||||
# action.__raw = ''function() require("luasnip.extras.select_choice")() end'';
|
|
||||||
# options.desc = "Search";
|
|
||||||
# }
|
|
||||||
# ];
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 = [
|
keymaps = [
|
||||||
## Go to current buffer's file in nvim-tree
|
## Go to current buffer's file in nvim-tree
|
||||||
{
|
{
|
||||||
|
@ -25,7 +38,7 @@
|
||||||
{
|
{
|
||||||
mode = [ "n" ];
|
mode = [ "n" ];
|
||||||
key = "<c-f>";
|
key = "<c-f>";
|
||||||
action = "<cmd>lua require('treeutils').launch_find_files()<CR>";
|
action = "<cmd>lua launch_find_files_wrapped()<CR>";
|
||||||
options = { noremap = true; };
|
options = { noremap = true; };
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,15 +22,28 @@ function M.launch_live_grep(opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.launch_find_files(opts)
|
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
|
end
|
||||||
|
|
||||||
function M.launch_telescope(func_name, opts)
|
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
|
||||||
|
|
||||||
local telescope_status_ok, _ = pcall(require, "telescope")
|
local telescope_status_ok, _ = pcall(require, "telescope")
|
||||||
if not telescope_status_ok then
|
if not telescope_status_ok then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local node = api.tree.get_node_under_cursor()
|
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 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")
|
local basedir = is_folder and node.absolute_path or vim.fn.fnamemodify(node.absolute_path, ":h")
|
||||||
if (node.name == '..' and TreeExplorer ~= nil) then
|
if (node.name == '..' and TreeExplorer ~= nil) then
|
||||||
|
|
Loading…
Add table
Reference in a new issue