mirror of
https://github.com/iofq/nvim.nix.git
synced 2026-01-23 00:45:17 -06:00
snacks rice + new colorscheme
This commit is contained in:
parent
66d50e274e
commit
d998429cb8
15 changed files with 1068 additions and 427 deletions
340
nix/mkNeovim.nix
340
nix/mkNeovim.nix
|
|
@ -7,195 +7,195 @@
|
|||
pkgs-wrapNeovim ? pkgs,
|
||||
}:
|
||||
with lib;
|
||||
{
|
||||
# NVIM_APPNAME - Defaults to 'nvim' if not set.
|
||||
# If set to something else, this will also rename the binary.
|
||||
appName ? null,
|
||||
# The Neovim package to wrap
|
||||
neovim-unwrapped ? pkgs-wrapNeovim.neovim-unwrapped,
|
||||
plugins ? [ ], # List of plugins
|
||||
# List of dev plugins (will be bootstrapped) - useful for plugin developers
|
||||
# { name = <plugin-name>; url = <git-url>; }
|
||||
devPlugins ? [ ],
|
||||
# Regexes for config files to ignore, relative to the nvim directory.
|
||||
# e.g. [ "^plugin/neogit.lua" "^ftplugin/.*.lua" ]
|
||||
ignoreConfigRegexes ? [ ],
|
||||
extraPackages ? [ ], # Extra runtime dependencies (e.g. ripgrep, ...)
|
||||
# The below arguments can typically be left as their defaults
|
||||
# Additional lua packages (not plugins), e.g. from luarocks.org.
|
||||
# e.g. p: [p.jsregexp]
|
||||
extraLuaPackages ? p: [ ],
|
||||
extraPython3Packages ? p: [ ], # Additional python 3 packages
|
||||
withPython3 ? false, # Build Neovim with Python 3 support?
|
||||
withRuby ? false, # Build Neovim with Ruby support?
|
||||
withNodeJs ? false, # Build Neovim with NodeJS support?
|
||||
withSqlite ? true, # Add sqlite? This is a dependency for some plugins
|
||||
# You probably don't want to create vi or vim aliases
|
||||
# if the appName is something different than "nvim"
|
||||
viAlias ? appName == "nvim", # Add a "vi" binary to the build output as an alias?
|
||||
vimAlias ? appName == "nvim", # Add a "vim" binary to the build output as an alias?
|
||||
wrapRc ? true,
|
||||
}:
|
||||
let
|
||||
# This is the structure of a plugin definition.
|
||||
# Each plugin in the `plugins` argument list can also be defined as this attrset
|
||||
defaultPlugin = {
|
||||
plugin = null; # e.g. nvim-lspconfig
|
||||
config = null; # plugin config
|
||||
# If `optional` is set to `false`, the plugin is installed in the 'start' packpath
|
||||
# set to `true`, it is installed in the 'opt' packpath, and can be lazy loaded with
|
||||
# ':packadd! {plugin-name}
|
||||
optional = false;
|
||||
runtime = { };
|
||||
};
|
||||
{
|
||||
# NVIM_APPNAME - Defaults to 'nvim' if not set.
|
||||
# If set to something else, this will also rename the binary.
|
||||
appName ? null,
|
||||
# The Neovim package to wrap
|
||||
neovim-unwrapped ? pkgs-wrapNeovim.neovim-unwrapped,
|
||||
plugins ? [], # List of plugins
|
||||
# List of dev plugins (will be bootstrapped) - useful for plugin developers
|
||||
# { name = <plugin-name>; url = <git-url>; }
|
||||
devPlugins ? [],
|
||||
# Regexes for config files to ignore, relative to the nvim directory.
|
||||
# e.g. [ "^plugin/neogit.lua" "^ftplugin/.*.lua" ]
|
||||
ignoreConfigRegexes ? [],
|
||||
extraPackages ? [], # Extra runtime dependencies (e.g. ripgrep, ...)
|
||||
# The below arguments can typically be left as their defaults
|
||||
# Additional lua packages (not plugins), e.g. from luarocks.org.
|
||||
# e.g. p: [p.jsregexp]
|
||||
extraLuaPackages ? p: [],
|
||||
extraPython3Packages ? p: [], # Additional python 3 packages
|
||||
withPython3 ? false, # Build Neovim with Python 3 support?
|
||||
withRuby ? false, # Build Neovim with Ruby support?
|
||||
withNodeJs ? false, # Build Neovim with NodeJS support?
|
||||
withSqlite ? true, # Add sqlite? This is a dependency for some plugins
|
||||
# You probably don't want to create vi or vim aliases
|
||||
# if the appName is something different than "nvim"
|
||||
viAlias ? appName == "nvim", # Add a "vi" binary to the build output as an alias?
|
||||
vimAlias ? appName == "nvim", # Add a "vim" binary to the build output as an alias?
|
||||
wrapRc ? true,
|
||||
}: let
|
||||
# This is the structure of a plugin definition.
|
||||
# Each plugin in the `plugins` argument list can also be defined as this attrset
|
||||
defaultPlugin = {
|
||||
plugin = null; # e.g. nvim-lspconfig
|
||||
config = null; # plugin config
|
||||
# If `optional` is set to `false`, the plugin is installed in the 'start' packpath
|
||||
# set to `true`, it is installed in the 'opt' packpath, and can be lazy loaded with
|
||||
# ':packadd! {plugin-name}
|
||||
optional = false;
|
||||
runtime = {};
|
||||
};
|
||||
|
||||
externalPackages = extraPackages ++ (optionals withSqlite [ pkgs.sqlite ]);
|
||||
externalPackages = extraPackages ++ (optionals withSqlite [pkgs.sqlite]);
|
||||
|
||||
# Map all plugins to an attrset { plugin = <plugin>; config = <config>; optional = <tf>; ... }
|
||||
normalizedPlugins = map (x: defaultPlugin // (if x ? plugin then x else { plugin = x; })) plugins;
|
||||
# Map all plugins to an attrset { plugin = <plugin>; config = <config>; optional = <tf>; ... }
|
||||
normalizedPlugins = map (x:
|
||||
defaultPlugin
|
||||
// (
|
||||
if x ? plugin
|
||||
then x
|
||||
else {plugin = x;}
|
||||
))
|
||||
plugins;
|
||||
|
||||
# This nixpkgs util function creates an attrset
|
||||
# that pkgs.wrapNeovimUnstable uses to configure the Neovim build.
|
||||
neovimConfig = pkgs-wrapNeovim.neovimUtils.makeNeovimConfig {
|
||||
inherit
|
||||
extraPython3Packages
|
||||
withPython3
|
||||
withRuby
|
||||
withNodeJs
|
||||
viAlias
|
||||
vimAlias
|
||||
;
|
||||
plugins = normalizedPlugins;
|
||||
};
|
||||
# This nixpkgs util function creates an attrset
|
||||
# that pkgs.wrapNeovimUnstable uses to configure the Neovim build.
|
||||
neovimConfig = pkgs-wrapNeovim.neovimUtils.makeNeovimConfig {
|
||||
inherit
|
||||
extraPython3Packages
|
||||
withPython3
|
||||
withRuby
|
||||
withNodeJs
|
||||
viAlias
|
||||
vimAlias
|
||||
;
|
||||
plugins = normalizedPlugins;
|
||||
};
|
||||
|
||||
packDir = pkgs.neovimUtils.packDir {
|
||||
myNeovimPackages = pkgs.neovimUtils.normalizedPluginsToVimPackage normalizedPlugins;
|
||||
};
|
||||
packDir = pkgs.neovimUtils.packDir {
|
||||
myNeovimPackages = pkgs.neovimUtils.normalizedPluginsToVimPackage normalizedPlugins;
|
||||
};
|
||||
|
||||
# This uses the ignoreConfigRegexes list to filter
|
||||
# the nvim directory
|
||||
nvimRtpSrc =
|
||||
let
|
||||
# This uses the ignoreConfigRegexes list to filter
|
||||
# the nvim directory
|
||||
nvimRtpSrc = let
|
||||
src = ../nvim;
|
||||
in
|
||||
lib.cleanSourceWith {
|
||||
inherit src;
|
||||
name = "nvim-rtp-src";
|
||||
filter =
|
||||
path: tyoe:
|
||||
let
|
||||
lib.cleanSourceWith {
|
||||
inherit src;
|
||||
name = "nvim-rtp-src";
|
||||
filter = path: tyoe: let
|
||||
srcPrefix = toString src + "/";
|
||||
relPath = lib.removePrefix srcPrefix (toString path);
|
||||
in
|
||||
lib.all (regex: builtins.match regex relPath == null) ignoreConfigRegexes;
|
||||
lib.all (regex: builtins.match regex relPath == null) ignoreConfigRegexes;
|
||||
};
|
||||
|
||||
# Split runtimepath into 3 directories:
|
||||
# - lua, to be prepended to the rtp at the beginning of init.lua
|
||||
# - nvim, containing plugin, ftplugin, ... subdirectories
|
||||
# - after, to be sourced last in the startup initialization
|
||||
# See also: https://neovim.io/doc/user/starting.html
|
||||
nvimRtp = stdenv.mkDerivation {
|
||||
name = "nvim-rtp";
|
||||
src = nvimRtpSrc;
|
||||
|
||||
buildPhase = ''
|
||||
mkdir -p $out/
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
cp -r . $out/
|
||||
'';
|
||||
};
|
||||
|
||||
# Split runtimepath into 3 directories:
|
||||
# - lua, to be prepended to the rtp at the beginning of init.lua
|
||||
# - nvim, containing plugin, ftplugin, ... subdirectories
|
||||
# - after, to be sourced last in the startup initialization
|
||||
# See also: https://neovim.io/doc/user/starting.html
|
||||
nvimRtp = stdenv.mkDerivation {
|
||||
name = "nvim-rtp";
|
||||
src = nvimRtpSrc;
|
||||
|
||||
buildPhase = ''
|
||||
mkdir -p $out/lua
|
||||
mkdir -p $out/ftplugin
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
cp -r lua $out/
|
||||
rm -r lua
|
||||
cp -r ftplugin $out/
|
||||
rm -r ftplugin
|
||||
'';
|
||||
};
|
||||
|
||||
# The final init.lua content that we pass to the Neovim wrapper.
|
||||
# It wraps the user init.lua, prepends the lua lib directory to the RTP
|
||||
# and prepends the nvim and after directory to the RTP
|
||||
initLua =
|
||||
''
|
||||
LAZY_OPTS = {
|
||||
performance = {
|
||||
reset_packpath = true,
|
||||
rtp = {
|
||||
disabled_plugins = {
|
||||
"netrwPlugin",
|
||||
"tutor",
|
||||
# The final init.lua content that we pass to the Neovim wrapper.
|
||||
# It wraps the user init.lua, prepends the lua lib directory to the RTP
|
||||
# and prepends the nvim and after directory to the RTP
|
||||
initLua =
|
||||
''
|
||||
LAZY_OPTS = {
|
||||
performance = {
|
||||
reset_packpath = false,
|
||||
rtp = {
|
||||
reset = false,
|
||||
disabled_plugins = {
|
||||
"netrwPlugin",
|
||||
"tutor",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
dev = {
|
||||
path = "${packDir}/pack/myNeovimPackages/start",
|
||||
patterns = {""},
|
||||
},
|
||||
checker = {
|
||||
enabled = false,
|
||||
},
|
||||
install = { missing = false, },
|
||||
spec = {{ import = "plugins" }},
|
||||
}
|
||||
vim.opt.rtp:prepend('${nvimRtp}')
|
||||
''
|
||||
+ (builtins.readFile ../nvim/init.lua);
|
||||
dev = {
|
||||
path = "${packDir}/pack/myNeovimPackages/start",
|
||||
patterns = {""},
|
||||
},
|
||||
checker = {
|
||||
enabled = false,
|
||||
},
|
||||
install = { missing = false, },
|
||||
spec = {{ import = "plugins" }},
|
||||
}
|
||||
vim.opt.rtp:prepend('${nvimRtp}')
|
||||
''
|
||||
+ (builtins.readFile ../nvim/init.lua);
|
||||
|
||||
# Add arguments to the Neovim wrapper script
|
||||
extraMakeWrapperArgs = builtins.concatStringsSep " " (
|
||||
# Set the NVIM_APPNAME environment variable
|
||||
(optional (
|
||||
appName != "nvim" && appName != null && appName != ""
|
||||
) ''--set NVIM_APPNAME "${appName}"'')
|
||||
# Add external packages to the PATH
|
||||
++ (optional (externalPackages != [ ]) ''--prefix PATH : "${makeBinPath externalPackages}"'')
|
||||
# Set the LIBSQLITE_CLIB_PATH if sqlite is enabled
|
||||
++ (optional withSqlite ''--set LIBSQLITE_CLIB_PATH "${pkgs.sqlite.out}/lib/libsqlite3.so"'')
|
||||
# Set the LIBSQLITE environment variable if sqlite is enabled
|
||||
++ (optional withSqlite ''--set LIBSQLITE "${pkgs.sqlite.out}/lib/libsqlite3.so"'')
|
||||
);
|
||||
# Add arguments to the Neovim wrapper script
|
||||
extraMakeWrapperArgs = builtins.concatStringsSep " " (
|
||||
# Set the NVIM_APPNAME environment variable
|
||||
(optional (
|
||||
appName != "nvim" && appName != null && appName != ""
|
||||
) ''--set NVIM_APPNAME "${appName}"'')
|
||||
# Add external packages to the PATH
|
||||
++ (optional (externalPackages != []) ''--prefix PATH : "${makeBinPath externalPackages}"'')
|
||||
# Set the LIBSQLITE_CLIB_PATH if sqlite is enabled
|
||||
++ (optional withSqlite ''--set LIBSQLITE_CLIB_PATH "${pkgs.sqlite.out}/lib/libsqlite3.so"'')
|
||||
# Set the LIBSQLITE environment variable if sqlite is enabled
|
||||
++ (optional withSqlite ''--set LIBSQLITE "${pkgs.sqlite.out}/lib/libsqlite3.so"'')
|
||||
);
|
||||
|
||||
luaPackages = neovim-unwrapped.lua.pkgs;
|
||||
resolvedExtraLuaPackages = extraLuaPackages luaPackages;
|
||||
luaPackages = neovim-unwrapped.lua.pkgs;
|
||||
resolvedExtraLuaPackages = extraLuaPackages luaPackages;
|
||||
|
||||
# Native Lua libraries
|
||||
extraMakeWrapperLuaCArgs =
|
||||
optionalString (resolvedExtraLuaPackages != [ ])
|
||||
# Native Lua libraries
|
||||
extraMakeWrapperLuaCArgs =
|
||||
optionalString (resolvedExtraLuaPackages != [])
|
||||
''--suffix LUA_CPATH ";" "${
|
||||
concatMapStringsSep ";" luaPackages.getLuaCPath resolvedExtraLuaPackages
|
||||
}"'';
|
||||
concatMapStringsSep ";" luaPackages.getLuaCPath resolvedExtraLuaPackages
|
||||
}"'';
|
||||
|
||||
# Lua libraries
|
||||
extraMakeWrapperLuaArgs =
|
||||
optionalString (resolvedExtraLuaPackages != [ ])
|
||||
# Lua libraries
|
||||
extraMakeWrapperLuaArgs =
|
||||
optionalString (resolvedExtraLuaPackages != [])
|
||||
''--suffix LUA_PATH ";" "${
|
||||
concatMapStringsSep ";" luaPackages.getLuaPath resolvedExtraLuaPackages
|
||||
}"'';
|
||||
concatMapStringsSep ";" luaPackages.getLuaPath resolvedExtraLuaPackages
|
||||
}"'';
|
||||
|
||||
# wrapNeovimUnstable is the nixpkgs utility function for building a Neovim derivation.
|
||||
neovim-wrapped = pkgs-wrapNeovim.wrapNeovimUnstable neovim-unwrapped (
|
||||
neovimConfig
|
||||
// {
|
||||
luaRcContent = initLua;
|
||||
wrapperArgs =
|
||||
escapeShellArgs neovimConfig.wrapperArgs
|
||||
+ " "
|
||||
+ extraMakeWrapperArgs
|
||||
+ " "
|
||||
+ extraMakeWrapperLuaCArgs
|
||||
+ " "
|
||||
+ extraMakeWrapperLuaArgs;
|
||||
wrapRc = wrapRc;
|
||||
}
|
||||
);
|
||||
# wrapNeovimUnstable is the nixpkgs utility function for building a Neovim derivation.
|
||||
neovim-wrapped = pkgs-wrapNeovim.wrapNeovimUnstable neovim-unwrapped (
|
||||
neovimConfig
|
||||
// {
|
||||
luaRcContent = initLua;
|
||||
wrapperArgs =
|
||||
escapeShellArgs neovimConfig.wrapperArgs
|
||||
+ " "
|
||||
+ extraMakeWrapperArgs
|
||||
+ " "
|
||||
+ extraMakeWrapperLuaCArgs
|
||||
+ " "
|
||||
+ extraMakeWrapperLuaArgs;
|
||||
wrapRc = wrapRc;
|
||||
}
|
||||
);
|
||||
|
||||
isCustomAppName = appName != null && appName != "nvim";
|
||||
in
|
||||
neovim-wrapped.overrideAttrs (oa: {
|
||||
buildPhase =
|
||||
oa.buildPhase
|
||||
# If a custom NVIM_APPNAME has been set, rename the `nvim` binary
|
||||
+ lib.optionalString isCustomAppName ''
|
||||
mv $out/bin/nvim $out/bin/${lib.escapeShellArg appName}
|
||||
'';
|
||||
})
|
||||
isCustomAppName = appName != null && appName != "nvim";
|
||||
in
|
||||
neovim-wrapped.overrideAttrs (oa: {
|
||||
buildPhase =
|
||||
oa.buildPhase
|
||||
# If a custom NVIM_APPNAME has been set, rename the `nvim` binary
|
||||
+ lib.optionalString isCustomAppName ''
|
||||
mv $out/bin/nvim $out/bin/${lib.escapeShellArg appName}
|
||||
'';
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,15 +1,18 @@
|
|||
# This overlay, when applied to nixpkgs, adds the final neovim derivation to nixpkgs.
|
||||
{inputs}: final: prev:
|
||||
with final.pkgs.lib; let
|
||||
{ inputs }:
|
||||
final: prev:
|
||||
with final.pkgs.lib;
|
||||
let
|
||||
pkgs = final;
|
||||
pkgs-wrapNeovim = prev;
|
||||
|
||||
mkNvimPlugin = src: pname:
|
||||
mkNvimPlugin =
|
||||
src: pname:
|
||||
pkgs.vimUtils.buildVimPlugin {
|
||||
inherit pname src;
|
||||
version = src.lastModifiedDate;
|
||||
};
|
||||
mkNeovim = pkgs.callPackage ./mkNeovim.nix {inherit pkgs-wrapNeovim;};
|
||||
mkNeovim = pkgs.callPackage ./mkNeovim.nix { inherit pkgs-wrapNeovim; };
|
||||
|
||||
all-plugins = with pkgs.vimPlugins; [
|
||||
blink-cmp
|
||||
|
|
@ -20,11 +23,11 @@ with final.pkgs.lib; let
|
|||
friendly-snippets
|
||||
lazy-nvim
|
||||
mini-nvim
|
||||
nightfox-nvim
|
||||
nvim-lint
|
||||
nvim-lspconfig
|
||||
nvim-treesitter-context
|
||||
nvim-treesitter-textobjects
|
||||
nvim-treesitter-textsubjects
|
||||
nvim-treesitter.withAllGrammars
|
||||
quicker-nvim
|
||||
refactoring-nvim
|
||||
|
|
@ -35,6 +38,7 @@ with final.pkgs.lib; let
|
|||
|
||||
basePackages = with pkgs; [
|
||||
ripgrep
|
||||
fd
|
||||
];
|
||||
# Extra packages that should be included on nixos but don't need to be bundled
|
||||
extraPackages = with pkgs; [
|
||||
|
|
@ -54,14 +58,14 @@ with final.pkgs.lib; let
|
|||
|
||||
#other
|
||||
jujutsu
|
||||
fd
|
||||
];
|
||||
in {
|
||||
in
|
||||
{
|
||||
nvim-pkg = mkNeovim {
|
||||
plugins = all-plugins;
|
||||
appName = "nvim";
|
||||
extraPackages = basePackages ++ extraPackages;
|
||||
withNodeJs = true;
|
||||
withNodeJs = false;
|
||||
};
|
||||
|
||||
nvim-min-pkg = mkNeovim {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue