added a few more plugins, got cmp+luasnip working.

LSP is the last major milestone now.
This commit is contained in:
Gabe Venberg 2024-03-20 00:20:20 -05:00
parent 030822d6c1
commit 25b2b07a46
16 changed files with 490 additions and 159 deletions

View file

@ -1,6 +1,7 @@
{ {
config, config,
pkgs, pkgs,
helpers,
... ...
}: { }: {
# Home Manager needs a bit of information about you and the paths it should # Home Manager needs a bit of information about you and the paths it should

58
nix/nvim/cmp/cmp.nix Normal file
View file

@ -0,0 +1,58 @@
{
configs,
pkgs,
...
}: {
programs.nixvim = {
plugins.luasnip.enable = true;
plugins.friendly-snippets.enable=true;
plugins.cmp = {
enable = true;
autoEnableSources = true;
settings = {
sources = [
{name = "luasnip";}
{name = "treesitter";}
{name = "path";}
{name = "emoji";}
{name = "buffer";}
{name = "latex_symbols";}
{name = "digraphs";}
{name = "spell";}
];
snippet = {
expand = "luasnip";
};
mapping = {
"<C-Space>" = "cmp.mapping.complete()";
"<C-d>" = "cmp.mapping.scroll_docs(-4)";
"<C-e>" = "cmp.mapping.close()";
"<C-f>" = "cmp.mapping.scroll_docs(4)";
"<CR>" = "cmp.mapping.confirm({ select = false })";
"<Tab>" = ''
function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif require("luasnip").expand_or_jumpable() then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-expand-or-jump", true, true, true), "")
else
fallback()
end
end
'';
"<S-Tab>" = ''
function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif require("luasnip").jumpable(-1) then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-jump-prev", true, true, true), "")
else
fallback()
end
end
'';
};
};
};
};
}

22
nix/nvim/gitsigns.nix Normal file
View file

@ -0,0 +1,22 @@
{
configs,
pkgs,
...
}: {
programs.nixvim = {
plugins.gitsigns = {
enable = true;
};
keymaps = [
{
action = ":Gitsigns toggle_current_line_blame<CR>";
key = "<leader>gb";
mode = "n";
options = {
silent = true;
desc = "toggle git blame";
};
}
];
};
}

95
nix/nvim/keybinds.nix Normal file
View file

@ -0,0 +1,95 @@
{
configs,
pkgs,
...
}: {
programs.nixvim = {
globals = {
mapleader = ";";
};
keymaps = [
{
action = ":setlocal spell!<CR>";
key = "<leader>cs";
mode = "n";
options = {
silent = true;
desc = "toggle spell check";
};
}
{
action = ":bnext<CR>";
key = "gf";
mode = "n";
options = {
silent = true;
desc = "next buffer";
};
}
{
action = ":bprevious<CR>";
key = "gF";
mode = "n";
options = {
silent = true;
desc = "prev buffer";
};
}
{
action = "<C-w>h";
key = "<C-h>";
mode = "n";
options = {
silent = true;
desc = "move to right split";
};
}
{
action = "<C-w>j";
key = "<C-j>";
mode = "n";
options = {
silent = true;
desc = "move to below split";
};
}
{
action = "<C-w>k";
key = "<C-k>";
mode = "n";
options = {
silent = true;
desc = "move to above split";
};
}
{
action = "<C-w>l";
key = "<C-l>";
mode = "n";
options = {
silent = true;
desc = "move to left split";
};
}
{
action = "za";
key = "<Space>";
mode = "n";
options = {
silent = true;
desc = "toggle fold";
};
}
{
action = ":nohls<CR>";
key = "<leader>h";
mode = "n";
options = {
silent = true;
desc = "clear highlighting";
};
}
];
};
}

11
nix/nvim/lsp/lsp.nix Normal file
View file

@ -0,0 +1,11 @@
{
configs,
pkgs,
...
}: {
programs.nixvim = {
};
imports = [
# ./outline.nix
];
}

22
nix/nvim/lsp/outline.nix Normal file
View file

@ -0,0 +1,22 @@
{
configs,
pkgs,
...
}: {
programs.nixvim = {
keymaps = [
{
action = ":Outline<CR>";
key = "<leader>o";
mode = "n";
options = {
silent = true;
desc = "toggle outline";
};
}
];
extraPlugins = [
pkgs.vimPlugins.outline-nvim
];
};
}

View file

@ -1,6 +1,6 @@
{ {
configs, configs,
pkg, pkgs,
... ...
}: { }: {
programs.nixvim = { programs.nixvim = {

View file

@ -1,6 +1,6 @@
{ {
configs, configs,
pkg, pkgs,
... ...
}: { }: {
programs.nixvim = { programs.nixvim = {

View file

@ -1,6 +1,7 @@
{ {
configs, configs,
pkg, pkgs,
helpers,
... ...
}: { }: {
programs.nixvim = { programs.nixvim = {
@ -13,161 +14,20 @@
enable = true; enable = true;
}; };
options = {
mouse = "a";
lazyredraw = true;
termguicolors = true;
autoread = true;
swapfile = false;
history = 500;
formatoptions = "rojq";
# dont hard wrap
textwidth = 0;
wrapmargin = 0;
breakindent = true;
# highlight after col
colorcolumn = "80,100,120";
# add ruler to side of screen
number = true;
numberwidth = 3;
#display cursor cordinates
ruler = true;
#always leave 5 cells between cursor and side of window
scrolloff = 5;
# better command line completion
wildmenu = true;
# ignore case if all lowercase
ignorecase = true;
smartcase = true;
# show unfinished keycombos in statusbar
showcmd = true;
# regex stuff
magic = true;
# always show statusline
laststatus = 2;
# tab stuff
tabstop = 4;
shiftwidth = 0;
autoindent = true;
smartindent = true;
smarttab = true;
# for true tabs, change to false
expandtab = true;
softtabstop = -1;
# highlight search results as you type
hlsearch = true;
incsearch = true;
# folding stuff
foldlevelstart = 5;
foldmethod = "indent";
foldcolumn = "auto:4";
foldenable = true;
# display whitespace as other chars
list = true;
listchars = {
tab = ">-";
eol = "";
nbsp = "";
trail = "";
extends = "";
precedes = "";
};
showbreak = "";
};
clipboard.providers.xsel.enable = true; clipboard.providers.xsel.enable = true;
globals = {
mapleader = ";";
};
keymaps = [
{
action = ":setlocal spell!<CR>";
key = "<leader>cs";
mode = "n";
options = {
silent = true;
desc = "toggle spell check";
};
}
{
action = ":bnext<CR>";
key = "gf";
mode = "n";
options = {
silent = true;
desc = "next buffer";
};
}
{
action = ":bprevious<CR>";
key = "gF";
mode = "n";
options = {
silent = true;
desc = "prev buffer";
};
}
{
action = "<C-w>h";
key = "<C-h>";
mode = "n";
options = {
silent = true;
desc = "move to right split";
};
}
{
action = "<C-w>j";
key = "<C-j>";
mode = "n";
options = {
silent = true;
desc = "move to below split";
};
}
{
action = "<C-w>k";
key = "<C-k>";
mode = "n";
options = {
silent = true;
desc = "move to above split";
};
}
{
action = "<C-w>l";
key = "<C-l>";
mode = "n";
options = {
silent = true;
desc = "move to left split";
};
}
{
action = "za";
key = "<Space>";
mode = "n";
options = {
silent = true;
desc = "toggle fold";
};
}
{
action = ":nohls<CR>";
key = "<leader>h";
mode = "n";
options = {
silent = true;
desc = "clear highlighting";
};
}
];
}; };
imports = [ imports = [
./keybinds.nix
./options.nix
./simpleplugins.nix
./lualine.nix ./lualine.nix
./nvim-tree.nix ./nvim-tree.nix
./toggleterm.nix ./toggleterm.nix
./gitsigns.nix
./which-key.nix
./telescope.nix
./treesitter/treesitter.nix
./cmp/cmp.nix
./lsp/lsp.nix
]; ];
} }

70
nix/nvim/options.nix Normal file
View file

@ -0,0 +1,70 @@
{
configs,
pkgs,
lib,
...
}: {
programs.nixvim = {
options = {
mouse = "a";
lazyredraw = true;
termguicolors = true;
autoread = true;
swapfile = false;
history = 500;
formatoptions = "rojq";
# dont hard wrap
textwidth = 0;
wrapmargin = 0;
breakindent = true;
# highlight after col
colorcolumn = "80,100,120";
# add ruler to side of screen
number = true;
numberwidth = 3;
#display cursor cordinates
ruler = true;
#always leave 5 cells between cursor and side of window
scrolloff = 5;
# better command line completion
wildmenu = true;
# ignore case if all lowercase
ignorecase = true;
smartcase = true;
# show unfinished keycombos in statusbar
showcmd = true;
# regex stuff
magic = true;
# always show statusline
laststatus = 2;
# tab stuff
tabstop = 4;
shiftwidth = 0;
autoindent = true;
smartindent = true;
smarttab = true;
# for true tabs, change to false
expandtab = true;
softtabstop = -1;
# highlight search results as you type
hlsearch = true;
incsearch = true;
# folding stuff
foldlevelstart = 5;
foldmethod = lib.mkDefault "indent";
foldcolumn = "auto:4";
foldenable = true;
# display whitespace as other chars
list = true;
listchars = {
tab = ">-";
eol = "";
nbsp = "";
trail = "";
extends = "";
precedes = "";
};
showbreak = "";
};
};
}

View file

@ -0,0 +1,19 @@
{
configs,
pkgs,
...
}: {
programs.nixvim = {
plugins.comment-nvim.enable = true;
plugins.marks.enable = true;
plugins.surround.enable = true;
plugins.todo-comments.enable = true;
plugins.leap = {
enable = true;
addDefaultMappings = true;
};
extraPlugins = [
pkgs.vimPlugins.vim-numbertoggle
];
};
}

116
nix/nvim/telescope.nix Normal file
View file

@ -0,0 +1,116 @@
{
configs,
pkgs,
...
}: {
programs.nixvim = {
plugins.telescope = {
enable = true;
};
plugins.which-key.registrations = {
"<leader>f" = "+telescope";
"<leader>fg" = "+telescope git";
};
keymaps = [
{
action = ":Telescope find_files<CR>";
key = "<leader>ff";
mode = "n";
options = {
silent = true;
desc = "files";
};
}
{
action = ":Telescope live_grep<CR>";
key = "<leader>fg";
mode = "n";
options = {
silent = true;
desc = "grep";
};
}
{
action = ":Telescope buffers<CR>";
key = "<leader>fb";
mode = "n";
options = {
silent = true;
desc = "buffers";
};
}
{
action = ":Telescope marks<CR>";
key = "<leader>fm";
mode = "n";
options = {
silent = true;
desc = "marks";
};
}
{
action = ":Telescope registers<CR>";
key = "<leader>fr";
mode = "n";
options = {
silent = true;
desc = "registers";
};
}
{
action = ":Telescope keymaps<CR>";
key = "<leader>fk";
mode = "n";
options = {
silent = true;
desc = "keymaps";
};
}
{
action = ":Telescope current_buffer_fuzzy_find<CR>";
key = "<leader>fz";
mode = "n";
options = {
silent = true;
desc = "fuzzy find";
};
}
{
action = ":Telescope git_commits<CR>";
key = "<leader>fgc";
mode = "n";
options = {
silent = true;
desc = "commits";
};
}
{
action = ":Telescope git_branches<CR>";
key = "<leader>fgb";
mode = "n";
options = {
silent = true;
desc = "branches";
};
}
{
action = ":Telescope git_stash<CR>";
key = "<leader>fgs";
mode = "n";
options = {
silent = true;
desc = "stash";
};
}
{
action = ":Telescope git_commits<CR>";
key = "<leader>fgc";
mode = "n";
options = {
silent = true;
desc = "commits";
};
}
];
};
}

View file

@ -1,19 +1,19 @@
{ {
configs, configs,
pkg, pkgs,
... ...
}: { }: {
programs.nixvim = { programs.nixvim = {
plugins.toggleterm={ plugins.toggleterm = {
enable=true; enable = true;
direction="horizontal"; direction = "horizontal";
insertMappings=false; insertMappings = false;
}; };
keymaps = [ keymaps = [
{ {
action = "function() Floatingterm:toggle() end"; action = "function() Floatingterm:toggle() end";
key = "<leader>s"; key = "<leader>s";
lua=true; lua = true;
mode = "n"; mode = "n";
options = { options = {
silent = true; silent = true;

View file

@ -0,0 +1,20 @@
{
configs,
pkgs,
...
}: {
programs.nixvim = {
plugins.rainbow-delimiters = {
enable = true;
highlight = [
"RainbowDelimiterYellow"
"RainbowDelimiterBlue"
"RainbowDelimiterOrange"
"RainbowDelimiterGreen"
"RainbowDelimiterViolet"
"RainbowDelimiterCyan"
# "RainbowDelimiterRed"
];
};
};
}

View file

@ -0,0 +1,22 @@
{
configs,
pkgs,
...
}: {
programs.nixvim = {
plugins.treesitter = {
enable = true;
folding = true;
indent = true;
nixvimInjections = true;
};
plugins.treesitter-context.enable = true;
plugins.indent-blankline.enable = true;
extraPlugins = [
pkgs.vimPlugins.treesj
];
};
imports = [
./rainbow-delimiters.nix
];
}

15
nix/nvim/which-key.nix Normal file
View file

@ -0,0 +1,15 @@
{
configs,
pkgs,
...
}: {
programs.nixvim = {
options = {
timeout = true;
timeoutlen = 300;
};
plugins.which-key = {
enable = true;
};
};
}