mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-30 04:14:28 +02:00
nixvim: support standalone nixvim
This represents a major rearchitecture for nixvim, so I'm leaving this up to track the progress for now, and to serve as a reference for any breaking changes during transition. The main change is, of course, being able to use nixvim standalone. To do this, you should use the new build function, which takes in two arguments: the system architecture (e.g. x86_64-linux) and the configuration. For the new configuration, do not use the programs.nixvim. prefix. For module development, the main change is that you should no longer prefix your modules with programs.nixvim..
This commit is contained in:
parent
bd6f978d51
commit
4ddd3969e5
52 changed files with 1410 additions and 904 deletions
|
@ -1,19 +1,20 @@
|
|||
{ pkgs, lib, config, ... }:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.programs.nixvim.plugins.coq-nvim;
|
||||
cfg = config.plugins.coq-nvim;
|
||||
helpers = import ../helpers.nix { lib = lib; };
|
||||
plugins = import ../plugin-defs.nix { inherit pkgs; };
|
||||
|
||||
in {
|
||||
in
|
||||
{
|
||||
options = {
|
||||
programs.nixvim.plugins.coq-nvim = {
|
||||
plugins.coq-nvim = {
|
||||
enable = mkEnableOption "Enable coq-nvim";
|
||||
|
||||
installArtifacts = mkEnableOption "Install coq-artifacts";
|
||||
|
||||
autoStart = mkOption {
|
||||
type = with types; nullOr (oneOf [bool (enum ["shut-up"])]);
|
||||
type = with types; nullOr (oneOf [ bool (enum [ "shut-up" ]) ]);
|
||||
default = null;
|
||||
description = "Auto-start or shut up";
|
||||
};
|
||||
|
@ -25,13 +26,14 @@ in {
|
|||
};
|
||||
};
|
||||
};
|
||||
config = let
|
||||
settings = {
|
||||
auto_start = cfg.autoStart;
|
||||
"keymap.recommended" = cfg.recommendedKeymaps;
|
||||
};
|
||||
in mkIf cfg.enable {
|
||||
programs.nixvim = {
|
||||
config =
|
||||
let
|
||||
settings = {
|
||||
auto_start = cfg.autoStart;
|
||||
"keymap.recommended" = cfg.recommendedKeymaps;
|
||||
};
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
extraPlugins = [
|
||||
plugins.coq-nvim
|
||||
] ++ optional cfg.installArtifacts plugins.coq-artifacts;
|
||||
|
@ -40,8 +42,7 @@ in {
|
|||
vim.g.coq_settings = ${helpers.toLuaObject settings}
|
||||
local coq = require 'coq'
|
||||
'';
|
||||
setupWrappers = [(s: ''coq.lsp_ensure_capabilities(${s})'')];
|
||||
setupWrappers = [ (s: ''coq.lsp_ensure_capabilities(${s})'') ];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{ pkgs, config, lib, ... }@args:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.programs.nixvim.plugins.nvim-cmp;
|
||||
cfg = config.plugins.nvim-cmp;
|
||||
helpers = import ../../helpers.nix { lib = lib; };
|
||||
mkNullOrOption = helpers.mkNullOrOption;
|
||||
cmpLib = import ./cmp-helpers.nix args;
|
||||
|
@ -14,7 +14,7 @@ let
|
|||
''${functionName}(${parameterString})'';
|
||||
in
|
||||
{
|
||||
options.programs.nixvim.plugins.nvim-cmp = {
|
||||
options.plugins.nvim-cmp = {
|
||||
enable = mkEnableOption "Enable nvim-cmp";
|
||||
|
||||
performance = mkOption {
|
||||
|
@ -392,32 +392,30 @@ in
|
|||
};
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
programs.nixvim = {
|
||||
extraPlugins = [ pkgs.vimPlugins.nvim-cmp ];
|
||||
extraPlugins = [ pkgs.vimPlugins.nvim-cmp ];
|
||||
|
||||
extraConfigLua = ''
|
||||
local cmp = require('cmp')
|
||||
cmp.setup(${helpers.toLuaObject options})
|
||||
'';
|
||||
extraConfigLua = ''
|
||||
local cmp = require('cmp')
|
||||
cmp.setup(${helpers.toLuaObject options})
|
||||
'';
|
||||
|
||||
# If auto_enable_sources is set to true, figure out which are provided by the user
|
||||
# and enable the corresponding plugins.
|
||||
plugins =
|
||||
let
|
||||
flattened_sources = if (isNull cfg.sources) then [ ] else flatten cfg.sources;
|
||||
# Take only the names from the sources provided by the user
|
||||
found_sources = lists.unique (lists.map (source: source.name) flattened_sources);
|
||||
# A list of known source names
|
||||
known_source_names = attrNames cmpLib.pluginAndSourceNames;
|
||||
# If auto_enable_sources is set to true, figure out which are provided by the user
|
||||
# and enable the corresponding plugins.
|
||||
plugins =
|
||||
let
|
||||
flattened_sources = if (isNull cfg.sources) then [ ] else flatten cfg.sources;
|
||||
# Take only the names from the sources provided by the user
|
||||
found_sources = lists.unique (lists.map (source: source.name) flattened_sources);
|
||||
# A list of known source names
|
||||
known_source_names = attrNames cmpLib.pluginAndSourceNames;
|
||||
|
||||
attrs_enabled = listToAttrs (map
|
||||
(name: {
|
||||
name = cmpLib.pluginAndSourceNames.${name};
|
||||
value.enable = mkIf (elem name found_sources) true;
|
||||
})
|
||||
known_source_names);
|
||||
in
|
||||
mkIf cfg.auto_enable_sources attrs_enabled;
|
||||
};
|
||||
attrs_enabled = listToAttrs (map
|
||||
(name: {
|
||||
name = cmpLib.pluginAndSourceNames.${name};
|
||||
value.enable = mkIf (elem name found_sources) true;
|
||||
})
|
||||
known_source_names);
|
||||
in
|
||||
mkIf cfg.auto_enable_sources attrs_enabled;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue