[fix] nvim: I broke it again ma #11

Merged
jalil merged 1 commit from fix-nvim into main 2024-06-23 15:53:32 +02:00
8 changed files with 561 additions and 576 deletions
Showing only changes of commit 6c248db49a - Show all commits

View file

@ -93,7 +93,7 @@
system: system:
f { f {
inherit system; inherit system;
pkgs = import nixpkgs {inherit system;}; pkgs = nixpkgs.legacyPackages.${system};
} }
); );
overlays = builtins.attrValues self.overlays; overlays = builtins.attrValues self.overlays;
@ -110,7 +110,7 @@
in { in {
nvim = nixvim.lib.${system}.check.mkTestDerivationFromNixvimModule { nvim = nixvim.lib.${system}.check.mkTestDerivationFromNixvimModule {
pkgs = import nixpkgs {inherit system overlays;}; pkgs = import nixpkgs {inherit system overlays;};
module = ./nvim/nixvim.nix; module = ./nvim/standalone.nix;
}; };
fmt = pkgs.callPackage ./fmt.nix {inherit src;}; fmt = pkgs.callPackage ./fmt.nix {inherit src;};
lint = pkgs.callPackage ./lint.nix {inherit src;}; lint = pkgs.callPackage ./lint.nix {inherit src;};
@ -133,7 +133,7 @@
# Nvim standalone module # Nvim standalone module
nvim = nixvim.legacyPackages.${system}.makeNixvimWithModule { nvim = nixvim.legacyPackages.${system}.makeNixvimWithModule {
pkgs = import nixpkgs {inherit system overlays;}; pkgs = import nixpkgs {inherit system overlays;};
module = ./nvim/nixvim.nix; module = ./nvim/standalone.nix;
}; };
} }
); );
@ -204,9 +204,8 @@
nixvim.homeManagerModules.nixvim nixvim.homeManagerModules.nixvim
./nvim ./nvim
]; ];
overlays = builtins.attrValues self.overlays; homeManagerModuleSandalone = import ./home {inherit nvim-config stylix;};
homeManagerModuleSandalone = import ./home {inherit overlays nvim-config stylix;}; homeManagerModuleNixOS = import ./home {inherit nvim-config;};
homeManagerModuleNixOS = import ./home {inherit overlays nvim-config;};
nixosModule = { nixosModule = {
imports = imports =
[ [

View file

@ -1,5 +1,4 @@
{ {
overlays,
nvim-config, nvim-config,
stylix ? null, stylix ? null,
}: { }: {
@ -13,8 +12,6 @@
in { in {
imports = imports =
[ [
# Apply overlays
{nixpkgs = {inherit overlays;};}
nvim-config nvim-config
./options.nix ./options.nix
./gui ./gui

View file

@ -1,87 +1,89 @@
{helpers, ...}: let {helpers, ...}: let
inherit (helpers) mkRaw; inherit (helpers) mkRaw;
in { in {
autoGroups = { config = {
"highlightOnYank" = {}; autoGroups = {
"lspConfig" = {}; "highlightOnYank" = {};
"restoreCursorPosition" = {}; "lspConfig" = {};
}; "restoreCursorPosition" = {};
autoCmd = [ };
{ autoCmd = [
group = "highlightOnYank"; {
event = "TextYankPost"; group = "highlightOnYank";
pattern = "*"; event = "TextYankPost";
callback = mkRaw '' pattern = "*";
function() callback = mkRaw ''
vim.highlight.on_yank { function()
higroup = ( vim.highlight.on_yank {
vim.fn['hlexists'] 'HighlightedyankRegion' > 0 and 'HighlightedyankRegion' or 'IncSearch' higroup = (
), vim.fn['hlexists'] 'HighlightedyankRegion' > 0 and 'HighlightedyankRegion' or 'IncSearch'
timeout = 200, ),
} timeout = 200,
end }
'';
}
{
group = "restoreCursorPosition";
event = "BufReadPost";
pattern = "*";
callback = mkRaw ''
function()
if vim.fn.line '\'"' > 0 and vim.fn.line '\'"' <= vim.fn.line '$' then
vim.cmd [[execute "normal! g'\""]]
end
end
'';
}
{
group = "lspConfig";
event = "LspAttach";
pattern = "*";
callback = let
opts = "noremap = true, buffer = bufnr";
in
mkRaw ''
function(opts)
local bufnr = opts.buf
local client = vim.lsp.get_client_by_id(opts.data.client_id)
local capabilities = client.server_capabilities
-- Set Omnifunc if supported
if capabilities.completionProvider then
vim.bo[bufnr].omnifunc = "v:lua.vim.lsp.omnifunc"
end
-- Enable inlay hints if supported
if capabilities.inlayHintProvider then
vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
end
-- Some Lsp servers do not advertise inlay hints properly so enable this keybinding regardless
vim.keymap.set('n', '<space>ht', function()
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({bufnr = 0}), { bufnr = 0 })
end,
{ desc = '[H]ints [T]oggle', ${opts} }
)
-- Enable hover if supported
if capabilities.hoverProvider then
vim.keymap.set('n', 'K', vim.lsp.buf.hover, { desc = 'Hover Documentation', ${opts} })
end
-- Enable rename if supported
if capabilities.renameProvider then
vim.keymap.set('n', '<leader>r', vim.lsp.buf.rename, { desc = '[R]ename', ${opts} })
end
-- Enable code actions if supported
if capabilities.codeActionProvider then
vim.keymap.set({ 'n', 'v' }, '<leader>fa', vim.lsp.buf.code_action, { desc = '[F]ind Code [A]ctions', ${opts} })
end
-- Enable formatting if supported
if capabilities.documentFormattingProvider then
vim.keymap.set('n', '<leader>w', function() require("conform").format({ lsp_fallback = true }) end, { desc = 'Format Buffer', ${opts} })
end
-- Other keybinds
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, { desc = '[G]o to [D]efinition', ${opts} })
vim.keymap.set('n', 'gt', vim.lsp.buf.type_definition, { desc = '[G]o to [T]ype Definition', ${opts} })
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, { desc = '[G]o to [I]mplementation', ${opts} })
end end
''; '';
} }
]; {
group = "restoreCursorPosition";
event = "BufReadPost";
pattern = "*";
callback = mkRaw ''
function()
if vim.fn.line '\'"' > 0 and vim.fn.line '\'"' <= vim.fn.line '$' then
vim.cmd [[execute "normal! g'\""]]
end
end
'';
}
{
group = "lspConfig";
event = "LspAttach";
pattern = "*";
callback = let
opts = "noremap = true, buffer = bufnr";
in
mkRaw ''
function(opts)
local bufnr = opts.buf
local client = vim.lsp.get_client_by_id(opts.data.client_id)
local capabilities = client.server_capabilities
-- Set Omnifunc if supported
if capabilities.completionProvider then
vim.bo[bufnr].omnifunc = "v:lua.vim.lsp.omnifunc"
end
-- Enable inlay hints if supported
if capabilities.inlayHintProvider then
vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
end
-- Some Lsp servers do not advertise inlay hints properly so enable this keybinding regardless
vim.keymap.set('n', '<space>ht', function()
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({bufnr = 0}), { bufnr = 0 })
end,
{ desc = '[H]ints [T]oggle', ${opts} }
)
-- Enable hover if supported
if capabilities.hoverProvider then
vim.keymap.set('n', 'K', vim.lsp.buf.hover, { desc = 'Hover Documentation', ${opts} })
end
-- Enable rename if supported
if capabilities.renameProvider then
vim.keymap.set('n', '<leader>r', vim.lsp.buf.rename, { desc = '[R]ename', ${opts} })
end
-- Enable code actions if supported
if capabilities.codeActionProvider then
vim.keymap.set({ 'n', 'v' }, '<leader>fa', vim.lsp.buf.code_action, { desc = '[F]ind Code [A]ctions', ${opts} })
end
-- Enable formatting if supported
if capabilities.documentFormattingProvider then
vim.keymap.set('n', '<leader>w', function() require("conform").format({ lsp_fallback = true }) end, { desc = 'Format Buffer', ${opts} })
end
-- Other keybinds
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, { desc = '[G]o to [D]efinition', ${opts} })
vim.keymap.set('n', 'gt', vim.lsp.buf.type_definition, { desc = '[G]o to [T]ype Definition', ${opts} })
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, { desc = '[G]o to [I]mplementation', ${opts} })
end
'';
}
];
};
} }

View file

@ -1,14 +1,17 @@
{ {
lib, lib,
pkgs,
config, config,
helpers,
... ...
}: let }: let
# Force inputs to be included cfg = config.jhome.nvim;
nixvim = import ./nixvim.nix {inherit lib pkgs config helpers;};
in { in {
imports = [./options.nix]; imports = [./options.nix];
config.programs.nixvim = nixvim.config; config.programs.nixvim = lib.mkMerge [
./standalone.nix
(lib.mkIf cfg.enable {
enable = true;
defaultEditor = lib.mkDefault true;
})
];
} }

View file

@ -1,148 +1,150 @@
{helpers, ...}: let {helpers, ...}: let
inherit (helpers) mkRaw; inherit (helpers) mkRaw;
in [ in {
# Quickfix config.keymaps = [
{ # Quickfix
mode = "n"; {
key = "<leader>qo"; mode = "n";
action = "<cmd>Copen<CR>"; key = "<leader>qo";
options.desc = "Quickfix Open"; action = "<cmd>Copen<CR>";
} options.desc = "Quickfix Open";
{ }
mode = "n"; {
key = "<leader>qq"; mode = "n";
action = "<cmd>cclose<CR>"; key = "<leader>qq";
options.desc = "Quickfix Quit"; action = "<cmd>cclose<CR>";
} options.desc = "Quickfix Quit";
{ }
mode = "n"; {
key = "<leader>qj"; mode = "n";
action = "<cmd>cnext<CR>"; key = "<leader>qj";
options.desc = "Quickfix next [J]"; action = "<cmd>cnext<CR>";
} options.desc = "Quickfix next [J]";
{ }
mode = "n"; {
key = "<leader>qk"; mode = "n";
action = "<cmd>cprev<CR>"; key = "<leader>qk";
options.desc = "Quickfix previous [K]"; action = "<cmd>cprev<CR>";
} options.desc = "Quickfix previous [K]";
# Open or create file }
{ # Open or create file
mode = "n"; {
key = "<leader>gf"; mode = "n";
action = "<cmd>e <cfile><CR>"; key = "<leader>gf";
options.desc = "Go to File"; action = "<cmd>e <cfile><CR>";
} options.desc = "Go to File";
# Keep Selection when indenting }
{ # Keep Selection when indenting
mode = "x"; {
key = ">"; mode = "x";
action = ">gv"; key = ">";
options.desc = "Indent Selection"; action = ">gv";
} options.desc = "Indent Selection";
{ }
mode = "x"; {
key = "<"; mode = "x";
action = "<gv"; key = "<";
options.desc = "Deindent Selection"; action = "<gv";
} options.desc = "Deindent Selection";
# Diagnostics }
{ # Diagnostics
mode = "n"; {
key = "<leader>dj"; mode = "n";
action = mkRaw "vim.diagnostic.goto_next"; key = "<leader>dj";
options.desc = "Diagnostics next [J]"; action = mkRaw "vim.diagnostic.goto_next";
} options.desc = "Diagnostics next [J]";
{ }
mode = "n"; {
key = "<leader>dk"; mode = "n";
action = mkRaw "vim.diagnostic.goto_prev"; key = "<leader>dk";
options.desc = "Diagnostics previous [K]"; action = mkRaw "vim.diagnostic.goto_prev";
} options.desc = "Diagnostics previous [K]";
{ }
mode = "n"; {
key = "<leader>xx"; mode = "n";
action = mkRaw "require('trouble').toggle"; key = "<leader>xx";
options.desc = "Toggle trouble"; action = mkRaw "require('trouble').toggle";
} options.desc = "Toggle trouble";
{ }
mode = "n"; {
key = "<leader>xw"; mode = "n";
action = mkRaw "function() require('trouble').toggle('workspace_diagnostics') end"; key = "<leader>xw";
options.desc = "Toggle Workspace trouble"; action = mkRaw "function() require('trouble').toggle('workspace_diagnostics') end";
} options.desc = "Toggle Workspace trouble";
{ }
mode = "n"; {
key = "<leader>xd"; mode = "n";
action = mkRaw "function() require('trouble').toggle('document_diagnostics') end"; key = "<leader>xd";
options.desc = "Toggle Document trouble"; action = mkRaw "function() require('trouble').toggle('document_diagnostics') end";
} options.desc = "Toggle Document trouble";
{ }
mode = "n"; {
key = "<leader>xq"; mode = "n";
action = mkRaw "function() require('trouble').toggle('quickfix') end"; key = "<leader>xq";
options.desc = "Toggle Quickfix trouble"; action = mkRaw "function() require('trouble').toggle('quickfix') end";
} options.desc = "Toggle Quickfix trouble";
{ }
mode = "n"; {
key = "<leader>xl"; mode = "n";
action = mkRaw "function() require('trouble').toggle('loclist') end"; key = "<leader>xl";
options.desc = "Toggle Loclist trouble"; action = mkRaw "function() require('trouble').toggle('loclist') end";
} options.desc = "Toggle Loclist trouble";
{ }
mode = "n"; {
key = "gR"; mode = "n";
action = mkRaw "function() require('trouble').toggle('lsp_references') end"; key = "gR";
options.desc = "Toggle lsp References trouble"; action = mkRaw "function() require('trouble').toggle('lsp_references') end";
} options.desc = "Toggle lsp References trouble";
# Telescope }
{ # Telescope
mode = "n"; {
key = "<leader>ff"; mode = "n";
action = mkRaw "require('telescope.builtin').find_files"; key = "<leader>ff";
options.desc = "Find Files"; action = mkRaw "require('telescope.builtin').find_files";
} options.desc = "Find Files";
{ }
mode = "n"; {
key = "<leader>fg"; mode = "n";
action = mkRaw "require('telescope.builtin').live_grep"; key = "<leader>fg";
options.desc = "Find Grep"; action = mkRaw "require('telescope.builtin').live_grep";
} options.desc = "Find Grep";
{ }
mode = "n"; {
key = "<leader>fh"; mode = "n";
action = mkRaw "require('telescope.builtin').help_tags"; key = "<leader>fh";
options.desc = "Find Help"; action = mkRaw "require('telescope.builtin').help_tags";
} options.desc = "Find Help";
{ }
mode = "n"; {
key = "<leader>fb"; mode = "n";
action = mkRaw "require('telescope.builtin').buffers"; key = "<leader>fb";
options.desc = "Find Buffer"; action = mkRaw "require('telescope.builtin').buffers";
} options.desc = "Find Buffer";
{ }
mode = "n"; {
key = "<leader>fd"; mode = "n";
action = mkRaw "require('telescope.builtin').diagnostics"; key = "<leader>fd";
options.desc = "Find Diagnostics"; action = mkRaw "require('telescope.builtin').diagnostics";
} options.desc = "Find Diagnostics";
{ }
mode = "n"; {
key = "<leader>fq"; mode = "n";
action = mkRaw "require('telescope.builtin').quickfix"; key = "<leader>fq";
options.desc = "Find Quickfix"; action = mkRaw "require('telescope.builtin').quickfix";
} options.desc = "Find Quickfix";
{ }
mode = "n"; {
key = "<leader>w"; mode = "n";
action = mkRaw "require('conform').format"; key = "<leader>w";
options.desc = "Format buffer"; action = mkRaw "require('conform').format";
} options.desc = "Format buffer";
# Nvim Silicon }
{ # Nvim Silicon
mode = "v"; {
key = "<leader>sc"; mode = "v";
action = mkRaw "require('nvim-silicon').clip"; key = "<leader>sc";
options.desc = "Snap Code (to clipboard)"; action = mkRaw "require('nvim-silicon').clip";
} options.desc = "Snap Code (to clipboard)";
] }
];
}

View file

@ -1,112 +0,0 @@
{
pkgs,
lib,
config,
...
} @ args: let
cfg = config.jhome.nvim;
hmAvailable = args ? hmConfig;
nixosAvailable = args ? nixosConfig;
darwinAvailable = args ? darwinConfig;
canSetAsDefault = hmAvailable || nixosAvailable;
notStandalone = hmAvailable || nixosAvailable || darwinAvailable;
augroups = import ./augroups.nix args;
in {
imports = [./options.nix];
config = lib.mkMerge [
(lib.optionalAttrs canSetAsDefault {defaultEditor = lib.mkDefault true;})
(lib.optionalAttrs notStandalone {enable = lib.mkDefault true;})
(lib.mkIf cfg.enable {
package = pkgs.unstable.neovim-unwrapped;
inherit (augroups) autoGroups autoCmd;
plugins = import ./plugins.nix args;
keymaps = import ./mappings.nix args;
globals.mapleader = " ";
# Appearance
colorschemes.gruvbox = {
enable = true;
settings = {
bold = true;
transparent_mode = true;
terminal_colors = true;
};
};
clipboard.providers.wl-copy.enable = true;
opts = {
number = true;
relativenumber = true;
colorcolumn = "+1";
cursorline = true;
wrap = false;
splitright = true;
# Tabs & indentation
smarttab = true;
autoindent = true;
smartindent = true;
# Search path
path = ".,/usr/include,**";
wildmenu = true;
hlsearch = true;
incsearch = true;
ignorecase = true; # Search ignores cases
smartcase = true; # Unless it has a capital letter
# Enable local configuration :h 'exrc'
exrc = true; # safe since nvim 0.9
};
extraPlugins = let
plugins = pkgs.unstable.vimPlugins;
extraPlugins = import ./extraPlugins {pkgs = pkgs.unstable;};
in [
plugins.nui-nvim
plugins.nvim-web-devicons
extraPlugins.vim-jjdescription
extraPlugins.nvim-silicon
];
# Formatting & linters
extraPackages = [
pkgs.unstable.silicon
pkgs.unstable.alejandra
pkgs.unstable.luajitPackages.jsregexp
pkgs.unstable.statix
pkgs.unstable.stylua
pkgs.unstable.shfmt
pkgs.unstable.taplo
pkgs.unstable.typos
pkgs.unstable.yamlfmt
];
extraConfigLuaPre = ''
-- Lua Pre Config
if vim.fn.has 'termguicolors' then
-- Enable RGB colors
vim.g.termguicolors = true
end
-- Useful function
local has_words_before = function()
-- unpack = unpack or table.unpack
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0
and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match '%s' == nil
end
-- END: Lua Pre Config
'';
extraConfigLua = ''
-- Lua Config
require("nvim-silicon").setup {
theme = "gruvbox-dark",
pad_horiz = 16,
pad_vert = 16,
-- Current buffer name
window_title = function()
return vim.fn.fnamemodify(
vim.api.nvim_buf_get_name(vim.api.nvim_get_current_buf()),
":t"
)
end,
}
-- END: Lua Config
'';
})
];
}

View file

@ -6,237 +6,239 @@
}: let }: let
inherit (helpers) mkRaw; inherit (helpers) mkRaw;
in { in {
bacon = { config.plugins = {
enable = true; bacon = {
settings.quickfix.enabled = true; enable = true;
}; settings.quickfix.enabled = true;
cmp = {
enable = true;
cmdline = {
"/" = {
mapping = mkRaw "cmp.mapping.preset.cmdline()";
sources = [
{name = "rg";}
{name = "buffer";}
];
};
":" = {
mapping = mkRaw "cmp.mapping.preset.cmdline()";
sources = [
{name = "path";}
{name = "cmdline";}
];
};
}; };
settings = { cmp = {
# Snippets enable = true;
snippet.expand = "function(args) require('luasnip').lsp_expand(args.body) end"; cmdline = {
# Completion Sources "/" = {
sources = [ mapping = mkRaw "cmp.mapping.preset.cmdline()";
{ sources = [
name = "buffer"; {name = "rg";}
groupIndex = 3; {name = "buffer";}
} ];
{ };
name = "calc"; ":" = {
groupIndex = 2; mapping = mkRaw "cmp.mapping.preset.cmdline()";
} sources = [
{ {name = "path";}
name = "conventionalcommits"; {name = "cmdline";}
groupIndex = 1; ];
}
{
name = "crates";
groupIndex = 1;
}
{
name = "luasnip";
groupIndex = 1;
}
{
name = "nvim_lsp";
groupIndex = 1;
}
{
name = "nvim_lsp_document_symbol";
groupIndex = 1;
}
{
name = "nvim_lsp_signature_help";
groupIndex = 1;
}
{
name = "path";
groupIndex = 2;
}
{
name = "spell";
groupIndex = 2;
}
{
name = "treesitter";
groupIndex = 2;
}
{
name = "zsh";
groupIndex = 1;
}
];
mapping = mkRaw ''
cmp.mapping.preset.insert({
["<C-n>"] = function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif require("luasnip").expand_or_jumpable() then
require("luasnip").expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end,
["<C-p>"] = function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif require("luasnip").jumpable(-1) then
require("luasnip").jump(-1)
else
fallback()
end
end,
["<C-u>"] = cmp.mapping(function(fallback)
if require("luasnip").choice_active() then
require("luasnip").next_choice()
else
fallback()
end
end),
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete { },
["<C-e>"] = cmp.mapping.close(),
["<CR>"] = cmp.mapping.confirm { select = true },
})
'';
};
};
# FIXME: doesn't include formatters
conform-nvim = {
enable = true;
formattersByFt = {
"_" = ["trim_whitespace"];
c = ["clang_format"];
cpp = ["clang_format"];
lua = ["stylua"];
nix = ["alejandra"];
rust = ["rustfmt"];
sh = ["shfmt"];
toml = ["taplo"];
yaml = ["yamlfmt"];
zig = ["zigfmt"];
};
};
gitsigns.enable = true;
lint = {
enable = true;
lintersByFt = {
rust = ["typos"];
latex = ["chktex" "typos"];
markdown = ["typos"];
nix = ["statix"];
sh = ["dash"];
zsh = ["zsh"];
};
};
lsp = {
enable = true;
servers = {
bashls.enable = true;
bashls.package = pkgs.unstable.bash-language-server;
# clangd.enable = true; # Adds ~2GiB
html.enable = true;
jsonls.enable = true;
marksman.enable = true;
nixd.enable = true;
nil-ls = {
enable = true;
settings.nix.flake = {
autoArchive = true;
autoEvalInputs = true;
}; };
}; };
ruff-lsp.enable = true; settings = {
taplo.enable = true; # Snippets
# texlab.enable = true; # Not writing TeX rn snippet.expand = "function(args) require('luasnip').lsp_expand(args.body) end";
typos-lsp.enable = true; # Completion Sources
typst-lsp.enable = true; sources = [
{
name = "buffer";
groupIndex = 3;
}
{
name = "calc";
groupIndex = 2;
}
{
name = "conventionalcommits";
groupIndex = 1;
}
{
name = "crates";
groupIndex = 1;
}
{
name = "luasnip";
groupIndex = 1;
}
{
name = "nvim_lsp";
groupIndex = 1;
}
{
name = "nvim_lsp_document_symbol";
groupIndex = 1;
}
{
name = "nvim_lsp_signature_help";
groupIndex = 1;
}
{
name = "path";
groupIndex = 2;
}
{
name = "spell";
groupIndex = 2;
}
{
name = "treesitter";
groupIndex = 2;
}
{
name = "zsh";
groupIndex = 1;
}
];
mapping = mkRaw ''
cmp.mapping.preset.insert({
["<C-n>"] = function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif require("luasnip").expand_or_jumpable() then
require("luasnip").expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end,
["<C-p>"] = function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif require("luasnip").jumpable(-1) then
require("luasnip").jump(-1)
else
fallback()
end
end,
["<C-u>"] = cmp.mapping(function(fallback)
if require("luasnip").choice_active() then
require("luasnip").next_choice()
else
fallback()
end
end),
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete { },
["<C-e>"] = cmp.mapping.close(),
["<CR>"] = cmp.mapping.confirm { select = true },
})
'';
};
}; };
}; # FIXME: doesn't include formatters
lspkind = { conform-nvim = {
enable = true; enable = true;
mode = "symbol"; formattersByFt = {
extraOptions.maxwidth = 50; "_" = ["trim_whitespace"];
}; c = ["clang_format"];
lualine = { cpp = ["clang_format"];
enable = true; lua = ["stylua"];
theme = lib.mkForce "gruvbox"; nix = ["alejandra"];
}; rust = ["rustfmt"];
luasnip = { sh = ["shfmt"];
enable = true; toml = ["taplo"];
extraConfig = { yaml = ["yamlfmt"];
update_events = "TextChanged,TextChangedI"; zig = ["zigfmt"];
};
}; };
}; gitsigns.enable = true;
noice = { lint = {
enable = true; enable = true;
lsp.override = { lintersByFt = {
"vim.lsp.util.convert_input_to_markdown_lines" = true; rust = ["typos"];
"vim.lsp.util.stylize_markdown" = true; latex = ["chktex" "typos"];
"cmp.entry.get_documentation" = true; markdown = ["typos"];
nix = ["statix"];
sh = ["dash"];
zsh = ["zsh"];
};
}; };
presets = { lsp = {
# use a classic bottom cmdline for search enable = true;
bottom_search = true; servers = {
# position the cmdline and popupmenu together bashls.enable = true;
command_palette = false; bashls.package = pkgs.unstable.bash-language-server;
# long messages will be sent to a split # clangd.enable = true; # Adds ~2GiB
long_message_to_split = true; html.enable = true;
# enables an input dialog for inc-rename.nvim jsonls.enable = true;
inc_rename = false; marksman.enable = true;
# add a border to hover docs and signature help nixd.enable = true;
lsp_doc_border = true; nil-ls = {
enable = true;
settings.nix.flake = {
autoArchive = true;
autoEvalInputs = true;
};
};
ruff-lsp.enable = true;
taplo.enable = true;
# texlab.enable = true; # Not writing TeX rn
typos-lsp.enable = true;
typst-lsp.enable = true;
};
}; };
}; lspkind = {
notify = { enable = true;
enable = true; mode = "symbol";
backgroundColour = "#000000"; extraOptions.maxwidth = 50;
};
nvim-colorizer = {
enable = true;
userDefaultOptions = {
names = false; # disable named colors (i.e. red)
mode = "virtualtext";
}; };
}; lualine = {
rustaceanvim = { enable = true;
enable = true; theme = lib.mkForce "gruvbox";
# Install through rustup };
rustAnalyzerPackage = null; luasnip = {
}; enable = true;
telescope = { extraConfig = {
enable = true; update_events = "TextChanged,TextChangedI";
extensions = { };
ui-select.enable = true; };
fzy-native.enable = true; noice = {
enable = true;
lsp.override = {
"vim.lsp.util.convert_input_to_markdown_lines" = true;
"vim.lsp.util.stylize_markdown" = true;
"cmp.entry.get_documentation" = true;
};
presets = {
# use a classic bottom cmdline for search
bottom_search = true;
# position the cmdline and popupmenu together
command_palette = false;
# long messages will be sent to a split
long_message_to_split = true;
# enables an input dialog for inc-rename.nvim
inc_rename = false;
# add a border to hover docs and signature help
lsp_doc_border = true;
};
};
notify = {
enable = true;
backgroundColour = "#000000";
};
nvim-colorizer = {
enable = true;
userDefaultOptions = {
names = false; # disable named colors (i.e. red)
mode = "virtualtext";
};
};
rustaceanvim = {
enable = true;
# Install through rustup
rustAnalyzerPackage = null;
};
telescope = {
enable = true;
extensions = {
ui-select.enable = true;
fzy-native.enable = true;
};
};
treesitter = {
enable = true;
indent = true;
incrementalSelection.enable = true;
};
trouble = {
enable = true;
settings.auto_close = true;
}; };
};
treesitter = {
enable = true;
indent = true;
incrementalSelection.enable = true;
};
trouble = {
enable = true;
settings.auto_close = true;
}; };
} }

92
nvim/standalone.nix Normal file
View file

@ -0,0 +1,92 @@
{pkgs, ...}: {
imports = [./options.nix ./plugins.nix ./mappings.nix ./augroups.nix];
config = {
package = pkgs.unstable.neovim-unwrapped;
globals.mapleader = " ";
# Appearance
colorschemes.gruvbox = {
enable = true;
settings = {
bold = true;
transparent_mode = true;
terminal_colors = true;
};
};
clipboard.providers.wl-copy.enable = true;
opts = {
number = true;
relativenumber = true;
colorcolumn = "+1";
cursorline = true;
wrap = false;
splitright = true;
# Tabs & indentation
smarttab = true;
autoindent = true;
smartindent = true;
# Search path
path = ".,/usr/include,**";
wildmenu = true;
hlsearch = true;
incsearch = true;
ignorecase = true; # Search ignores cases
smartcase = true; # Unless it has a capital letter
# Enable local configuration :h 'exrc'
exrc = true; # safe since nvim 0.9
};
extraPlugins = let
plugins = pkgs.unstable.vimPlugins;
extraPlugins = import ./extraPlugins {pkgs = pkgs.unstable;};
in [
plugins.nui-nvim
plugins.nvim-web-devicons
extraPlugins.vim-jjdescription
extraPlugins.nvim-silicon
];
# Formatting & linters
extraPackages = [
pkgs.unstable.silicon
pkgs.unstable.alejandra
pkgs.unstable.luajitPackages.jsregexp
pkgs.unstable.statix
pkgs.unstable.stylua
pkgs.unstable.shfmt
pkgs.unstable.taplo
pkgs.unstable.typos
pkgs.unstable.yamlfmt
];
extraConfigLuaPre = ''
-- Lua Pre Config
if vim.fn.has 'termguicolors' then
-- Enable RGB colors
vim.g.termguicolors = true
end
-- Useful function
local has_words_before = function()
-- unpack = unpack or table.unpack
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0
and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match '%s' == nil
end
-- END: Lua Pre Config
'';
extraConfigLua = ''
-- Lua Config
require("nvim-silicon").setup {
theme = "gruvbox-dark",
pad_horiz = 16,
pad_vert = 16,
-- Current buffer name
window_title = function()
return vim.fn.fnamemodify(
vim.api.nvim_buf_get_name(vim.api.nvim_get_current_buf()),
":t"
)
end,
}
-- END: Lua Config
'';
};
}