modules: make lib calls explicit where possible

This commit is contained in:
raf 2024-02-26 08:05:23 +03:00
commit 024e1a6845
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29
41 changed files with 245 additions and 203 deletions

View file

@ -1,4 +1,4 @@
_: {
{
imports = [
./nvim-cmp
];

View file

@ -4,8 +4,11 @@
...
}: let
inherit (builtins) toJSON;
inherit (lib) addDescriptionsToMappings concatMapStringsSep attrNames concatStringsSep mapAttrsToList mkIf mkSetLuaBinding mkMerge optionalString;
inherit (lib.nvim) dag;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.attrsets) attrNames mapAttrsToList;
inherit (lib.strings) concatMapStringsSep concatStringsSep optionalString;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding;
inherit (lib.nvim.dag) entryAnywhere entryAfter;
cfg = config.vim.autocomplete;
lspkindEnabled = config.vim.lsp.enable && config.vim.lsp.lspkind.enable;
@ -33,8 +36,8 @@
dagPlacement =
if lspkindEnabled
then dag.entryAfter ["lspkind"]
else dag.entryAnywhere;
then entryAfter ["lspkind"]
else entryAnywhere;
in {
config = mkIf cfg.enable {
vim.startPlugins = [
@ -195,7 +198,7 @@ in {
local cmp = require'cmp'
cmp.setup({
${optionalString (config.vim.ui.borders.enable) ''
${optionalString config.vim.ui.borders.enable ''
-- explicitly enabled by setting ui.borders.enable = true
-- TODO: try to get nvim-cmp to follow global border style
window = {

View file

@ -1,5 +1,7 @@
{lib, ...}: let
inherit (lib) mkEnableOption mkMappingOption mkOption types;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.types) enum attrsOf nullOr str;
in {
options.vim = {
autocomplete = {
@ -16,7 +18,7 @@ in {
};
type = mkOption {
type = types.enum ["nvim-cmp"];
type = enum ["nvim-cmp"];
default = "nvim-cmp";
description = "Set the autocomplete plugin. Options: [nvim-cmp]";
};
@ -31,7 +33,7 @@ in {
Note: only use a single attribute name per attribute set
'';
type = with types; attrsOf (nullOr str);
type = attrsOf (nullOr str);
default = {};
example = ''
{nvim-cmp = null; buffer = "[Buffer]";}
@ -48,7 +50,7 @@ in {
Default is to call the menu mapping function.
'';
type = types.str;
type = str;
default = "nvim_cmp_menu_map";
example = lib.literalMD ''
```lua