mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
add vim-airline
This commit is contained in:
parent
005df95e7b
commit
7122ccd208
9 changed files with 142 additions and 18 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
.tmp/
|
2
.tmp
2
.tmp
|
@ -1 +1 @@
|
||||||
/nix/store/5ixvasljzz7fixv2nd28c8d6bsnam3ap-nixos-system-nixos-21.03.20201227.2f47650
|
/nix/store/r2p2qi63zznjdf0gjif7v8qmsm5g72d7-nixos-system-nixos-21.03.20201227.2f47650
|
|
@ -35,7 +35,12 @@
|
||||||
package = pkgs.neovim-nightly;
|
package = pkgs.neovim-nightly;
|
||||||
colorschemes.gruvbox.enable = true;
|
colorschemes.gruvbox.enable = true;
|
||||||
|
|
||||||
plugins.lightline.enable = true;
|
options.number = true;
|
||||||
|
|
||||||
|
plugins.airline = {
|
||||||
|
enable = true;
|
||||||
|
powerline = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
48
nixvim.nix
48
nixvim.nix
|
@ -21,6 +21,8 @@ let
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
helpers = import ./plugins/helpers.nix { lib = lib; };
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
|
@ -60,6 +62,18 @@ in
|
||||||
type = types.attrsOf types.anything;
|
type = types.attrsOf types.anything;
|
||||||
default = { };
|
default = { };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
options = mkOption {
|
||||||
|
type = types.attrsOf types.anything;
|
||||||
|
default = { };
|
||||||
|
description = "The configuration options, e.g. line numbers";
|
||||||
|
};
|
||||||
|
|
||||||
|
globals = mkOption {
|
||||||
|
type = types.attrsOf types.anything;
|
||||||
|
default = {};
|
||||||
|
description = "Global variables";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -85,7 +99,11 @@ in
|
||||||
environment.systemPackages = [ wrappedNeovim ];
|
environment.systemPackages = [ wrappedNeovim ];
|
||||||
programs.nixvim = {
|
programs.nixvim = {
|
||||||
configure = {
|
configure = {
|
||||||
customRC = cfg.extraConfigVim + (optionalString (cfg.colorscheme != "") ''
|
customRC = ''
|
||||||
|
lua <<EOF
|
||||||
|
${cfg.extraConfigLua}
|
||||||
|
EOF
|
||||||
|
'' + cfg.extraConfigVim + (optionalString (cfg.colorscheme != "") ''
|
||||||
|
|
||||||
colorscheme ${cfg.colorscheme}
|
colorscheme ${cfg.colorscheme}
|
||||||
'');
|
'');
|
||||||
|
@ -98,6 +116,34 @@ in
|
||||||
cfg.extraPlugins);
|
cfg.extraPlugins);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extraConfigLua = optionalString (cfg.globals != {}) ''
|
||||||
|
-- Set up globals {{{
|
||||||
|
local __nixvim_globals = ${helpers.toLuaObject cfg.globals}
|
||||||
|
|
||||||
|
for k,v in pairs(__nixvim_globals) do
|
||||||
|
vim.g[k] = v
|
||||||
|
end
|
||||||
|
-- }}}
|
||||||
|
'' + optionalString (cfg.options != {}) ''
|
||||||
|
-- Set up options {{{
|
||||||
|
local __nixvim_options = ${helpers.toLuaObject cfg.options}
|
||||||
|
|
||||||
|
for k,v in pairs(__nixvim_options) do
|
||||||
|
-- Here we use the set command because, as of right now, neovim has
|
||||||
|
-- no equivalent using the lua API. You have to sort through the
|
||||||
|
-- options and know which options are local to what
|
||||||
|
if type(v) == "boolean" then
|
||||||
|
local no
|
||||||
|
if v then no = "" else no = "no" end
|
||||||
|
|
||||||
|
vim.cmd("set " .. no .. k)
|
||||||
|
else
|
||||||
|
vim.cmd("set " .. k .. "=" .. tostring(v))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- }}}
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
environment.etc."xdg/nvim/sysinit.vim".text = neovimConfig.neovimRcContent;
|
environment.etc."xdg/nvim/sysinit.vim".text = neovimConfig.neovimRcContent;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./statuslines/lightline.nix
|
./statuslines/lightline.nix
|
||||||
|
./statuslines/airline.nix
|
||||||
./colorschemes/gruvbox.nix
|
./colorschemes/gruvbox.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ rec {
|
||||||
"{" + (concatStringsSep ","
|
"{" + (concatStringsSep ","
|
||||||
(mapAttrsToList
|
(mapAttrsToList
|
||||||
(n: v: "[${toLuaObject n}] = " + (toLuaObject v))
|
(n: v: "[${toLuaObject n}] = " + (toLuaObject v))
|
||||||
args)) + "}"
|
(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
|
||||||
|
|
75
plugins/statuslines/airline.nix
Normal file
75
plugins/statuslines/airline.nix
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
{ pkgs, config, lib, ... }:
|
||||||
|
with lib;
|
||||||
|
let
|
||||||
|
cfg = config.programs.nixvim.plugins.airline;
|
||||||
|
helpers = import ../helpers.nix { inherit lib; };
|
||||||
|
|
||||||
|
sectionType = with types; nullOr (oneOf [ str (listOf str)]);
|
||||||
|
sectionOption = mkOption {
|
||||||
|
default = null;
|
||||||
|
type = sectionType;
|
||||||
|
description = "Configuration for this section. Can be either a statusline-format string or a list of modules to be passed to airline#section#create_*.";
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
options = {
|
||||||
|
programs.nixvim.plugins.airline = {
|
||||||
|
enable = mkEnableOption "Enable airline";
|
||||||
|
|
||||||
|
extensions = mkOption {
|
||||||
|
default = null;
|
||||||
|
type = with types; nullOr attrs;
|
||||||
|
description = "A list of extensions and their configuration";
|
||||||
|
};
|
||||||
|
|
||||||
|
onTop = mkOption {
|
||||||
|
default = false;
|
||||||
|
type = types.bool;
|
||||||
|
description = "Whether to show the statusline on the top instead of the bottom";
|
||||||
|
};
|
||||||
|
|
||||||
|
sections = mkOption {
|
||||||
|
default = null;
|
||||||
|
type = with types; nullOr (submodule {
|
||||||
|
options = {
|
||||||
|
a = sectionOption;
|
||||||
|
b = sectionOption;
|
||||||
|
c = sectionOption;
|
||||||
|
x = sectionOption;
|
||||||
|
y = sectionOption;
|
||||||
|
z = sectionOption;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
powerline = mkOption {
|
||||||
|
default = null;
|
||||||
|
type = with types; nullOr bool;
|
||||||
|
description = "Whether to use powerline symbols";
|
||||||
|
};
|
||||||
|
|
||||||
|
theme = mkOption {
|
||||||
|
default = config.programs.nixvim.colorscheme;
|
||||||
|
type = with types; nullOr str;
|
||||||
|
description = "The theme to use for vim-airline. If set, vim-airline-themes will be installed.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = let
|
||||||
|
sections = {};
|
||||||
|
in mkIf cfg.enable {
|
||||||
|
programs.nixvim = {
|
||||||
|
extraPlugins = with pkgs.vimPlugins; [
|
||||||
|
vim-airline
|
||||||
|
] ++ optional (!isNull cfg.theme) vim-airline-themes;
|
||||||
|
globals = {
|
||||||
|
airline.extensions = cfg.extensions;
|
||||||
|
|
||||||
|
airline_statusline_ontop = mkIf cfg.onTop 1;
|
||||||
|
airline_powerline_fonts = mkIf (cfg.powerline) 1;
|
||||||
|
|
||||||
|
airline_theme = mkIf (!isNull cfg.theme) cfg.theme;
|
||||||
|
} // sections;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -71,29 +71,17 @@ in {
|
||||||
description = "Mode name mappings";
|
description = "Mode name mappings";
|
||||||
default = null;
|
default = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
extraConfig = mkOption {
|
|
||||||
type = types.lines;
|
|
||||||
default = "";
|
|
||||||
description = "Extra configuration for this plugin";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = let
|
config = let
|
||||||
configString = helpers.toVimDict {
|
configAttrs = {
|
||||||
inherit (cfg) colorscheme active component componentFunction modeMap;
|
inherit (cfg) colorscheme active component componentFunction modeMap;
|
||||||
};
|
};
|
||||||
in mkIf cfg.enable {
|
in mkIf cfg.enable {
|
||||||
programs.nixvim = {
|
programs.nixvim = {
|
||||||
extraPlugins = [ pkgs.vimPlugins.lightline-vim ];
|
extraPlugins = [ pkgs.vimPlugins.lightline-vim ];
|
||||||
extraConfigVim = ''
|
globals.lightline = configAttrs;
|
||||||
""" lightline {{{
|
|
||||||
let g:lightline = ${configString}
|
|
||||||
|
|
||||||
${cfg.extraConfig}
|
|
||||||
""" }}}
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
8
test.sh
Executable file
8
test.sh
Executable file
|
@ -0,0 +1,8 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
# Creates a container and then runs the resulting neovim executable with the configuration
|
||||||
|
set -e
|
||||||
|
|
||||||
|
sudo nixos-container destroy nvim-test
|
||||||
|
sudo nixos-container create nvim-test --flake .
|
||||||
|
|
||||||
|
.tmp/sw/bin/nvim -u .tmp/etc/xdg/nvim/sysinit.vim .tmp/etc/xdg/nvim/sysinit.vim
|
Loading…
Add table
Add a link
Reference in a new issue