mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
packer: init plugin
This commit is contained in:
parent
5ffa2b4543
commit
f7e02b3ccf
6 changed files with 119 additions and 22 deletions
18
flake.lock
generated
18
flake.lock
generated
|
@ -57,11 +57,11 @@
|
||||||
"pre-commit-hooks": "pre-commit-hooks"
|
"pre-commit-hooks": "pre-commit-hooks"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1615968721,
|
"lastModified": 1616055137,
|
||||||
"narHash": "sha256-ZcwQ6b0opzgZZw9Tnmbd+F0VfxETk1CdQw6wv6Z9sXs=",
|
"narHash": "sha256-pEVSPu8MnqAj4xHYPZ/oKcwFkPqFKm2fMDv1nw8YA8E=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "neovim-nightly-overlay",
|
"repo": "neovim-nightly-overlay",
|
||||||
"rev": "d1e9a434963196fc1a3415e146ca66f00024651c",
|
"rev": "b247024d70256660111942e6c51e6486487edc14",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -88,11 +88,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1615949961,
|
"lastModified": 1615991631,
|
||||||
"narHash": "sha256-4H/yj5nXo/BztcYUyAaz5NkNmF1Gb02nxeQ6C2w95ig=",
|
"narHash": "sha256-TEDPXYy9sVLyctW/OBqxhxlxPmvTwRqXBch0eexJm8Y=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "8e1891d5b8d0b898db8890ddab73141f0cd3c2bc",
|
"rev": "f137bcd5c92906ae0f924769a95b8c8e6602f90b",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -104,11 +104,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs_2": {
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1615797423,
|
"lastModified": 1615888535,
|
||||||
"narHash": "sha256-5NGDZXPQzuoxf/42NiyC9YwwhwzfMfIRrz3aT0XHzSc=",
|
"narHash": "sha256-wR49KkuahcNq1xU3Tk+Mfbob3g2/B/fpbWPw8X+1wsg=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "266dc8c3d052f549826ba246d06787a219533b8f",
|
"rev": "1f77a4c8c74bbe896053994836790aa9bf6dc5ba",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
14
flake.nix
14
flake.nix
|
@ -43,8 +43,18 @@
|
||||||
pkgs.vimPlugins.vim-nix
|
pkgs.vimPlugins.vim-nix
|
||||||
];
|
];
|
||||||
|
|
||||||
options.number = true;
|
options = {
|
||||||
options.mouse = "a";
|
number = true;
|
||||||
|
mouse = "a";
|
||||||
|
tabstop = 2;
|
||||||
|
shiftwidth = 2;
|
||||||
|
expandtab = true;
|
||||||
|
smarttab = true;
|
||||||
|
autoindent = true;
|
||||||
|
cindent = true;
|
||||||
|
linebreak = true;
|
||||||
|
hidden = true;
|
||||||
|
};
|
||||||
|
|
||||||
maps.normalVisualOp."ç" = ":";
|
maps.normalVisualOp."ç" = ":";
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
./colorschemes/one.nix
|
./colorschemes/one.nix
|
||||||
./colorschemes/base16.nix
|
./colorschemes/base16.nix
|
||||||
|
|
||||||
|
./pluginmanagers/packer.nix
|
||||||
|
|
||||||
./statuslines/lightline.nix
|
./statuslines/lightline.nix
|
||||||
./statuslines/airline.nix
|
./statuslines/airline.nix
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,15 @@ rec {
|
||||||
# lua equivalents!
|
# lua equivalents!
|
||||||
toLuaObject = args:
|
toLuaObject = args:
|
||||||
if builtins.isAttrs args then
|
if builtins.isAttrs args then
|
||||||
"{" + (concatStringsSep ","
|
if hasAttr "__raw" args then
|
||||||
(mapAttrsToList
|
args.__raw
|
||||||
(n: v: "[${toLuaObject n}] = " + (toLuaObject v))
|
else
|
||||||
(filterAttrs (n: v: !isNull v || v == {}) args))) + "}"
|
"{" + (concatStringsSep ","
|
||||||
|
(mapAttrsToList
|
||||||
|
(n: v: if head (stringToCharacters n) == "@" then
|
||||||
|
toLuaObject v
|
||||||
|
else "[${toLuaObject n}] = " + (toLuaObject v))
|
||||||
|
(filterAttrs (n: v: !isNull v || v == {}) args))) + "}"
|
||||||
else if builtins.isList args then
|
else if builtins.isList args then
|
||||||
"{" + concatMapStringsSep "," toLuaObject args + "}"
|
"{" + concatMapStringsSep "," toLuaObject args + "}"
|
||||||
else if builtins.isString args then
|
else if builtins.isString args then
|
||||||
|
@ -97,4 +102,6 @@ rec {
|
||||||
|
|
||||||
inherit value global;
|
inherit value global;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
mkRaw = r: { __raw = r; };
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,7 @@ in
|
||||||
|
|
||||||
disabledLanguages = mkOption {
|
disabledLanguages = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
# Nix is out of date right now! Try not to use it :D
|
default = [];
|
||||||
default = [ "nix" ];
|
|
||||||
description = "A list of languages to disable";
|
description = "A list of languages to disable";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -76,11 +75,17 @@ in
|
||||||
};
|
};
|
||||||
in mkIf cfg.enable {
|
in mkIf cfg.enable {
|
||||||
programs.nixvim = {
|
programs.nixvim = {
|
||||||
extraPlugins = [ pkgs.vimPlugins.nvim-treesitter ];
|
plugins.packer = {
|
||||||
|
enable = true;
|
||||||
extraConfigLua = ''
|
plugins = [{
|
||||||
require('nvim-treesitter.configs').setup(${helpers.toLuaObject tsOptions})
|
name = "nvim-treesitter/nvim-treesitter";
|
||||||
'';
|
run = ":TSUpdate";
|
||||||
|
config = helpers.mkRaw ''function()
|
||||||
|
require('nvim-treesitter.configs').setup(${helpers.toLuaObject tsOptions})
|
||||||
|
end'';
|
||||||
|
}];
|
||||||
|
};
|
||||||
|
extraPackages = [ pkgs.tree-sitter ];
|
||||||
|
|
||||||
options = mkIf cfg.folding {
|
options = mkIf cfg.folding {
|
||||||
foldmethod = "expr";
|
foldmethod = "expr";
|
||||||
|
|
73
plugins/pluginmanagers/packer.nix
Normal file
73
plugins/pluginmanagers/packer.nix
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
{ pkgs, config, lib, ... }:
|
||||||
|
with lib;
|
||||||
|
let
|
||||||
|
cfg = config.programs.nixvim.plugins.packer;
|
||||||
|
helpers = import ../helpers.nix { lib = lib; };
|
||||||
|
in {
|
||||||
|
options = {
|
||||||
|
programs.nixvim.plugins.packer = {
|
||||||
|
enable = mkEnableOption "Enable packer.nvim";
|
||||||
|
|
||||||
|
plugins = mkOption {
|
||||||
|
type = types.listOf (types.oneOf [types.str (with types; let
|
||||||
|
mkOpt = type: desc: mkOption {
|
||||||
|
type = nullOr type;
|
||||||
|
default = null;
|
||||||
|
description = desc;
|
||||||
|
};
|
||||||
|
function = attrsOf str;
|
||||||
|
in types.submodule {
|
||||||
|
options = {
|
||||||
|
name = mkOption {
|
||||||
|
type = str;
|
||||||
|
description = "Name of the plugin to install";
|
||||||
|
};
|
||||||
|
|
||||||
|
disable = mkOpt bool "Mark plugin as inactive";
|
||||||
|
as = mkOpt bool "Specifies an alias under which to install the plugin";
|
||||||
|
installer = mkOpt function "A custom installer";
|
||||||
|
updater = mkOpt function "A custom updater";
|
||||||
|
after = mkOpt (oneOf [str (listOf any)]) "Plugins to load after this plugin";
|
||||||
|
rtp = mkOpt str "Specifies a subdirectory of the plugin to add to runtimepath";
|
||||||
|
opt = mkOpt str "Marks a plugin as optional";
|
||||||
|
branch = mkOpt str "Git branch to use";
|
||||||
|
tag = mkOpt str "Git tag to use";
|
||||||
|
commit = mkOpt str "Git commit to use";
|
||||||
|
lock = mkOpt bool "Skip this plugin in updates";
|
||||||
|
run = mkOpt (oneOf [str function]) "Post-install hook";
|
||||||
|
requires = mkOpt (oneOf [str (listOf any)]) "Plugin dependencies";
|
||||||
|
rocks = mkOpt (oneOf [str (listOf any)]) "Luarocks dependencies";
|
||||||
|
config = mkOpt (oneOf [str function]) "Code to run after this plugin is loaded";
|
||||||
|
setup = mkOpt (oneOf [str function]) "Code to be run before this plugin is loaded";
|
||||||
|
cmd = mkOpt (oneOf [str (listOf str)]) "Commands which load this plugin";
|
||||||
|
ft = mkOpt (oneOf [str (listOf str)]) "Filetypes which load this plugin";
|
||||||
|
keys = mkOpt (oneOf [str (listOf str)]) "Keymaps which load this plugin";
|
||||||
|
event = mkOpt (oneOf [str (listOf str)]) "Autocommand events which load this plugin";
|
||||||
|
fn = mkOpt (oneOf [str (listOf str)]) "Functions which load this plugin";
|
||||||
|
cond = mkOpt (oneOf [str function (listOf (oneOf [str function]))]) "Conditional test to load this plugin";
|
||||||
|
module = mkOpt (oneOf [str (listOf str)]) "Patterns of module names which load this plugin";
|
||||||
|
};
|
||||||
|
})]);
|
||||||
|
default = [];
|
||||||
|
description = "List of plugins";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
programs.nixvim = {
|
||||||
|
extraPlugins = [ pkgs.vimPlugins.packer-nvim ];
|
||||||
|
|
||||||
|
extraConfigLua = let
|
||||||
|
plugins = map (plugin: if isAttrs plugin then
|
||||||
|
mapAttrs' (k: v: { name = if k == "name" then "@" else k; value = v; }) plugin
|
||||||
|
else plugin) cfg.plugins;
|
||||||
|
packedPlugins = if length plugins == 1 then head plugins else plugins;
|
||||||
|
in mkIf (cfg.plugins != []) ''
|
||||||
|
require('packer').startup(function()
|
||||||
|
use ${helpers.toLuaObject packedPlugins}
|
||||||
|
end)
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue