Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • etcinit/neovim-config
1 result
Show changes
Commits on Source (2)
Showing
with 174 additions and 68 deletions
......@@ -6,7 +6,7 @@ My personal [Neovim][1] configuration as a [home-manager][2] module.
## Overview
- Reproducible environment thanks to [Nix][5] and [lazy.nvim][6]
- Reproducible environment thanks to [Nix][5]
- Can be used standalone or imported in a home-manager configuration.
- Available as a VM for trying out the configuration and testing.
- Focused on Rust, Typescript, and Nix development.
......@@ -43,32 +43,18 @@ My personal [Neovim][1] configuration as a [home-manager][2] module.
}
```
- Use `home-manager switch` to apply the new configuration.
- Start `nvim` and run `:Lazy install`.
- If you had another pluging manager set up before, you may want to run `:checkhealth lazy` to check for any issues.
### Standalone
As a fallback, this configuration can be used without `home-manager`. Expect some rough edges. Dependencies will need to be set up manually, and a compatible version of Neovim needs to be installed:
- Install plugin dependencies: `git`, `gcc`, etc.
- Clone this repository.
- Create a soft link between the `src` directory and `~/.config/nvim`.
- Start `nvim` and wait for `lazy.nvim` to install automatically.
- Run `:Lazy install`.
While `lazy-lock.json` will still be used, Neovim and dependency versions are not guaranteed to be compatible.
## Reproducible Environment
When using this configuration as a `home-manager` module, it is possible to build a reproducible environment. Thanks to Nix's reproducible builds and `lazy.nvim`'s `lazy-lock.json` file, this module will always pull the same versions of all packages/plugins, unless the respective Lockfiles are updated.
While `home-manager` offers a module for managing Neovim plugins, I've opted for using `lazy.nvim` as the Neovim plugin manager to allow for this configuration to be usable in environments where Nix is not available or where `home-manager` is not usable.
### `lazy-lock.json`
On first use, the configuration will create a `lazy-lock.json` file from a static copy. This allows the end-user to upgrade plugins over time without sacrificing the reproducible aspect of the configuration.
When using this configuration as a `home-manager` module, it is possible to build a reproducible environment. Thanks to Nix's reproducible builds, this module will always pull the same versions of all packages/plugins, unless the flake lock is updated.
If a plugin update breaks the configuration, it is possible to revert the lockfile. Simply delete `~/.config/nvim/lazy-lock.json`, restart Neovim, and use the `:Lazy restore` command to revert all plugins to the versions in the Lockfile.
A previous version of this module made use of Lazy.nvim which offered faster
startup times and a path for using this configuration without Nix. However, it
also resulted in frequent broken setups when attempting to update packages. In
an effort to simplify my setup, I've opted for a full Nix-based solution,
specially now that most of my systems use Nix. This results in slightly slower
startup times (a few 100 ms), but most plugins are now using definitions from
nixpkgs. Version upgrades will follow the NixOS release cycle.
## Development
......@@ -105,5 +91,4 @@ Testing the configuration in a VM is the recommended approach since it doesn't a
[3]: https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-flake.html#url-like-syntax
[4]: https://github.com/direnv/direnv
[5]: https://nixos.org
[6]: https://github.com/folke/lazy.nvim
[7]: https://nix-community.github.io/home-manager/index.html#ch-nix-flakes
\ No newline at end of file
[7]: https://nix-community.github.io/home-manager/index.html#ch-nix-flakes
......@@ -25,32 +25,32 @@
]
},
"locked": {
"lastModified": 1694465129,
"narHash": "sha256-8BQiuobMrCfCbGM7w6Snx+OBYdtTIm0+cGVaKwQ5BFg=",
"lastModified": 1705273357,
"narHash": "sha256-JAlkxgJbWh7+auiT0rJL3IUXXtkULRqygfxQA6mvLgc=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "9787dffff5d315c9593d3f9fb0f9bf2097e1b57b",
"rev": "924d91e1e4c802fd8e60279a022dbae5acb36f2d",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "release-23.05",
"ref": "release-23.11",
"repo": "home-manager",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1694499547,
"narHash": "sha256-R7xMz1Iia6JthWRHDn36s/E248WB1/je62ovC/dUVKI=",
"lastModified": 1705183652,
"narHash": "sha256-rnfkyUH0x72oHfiSDhuCHDHg3gFgF+lF8zkkg5Zihsw=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e5f018cf150e29aac26c61dac0790ea023c46b24",
"rev": "428544ae95eec077c7f823b422afae5f174dee4b",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-23.05",
"ref": "nixos-23.11",
"type": "indirect"
}
},
......
{
inputs = {
nixpkgs.url = "nixpkgs/nixos-23.05";
nixpkgs.url = "nixpkgs/nixos-23.11";
flake-utils.url = "github:numtide/flake-utils";
home-manager = {
url = "github:nix-community/home-manager/release-23.05";
url = "github:nix-community/home-manager/release-23.11";
inputs.nixpkgs.follows = "nixpkgs";
};
};
......@@ -35,7 +35,7 @@
modules = [
home-manager.nixosModules.home-manager
({pkgs, ...}: {
system.stateVersion = "22.11";
system.stateVersion = "23.11";
services.getty.autologinUser = "neovim";
......@@ -61,13 +61,13 @@
useGlobalPkgs = true;
useUserPackages = true;
users.neovim = ({...}: {
users.neovim = {...}: {
imports = [self.nixosModules.home-manager.neovim-config];
config = {
home = {
homeDirectory = "/home/neovim";
stateVersion = "22.11";
stateVersion = "23.11";
};
programs.bash = {
......@@ -77,7 +77,7 @@
'';
};
};
});
};
};
})
];
......@@ -97,5 +97,3 @@
nixosModules.home-manager.neovim-config = import ./home-manager;
};
}
......@@ -4,7 +4,25 @@
...
}: {
imports = [
./lazy-nvim.nix
./plugins/barbar
./plugins/cmp
./plugins/dap
./plugins/dap-ui
./plugins/gitsigns
./plugins/indent-blankline
./plugins/lsp-status
./plugins/lspconfig
./plugins/lualine
./plugins/null-ls
./plugins/nvim-tree
./plugins/nvim-treesitter
./plugins/one-small-step-for-vimkind
./plugins/prettier
./plugins/scrollbar
./plugins/telescope
./plugins/toggleterm
./plugins/tokyonight
./plugins/trouble
];
config = {
......@@ -12,16 +30,25 @@
enable = true;
defaultEditor = true;
};
home.file.".config/nvim/init.lua" = {
source = ../src/init.lua;
target = ".config/nvim/init.lua";
};
home.file.".config/nvim/lazy-lock.initial.json" = {
source = ../src/lazy-lock.initial.json;
target = ".config/nvim/lazy-lock.initial.json";
extraLuaConfig = ''
vim.g.mapleader = ","
-- Options
require('options')
-- Mappings
require('mappings')
-- Misc
vim.api.nvim_command("syntax on")
vim.api.nvim_command("filetype plugin indent on")
-- Hooks
local lazyhooks = require('lib.lazyhooks');
'';
};
home.file.".config/nvim/after" = {
source = ../src/after;
target = ".config/nvim/after";
......
{pkgs, ...}: {
config = {
home.file.".local/share/nvim/lazy/lazy.nvim" = {
source = pkgs.fetchFromGitHub {
owner = "folke";
repo = "lazy.nvim";
rev = "690f9e88e2a7dc92bcb0cca85f778a3e99fe1f7e";
sha256 = "Sg5dVBtU+o80qzNdhmPCN7viVfEcH5jCYCCTEKzdfAg=";
};
target = ".local/share/nvim/lazy/lazy.nvim";
};
};
}
require('barbar').setup {
icons = { filetype = { enabled = true } },
}
{pkgs, ...}: {
config = {
programs.neovim.plugins = [
{
type = "lua";
config = builtins.readFile ./config.lua;
plugin = pkgs.vimPlugins.barbar-nvim;
}
pkgs.vimPlugins.nvim-web-devicons
];
};
}
return function()
local setup_cmp = function()
local cmp = require 'cmp'
local luasnip = require 'luasnip'
......@@ -62,3 +62,5 @@ return function()
})
})
end
setup_cmp()
{pkgs, ...}: let
subplugins = with pkgs.vimPlugins; [
cmp-nvim-lsp
cmp-buffer
cmp-path
cmp-cmdline
cmp_luasnip
luasnip
];
in {
config = {
programs.neovim.plugins =
[
{
type = "lua";
config = builtins.readFile ./config.lua;
plugin = pkgs.vimPlugins.nvim-cmp;
}
]
++ subplugins;
};
}
require('dapui').setup()
{pkgs, ...}: {
config = {
programs.neovim.plugins = [
{
type = "lua";
config = builtins.readFile ./config.lua;
plugin = pkgs.vimPlugins.nvim-dap-ui;
}
];
};
}
return function()
local setup_dap = function()
local dap = require "dap"
local map = require('lib.utils').map
......@@ -50,3 +50,5 @@ return function()
map('n', '<leader>dr', dap.repl.open, { noremap = true })
map('n', '<leader>dl', dap.run_last, { noremap = true })
end
setup_dap()
{pkgs, ...}: {
config = {
programs.neovim.plugins = [
{
type = "lua";
config = builtins.readFile ./config.lua;
plugin = pkgs.vimPlugins.nvim-dap;
}
];
};
}
require('gitsigns').setup()
{pkgs, ...}: {
config = {
programs.neovim.plugins = [
{
type = "lua";
config = builtins.readFile ./config.lua;
plugin = pkgs.vimPlugins.gitsigns-nvim;
}
];
};
}
require("ibl").setup {
exclude = {
buftypes = { "terminal" },
},
indent = {
char = '|',
},
}
{pkgs, ...}: {
config = {
programs.neovim.plugins = [
{
type = "lua";
config = builtins.readFile ./config.lua;
plugin = pkgs.vimPlugins.indent-blankline-nvim;
}
];
};
}
return function()
local setup_lspstatus = function()
local lsp_status = require('lsp-status')
local kind_labels_mt = {
......@@ -20,3 +20,5 @@ return function()
status_symbol = "",
})
end
setup_lspstatus()
{pkgs, ...}: {
config = {
programs.neovim.plugins = [
{
type = "lua";
config = builtins.readFile ./config.lua;
plugin = pkgs.vimPlugins.lsp-status-nvim;
}
];
};
}
return function()
local setup_lspconfig = function()
local lspconfig = require('lspconfig')
local lsp_status = require('lsp-status')
......@@ -99,3 +99,5 @@ return function()
}
end
end
setup_lspconfig()