Switch to using nixvim and setup full config

This commit is contained in:
Julian Mutter 2024-10-26 13:44:29 +02:00
parent 63a548d6b9
commit 7718fb4118
3 changed files with 358 additions and 52 deletions

216
flake.lock generated
View File

@ -87,6 +87,27 @@
"type": "github"
}
},
"devshell_2": {
"inputs": {
"nixpkgs": [
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1728330715,
"narHash": "sha256-xRJ2nPOXb//u1jaBnDP56M7v5ldavjbtR6lfGqSvcKg=",
"owner": "numtide",
"repo": "devshell",
"rev": "dd6b80932022cea34a019e2bb32f6fa9e494dfef",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
@ -136,6 +157,36 @@
}
},
"flake-compat_4": {
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"revCount": 57,
"type": "tarball",
"url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"
}
},
"flake-compat_5": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-compat_6": {
"flake": false,
"locked": {
"lastModified": 1650374568,
@ -151,6 +202,27 @@
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": [
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1727826117,
"narHash": "sha256-K5ZLCyfO/Zj9mPFldf3iwS6oZStJcU4tSpiXTMYaaL0=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "3d04084d54bedc3d6b8b736c70ef449225c361b1",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems_2"
@ -224,6 +296,33 @@
"type": "github"
}
},
"git-hooks": {
"inputs": {
"flake-compat": "flake-compat_5",
"gitignore": "gitignore_3",
"nixpkgs": [
"nixvim",
"nixpkgs"
],
"nixpkgs-stable": [
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1729104314,
"narHash": "sha256-pZRZsq5oCdJt3upZIU4aslS9XwFJ+/nVtALHIciX/BI=",
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "3c3e88f0f544d6bb54329832616af7eb971b6be6",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "git-hooks.nix",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
@ -268,6 +367,28 @@
"type": "github"
}
},
"gitignore_3": {
"inputs": {
"nixpkgs": [
"nixvim",
"git-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
@ -289,6 +410,28 @@
"type": "github"
}
},
"home-manager_2": {
"inputs": {
"nixpkgs": [
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1726989464,
"narHash": "sha256-Vl+WVTJwutXkimwGprnEtXc/s/s8sMuXzqXaspIGlwM=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "2f23fa308a7c067e52dfcc30a0758f47043ec176",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "release-24.05",
"repo": "home-manager",
"type": "github"
}
},
"hyprcursor": {
"inputs": {
"hyprlang": [
@ -500,6 +643,27 @@
"type": "github"
}
},
"nix-darwin": {
"inputs": {
"nixpkgs": [
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1729757100,
"narHash": "sha256-x+8uGaX66V5+fUBHY23Q/OQyibQ38nISzxgj7A7Jqds=",
"owner": "lnl7",
"repo": "nix-darwin",
"rev": "04193f188e4144d7047f83ad1de81d6034d175cd",
"type": "github"
},
"original": {
"owner": "lnl7",
"repo": "nix-darwin",
"type": "github"
}
},
"nix-ld": {
"inputs": {
"nixpkgs": [
@ -691,6 +855,34 @@
"type": "github"
}
},
"nixvim": {
"inputs": {
"devshell": "devshell_2",
"flake-compat": "flake-compat_4",
"flake-parts": "flake-parts",
"git-hooks": "git-hooks",
"home-manager": "home-manager_2",
"nix-darwin": "nix-darwin",
"nixpkgs": [
"nixpkgs"
],
"treefmt-nix": "treefmt-nix"
},
"locked": {
"lastModified": 1729100089,
"narHash": "sha256-B44+e/cYjrzgaDvCNz9TyHQy0q9Q6WaDISV57jxejJ8=",
"owner": "nix-community",
"repo": "nixvim",
"rev": "341dbb1b5867adb95d75e6dabef6627eb0eae38e",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "nixos-24.05",
"repo": "nixvim",
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat",
@ -756,6 +948,7 @@
"nixpkgs": "nixpkgs_2",
"nixpkgs-stable": "nixpkgs-stable_3",
"nixpkgs-unstable": "nixpkgs-unstable",
"nixvim": "nixvim",
"snowfall-lib": "snowfall-lib",
"sops-nix": "sops-nix",
"yazi-flavors": "yazi-flavors"
@ -763,7 +956,7 @@
},
"snowfall-lib": {
"inputs": {
"flake-compat": "flake-compat_4",
"flake-compat": "flake-compat_6",
"flake-utils-plus": "flake-utils-plus",
"nixpkgs": [
"nixpkgs"
@ -864,6 +1057,27 @@
"type": "github"
}
},
"treefmt-nix": {
"inputs": {
"nixpkgs": [
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1729613947,
"narHash": "sha256-XGOvuIPW1XRfPgHtGYXd5MAmJzZtOuwlfKDgxX5KT3s=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "aac86347fb5063960eccb19493e0cadcdb4205ca",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
},
"xdph": {
"inputs": {
"hyprland-protocols": [

View File

@ -27,6 +27,12 @@
flake = false;
};
nixvim = {
url = "github:nix-community/nixvim/nixos-24.05";
# If using a stable channel you can use `url = "github:nix-community/nixvim/nixos-<version>"`
inputs.nixpkgs.follows = "nixpkgs";
};
nix-matlab.url = "gitlab:doronbehar/nix-matlab";
nix-matlab.inputs.nixpkgs.follows = "nixpkgs";

View File

@ -19,17 +19,17 @@
...
}:
with lib;
let
cfg = config.modules.neovim;
in
{
options.modules.neovim = {
enable = mkOption { default = false; };
enable = lib.mkOption { default = false; };
};
config = mkIf cfg.enable {
imports = [ inputs.nixvim.homeManagerModules.nixvim ];
config = lib.mkIf cfg.enable {
home.sessionVariables = {
EDITOR = "nvim";
VISUAL = "nvim";
@ -41,56 +41,142 @@ in
gcc
ripgrep
fd
stylua
black
nixfmt-rfc-style # nixfmt
];
programs.neovim =
let
toLua = str: ''
lua << EOF
${str}
EOF
'';
in
{
# https://www.youtube.com/watch?v=YZAnJ0rwREA
programs.nixvim = {
enable = true;
viAlias = true;
vimAlias = true;
colorschemes.catppuccin = {
enable = true;
viAlias = true;
vimAlias = true;
# vimdiffAlias = true;
# plugins = with pkgs.vimPlugins; [
# {
# plugin = dracula-nvim;
# config = "colorscheme dracula";
# }
# {
# plugin = comment-nvim;
# config = toLua ''require("Comment").setup()'';
# }
# # nix file support
# vim-nix
# # Syntax highlighting
# (nvim-treesitter.withPlugins (p: [
# p.tree-sitter-nix
# p.tree-sitter-vim
# p.tree-sitter-bash
# p.tree-sitter-lua
# p.tree-sitter-python
# p.tree-sitter-json
# p.tree-sitter-cpp
# p.tree-sitter-rust
# ]))
# ];
# extraConfig = ''
# set clipboard=unnamedplus
# '';
# extraLuaConfig = ''
# vim.o.termguicolors = true
# '';
settings.flavour = "mocha";
};
globals.mapleader = " ";
opts = {
number = false;
relativenumber = false;
};
clipboard.register = "unnamedplus"; # Use system clipboard
keymaps = [
{
action = "<cmd>Telescope live_grep<cr>";
key = "<leader>/";
}
{
action = "<cmd>Telescope find_files<cr>";
key = "<leader><space>";
}
{
action = "<cmd>Telescope file_browser<cr>";
key = "<leader>.";
}
{
action = "<cmd>Neogit<cr>";
key = "<leader>gg";
}
{
key = "<C-s>";
action = "<esc><cmd>lua require('conform').format()<cr><cmd>write<cr>";
mode = [
"i"
"x"
"n"
"s"
];
}
];
plugins = {
lualine.enable = true;
commentary.enable = true;
which-key.enable = true;
treesitter.enable = true; # enables all grammar packages
neogit.enable = true; # like magit
trouble.enable = true;
# Shows file trees
oil = {
enable = true;
settings = {
view_options.show_hidden = true;
};
};
# Code formatting
conform-nvim = {
enable = true;
formattersByFt = with pkgs; {
lua = [ "stylua" ];
python = [ "black" ];
nix = [ "nixfmt" ];
};
# extraOptions = {
# default_format_opts.lsp_format = "fallback";
# };
};
# autocomplete
cmp = {
enable = true;
autoEnableSources = true;
settings.sources = [
{ name = "nvim_lsp"; }
{ name = "path"; }
{ name = "buffer"; }
];
settings.mapping = {
"<Tab>" = "cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})";
"<C-j>" = "cmp.mapping.select_next_item()";
"<C-k>" = "cmp.mapping.select_prev_item()";
"<C-e>" = "cmp.mapping.abort()";
"<CR>" = "cmp.mapping.confirm({ select = true })";
};
};
# Fuzzy finder
telescope = {
enable = true;
defaults.mappings = {
i = {
"<C-j>".__raw = "require('telescope.actions').move_selection_next";
"<C-k>".__raw = "require('telescope.actions').move_selection_previous";
"<tab>".__raw = "require('telescope.actions').select_default";
};
};
extensions = {
fzf-native.enable = true;
file-browser = {
enable = true;
hidden = true; # show hidden files
};
};
# Small hack since these file-browser options are not implemented in nixvim jet
extraOptions = {
extensions.file_browser.follow_symlinks = true;
extensions.file_browser.no_ignore = true;
};
};
lsp = {
enable = true;
servers = {
rust-analyzer.enable = true;
nixd.enable = true;
pyright.enable = true;
dockerls.enable = true;
lua_ls.enable = true;
};
};
};
};
};
}