mirror of
https://github.com/nix-community/nixvim.git
synced 2025-08-03 01:25:22 +02:00
added formatter + reformat existing codebase (#175)
This commit is contained in:
parent
0bf4313f22
commit
264de8cefb
96 changed files with 3727 additions and 3341 deletions
|
@ -1,7 +1,10 @@
|
|||
{ config, lib, ... }:
|
||||
with lib;
|
||||
let
|
||||
helpers = import ../lib/helpers.nix { inherit lib; };
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
helpers = import ../lib/helpers.nix {inherit lib;};
|
||||
|
||||
autoGroupOption = types.submodule {
|
||||
options = {
|
||||
|
@ -47,13 +50,11 @@ let
|
|||
nested = helpers.defaultNullOpts.mkBool false "Run nested autocommands.";
|
||||
};
|
||||
};
|
||||
|
||||
in
|
||||
{
|
||||
in {
|
||||
options = {
|
||||
autoGroups = mkOption {
|
||||
type = types.attrsOf autoGroupOption;
|
||||
default = { };
|
||||
default = {};
|
||||
description = "augroup definitions";
|
||||
example = ''
|
||||
autoGroups = {
|
||||
|
@ -66,7 +67,7 @@ in
|
|||
|
||||
autoCmd = mkOption {
|
||||
type = types.listOf autoCmdOption;
|
||||
default = [ ];
|
||||
default = [];
|
||||
description = "autocmd definitions";
|
||||
example = ''
|
||||
autoCmd = [
|
||||
|
@ -80,40 +81,41 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
config = mkIf (config.autoGroups != { } || config.autoCmd != { }) {
|
||||
extraConfigLuaPost = (optionalString (config.autoGroups != { }) ''
|
||||
-- Set up autogroups {{
|
||||
do
|
||||
local __nixvim_autogroups = ${helpers.toLuaObject config.autoGroups}
|
||||
config = mkIf (config.autoGroups != {} || config.autoCmd != {}) {
|
||||
extraConfigLuaPost =
|
||||
(optionalString (config.autoGroups != {}) ''
|
||||
-- Set up autogroups {{
|
||||
do
|
||||
local __nixvim_autogroups = ${helpers.toLuaObject config.autoGroups}
|
||||
|
||||
for group_name, options in pairs(__nixvim_autogroups) do
|
||||
vim.api.nvim_create_augroup(group_name, options)
|
||||
for group_name, options in pairs(__nixvim_autogroups) do
|
||||
vim.api.nvim_create_augroup(group_name, options)
|
||||
end
|
||||
end
|
||||
end
|
||||
-- }}
|
||||
'') +
|
||||
(optionalString (config.autoCmd != [ ]) ''
|
||||
-- Set up autocommands {{
|
||||
do
|
||||
local __nixvim_autocommands = ${helpers.toLuaObject config.autoCmd}
|
||||
-- }}
|
||||
'')
|
||||
+ (optionalString (config.autoCmd != []) ''
|
||||
-- Set up autocommands {{
|
||||
do
|
||||
local __nixvim_autocommands = ${helpers.toLuaObject config.autoCmd}
|
||||
|
||||
for _, autocmd in ipairs(__nixvim_autocommands) do
|
||||
vim.api.nvim_create_autocmd(
|
||||
autocmd.event,
|
||||
{
|
||||
group = autocmd.group,
|
||||
pattern = autocmd.pattern,
|
||||
buffer = autocmd.buffer,
|
||||
desc = autocmd.desc,
|
||||
callback = autocmd.callback,
|
||||
command = autocmd.command,
|
||||
once = autocmd.once,
|
||||
nested = autocmd.nested
|
||||
}
|
||||
)
|
||||
for _, autocmd in ipairs(__nixvim_autocommands) do
|
||||
vim.api.nvim_create_autocmd(
|
||||
autocmd.event,
|
||||
{
|
||||
group = autocmd.group,
|
||||
pattern = autocmd.pattern,
|
||||
buffer = autocmd.buffer,
|
||||
desc = autocmd.desc,
|
||||
callback = autocmd.callback,
|
||||
command = autocmd.command,
|
||||
once = autocmd.once,
|
||||
nested = autocmd.nested
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
-- }}
|
||||
'');
|
||||
-- }}
|
||||
'');
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
{ config, lib, ... }:
|
||||
with lib;
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib; {
|
||||
options = {
|
||||
colorscheme = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
|
|
|
@ -1,56 +1,58 @@
|
|||
{ config, lib, ... }:
|
||||
let
|
||||
helpers = import ../lib/helpers.nix { inherit lib; };
|
||||
in
|
||||
with lib;
|
||||
{
|
||||
options = {
|
||||
highlight = mkOption {
|
||||
type = types.attrsOf types.anything;
|
||||
default = { };
|
||||
description = "Define highlight groups";
|
||||
example = ''
|
||||
highlight = {
|
||||
Comment.fg = '#ff0000';
|
||||
};
|
||||
'';
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
helpers = import ../lib/helpers.nix {inherit lib;};
|
||||
in
|
||||
with lib; {
|
||||
options = {
|
||||
highlight = mkOption {
|
||||
type = types.attrsOf types.anything;
|
||||
default = {};
|
||||
description = "Define highlight groups";
|
||||
example = ''
|
||||
highlight = {
|
||||
Comment.fg = '#ff0000';
|
||||
};
|
||||
'';
|
||||
};
|
||||
|
||||
match = mkOption {
|
||||
type = types.attrsOf types.str;
|
||||
default = {};
|
||||
description = "Define match groups";
|
||||
example = ''
|
||||
match = {
|
||||
ExtraWhitespace = '\\s\\+$';
|
||||
};
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
match = mkOption {
|
||||
type = types.attrsOf types.str;
|
||||
default = { };
|
||||
description = "Define match groups";
|
||||
example = ''
|
||||
match = {
|
||||
ExtraWhitespace = '\\s\\+$';
|
||||
};
|
||||
'';
|
||||
};
|
||||
};
|
||||
config = mkIf (config.highlight != {} || config.match != {}) {
|
||||
extraConfigLuaPost =
|
||||
(optionalString (config.highlight != {}) ''
|
||||
-- Highlight groups {{
|
||||
do
|
||||
local highlights = ${helpers.toLuaObject config.highlight}
|
||||
|
||||
config = mkIf (config.highlight != { } || config.match != { }) {
|
||||
extraConfigLuaPost = (optionalString (config.highlight != { }) ''
|
||||
-- Highlight groups {{
|
||||
do
|
||||
local highlights = ${helpers.toLuaObject config.highlight}
|
||||
|
||||
for k,v in pairs(highlights) do
|
||||
vim.api.nvim_set_hl(0, k, v)
|
||||
end
|
||||
end
|
||||
-- }}
|
||||
'') +
|
||||
(optionalString (config.match != { }) ''
|
||||
-- Match groups {{
|
||||
do
|
||||
local match = ${helpers.toLuaObject config.match}
|
||||
|
||||
for k,v in pairs(match) do
|
||||
vim.fn.matchadd(k, v)
|
||||
for k,v in pairs(highlights) do
|
||||
vim.api.nvim_set_hl(0, k, v)
|
||||
end
|
||||
end
|
||||
end
|
||||
-- }}
|
||||
'');
|
||||
};
|
||||
}
|
||||
-- }}
|
||||
'')
|
||||
+ (optionalString (config.match != {}) ''
|
||||
-- Match groups {{
|
||||
do
|
||||
local match = ${helpers.toLuaObject config.match}
|
||||
|
||||
for k,v in pairs(match) do
|
||||
vim.fn.matchadd(k, v)
|
||||
end
|
||||
end
|
||||
-- }}
|
||||
'');
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
{ config, lib, ... }:
|
||||
with lib;
|
||||
let
|
||||
helpers = import ../lib/helpers.nix { inherit lib; };
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
helpers = import ../lib/helpers.nix {inherit lib;};
|
||||
|
||||
mapOption = types.oneOf [
|
||||
types.str
|
||||
|
@ -57,13 +60,13 @@ let
|
|||
})
|
||||
];
|
||||
|
||||
mapOptions = mode: mkOption {
|
||||
description = "Mappings for ${mode} mode";
|
||||
type = types.attrsOf mapOption;
|
||||
default = { };
|
||||
};
|
||||
in
|
||||
{
|
||||
mapOptions = mode:
|
||||
mkOption {
|
||||
description = "Mappings for ${mode} mode";
|
||||
type = types.attrsOf mapOption;
|
||||
default = {};
|
||||
};
|
||||
in {
|
||||
options = {
|
||||
maps = mkOption {
|
||||
type = types.submodule {
|
||||
|
@ -82,7 +85,7 @@ in
|
|||
command = mapOptions "command-line";
|
||||
};
|
||||
};
|
||||
default = { };
|
||||
default = {};
|
||||
description = ''
|
||||
Custom keybindings for any mode.
|
||||
|
||||
|
@ -101,32 +104,30 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
mappings =
|
||||
(helpers.genMaps "" config.maps.normalVisualOp) ++
|
||||
(helpers.genMaps "n" config.maps.normal) ++
|
||||
(helpers.genMaps "i" config.maps.insert) ++
|
||||
(helpers.genMaps "v" config.maps.visual) ++
|
||||
(helpers.genMaps "x" config.maps.visualOnly) ++
|
||||
(helpers.genMaps "s" config.maps.select) ++
|
||||
(helpers.genMaps "t" config.maps.terminal) ++
|
||||
(helpers.genMaps "o" config.maps.operator) ++
|
||||
(helpers.genMaps "l" config.maps.lang) ++
|
||||
(helpers.genMaps "!" config.maps.insertCommand) ++
|
||||
(helpers.genMaps "c" config.maps.command);
|
||||
in
|
||||
{
|
||||
extraConfigLua = optionalString (mappings != [ ]) ''
|
||||
-- Set up keybinds {{{
|
||||
do
|
||||
local __nixvim_binds = ${helpers.toLuaObject mappings}
|
||||
config = let
|
||||
mappings =
|
||||
(helpers.genMaps "" config.maps.normalVisualOp)
|
||||
++ (helpers.genMaps "n" config.maps.normal)
|
||||
++ (helpers.genMaps "i" config.maps.insert)
|
||||
++ (helpers.genMaps "v" config.maps.visual)
|
||||
++ (helpers.genMaps "x" config.maps.visualOnly)
|
||||
++ (helpers.genMaps "s" config.maps.select)
|
||||
++ (helpers.genMaps "t" config.maps.terminal)
|
||||
++ (helpers.genMaps "o" config.maps.operator)
|
||||
++ (helpers.genMaps "l" config.maps.lang)
|
||||
++ (helpers.genMaps "!" config.maps.insertCommand)
|
||||
++ (helpers.genMaps "c" config.maps.command);
|
||||
in {
|
||||
extraConfigLua = optionalString (mappings != []) ''
|
||||
-- Set up keybinds {{{
|
||||
do
|
||||
local __nixvim_binds = ${helpers.toLuaObject mappings}
|
||||
|
||||
for i, map in ipairs(__nixvim_binds) do
|
||||
vim.keymap.set(map.mode, map.key, map.action, map.config)
|
||||
end
|
||||
for i, map in ipairs(__nixvim_binds) do
|
||||
vim.keymap.set(map.mode, map.key, map.action, map.config)
|
||||
end
|
||||
-- }}}
|
||||
'';
|
||||
};
|
||||
end
|
||||
-- }}}
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,44 +1,48 @@
|
|||
{ config, lib, ... }:
|
||||
with lib;
|
||||
let
|
||||
helpers = import ../lib/helpers.nix { inherit lib; };
|
||||
in
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
helpers = import ../lib/helpers.nix {inherit lib;};
|
||||
in {
|
||||
options = {
|
||||
options = mkOption {
|
||||
type = types.attrsOf types.anything;
|
||||
default = { };
|
||||
default = {};
|
||||
description = "The configuration options, e.g. line numbers";
|
||||
};
|
||||
|
||||
globals = mkOption {
|
||||
type = types.attrsOf types.anything;
|
||||
default = { };
|
||||
default = {};
|
||||
description = "Global variables";
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
extraConfigLuaPre = optionalString (config.globals != { }) ''
|
||||
-- Set up globals {{{
|
||||
do
|
||||
local nixvim_globals = ${helpers.toLuaObject config.globals}
|
||||
extraConfigLuaPre =
|
||||
optionalString (config.globals != {}) ''
|
||||
-- Set up globals {{{
|
||||
do
|
||||
local nixvim_globals = ${helpers.toLuaObject config.globals}
|
||||
|
||||
for k,v in pairs(nixvim_globals) do
|
||||
vim.g[k] = v
|
||||
for k,v in pairs(nixvim_globals) do
|
||||
vim.g[k] = v
|
||||
end
|
||||
end
|
||||
end
|
||||
-- }}}
|
||||
'' + optionalString (config.options != { }) ''
|
||||
-- Set up options {{{
|
||||
do
|
||||
local nixvim_options = ${helpers.toLuaObject config.options}
|
||||
-- }}}
|
||||
''
|
||||
+ optionalString (config.options != {}) ''
|
||||
-- Set up options {{{
|
||||
do
|
||||
local nixvim_options = ${helpers.toLuaObject config.options}
|
||||
|
||||
for k,v in pairs(nixvim_options) do
|
||||
vim.opt[k] = v
|
||||
for k,v in pairs(nixvim_options) do
|
||||
vim.opt[k] = v
|
||||
end
|
||||
end
|
||||
end
|
||||
-- }}}
|
||||
'';
|
||||
-- }}}
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
{ pkgs, config, lib, ... }:
|
||||
with lib;
|
||||
let
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
pluginWithConfigType = types.submodule {
|
||||
options = {
|
||||
config = mkOption {
|
||||
|
@ -9,9 +13,11 @@ let
|
|||
default = "";
|
||||
};
|
||||
|
||||
optional = mkEnableOption "optional" // {
|
||||
description = "Don't load by default (load with :packadd)";
|
||||
};
|
||||
optional =
|
||||
mkEnableOption "optional"
|
||||
// {
|
||||
description = "Don't load by default (load with :packadd)";
|
||||
};
|
||||
|
||||
plugin = mkOption {
|
||||
type = types.package;
|
||||
|
@ -19,8 +25,7 @@ let
|
|||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
in {
|
||||
options = {
|
||||
viAlias = mkOption {
|
||||
type = types.bool;
|
||||
|
@ -46,13 +51,13 @@ in
|
|||
|
||||
extraPlugins = mkOption {
|
||||
type = with types; listOf (either package pluginWithConfigType);
|
||||
default = [ ];
|
||||
default = [];
|
||||
description = "List of vim plugins to install";
|
||||
};
|
||||
|
||||
extraPackages = mkOption {
|
||||
type = types.listOf types.package;
|
||||
default = [ ];
|
||||
default = [];
|
||||
description = "Extra packages to be made available to neovim";
|
||||
};
|
||||
|
||||
|
@ -74,7 +79,6 @@ in
|
|||
description = "Extra contents for init.lua after everything else";
|
||||
};
|
||||
|
||||
|
||||
extraConfigVim = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
|
@ -101,18 +105,23 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
config = let
|
||||
defaultPlugin = {
|
||||
plugin = null;
|
||||
config = "";
|
||||
optional = false;
|
||||
};
|
||||
|
||||
defaultPlugin = {
|
||||
plugin = null;
|
||||
config = "";
|
||||
optional = false;
|
||||
};
|
||||
normalizedPlugins = map (x:
|
||||
defaultPlugin
|
||||
// (
|
||||
if x ? plugin
|
||||
then x
|
||||
else {plugin = x;}
|
||||
))
|
||||
config.extraPlugins;
|
||||
|
||||
normalizedPlugins = map (x: defaultPlugin // (if x ? plugin then x else { plugin = x; })) config.extraPlugins;
|
||||
|
||||
neovimConfig = pkgs.neovimUtils.makeNeovimConfig ({
|
||||
neovimConfig = pkgs.neovimUtils.makeNeovimConfig ({
|
||||
inherit (config) viAlias vimAlias;
|
||||
# inherit customRC;
|
||||
plugins = normalizedPlugins;
|
||||
|
@ -121,44 +130,47 @@ in
|
|||
# or more generally before the commit:
|
||||
# cda1f8ae468 - neovim: pass packpath via the wrapper
|
||||
// optionalAttrs (functionArgs pkgs.neovimUtils.makeNeovimConfig ? configure) {
|
||||
configure.packages =
|
||||
{ nixvim = { start = map (x: x.plugin) normalizedPlugins; opt = [ ]; }; };
|
||||
configure.packages = {
|
||||
nixvim = {
|
||||
start = map (x: x.plugin) normalizedPlugins;
|
||||
opt = [];
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
customRC =
|
||||
''
|
||||
vim.cmd([[
|
||||
${neovimConfig.neovimRcContent}
|
||||
]])
|
||||
'' +
|
||||
(optionalString (config.extraConfigLuaPre != "") ''
|
||||
${config.extraConfigLuaPre}
|
||||
'') +
|
||||
(optionalString (config.extraConfigVim != "") ''
|
||||
vim.cmd([[
|
||||
${config.extraConfigVim}
|
||||
]])
|
||||
'') +
|
||||
(optionalString (config.extraConfigLua != "" || config.extraConfigLuaPost != "") ''
|
||||
${config.extraConfigLua}
|
||||
${config.extraConfigLuaPost}
|
||||
'');
|
||||
customRC =
|
||||
''
|
||||
vim.cmd([[
|
||||
${neovimConfig.neovimRcContent}
|
||||
]])
|
||||
''
|
||||
+ (optionalString (config.extraConfigLuaPre != "") ''
|
||||
${config.extraConfigLuaPre}
|
||||
'')
|
||||
+ (optionalString (config.extraConfigVim != "") ''
|
||||
vim.cmd([[
|
||||
${config.extraConfigVim}
|
||||
]])
|
||||
'')
|
||||
+ (optionalString (config.extraConfigLua != "" || config.extraConfigLuaPost != "") ''
|
||||
${config.extraConfigLua}
|
||||
${config.extraConfigLuaPost}
|
||||
'');
|
||||
|
||||
extraWrapperArgs = builtins.concatStringsSep " " (
|
||||
(optional (config.extraPackages != [ ])
|
||||
''--prefix PATH : "${makeBinPath config.extraPackages}"'')
|
||||
++
|
||||
(optional (config.wrapRc)
|
||||
''--add-flags -u --add-flags "${pkgs.writeText "init.lua" customRC}"'')
|
||||
);
|
||||
extraWrapperArgs = builtins.concatStringsSep " " (
|
||||
(optional (config.extraPackages != [])
|
||||
''--prefix PATH : "${makeBinPath config.extraPackages}"'')
|
||||
++ (optional (config.wrapRc)
|
||||
''--add-flags -u --add-flags "${pkgs.writeText "init.lua" customRC}"'')
|
||||
);
|
||||
|
||||
wrappedNeovim = pkgs.wrapNeovimUnstable config.package (neovimConfig // {
|
||||
wrappedNeovim = pkgs.wrapNeovimUnstable config.package (neovimConfig
|
||||
// {
|
||||
wrapperArgs = lib.escapeShellArgs neovimConfig.wrapperArgs + " " + extraWrapperArgs;
|
||||
wrapRc = false;
|
||||
});
|
||||
in
|
||||
{
|
||||
finalPackage = wrappedNeovim;
|
||||
initContent = customRC;
|
||||
};
|
||||
in {
|
||||
finalPackage = wrappedNeovim;
|
||||
initContent = customRC;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
{ ... }:
|
||||
{
|
||||
{...}: {
|
||||
imports = [
|
||||
../plugins/default.nix
|
||||
];
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
{ lib, ... }:
|
||||
with lib;
|
||||
|
||||
{
|
||||
{lib, ...}:
|
||||
with lib; {
|
||||
options = {
|
||||
warnings = mkOption {
|
||||
type = types.listOf types.str;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue