Compare commits

..

No commits in common. "10253909c98a586ffdbe31f5806e96b58da01be1" and "aaa7fb7c07eb0bb2d1d6003c3d3b65fe746f142f" have entirely different histories.

12 changed files with 74 additions and 247 deletions

View file

@ -1,46 +1,30 @@
# Neovim Configuration Flake # Neovim Configuration Flake
This is the Neovim configuration for all my NixOS and Nix enabled systems (such This is the Neovim configuration for all my NixOS and Nix enabled systems (such as with nix-darwin on macOS).
as with nix-darwin on macOS). It aims to be minimal and utilitarian; it forgoes It aims to be minimal and utilitarian; it forgoes many blingful features like status lines, sidebars, or fancy UI enhancements
many blingful features like sidebars or fancy UI enhancements in favor of in favor of native (neo)Vim, while still having everything useful you'd expect, like LSPs, file explorer (`yazi`), completions,
native (neo)Vim, while still having everything useful you'd expect, like LSPs, advanced language tools, and QoL enhancements.
file explorer (`oil.nvim`), completions, advanced language tools, and QoL
enhancements.
It uses the [Nixvim](https://nix-community.github.io/nixvim/) project under It uses the [Nixvim](https://nix-community.github.io/nixvim/) project under the hood to declaratively
the hood to declaratively configure Neovim and its plugins, and installs tools configure Neovim and its plugins, and installs some LSPs and other tools needed by it (like `yazi`, `fd`, etc).
needed by it (like `ripgrep`, `fd`, etc). However, LSPs are not installed or
handled by the plugin. The user is expected to provide their own LSPs in the
`$PATH`, but since they are using Nix, this is trivial.
The flake simply provides a package that contains the binaries `nvim`, `vim`, It simply outputs a package which provides the binary `nvim`. It can be called just like the regular `nvim` binary, except it bundles
and `vi`. It can be called just like the regular `nvim` binary (`vim` and `vi` all of my custom configuration and their dependencies with the power of Nix. An entirely self-contained, reproducible, purely functional text editor. Amazing.
are just symlinks to `nvim`), except it bundles all of my custom configuration
and their dependencies with the power of Nix. Plugins are managed by Nix. An
entirely self-contained, reproducible, purely functional text editor. Amazing.
All plugins are precompiled to Lua bytecode by `Luajit` when the package is Feel free to fork or copy the config to use yourself. It's free in the [public domain](./LICENSE).
built for maximum speed and efficiency. When possible, plugins are also
combined for a massive efficiency boost. This allows startup times as fast as
lazy loading without all of the hassle.
Feel free to fork or copy the config to use yourself. It's free in the [public Thanks to [this gist](https://gist.github.com/siph/288b7c6b5f68a1902d28aebc95fde4c5) for showing me how to
domain](./LICENSE). build a Nixvim configuration as a standalone Nix package.
Thanks to [this
gist](https://gist.github.com/siph/288b7c6b5f68a1902d28aebc95fde4c5) for
showing me how to build a Nixvim configuration as a standalone Nix package.
## Usage ## Usage
You can test drive my config in just one line (if you have Nix, of course): You can test drive my config in just one line (if you have Nix, of course):
```sh ```sh
nix run 'github:youwen5/neovim-flake' --extra-experimental-features flakes --extra-experimental-features nix-command nix run 'github:youwen5/neovim-flake' --extra-experimental-features flakes --extra-experimental-features nix-command
``` ```
If for some reason, you want to install it permanently, add it to your flake If for some reason, you want to install it permanently, add it to your flake inputs,
inputs, and install the package in the usual way: and install the package in the usual way:
```nix ```nix
# flake.nix # flake.nix
@ -70,7 +54,7 @@ inputs, and install the package in the usual way:
``` ```
> [!WARNING] > [!WARNING]
> This package will add the symlinks `vim -> nvim` and `vi -> nvim` > This package will add the symlinks `vim -> nvim` and `vi -> nvim` so it will conflict with
> so it will conflict with `pkgs.vim` and any programs installing binaries > `pkgs.vim` and any programs installing binaries called `vim` or `vi`. You must remove existing
> called `vim` or `vi`. You must remove existing Neovim and Vim packages to > Neovim and Vim packages to install this.
> install this.

View file

@ -1,3 +1,4 @@
{ pkgs, ... }:
{ {
imports = [ imports = [
./plugins ./plugins
@ -12,17 +13,7 @@
luaLoader.enable = true; luaLoader.enable = true;
performance = { performance = {
combinePlugins = { combinePlugins.enable = true;
enable = true; byteCompileLua.enable = true;
standalonePlugins = [
"nvim-treesitter"
"vimplugin-treesitter-grammar-nix"
];
};
byteCompileLua = {
enable = true;
plugins = true;
nvimRuntime = true;
};
}; };
} }

View file

@ -323,19 +323,10 @@
options.desc = "Look through yank history with telescope."; options.desc = "Look through yank history with telescope.";
} }
{ {
action = '':Oil<CR>''; action = '':lua require("yazi").yazi()<CR>'';
key = "<Leader>e"; key = "<Leader>e";
options = { options = {
desc = "Open oil file explorer in current nvim working directory"; desc = "Open Yazi current nvim working directory";
noremap = true;
silent = true;
};
}
{
action = '':Oil<CR>'';
key = "<Leader>e";
options = {
desc = "Open oil file explorer in current nvim working directory";
noremap = true; noremap = true;
silent = true; silent = true;
}; };
@ -386,6 +377,15 @@
}; };
} }
# { # {
# action = ":Yazi<CR>";
# key = "<Leader>mf";
# options = {
# desc = "Open Yazi at current file";
# noremap = true;
# silent = true;
# };
# }
# {
# action = "<cmd>lua require'conform'.format({ bufnr = args.bf })<CR>"; # action = "<cmd>lua require'conform'.format({ bufnr = args.bf })<CR>";
# key = "<Leader>cf"; # key = "<Leader>cf";
# options = { # options = {

View file

@ -1,9 +1,5 @@
{ {
plugins = { plugins = {
lspkind = {
enable = true;
cmp.enable = true;
};
cmp-async-path.enable = true; cmp-async-path.enable = true;
cmp = { cmp = {
enable = true; enable = true;

View file

@ -28,16 +28,6 @@
plugins.conform-nvim = { plugins.conform-nvim = {
enable = true; enable = true;
# because combinePlugins.enable = true, the collision of `doc` is
# unavoidable. this renames them.
package = pkgs.vimPlugins.conform-nvim.overrideAttrs (oldAttrs: {
postInstall =
(oldAttrs.postInstall or "")
+ ''
mv $out/doc/recipes.md $out/doc/conform-nvim_recipes.md
'';
});
# package = pkgs.vimPlugins.conform-nvim;
settings = { settings = {
format_on_save = { format_on_save = {
timeoutMs = 500; timeoutMs = 500;

View file

@ -1,6 +1,11 @@
# LSP setup # LSP setup
{ pkgs, inputs, ... }: { pkgs, inputs, ... }:
{ {
extraPackages = with pkgs; [
rust-analyzer
lua-language-server
];
plugins = { plugins = {
lsp = { lsp = {
enable = true; enable = true;

View file

@ -6,9 +6,7 @@
surround = { }; surround = { };
ai = { }; ai = { };
hipatterns = { }; hipatterns = { };
notify = { notify = { };
lsp_progress.enable = false;
};
tabline = { }; tabline = { };
trailspace = { }; trailspace = { };
cursorword = { }; cursorword = { };

View file

@ -1,5 +1,4 @@
# Getting around REALLY FAST # Getting around REALLY FAST
{ pkgs, ... }:
{ {
plugins = { plugins = {
telescope = { telescope = {
@ -36,38 +35,10 @@
}; };
}; };
}; };
oil = { yazi = {
enable = true; enable = true;
# because combinePlugins.enable = true, the collision of `doc` is
# unavoidable. this renames them.
package = pkgs.vimPlugins.oil-nvim.overrideAttrs (oldAttrs: {
postInstall =
(oldAttrs.postInstall or "")
+ ''
mv $out/doc/recipes.md $out/doc/oil_recipes.md
'';
});
settings = { settings = {
keymaps = { open_for_directories = true;
"J" = "actions.parent";
"Q" = "actions.close";
"<C-h>" = "actions.select_split";
"<C-l>" = "actions.refresh";
"<C-p>" = "actions.preview";
"<C-s>" = "actions.select_vsplit";
"<C-t>" = "actions.select_tab";
"<CR>" = "actions.select";
"K" = "actions.select";
_ = "actions.open_cwd";
"`" = "actions.cd";
"g." = "actions.toggle_hidden";
"g?" = "actions.show_help";
"g\\" = "actions.toggle_trash";
gs = "actions.change_sort";
gx = "actions.open_external";
"~" = "actions.tcd";
};
use_default_keymaps = false;
}; };
}; };
harpoon = { harpoon = {

View file

@ -3,6 +3,7 @@
{ {
extraPackages = with pkgs; [ extraPackages = with pkgs; [
ripgrep ripgrep
yazi
fd fd
]; ];
@ -21,28 +22,6 @@
enableTelescope = true; enableTelescope = true;
}; };
trouble.enable = true; trouble.enable = true;
barbecue.enable = true;
lualine = {
enable = true;
settings = {
sections = {
lualine_a = [ "branch" ];
lualine_b = [
{
__unkeyed-1 = {
__raw = ''
function()
return require('lsp-progress').progress()
end,
'';
};
}
];
lualine_c = [ "diff" ];
};
options.globalstatus = true;
};
};
crates-nvim.enable = true; crates-nvim.enable = true;
# git stuff # git stuff
lazygit.enable = true; lazygit.enable = true;
@ -60,9 +39,5 @@
name = "render-markdown.nvim"; name = "render-markdown.nvim";
src = inputs.render-markdown; src = inputs.render-markdown;
}) })
(pkgs.vimUtils.buildVimPlugin {
name = "lsp-progress.nvim";
src = inputs.lsp-progress;
})
]; ];
} }

View file

@ -3,64 +3,6 @@
extraConfigLua = '' extraConfigLua = ''
require("telescope").load_extension("yank_history") require("telescope").load_extension("yank_history")
require("telescope").load_extension("ht") require("telescope").load_extension("ht")
vim.diagnostic.config({ virtual_lines = false }) vim.diagnostic.config({ virtual_lines = false });
require("lsp-progress").setup({
client_format = function(client_name, spinner, series_messages)
if #series_messages == 0 then
return nil
end
return {
name = client_name,
body = spinner .. " " .. table.concat(series_messages, ", "),
}
end,
format = function(client_messages)
--- @param name string
--- @param msg string?
--- @return string
local function stringify(name, msg)
return msg and string.format("%s %s", name, msg) or name
end
local sign = "󰆧" -- nf-fa-gear \uf013
local lsp_clients = vim.lsp.get_active_clients()
local messages_map = {}
for _, climsg in ipairs(client_messages) do
messages_map[climsg.name] = climsg.body
end
if #lsp_clients > 0 then
table.sort(lsp_clients, function(a, b)
return a.name < b.name
end)
local builder = {}
for _, cli in ipairs(lsp_clients) do
if
type(cli) == "table"
and type(cli.name) == "string"
and string.len(cli.name) > 0
then
if messages_map[cli.name] then
table.insert(builder, stringify(cli.name, messages_map[cli.name]))
else
table.insert(builder, stringify(cli.name))
end
end
end
if #builder > 0 then
return sign .. " " .. table.concat(builder, ", ")
end
end
return ""
end,
})
vim.api.nvim_create_augroup("lualine_augroup", { clear = true })
vim.api.nvim_create_autocmd("User", {
group = "lualine_augroup",
pattern = "LspProgressStatusUpdated",
callback = require("lualine").refresh,
})
''; '';
} }

View file

@ -61,11 +61,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1726153070, "lastModified": 1722555600,
"narHash": "sha256-HO4zgY0ekfwO5bX0QH/3kJ/h4KvUDFZg8YpkNwIbg1U=", "narHash": "sha256-XOQkdLafnb/p9ij77byFQjDf5m5QYl9b2REiVClC+x4=",
"owner": "hercules-ci", "owner": "hercules-ci",
"repo": "flake-parts", "repo": "flake-parts",
"rev": "bcef6817a8b2aa20a5a6dbb19b43e63c5bf8619a", "rev": "8471fe90ad337a8074e957b69ca4d0089218391d",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -109,11 +109,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1725513492, "lastModified": 1724857454,
"narHash": "sha256-tyMUA6NgJSvvQuzB7A1Sf8+0XCHyfSPRx/b00o6K0uo=", "narHash": "sha256-Qyl9Q4QMTLZnnBb/8OuQ9LSkzWjBU1T5l5zIzTxkkhk=",
"owner": "cachix", "owner": "cachix",
"repo": "git-hooks.nix", "repo": "git-hooks.nix",
"rev": "7570de7b9b504cfe92025dd1be797bf546f66528", "rev": "4509ca64f1084e73bc7a721b20c669a8d4c5ebe6",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -147,11 +147,11 @@
"haskell-tools": { "haskell-tools": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1726521542, "lastModified": 1725935019,
"narHash": "sha256-TyqjJohmIwuqMqy01H3sRRcm8okNeWtAfLqX2Ehr9mQ=", "narHash": "sha256-M+AcprniBOBQFkhXCacAyBtFF5FZyGSG5F6e8ld+r9c=",
"owner": "mrcjkb", "owner": "mrcjkb",
"repo": "haskell-tools.nvim", "repo": "haskell-tools.nvim",
"rev": "1edf2bb5ced056b5d3d1df783dd02041ce09b087", "rev": "2443c3b2ab049561009d1b5712e839db546b6586",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -168,11 +168,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1726357542, "lastModified": 1724435763,
"narHash": "sha256-p4OrJL2weh0TRtaeu1fmNYP6+TOp/W2qdaIJxxQay4c=", "narHash": "sha256-UNky3lJNGQtUEXT2OY8gMxejakSWPTfWKvpFkpFlAfM=",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "e524c57b1fa55d6ca9d8354c6ce1e538d2a1f47f", "rev": "c2cd2a52e02f1dfa1c88f95abeb89298d46023be",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -181,22 +181,6 @@
"type": "github" "type": "github"
} }
}, },
"lsp-progress": {
"flake": false,
"locked": {
"lastModified": 1721008335,
"narHash": "sha256-OafRT5AnxRTOh7MYofRFjti0+pobKQihymZs/kr5w0A=",
"owner": "linrongbin16",
"repo": "lsp-progress.nvim",
"rev": "d5f4d28efe75ce636bfbe271eb45f39689765aab",
"type": "github"
},
"original": {
"owner": "linrongbin16",
"repo": "lsp-progress.nvim",
"type": "github"
}
},
"nix-darwin": { "nix-darwin": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -205,11 +189,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1726188813, "lastModified": 1724561770,
"narHash": "sha256-Vop/VRi6uCiScg/Ic+YlwsdIrLabWUJc57dNczp0eBc=", "narHash": "sha256-zv8C9RNa86CIpyHwPIVO/k+5TfM8ZbjGwOOpTe1grls=",
"owner": "lnl7", "owner": "lnl7",
"repo": "nix-darwin", "repo": "nix-darwin",
"rev": "21fe31f26473c180390cfa81e3ea81aca0204c80", "rev": "ac5694a0b855a981e81b4d9f14052e3ff46ca39e",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -220,11 +204,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1726463316, "lastModified": 1725983898,
"narHash": "sha256-gI9kkaH0ZjakJOKrdjaI/VbaMEo9qBbSUl93DnU7f4c=", "narHash": "sha256-4b3A9zPpxAxLnkF9MawJNHDtOOl6ruL0r6Og1TEDGCE=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "99dc8785f6a0adac95f5e2ab05cc2e1bf666d172", "rev": "1355a0cbfeac61d785b7183c0caaec1f97361b43",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -261,11 +245,11 @@
"treefmt-nix": "treefmt-nix" "treefmt-nix": "treefmt-nix"
}, },
"locked": { "locked": {
"lastModified": 1726502324, "lastModified": 1726148694,
"narHash": "sha256-I/WFSIBeIjlY3CgSJ6IRYxP2aEJ6b42Y1HAeATlBh48=", "narHash": "sha256-bR7LFVtMjiVlO2OpmDSuLQ2XQr+h+JtVFYObAbThZSs=",
"owner": "nix-community", "owner": "nix-community",
"repo": "nixvim", "repo": "nixvim",
"rev": "2e3083e42509c399b224239f6d7fa17976b18536", "rev": "27a0dd435dd3563f4cf9d788601fadfce8c59db6",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -283,11 +267,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1726392886, "lastModified": 1724584782,
"narHash": "sha256-9RtOuG7V8KG8IU8nZje5EQ1WSM/inr7+zb3tAgTiHDM=", "narHash": "sha256-7FfHv7b1jwMPSu9SPY9hdxStk8E6EeSwzqdvV69U4BM=",
"owner": "NuschtOS", "owner": "NuschtOS",
"repo": "search", "repo": "search",
"rev": "97d34b70deed4878fcb2449ac89dab717d72efa1", "rev": "5a08d691de30b6fc28d58ce71a5e420f2694e087",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -299,11 +283,11 @@
"render-markdown": { "render-markdown": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1726511696, "lastModified": 1726214512,
"narHash": "sha256-l0k39OXcpoH7D6UmuQy0LNLj+8HCkKz9R/4zVH4bEt0=", "narHash": "sha256-lroID1tHXL91WxTMxy8CsDp/3M5oHVQ4SvwGSGkTa5k=",
"owner": "MeanderingProgrammer", "owner": "MeanderingProgrammer",
"repo": "render-markdown.nvim", "repo": "render-markdown.nvim",
"rev": "2424693c7a4c79641a7ea1e2a838dbc9238d6066", "rev": "cdb58fc97c49a1ab75b35d99183c35b5863e845a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -316,7 +300,6 @@
"inputs": { "inputs": {
"flake-parts": "flake-parts", "flake-parts": "flake-parts",
"haskell-tools": "haskell-tools", "haskell-tools": "haskell-tools",
"lsp-progress": "lsp-progress",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"nixvim": "nixvim", "nixvim": "nixvim",
"render-markdown": "render-markdown", "render-markdown": "render-markdown",
@ -362,11 +345,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1725271838, "lastModified": 1724833132,
"narHash": "sha256-VcqxWT0O/gMaeWTTjf1r4MOyG49NaNxW4GHTO3xuThE=", "narHash": "sha256-F4djBvyNRAXGusJiNYInqR6zIMI3rvlp6WiKwsRISos=",
"owner": "numtide", "owner": "numtide",
"repo": "treefmt-nix", "repo": "treefmt-nix",
"rev": "9fb342d14b69aefdf46187f6bb80a4a0d97007cd", "rev": "3ffd842a5f50f435d3e603312eefa4790db46af5",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -1,15 +1,12 @@
{ {
description = "A minimal and productive Neovim configuration."; description = "Personal Neovim configuration.";
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixvim = { nixvim.url = "github:nix-community/nixvim";
url = "github:nix-community/nixvim"; nixvim.inputs.nixpkgs.follows = "nixpkgs";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-parts.url = "github:hercules-ci/flake-parts"; flake-parts.url = "github:hercules-ci/flake-parts";
# Neovim plugins
render-markdown = { render-markdown = {
url = "github:MeanderingProgrammer/render-markdown.nvim"; url = "github:MeanderingProgrammer/render-markdown.nvim";
flake = false; flake = false;
@ -22,10 +19,6 @@
url = "github:mrcjkb/haskell-tools.nvim"; url = "github:mrcjkb/haskell-tools.nvim";
flake = false; flake = false;
}; };
lsp-progress = {
url = "github:linrongbin16/lsp-progress.nvim";
flake = false;
};
}; };
outputs = outputs =
@ -61,7 +54,6 @@
nvim = nixvim'.makeNixvimWithModule nixvimModule; nvim = nixvim'.makeNixvimWithModule nixvimModule;
in in
{ {
formatter = pkgs.nixfmt-rfc-style; formatter = pkgs.nixfmt-rfc-style;
checks = { checks = {
default = nixvimLib.check.mkTestDerivationFromNixvimModule nixvimModule; default = nixvimLib.check.mkTestDerivationFromNixvimModule nixvimModule;