neovim: migrate config from nixvim to nvf

This commit is contained in:
Anthony Rodriguez 2024-09-24 15:09:24 +02:00
parent 0a65675d06
commit 5ca57843d6
Signed by: nezia
GPG key ID: EE3BE97C040A86CE
19 changed files with 2185 additions and 628 deletions

1982
flake.lock

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,62 @@
{
description = "nezia's nixos configuration";
outputs =
{
nixpkgs,
home-manager,
nixvim,
nvf,
sops-nix,
stylix,
...
}@inputs:
let
username = "nezia";
system = "x86_64-linux";
commonModules = hostname: [
./modules
./hosts/common
./hosts/${hostname}
sops-nix.nixosModules.sops
stylix.nixosModules.stylix
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.sharedModules = [
nixvim.homeManagerModules.nixvim
];
home-manager.extraSpecialArgs = {
inherit inputs system;
};
}
{
_module.args = {
inherit hostname username;
};
}
];
configureSystem =
hostname: homeConfig:
nixpkgs.lib.nixosSystem {
system = system;
modules = commonModules hostname ++ [ { home-manager.users."${username}" = import homeConfig; } ];
specialArgs = {
inherit inputs;
};
};
in
{
nixosConfigurations = {
vamos = configureSystem "vamos" ./home/laptop;
solaire = configureSystem "solaire" ./home/desktop;
};
};
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixvim = {
@ -20,42 +77,10 @@
inputs.nixpkgs.follows = "nixpkgs";
};
zen-browser.url = "github:MarceColl/zen-browser-flake";
nvf = {
url = "github:notashelf/nvf";
inputs.nixpkgs.follows = "nixpkgs";
};
nixos-hardware.url = "github:NixOS/nixos-hardware";
};
outputs = { nixpkgs, home-manager, nixvim, sops-nix, stylix, ... }@inputs:
let
username = "nezia";
system = "x86_64-linux";
commonModules = hostname: [
./modules
./hosts/common
./hosts/${hostname}
sops-nix.nixosModules.sops
stylix.nixosModules.stylix
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.sharedModules = [
nixvim.homeManagerModules.nixvim
];
home-manager.extraSpecialArgs = { inherit inputs system; };
}
{ _module.args = { inherit hostname username; }; }
];
configureSystem = hostname: homeConfig: nixpkgs.lib.nixosSystem {
system = system;
modules = commonModules hostname ++ [ { home-manager.users."${username}" = import homeConfig; } ];
specialArgs = {inherit inputs; };
};
in {
nixosConfigurations = {
vamos = configureSystem "vamos" ./home/laptop;
solaire = configureSystem "solaire" ./home/desktop;
};
};
}

View file

@ -1,10 +1,8 @@
_:
{
imports = [
./git.nix
_: {
imports = [
./git.nix
./gnupg.nix
# ./wezterm.nix
./nixvim
./browsers.nix
./miscellaneous.nix
];

View file

@ -1,17 +0,0 @@
{ ... }:
{
programs.nixvim.autoCmd = [{
event = [ "BufWritePre" ];
callback = {
__raw = ''
function()
vim.lsp.buf.format { async = false }
end
'';
};
desc = "Auto format buffer before save using LSP";
}];
}

View file

@ -1,36 +0,0 @@
{ ... }:
{
programs.nixvim = {
enable = true;
defaultEditor = true;
viAlias = true;
vimAlias = true;
performance.byteCompileLua.enable = true;
colorschemes.catppuccin = {
enable = true;
settings.flavour = "frappe";
};
clipboard.providers.wl-copy.enable = true;
globals.mapleader = " ";
opts = {
relativenumber = true;
clipboard = "unnamedplus";
};
files = {
"ftplugin/nix.lua" = {
opts = {
expandtab = true;
shiftwidth = 2;
tabstop = 2;
};
};
};
};
}

View file

@ -1,18 +0,0 @@
_:
{
imports = [
./core.nix
./keymaps.nix
./autocmds.nix
./plugins/alpha.nix
./plugins/lsp.nix
./plugins/lualine.nix
./plugins/neo-tree.nix
./plugins/which-key.nix
./plugins/project-nvim.nix
./plugins/smart-splits.nix
./plugins/telescope.nix
./plugins/misc.nix
];
}

View file

@ -1,13 +0,0 @@
{ ... }:
{
programs.nixvim.keymaps = [
{
action = "<cmd>Neotree toggle<CR>";
key = "<leader>t";
options = {
desc = "Neotree";
};
}
];
}

View file

@ -1,68 +0,0 @@
{ ... }:
{
programs.nixvim = {
plugins = {
alpha = {
enable = true;
layout = [
{
type = "padding";
val = 2;
}
{
opts = {
hl = "Keyword";
position = "center";
};
type = "text";
val = [
""
""
""
""
""
""
""
""
""
""
""
""
""
""
];
}
{
type = "padding";
val = 2;
}
{
type = "group";
val = let
mkButton = shortcut: cmd: val: hl: {
type = "button";
inherit val;
opts = {
inherit hl shortcut;
keymap = [ "n" shortcut cmd { } ];
position = "center";
cursor = 0;
width = 40;
align_shortcut = "right";
hl_shortcut = "Keyword";
};
};
in [
(mkButton "f" "<CMD>:Telescope find_files<CR>" " Find File"
"Operator")
(mkButton "p" "<CMD>:Telescope projects<CR>" " Projects"
"Operator")
(mkButton "q" "<CMD>qa<CR>" "󰈆 Quit" "Error")
];
}
];
};
};
};
}

View file

@ -1,186 +0,0 @@
{ ... }:
{
programs.nixvim = {
opts = {
tabstop = 4;
shiftwidth = 4;
softtabstop = 0;
expandtab = true;
smartindent = true;
};
plugins = {
treesitter = {
enable = true;
settings = {
auto_install = true;
highlight = {
additional_vim_regex_highlighting = true;
custom_captures = { };
enable = true;
};
indent.enable = false;
folding = true;
parser_install_dir = {
__raw = "vim.fs.joinpath(vim.fn.stdpath('data'), 'treesitter')";
};
};
};
treesitter-context = {
enable = true;
settings = {
line_numbers = true;
max_lines = 0;
min_window_height = 0;
mode = "cursor";
multiline_threshold = 5;
separator = "-";
trim_scope = "inner";
zindex = 20;
};
};
indent-blankline = {
enable = true;
settings =
{
exclude = {
buftypes = [
"terminal"
"quickfix"
];
filetypes = [
""
"checkhealth"
"help"
"lspinfo"
"packer"
"TelescopePrompt"
"TelescopeResults"
"yaml"
];
};
indent = {
char = "";
};
scope = {
show_end = false;
show_exact_scope = true;
show_start = false;
};
};
};
lsp = {
enable = true;
servers = {
gopls.enable = true;
nixd.enable = true;
lua-ls.enable = true;
pylsp.enable = true;
clangd = {
enable = true;
cmd = [
"clangd"
"--fallback-style=webkit"
];
};
};
keymaps = {
lspBuf = {
gr = {
action = "references";
desc = "Go to references";
};
gi = {
action = "implementation";
desc = "Go to implementation";
};
gt = {
action = "type_definition";
desc = "Go to type definition";
};
};
extra = [
{
action = "<CMD>LspStop<Enter>";
key = "<leader>lx";
options = {
desc = "Stop LSP";
};
}
{
action = "<CMD>LspStart<Enter>";
key = "<leader>ls";
options = {
desc = "Start LSP";
};
}
{
action = "<CMD>LspRestart<Enter>";
key = "<leader>lr";
options = {
desc = "Restart LSP";
};
}
{
action = "<CMD>Telescope lsp_definitions<Enter>";
key = "gd";
options = {
desc = "Go to definitions";
};
}
];
};
};
cmp = {
enable = true;
autoEnableSources = true;
settings = {
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 = true })";
"<S-Tab>" = ''
cmp.mapping(function (fallback)
local luasnip = require('luasnip')
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, {'i', 's'})
'';
"<Tab>" = ''
cmp.mapping(function (fallback)
local luasnip = require('luasnip')
if luasnip.expandable() then
luasnip.expand()
elseif cmp.visible() then
cmp.select_next_item()
elseif luasnip.jumpable(1) then
luasnip.jump(1)
else
fallback()
end
end, {'i', 's'})
'';
};
sources =
[ { name = "nvim_lsp"; } { name = "path"; } { name = "buffer"; } { name = "luasnip"; } ];
};
};
cmp-nvim-lsp.enable = true;
cmp-nvim-lsp-signature-help.enable = true;
telescope = {
enable = true;
};
luasnip.enable = true;
friendly-snippets.enable = true;
};
};
}

View file

@ -1,9 +0,0 @@
{ ... }:
{
programs.nixvim.plugins.lualine = {
enable = true;
extensions = [ "neo-tree" ];
globalstatus = true;
};
}

View file

@ -1,8 +0,0 @@
{ ... }:
{
programs.nixvim.plugins = {
nvim-autopairs.enable = true;
direnv.enable = true;
};
}

View file

@ -1,8 +0,0 @@
{ ... }:
{
programs.nixvim.plugins.neo-tree = {
enable = true;
useDefaultMappings = true;
};
}

View file

@ -1,8 +0,0 @@
{ ... }:
{
programs.nixvim.plugins.project-nvim = {
enable = true;
enableTelescope = true;
};
}

View file

@ -1,117 +0,0 @@
{
programs.nixvim = {
plugins.smart-splits = {
enable = true;
settings = {
ignored_events = [
"BufEnter"
"WinEnter"
];
resize_mode = {
quit_key = "<ESC>";
resize_keys = [
"h"
"j"
"k"
"l"
];
silent = true;
};
};
};
keymaps = [
{
action = "<cmd>lua require('smart-splits').resize_left()<CR>";
key = "<A-h>";
options = {
desc = "Resize split to the left";
};
}
{
action = "<cmd>lua require('smart-splits').resize_down()<CR>";
key = "<A-j>";
options = {
desc = "Resize split downwards";
};
}
{
action = "<cmd>lua require('smart-splits').resize_up()<CR>";
key = "<A-k>";
options = {
desc = "Resize split upwards";
};
}
{
action = "<cmd>lua require('smart-splits').resize_right()<CR>";
key = "<A-l>";
options = {
desc = "Resize split to the right";
};
}
{
action = "<cmd>lua require('smart-splits').move_cursor_left()<CR>";
key = "<C-h>";
options = {
desc = "Move cursor to the left split";
};
}
{
action = "<cmd>lua require('smart-splits').move_cursor_down()<CR>";
key = "<C-j>";
options = {
desc = "Move cursor to the downward split";
};
}
{
action = "<cmd>lua require('smart-splits').move_cursor_up()<CR>";
key = "<C-k>";
options = {
desc = "Move cursor to the upward split";
};
}
{
action = "<cmd>lua require('smart-splits').move_cursor_right()<CR>";
key = "<C-l>";
options = {
desc = "Move cursor to the right split";
};
}
{
action = "<cmd>lua require('smart-splits').move_cursor_previous()<CR>";
key = "<C-\\>";
options = {
desc = "Move cursor to the previous split";
};
}
{
action = "<cmd>lua require('smart-splits').swap_buf_left()<CR>";
key = "<leader><leader>h>";
options = {
desc = "Swap buffer to the left";
};
}
{
action = "<cmd>lua require('smart-splits').swap_buf_down()<CR>";
key = "<leader><leader>j>";
options = {
desc = "Swap buffer downwards";
};
}
{
action = "<cmd>lua require('smart-splits').swap_buf_up()<CR>";
key = "<leader><leader>k>";
options = {
desc = "Swap buffer upwards";
};
}
{
action = "<cmd>lua require('smart-splits').swap_buf_right()<CR>";
key = "<leader><leader>l>";
options = {
desc = "Swap buffer to the right";
};
}
];
};
}

View file

@ -1,39 +0,0 @@
{ ... }:
{
programs.nixvim.plugins.telescope = {
enable = true;
keymaps = {
"<C-p>" = {
action = "git_files";
options = {
desc = "Telescope Git Files";
};
};
"<leader>fg" = {
action = "live_grep";
options = {
desc = "Live grep";
};
};
"<leader>ff" = {
action = "find_files";
options = {
desc = "Files";
};
};
"<leader>fp" = {
action = "projects";
options = {
desc = "Projects";
};
};
"<leader>fb" = {
action = "buffers";
options = {
desc = "Buffers";
};
};
};
};
}

View file

@ -1,32 +0,0 @@
{ ... }:
{
programs.nixvim.plugins.which-key = {
enable = true;
settings = {
delay = 200;
expand = 1;
notify = false;
preset = false;
replace = {
desc = [
[ "<space>" "SPACE" ]
[ "<leader>" "SPACE" ]
[ "<[cC][rR]>" "RETURN" ]
[ "<[tT][aA][bB]>" "TAB" ]
[ "<[bB][sS]>" "BACKSPACE" ]
];
};
spec = [
{
__unkeyed = "<leader>f";
group = "Telescope";
}
{
__unkeyed = "<leader>l";
group = "LSP";
}
];
};
};
}

View file

@ -1,26 +1,27 @@
{ inputs, ... }:
{
imports = [
./hardware-configuration.nix
inputs.nixos-hardware.nixosModules.framework-13-7040-amd
];
imports = [
./hardware-configuration.nix
inputs.nixos-hardware.nixosModules.framework-13-7040-amd
];
services.fprintd.enable = true;
services.power-profiles-daemon.enable = true;
services.fprintd.enable = true;
services.power-profiles-daemon.enable = true;
services.keyd = {
enable = true;
keyboards = {
default = {
ids = [ "*" ];
settings = {
main = {
capslock = "overload(control, esc)";
};
};
};
};
};
services.keyd = {
enable = true;
keyboards = {
default = {
ids = [ "*" ];
settings = {
main = {
capslock = "overload(control, esc)";
};
};
};
};
};
config.modules.neovim.enable = true;
}

View file

@ -8,5 +8,6 @@ _:
./gaming.nix
./wezterm.nix
./stylix.nix
./neovim.nix
];
}

127
modules/neovim.nix Normal file
View file

@ -0,0 +1,127 @@
{
config,
inputs,
lib,
pkgs,
username,
...
}:
let
cfg = config.modules.neovim;
in
{
options.modules.neovim.enable = lib.mkEnableOption "neovim";
config = lib.mkIf cfg.enable {
environment.sessionVariables = {
EDITOR = "nvim";
};
home-manager.users.${username} = {
imports = [ inputs.nvf.homeManagerModules.default ];
programs.nvf = {
enable = true;
settings.vim = {
viAlias = true;
vimAlias = true;
enableLuaLoader = true;
preventJunkFiles = true;
tabWidth = 4;
autoIndent = false;
useSystemClipboard = true;
luaConfigPost = lib.concatStrings [
''
vim.opt.formatoptions:remove('c')
vim.opt.formatoptions:remove('r')
vim.opt.formatoptions:remove('o')
''
];
theme = {
enable = true;
name = "catppuccin";
style = "frappe";
};
maps = {
normal = {
"<leader>t" = {
action = "<CMD>Neotree toggle<CR>";
silent = true;
};
};
};
statusline.lualine = {
enable = true;
theme = "catppuccin";
};
lsp = {
enable = true;
lspSignature.enable = true;
lspconfig.enable = true;
formatOnSave = true;
mappings = {
addWorkspaceFolder = "<leader>wa";
codeAction = "<leader>a";
goToDeclaration = "gD";
goToDefinition = "gd";
hover = "K";
listImplementations = "gi";
listReferences = "gr";
listWorkspaceFolders = "<leader>wl";
nextDiagnostic = "<leader>k";
previousDiagnostic = "<leader>j";
openDiagnosticFloat = "<leader>e";
removeWorkspaceFolder = "<leader>wr";
renameSymbol = "<leader>r";
signatureHelp = "<C-k>";
};
};
autocomplete = {
enable = true;
alwaysComplete = true;
};
autopairs.enable = true;
languages = {
enableExtraDiagnostics = true;
enableFormat = true;
enableLSP = true;
enableTreesitter = true;
nix.enable = true;
clang.enable = true;
python.enable = true;
};
treesitter = {
enable = true;
fold = true;
context.enable = true;
grammars = [
pkgs.vimPlugins.nvim-treesitter.builtGrammars.nix
pkgs.vimPlugins.nvim-treesitter.builtGrammars.c
pkgs.vimPlugins.nvim-treesitter.builtGrammars.python
];
};
binds.whichKey.enable = true;
visuals.nvimWebDevicons.enable = true;
filetree.neo-tree = {
enable = true;
setupOpts = {
git_status_async = true;
};
};
telescope.enable = true;
};
};
};
};
}