mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-06 02:11:33 +00:00
treewide: Use nixpkgs fetchers for npins
plugins: switch from neodev to lazydev
This commit is contained in:
parent
7510ef2c13
commit
8adc4c352a
32 changed files with 700 additions and 681 deletions
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
self,
|
||||
inputs,
|
||||
lib,
|
||||
}: {
|
||||
|
@ -23,7 +24,7 @@
|
|||
specialArgs =
|
||||
extraSpecialArgs
|
||||
// {
|
||||
inherit inputs;
|
||||
inherit self inputs;
|
||||
modulesPath = toString ./.;
|
||||
};
|
||||
modules = concatLists [
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.meta) getExe;
|
||||
inherit (lib.lists) isList;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.types) either listOf package str;
|
||||
inherit (lib.nvim.types) mkGrammarOption;
|
||||
inherit (lib.nvim.lua) expToLua;
|
||||
|
@ -16,6 +15,12 @@
|
|||
|
||||
cfg = config.vim.languages.lua;
|
||||
in {
|
||||
imports = [
|
||||
(lib.mkRemovedOptionModule ["vim" "languages" "lua" "lsp" "neodev"] ''
|
||||
neodev has been replaced by lazydev
|
||||
'')
|
||||
];
|
||||
|
||||
options.vim.languages.lua = {
|
||||
enable = mkEnableOption "Lua language support";
|
||||
treesitter = {
|
||||
|
@ -32,7 +37,7 @@ in {
|
|||
default = pkgs.lua-language-server;
|
||||
};
|
||||
|
||||
neodev.enable = mkEnableOption "neodev.nvim integration, useful for neovim plugin developers";
|
||||
lazydev.enable = mkEnableOption "lazydev.nvim integration, useful for neovim plugin developers";
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -49,7 +54,6 @@ in {
|
|||
lspconfig.lua_ls.setup {
|
||||
capabilities = capabilities;
|
||||
on_attach = default_on_attach;
|
||||
${optionalString cfg.lsp.neodev.enable "before_init = require('neodev.lsp').before_init;"}
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then expToLua cfg.lsp.package
|
||||
|
@ -59,10 +63,15 @@ in {
|
|||
'';
|
||||
})
|
||||
|
||||
(mkIf cfg.lsp.neodev.enable {
|
||||
vim.startPlugins = ["neodev-nvim"];
|
||||
vim.pluginRC.neodev = entryBefore ["lua-lsp"] ''
|
||||
require("neodev").setup({})
|
||||
(mkIf cfg.lsp.lazydev.enable {
|
||||
vim.startPlugins = ["lazydev-nvim"];
|
||||
vim.pluginRC.lazydev = entryBefore ["lua-lsp"] ''
|
||||
require("lazydev").setup({
|
||||
enabled = function(root_dir)
|
||||
return not vim.uv.fs_stat(root_dir .. "/.luarc.json")
|
||||
end,
|
||||
library = { { path = "''${3rd}/luv/library", words = { "vim%.uv" } } },
|
||||
})
|
||||
'';
|
||||
})
|
||||
]))
|
||||
|
|
|
@ -22,7 +22,7 @@ in {
|
|||
];
|
||||
vim = {
|
||||
startPlugins = [
|
||||
"lsp-signature"
|
||||
"lsp-signature-nvim"
|
||||
];
|
||||
|
||||
lsp.lspSignature.setupOpts = {
|
||||
|
|
|
@ -14,7 +14,7 @@ in {
|
|||
{
|
||||
vim = {
|
||||
startPlugins = [
|
||||
"none-ls"
|
||||
"none-ls-nvim"
|
||||
"plenary-nvim"
|
||||
];
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ in {
|
|||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = [
|
||||
"todo-comments"
|
||||
"todo-comments-nvim"
|
||||
];
|
||||
|
||||
maps.normal = mkMerge [
|
||||
|
|
|
@ -34,7 +34,7 @@ in {
|
|||
})
|
||||
(mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = ["lualine"];
|
||||
startPlugins = ["lualine-nvim"];
|
||||
pluginRC.lualine = entryAnywhere ''
|
||||
local lualine = require('lualine')
|
||||
lualine.setup ${toLuaObject cfg.setupOpts}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = ["smartcolumn"];
|
||||
startPlugins = ["smartcolumn-nvim"];
|
||||
|
||||
pluginRC.smartcolumn = entryAnywhere ''
|
||||
require("smartcolumn").setup(${toLuaObject cfg.setupOpts})
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = ["which-key"];
|
||||
startPlugins = ["which-key-nvim"];
|
||||
|
||||
pluginRC.whichkey = entryAnywhere ''
|
||||
local wk = require("which-key")
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = ["highlight-undo"];
|
||||
startPlugins = ["highlight-undo-nvim"];
|
||||
|
||||
pluginRC.highlight-undo = entryAnywhere ''
|
||||
require("highlight-undo").setup(${toLuaObject cfg.setupOpts})
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = ["indent-blankline"];
|
||||
startPlugins = ["indent-blankline-nvim"];
|
||||
|
||||
pluginRC.indent-blankline = entryAnywhere ''
|
||||
require("ibl").setup(${toLuaObject cfg.setupOpts})
|
||||
|
|
|
@ -1,29 +1,27 @@
|
|||
{
|
||||
inputs,
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}
|
||||
: let
|
||||
}: let
|
||||
inherit (pkgs) vimPlugins;
|
||||
inherit (lib.strings) isString;
|
||||
inherit (lib.lists) filter map;
|
||||
inherit (builtins) path;
|
||||
|
||||
# alias to the internal configuration
|
||||
vimOptions = config.vim;
|
||||
getPin = name: ((pkgs.callPackages ../../../npins/sources.nix {}) // config.vim.pluginOverrides).${name};
|
||||
|
||||
noBuildPlug = pname: let
|
||||
input = inputs."plugin-${pname}";
|
||||
version = input.shortRev or input.shortDirtyRev or "dirty";
|
||||
pin = getPin pname;
|
||||
version = pin.revision or "dirty";
|
||||
in {
|
||||
# vim.lazy.plugins relies on pname, so we only set that here
|
||||
# version isn't needed for anything, but inherit it anyway for correctness
|
||||
inherit pname version;
|
||||
outPath = path {
|
||||
name = "${pname}-0-unstable-${version}";
|
||||
path = input.outPath;
|
||||
path = pin.outPath;
|
||||
};
|
||||
passthru.vimPlugin = false;
|
||||
};
|
||||
|
@ -32,12 +30,12 @@
|
|||
# if the plugin is nvim-treesitter, warn the user to use buildTreesitterPlug
|
||||
# instead
|
||||
buildPlug = attrs: let
|
||||
input = inputs."plugin-${attrs.pname}";
|
||||
pin = getPin attrs.pname;
|
||||
in
|
||||
pkgs.vimUtils.buildVimPlugin (
|
||||
{
|
||||
version = input.shortRev or input.shortDirtyRev or "dirty";
|
||||
src = input.outPath;
|
||||
version = pin.revision or "dirty";
|
||||
src = pin.outPath;
|
||||
}
|
||||
// attrs
|
||||
);
|
||||
|
@ -45,7 +43,7 @@
|
|||
buildTreesitterPlug = grammars: vimPlugins.nvim-treesitter.withPlugins (_: grammars);
|
||||
|
||||
pluginBuilders = {
|
||||
nvim-treesitter = buildTreesitterPlug vimOptions.treesitter.grammars;
|
||||
nvim-treesitter = buildTreesitterPlug config.vim.treesitter.grammars;
|
||||
flutter-tools-patched = buildPlug {
|
||||
pname = "flutter-tools";
|
||||
patches = [./patches/flutter-tools.patch];
|
||||
|
@ -65,39 +63,41 @@
|
|||
};
|
||||
|
||||
buildConfigPlugins = plugins:
|
||||
map (
|
||||
plug:
|
||||
if (isString plug)
|
||||
then pluginBuilders.${plug} or (noBuildPlug plug)
|
||||
else plug
|
||||
) (filter (f: f != null) plugins);
|
||||
map (plug:
|
||||
if (isString plug)
|
||||
then pluginBuilders.${plug} or (noBuildPlug plug)
|
||||
else plug) (
|
||||
filter (f: f != null) plugins
|
||||
);
|
||||
|
||||
# built (or "normalized") plugins that are modified
|
||||
builtStartPlugins = buildConfigPlugins vimOptions.startPlugins;
|
||||
builtOptPlugins = map (package: package // {optional = true;}) (buildConfigPlugins vimOptions.optPlugins);
|
||||
builtStartPlugins = buildConfigPlugins config.vim.startPlugins;
|
||||
builtOptPlugins = map (package: package // {optional = true;}) (
|
||||
buildConfigPlugins config.vim.optPlugins
|
||||
);
|
||||
|
||||
# additional Lua and Python3 packages, mapped to their respective functions
|
||||
# to conform to the format mnw expects. end user should
|
||||
# only ever need to pass a list of packages, which are modified
|
||||
# here
|
||||
extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages;
|
||||
extraPython3Packages = ps: map (x: ps.${x}) vimOptions.python3Packages;
|
||||
extraLuaPackages = ps: map (x: ps.${x}) config.vim.luaPackages;
|
||||
extraPython3Packages = ps: map (x: ps.${x}) config.vim.python3Packages;
|
||||
|
||||
# Wrap the user's desired (unwrapped) Neovim package with arguments that'll be used to
|
||||
# generate a wrapped Neovim package.
|
||||
neovim-wrapped = inputs.mnw.lib.wrap pkgs {
|
||||
neovim = vimOptions.package;
|
||||
neovim = config.vim.package;
|
||||
plugins = builtStartPlugins ++ builtOptPlugins;
|
||||
appName = "nvf";
|
||||
extraBinPath = vimOptions.extraPackages;
|
||||
initLua = vimOptions.builtLuaConfigRC;
|
||||
luaFiles = vimOptions.extraLuaFiles;
|
||||
extraBinPath = config.vim.extraPackages;
|
||||
initLua = config.vim.builtLuaConfigRC;
|
||||
luaFiles = config.vim.extraLuaFiles;
|
||||
|
||||
inherit (vimOptions) viAlias vimAlias withRuby withNodeJs withPython3;
|
||||
inherit (config.vim) viAlias vimAlias withRuby withNodeJs withPython3;
|
||||
inherit extraLuaPackages extraPython3Packages;
|
||||
};
|
||||
|
||||
dummyInit = pkgs.writeText "nvf-init.lua" vimOptions.builtLuaConfigRC;
|
||||
dummyInit = pkgs.writeText "nvf-init.lua" config.vim.builtLuaConfigRC;
|
||||
# Additional helper scripts for printing and displaying nvf configuration
|
||||
# in your commandline.
|
||||
printConfig = pkgs.writers.writeDashBin "nvf-print-config" "cat ${dummyInit}";
|
||||
|
@ -110,10 +110,10 @@
|
|||
paths = [neovim-wrapped printConfig printConfigPath];
|
||||
postBuild = "echo Helpers added";
|
||||
|
||||
# Allow evaluating vimOptions, i.e., config.vim from the packages' passthru
|
||||
# Allow evaluating config.vim, i.e., config.vim from the packages' passthru
|
||||
# attribute. For example, packages.x86_64-linux.neovim.passthru.neovimConfig
|
||||
# will return the configuration in full.
|
||||
passthru.neovimConfig = vimOptions;
|
||||
passthru.neovimConfig = config.vim;
|
||||
|
||||
meta =
|
||||
neovim-wrapped.meta
|
||||
|
|
|
@ -140,5 +140,21 @@ in {
|
|||
example = ''["pynvim"]'';
|
||||
description = "List of python packages to install";
|
||||
};
|
||||
|
||||
pluginOverrides = mkOption {
|
||||
type = attrsOf package;
|
||||
default = {};
|
||||
example = ''
|
||||
{
|
||||
lazydev-nvim = pkgs.fetchFromGitHub {
|
||||
owner = "folke";
|
||||
repo = "lazydev.nvim";
|
||||
rev = "";
|
||||
hash = "";
|
||||
};
|
||||
}
|
||||
'';
|
||||
description = "Attribute set of plugins to override default values";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue