-
-
Notifications
You must be signed in to change notification settings - Fork 15.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add infrastruture: vimProfile #4432
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VimProfile allows to wrap vim with different configurations. A configuration is composed by enabling and customizing pre-defined modules. A module is a set of vim plugins and vimrc statements that are tightly linked. Configurations are hierarchical and can inherit from each other. The base of each hierarchy of configurations is a distingued default configuration. Enabled vim configurations appear as normal package in nix, and have to be installed accordingly. The vimProfiles are declared either for system wide installations in /etc/nixos/configuration.nix, or for each user in ~/.nixuser/configuration.nix. An example for a vim configuration, here the content of ~/.nixuser/configuration.nix: { config, pkgs, ... }: with pkgs; { programs.vim = { enable = true; leader = " "; general.enable = true; statusline.enable = true; profiles = { # Haskell configuration hvim = { enable = true; exec = { package = pkgs.vim_configurable; bin = "bin/vim"; }; search.enable = true; # leader can be overwritten independently for each module search.leader = "|"; text.enable = true; sidebar.enable = true; # overwrite default key binding sidebar.toggleUndo = "<Leader>uu"; completion.enable = true; haskell.enable = true; }; # graphical Haskell configuration hqvim = { enable = true; # set the name to call the wrapped vim name = "Hvim"; parent = "hvim"; exec = { package = pkgs.qvim; bin = "bin/qvim"; }; # just as an example that inherited modules can also be disabled search.enable = false; }; # same configuration as for default, but with qvim qvim = { # don't make that profile installable enable = false; exec = { package = pkgs.qvim; bin = "bin/qvim"; }; # if no name attribute is given, the attribute name # of the configuration is taken: "qvim" }; # alias declaration for qvim gvim = { enable = true; # inherit from a configuration by its attribute name # you can inherit from a disabled configuration as well parent = "qvim"; # add statement to the generated vimrc; it is inserted # before any module statement vimrc = '' " Leader key timeout set tm=2000 ''; }; }; }; } The declaration above defines the following packages in nix: "vimProfile.hvim", "vimProfile.hqvim" and "vimProfile.gvim". When the default profile is enabled, it is automatically installed with the package "vim". An un-wrapped vim package is always available with "vimPlain". ------------------- Internals of the implementation: A new file "nixos/modules/nixuser-module-list.nix" is added. The file lists modules that are made available both for system configuration and for user configuration. The file is imported by "nixos/modules/module-list.nix" and is used in "pkgs/top-level/all-packages.nix". A new user specific configuration file is introduced. It is located in "~/.nixuser/configuration.nix". The idea is to have a declarative approach for defining the user environment at some point. The configuration file acts as the input of a module evaluation system, similar to "/etc/nixos/configuration.nix" for the NixOS configuration. The configuration modules provided with vimProfile reduce to "nixpkgs.config" attributes, which are added to the configuration of "~/.nixpkgs/config.nix".
I can't figure out why Travis CI build fails. It all works locally on my system --- at least it seems to :) Could someone maybe give it a try, nevertheless? I would also very much like to hear about what you think about it. Any feedback would be highly appreciated! |
Close PR and split it into smaller parts. The PR was superseded by #4493 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The PR was superseded by #4493
VimProfile allows to wrap vim with different configurations.
A configuration is composed by enabling and customizing pre-defined modules.
A module is a set of vim plugins and vimrc statements that are tightly linked.
Configurations are hierarchical and can inherit from each other.
The base of each hierarchy of configurations is a distingued default configuration.
Enabled vim configurations appear as normal package in nix, and have to be
installed accordingly.
The vimProfiles are declared either for system wide installations in
/etc/nixos/configuration.nix, or for each user in ~/.nixuser/configuration.nix.
An example for a vim configuration, here the content of ~/.nixuser/configuration.nix:
{ config, pkgs, ... }:
with pkgs;
{
programs.vim =
{ enable = true;
leader = " ";
general.enable = true;
statusline.enable = true;
profiles =
{ # Haskell configuration
hvim =
{ enable = true;
exec = { package = pkgs.vim_configurable; bin = "bin/vim"; };
search.enable = true;
# leader can be overwritten independently for each module
search.leader = "|";
text.enable = true;
sidebar.enable = true;
# overwrite default key binding
sidebar.toggleUndo = "uu";
completion.enable = true;
haskell.enable = true;
};
# graphical Haskell configuration
hqvim =
{ enable = true;
# set the name to call the wrapped vim
name = "Hvim";
parent = "hvim";
exec = { package = pkgs.qvim; bin = "bin/qvim"; };
# just as an example that inherited modules can also be disabled
search.enable = false;
};
# same configuration as for default, but with qvim
qvim =
{ # don't make that profile installable
enable = false;
exec = { package = pkgs.qvim; bin = "bin/qvim"; };
# if no name attribute is given, the attribute name
# of the configuration is taken: "qvim"
};
# alias declaration for qvim
gvim =
{ enable = true;
# inherit from a configuration by its attribute name
# you can inherit from a disabled configuration as well
parent = "qvim";
# add statement to the generated vimrc; it is inserted
# before any module statement
vimrc = ''
" Leader key timeout
set tm=2000
'';
};
};
};
}
The declaration above defines the following packages in nix:
"vimProfile.hvim", "vimProfile.hqvim" and "vimProfile.gvim".
When the default profile is enabled, it is automatically installed with
the package "vim".
An un-wrapped vim package is always available with "vimPlain".
Internals of the implementation:
A new file "nixos/modules/nixuser-module-list.nix" is added.
The file lists modules that are made available both for system configuration
and for user configuration.
The file is imported by "nixos/modules/module-list.nix" and is used in
"pkgs/top-level/all-packages.nix".
A new user specific configuration file is introduced.
It is located in "~/.nixuser/configuration.nix".
The idea is to have a declarative approach for defining the user environment
at some point. The configuration file acts as the input of a module evaluation
system, similar to "/etc/nixos/configuration.nix" for the NixOS configuration.
The configuration modules provided with vimProfile reduce to "nixpkgs.config"
attributes, which are added to the configuration of "~/.nixpkgs/config.nix".