modules: make lib calls explicit where possible

This commit is contained in:
raf 2024-02-26 08:05:23 +03:00
parent bf1118eb28
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,11 +1,14 @@
{ {
pkgs,
config, config,
lib, lib,
... ...
}: let }: let
inherit (builtins) toJSON; inherit (builtins) toJSON;
inherit (lib) mkIf nvim mkLuaBinding mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.lists) optionals;
inherit (lib.trivial) boolToString;
inherit (lib.nvim.binds) mkLuaBinding;
cfg = config.vim.assistant.copilot; cfg = config.vim.assistant.copilot;
@ -27,16 +30,16 @@ in {
"copilot-lua" "copilot-lua"
cfg.copilotNodePackage cfg.copilotNodePackage
] ]
++ lib.optionals (cfg.cmp.enable) [ ++ optionals (cfg.cmp.enable) [
"copilot-cmp" "copilot-cmp"
]; ];
vim.luaConfigRC.copilot = nvim.dag.entryAnywhere '' vim.luaConfigRC.copilot = entryAnywhere ''
require("copilot").setup({ require("copilot").setup({
-- available options: https://github.com/zbirenbaum/copilot.lua -- available options: https://github.com/zbirenbaum/copilot.lua
copilot_node_command = "${cfg.copilotNodeCommand}", copilot_node_command = "${cfg.copilotNodeCommand}",
panel = { panel = {
enabled = ${lib.boolToString (!cfg.cmp.enable)}, enabled = ${boolToString (!cfg.cmp.enable)},
keymap = { keymap = {
jump_prev = false, jump_prev = false,
jump_next = false, jump_next = false,
@ -50,7 +53,7 @@ in {
}, },
}, },
suggestion = { suggestion = {
enabled = ${lib.boolToString (!cfg.cmp.enable)}, enabled = ${boolToString (!cfg.cmp.enable)},
keymap = { keymap = {
accept = false, accept = false,
accept_word = false, accept_word = false,

View file

@ -1,10 +1,12 @@
{ {
pkgs,
config, config,
pkgs,
lib, lib,
... ...
}: let }: let
inherit (lib) mkEnableOption mkOption types; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) enum float nullOr str package;
inherit (lib.meta) getExe;
cfg = config.vim.assistant.copilot; cfg = config.vim.assistant.copilot;
in { in {
@ -14,7 +16,7 @@ in {
panel = { panel = {
position = mkOption { position = mkOption {
type = types.enum [ type = enum [
"bottom" "bottom"
"top" "top"
"left" "left"
@ -24,7 +26,7 @@ in {
description = "Panel position"; description = "Panel position";
}; };
ratio = mkOption { ratio = mkOption {
type = types.float; type = float;
default = 0.4; default = 0.4;
description = "Panel size"; description = "Panel size";
}; };
@ -33,59 +35,68 @@ in {
mappings = { mappings = {
panel = { panel = {
jumpPrev = mkOption { jumpPrev = mkOption {
type = types.nullOr types.str; type = nullOr str;
default = "[["; default = "[[";
description = "Jump to previous suggestion"; description = "Jump to previous suggestion";
}; };
jumpNext = mkOption { jumpNext = mkOption {
type = types.nullOr types.str; type = nullOr str;
default = "]]"; default = "]]";
description = "Jump to next suggestion"; description = "Jump to next suggestion";
}; };
accept = mkOption { accept = mkOption {
type = types.nullOr types.str; type = nullOr str;
default = "<CR>"; default = "<CR>";
description = "Accept suggestion"; description = "Accept suggestion";
}; };
refresh = mkOption { refresh = mkOption {
type = types.nullOr types.str; type = nullOr str;
default = "gr"; default = "gr";
description = "Refresh suggestions"; description = "Refresh suggestions";
}; };
open = mkOption { open = mkOption {
type = types.nullOr types.str; type = nullOr str;
default = "<M-CR>"; default = "<M-CR>";
description = "Open suggestions"; description = "Open suggestions";
}; };
}; };
suggestion = { suggestion = {
accept = mkOption { accept = mkOption {
type = types.nullOr types.str; type = nullOr str;
default = "<M-l>"; default = "<M-l>";
description = "Accept suggetion"; description = "Accept suggetion";
}; };
acceptWord = mkOption { acceptWord = mkOption {
type = types.nullOr types.str; type = nullOr str;
default = null; default = null;
description = "Accept next word"; description = "Accept next word";
}; };
acceptLine = mkOption { acceptLine = mkOption {
type = types.nullOr types.str; type = nullOr str;
default = null; default = null;
description = "Accept next line"; description = "Accept next line";
}; };
prev = mkOption { prev = mkOption {
type = types.nullOr types.str; type = nullOr str;
default = "<M-[>"; default = "<M-[>";
description = "Previous suggestion"; description = "Previous suggestion";
}; };
next = mkOption { next = mkOption {
type = types.nullOr types.str; type = nullOr str;
default = "<M-]>"; default = "<M-]>";
description = "Next suggestion"; description = "Next suggestion";
}; };
dismiss = mkOption { dismiss = mkOption {
type = types.nullOr types.str; type = nullOr str;
default = "<C-]>"; default = "<C-]>";
description = "Dismiss suggestion"; description = "Dismiss suggestion";
}; };
@ -93,8 +104,8 @@ in {
}; };
copilotNodeCommand = mkOption { copilotNodeCommand = mkOption {
type = types.str; type = str;
default = "${lib.getExe cfg.copilotNodePackage}"; default = "${getExe cfg.copilotNodePackage}";
description = '' description = ''
The command that will be executed to initiate nodejs for GitHub Copilot. The command that will be executed to initiate nodejs for GitHub Copilot.
Recommended to leave as default. Recommended to leave as default.
@ -102,7 +113,7 @@ in {
}; };
copilotNodePackage = mkOption { copilotNodePackage = mkOption {
type = with types; nullOr package; type = nullOr package;
default = pkgs.nodejs-slim; default = pkgs.nodejs-slim;
description = '' description = ''
The nodeJS package that will be used for GitHub Copilot. If you are using a custom node command The nodeJS package that will be used for GitHub Copilot. If you are using a custom node command

View file

@ -1,4 +1,4 @@
_: { {
imports = [ imports = [
./copilot.nix ./copilot.nix
./config.nix ./config.nix

View file

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

View file

@ -1,20 +1,22 @@
{ {
lib,
config, config,
lib,
... ...
}: let }: let
inherit (lib) mkIf nvim optionalString boolToString; inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.strings) optionalString;
inherit (lib.trivial) boolToString;
cfg = config.vim.autopairs; cfg = config.vim.autopairs;
in { in {
config = config = mkIf cfg.enable {
mkIf (cfg.enable)
{
vim.startPlugins = ["nvim-autopairs"]; vim.startPlugins = ["nvim-autopairs"];
vim.luaConfigRC.autopairs = nvim.dag.entryAnywhere '' vim.luaConfigRC.autopairs = entryAnywhere ''
require("nvim-autopairs").setup{} require("nvim-autopairs").setup{}
${optionalString (config.vim.autocomplete.type == "nvim-compe") '' ${optionalString (config.vim.autocomplete.type == "nvim-compe") ''
-- nvim-compe integration
require('nvim-autopairs.completion.compe').setup({ require('nvim-autopairs.completion.compe').setup({
map_cr = ${boolToString cfg.nvim-compe.map_cr}, map_cr = ${boolToString cfg.nvim-compe.map_cr},
map_complete = ${boolToString cfg.nvim-compe.map_complete}, map_complete = ${boolToString cfg.nvim-compe.map_complete},

View file

@ -1,4 +1,4 @@
_: { {
imports = [ imports = [
./config.nix ./config.nix
./nvim-autopairs.nix ./nvim-autopairs.nix

View file

@ -1,31 +1,32 @@
{lib, ...}: let {lib, ...}: let
inherit (lib) mkEnableOption mkOption types; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) enum bool;
in { in {
options.vim = { options.vim = {
autopairs = { autopairs = {
enable = mkEnableOption "autopairs" // {default = false;}; enable = mkEnableOption "autopairs" // {default = false;};
type = mkOption { type = mkOption {
type = types.enum ["nvim-autopairs"]; type = enum ["nvim-autopairs"];
default = "nvim-autopairs"; default = "nvim-autopairs";
description = "Set the autopairs type. Options: nvim-autopairs [nvim-autopairs]"; description = "Set the autopairs type. Options: nvim-autopairs [nvim-autopairs]";
}; };
nvim-compe = { nvim-compe = {
map_cr = mkOption { map_cr = mkOption {
type = types.bool; type = bool;
default = true; default = true;
description = ''map <CR> on insert mode''; description = ''map <CR> on insert mode'';
}; };
map_complete = mkOption { map_complete = mkOption {
type = types.bool; type = bool;
default = true; default = true;
description = "auto insert `(` after select function or method item"; description = "auto insert `(` after select function or method item";
}; };
auto_select = mkOption { auto_select = mkOption {
type = types.bool; type = bool;
default = false; default = false;
description = "auto select first item"; description = "auto select first item";
}; };

View file

@ -1,5 +1,6 @@
{lib, ...}: let {lib, ...}: let
inherit (lib) mkEnableOption mkMappingOption; inherit (lib.options) mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption;
in { in {
options.vim.comments.comment-nvim = { options.vim.comments.comment-nvim = {
enable = mkEnableOption "smart and powerful comment plugin for neovim comment-nvim"; enable = mkEnableOption "smart and powerful comment plugin for neovim comment-nvim";

View file

@ -3,13 +3,13 @@
lib, lib,
... ...
}: let }: let
inherit (lib) mkIf mkMerge mkExprBinding mkBinding nvim; inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.binds) mkExprBinding mkBinding;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.comments.comment-nvim; cfg = config.vim.comments.comment-nvim;
self = import ./comment-nvim.nix { self = import ./comment-nvim.nix {inherit lib;};
inherit lib; inherit (self.options.vim.comments.comment-nvim) mappings;
};
mappings = self.options.vim.comments.comment-nvim.mappings;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim.startPlugins = [ vim.startPlugins = [
@ -41,7 +41,7 @@ in {
(mkBinding cfg.mappings.toggleSelectedBlock "<Plug>(comment_toggle_blockwise_visual)" mappings.toggleSelectedBlock.description) (mkBinding cfg.mappings.toggleSelectedBlock "<Plug>(comment_toggle_blockwise_visual)" mappings.toggleSelectedBlock.description)
]; ];
vim.luaConfigRC.comment-nvim = nvim.dag.entryAnywhere '' vim.luaConfigRC.comment-nvim = entryAnywhere ''
require('Comment').setup({ require('Comment').setup({
mappings = { basic = false, extra = false, }, mappings = { basic = false, extra = false, },
}) })

View file

@ -1,4 +1,4 @@
_: { {
imports = [ imports = [
./config.nix ./config.nix
./comment-nvim.nix ./comment-nvim.nix

View file

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

View file

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

View file

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

View file

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

View file

@ -1,11 +1,7 @@
{ {lib, ...}: let
config, inherit (lib.options) mkEnableOption;
lib,
...
}: let
inherit (lib) mkEnableOption;
in { in {
options.vim.dashboard.alpha = { options.vim.dashboard.alpha = {
enable = mkEnableOption "dashboard via alpha.nvim"; enable = mkEnableOption "fast and fully programmable greeter for neovim [alpha.mvim]";
}; };
} }

View file

@ -3,7 +3,8 @@
lib, lib,
... ...
}: let }: let
inherit (lib) mkIf nvim; inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.dashboard.alpha; cfg = config.vim.dashboard.alpha;
in { in {
@ -15,7 +16,7 @@ in {
# the entire credit for this dashboard configuration to https://github.com/Rishabh672003 # the entire credit for this dashboard configuration to https://github.com/Rishabh672003
# honestly, excellent work # honestly, excellent work
vim.luaConfigRC.alpha = nvim.dag.entryAnywhere '' vim.luaConfigRC.alpha = entryAnywhere ''
local alpha = require("alpha") local alpha = require("alpha")
local plenary_path = require("plenary.path") local plenary_path = require("plenary.path")
local dashboard = require("alpha.themes.dashboard") local dashboard = require("alpha.themes.dashboard")

View file

@ -1,4 +1,4 @@
_: { {
imports = [ imports = [
./alpha.nix ./alpha.nix
./config.nix ./config.nix

View file

@ -3,7 +3,8 @@
lib, lib,
... ...
}: let }: let
inherit (lib) mkIf nvim; inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.dashboard.dashboard-nvim; cfg = config.vim.dashboard.dashboard-nvim;
in { in {
@ -12,7 +13,7 @@ in {
"dashboard-nvim" "dashboard-nvim"
]; ];
vim.luaConfigRC.dashboard-nvim = nvim.dag.entryAnywhere '' vim.luaConfigRC.dashboard-nvim = entryAnywhere ''
require("dashboard").setup{} require("dashboard").setup{}
''; '';
}; };

View file

@ -1,11 +1,7 @@
{ {lib, ...}: let
config,
lib,
...
}: let
inherit (lib) mkEnableOption; inherit (lib) mkEnableOption;
in { in {
options.vim.dashboard.dashboard-nvim = { options.vim.dashboard.dashboard-nvim = {
enable = mkEnableOption "dashboard via dashboard.nvim"; enable = mkEnableOption "Fancy and Blazing Fast start screen plugin of neovim [dashboard.nvim]";
}; };
} }

View file

@ -1,4 +1,4 @@
_: { {
imports = [ imports = [
./dashboard-nvim.nix ./dashboard-nvim.nix
./config.nix ./config.nix

View file

@ -1,4 +1,4 @@
{...}: { {
imports = [ imports = [
./alpha ./alpha
./dashboard-nvim ./dashboard-nvim

View file

@ -4,8 +4,8 @@
lib, lib,
... ...
}: let }: let
inherit (lib) mkIf nvim; inherit (lib.modules) mkIf;
inherit (nvim.vim) mkVimBool; inherit (lib.nvim.vim) mkVimBool;
cfg = config.vim.dashboard.startify; cfg = config.vim.dashboard.startify;
in { in {

View file

@ -3,7 +3,8 @@
lib, lib,
... ...
}: let }: let
inherit (lib) mkEnableOption mkOption types; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) listOf attrs bool enum str oneOf int;
in { in {
options.vim.dashboard.startify = { options.vim.dashboard.startify = {
enable = mkEnableOption "dashboard via vim-startify"; enable = mkEnableOption "dashboard via vim-startify";
@ -11,38 +12,38 @@ in {
bookmarks = mkOption { bookmarks = mkOption {
default = []; default = [];
description = ''List of book marks to disaply on start page''; description = ''List of book marks to disaply on start page'';
type = with types; listOf attrs; type = listOf attrs;
example = {"c" = "~/.vimrc";}; example = {"c" = "~/.vimrc";};
}; };
changeToDir = mkOption { changeToDir = mkOption {
default = true; default = true;
description = "Should vim change to the directory of the file you open"; description = "Should vim change to the directory of the file you open";
type = types.bool; type = bool;
}; };
changeToVCRoot = mkOption { changeToVCRoot = mkOption {
default = false; default = false;
description = "Should vim change to the version control root when opening a file"; description = "Should vim change to the version control root when opening a file";
type = types.bool; type = bool;
}; };
changeDirCmd = mkOption { changeDirCmd = mkOption {
default = "lcd"; default = "lcd";
description = "Command to change the current window with. Can be cd, lcd or tcd"; description = "Command to change the current window with. Can be cd, lcd or tcd";
type = types.enum ["cd" "lcd" "tcd"]; type = enum ["cd" "lcd" "tcd"];
}; };
customHeader = mkOption { customHeader = mkOption {
default = []; default = [];
description = "Text to place in the header"; description = "Text to place in the header";
type = with types; listOf str; type = listOf str;
}; };
customFooter = mkOption { customFooter = mkOption {
default = []; default = [];
description = "Text to place in the footer"; description = "Text to place in the footer";
type = with types; listOf str; type = listOf str;
}; };
lists = mkOption { lists = mkOption {
@ -69,121 +70,121 @@ in {
} }
]; ];
description = "Specify the lists and in what order they are displayed on startify."; description = "Specify the lists and in what order they are displayed on startify.";
type = with types; listOf attrs; type = listOf attrs;
}; };
skipList = mkOption { skipList = mkOption {
default = []; default = [];
description = "List of regex patterns to exclude from MRU lists"; description = "List of regex patterns to exclude from MRU lists";
type = with types; listOf str; type = listOf str;
}; };
updateOldFiles = mkOption { updateOldFiles = mkOption {
default = false; default = false;
description = "Set if you want startify to always update and not just when neovim closes"; description = "Set if you want startify to always update and not just when neovim closes";
type = types.bool; type = bool;
}; };
sessionAutoload = mkOption { sessionAutoload = mkOption {
default = false; default = false;
description = "Make startify auto load Session.vim files from the current directory"; description = "Make startify auto load Session.vim files from the current directory";
type = types.bool; type = bool;
}; };
commands = mkOption { commands = mkOption {
default = []; default = [];
description = "Commands that are presented to the user on startify page"; description = "Commands that are presented to the user on startify page";
type = with types; listOf (oneOf [str attrs (listOf str)]); type = listOf (oneOf [str attrs (listOf str)]);
}; };
filesNumber = mkOption { filesNumber = mkOption {
default = 10; default = 10;
description = "How many files to list"; description = "How many files to list";
type = types.int; type = int;
}; };
customIndices = mkOption { customIndices = mkOption {
default = []; default = [];
description = "Specify a list of default charecters to use instead of numbers"; description = "Specify a list of default charecters to use instead of numbers";
type = with types; listOf str; type = listOf str;
}; };
disableOnStartup = mkOption { disableOnStartup = mkOption {
default = false; default = false;
description = "Prevent startify from opening on startup but can be called with :Startify"; description = "Prevent startify from opening on startup but can be called with :Startify";
type = types.bool; type = bool;
}; };
unsafe = mkOption { unsafe = mkOption {
default = false; default = false;
description = "Turns on unsafe mode for Startify. Stops resolving links, checking files are readable and filtering bookmark list"; description = "Turns on unsafe mode for Startify. Stops resolving links, checking files are readable and filtering bookmark list";
type = types.bool; type = bool;
}; };
paddingLeft = mkOption { paddingLeft = mkOption {
default = 3; default = 3;
description = "Number of spaces used for left padding."; description = "Number of spaces used for left padding.";
type = types.int; type = int;
}; };
useEnv = mkOption { useEnv = mkOption {
default = false; default = false;
description = "Show environment variables in path if name is shorter than value"; description = "Show environment variables in path if name is shorter than value";
type = types.bool; type = bool;
}; };
sessionBeforeSave = mkOption { sessionBeforeSave = mkOption {
default = []; default = [];
description = "Commands to run before saving a session"; description = "Commands to run before saving a session";
type = with types; listOf str; type = listOf str;
}; };
sessionPersistence = mkOption { sessionPersistence = mkOption {
default = false; default = false;
description = "Persist session before leaving vim or switching session"; description = "Persist session before leaving vim or switching session";
type = types.bool; type = bool;
}; };
sessionDeleteBuffers = mkOption { sessionDeleteBuffers = mkOption {
default = true; default = true;
description = "Delete all buffers when loading or closing a session"; description = "Delete all buffers when loading or closing a session";
type = types.bool; type = bool;
}; };
sessionDir = mkOption { sessionDir = mkOption {
default = "~/.vim/session"; default = "~/.vim/session";
description = "Directory to save and load sessions from"; description = "Directory to save and load sessions from";
type = types.str; type = str;
}; };
skipListServer = mkOption { skipListServer = mkOption {
default = []; default = [];
description = "List of vim servers to not load startify for"; description = "List of vim servers to not load startify for";
type = with types; listOf str; type = listOf str;
}; };
sessionRemoveLines = mkOption { sessionRemoveLines = mkOption {
default = []; default = [];
description = "Patterns to remove from session files"; description = "Patterns to remove from session files";
type = with types; listOf str; type = listOf str;
}; };
sessionSavevars = mkOption { sessionSavevars = mkOption {
default = []; default = [];
description = "List of variables to save into a session file."; description = "List of variables to save into a session file.";
type = with types; listOf str; type = listOf str;
}; };
sessionSavecmds = mkOption { sessionSavecmds = mkOption {
default = []; default = [];
description = "List of commands to run when loading a session."; description = "List of commands to run when loading a session.";
type = with types; listOf str; type = listOf str;
}; };
sessionSort = mkOption { sessionSort = mkOption {
default = false; default = false;
description = "Set if you want items sorted by date rather than alphabetically"; description = "Set if you want items sorted by date rather than alphabetically";
type = types.bool; type = bool;
}; };
}; };
} }

View file

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

View file

@ -3,12 +3,14 @@
lib, lib,
... ...
}: let }: let
inherit (lib) addDescriptionsToMappings mkMerge mkIf mapAttrs nvim mkSetLuaBinding optionalString; inherit (lib.strings) optionalString;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.attrsets) mapAttrs;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding;
inherit (lib.nvim.dag) entryAnywhere entryAfter;
cfg = config.vim.debugger.nvim-dap; cfg = config.vim.debugger.nvim-dap;
self = import ./nvim-dap.nix { self = import ./nvim-dap.nix {inherit lib;};
inherit lib;
};
mappingDefinitions = self.options.vim.debugger.nvim-dap.mappings; mappingDefinitions = self.options.vim.debugger.nvim-dap.mappings;
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions; mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
in { in {
@ -19,12 +21,12 @@ in {
vim.luaConfigRC = vim.luaConfigRC =
{ {
# TODO customizable keymaps # TODO customizable keymaps
nvim-dap = nvim.dag.entryAnywhere '' nvim-dap = entryAnywhere ''
local dap = require("dap") local dap = require("dap")
vim.fn.sign_define("DapBreakpoint", { text = "🛑", texthl = "ErrorMsg", linehl = "", numhl = "" }) vim.fn.sign_define("DapBreakpoint", { text = "🛑", texthl = "ErrorMsg", linehl = "", numhl = "" })
''; '';
} }
// mapAttrs (_: v: (nvim.dag.entryAfter ["nvim-dap"] v)) cfg.sources; // mapAttrs (_: v: (entryAfter ["nvim-dap"] v)) cfg.sources;
vim.maps.normal = mkMerge [ vim.maps.normal = mkMerge [
(mkSetLuaBinding mappings.continue "require('dap').continue") (mkSetLuaBinding mappings.continue "require('dap').continue")
@ -49,7 +51,7 @@ in {
(mkIf (cfg.enable && cfg.ui.enable) { (mkIf (cfg.enable && cfg.ui.enable) {
vim.startPlugins = ["nvim-dap-ui"]; vim.startPlugins = ["nvim-dap-ui"];
vim.luaConfigRC.nvim-dap-ui = nvim.dag.entryAfter ["nvim-dap"] ('' vim.luaConfigRC.nvim-dap-ui = entryAfter ["nvim-dap"] (''
local dapui = require("dapui") local dapui = require("dapui")
dapui.setup() dapui.setup()
'' ''

View file

@ -1,4 +1,4 @@
_: { {
imports = [ imports = [
./config.nix ./config.nix
./nvim-dap.nix ./nvim-dap.nix

View file

@ -1,5 +1,7 @@
{lib, ...}: let {lib, ...}: let
inherit (lib) mkEnableOption mkOption types mkMappingOption; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) bool attrsOf str;
inherit (lib.nvim.binds) mkMappingOption;
in { in {
options.vim.debugger.nvim-dap = { options.vim.debugger.nvim-dap = {
enable = mkEnableOption "debugging via nvim-dap"; enable = mkEnableOption "debugging via nvim-dap";
@ -7,7 +9,7 @@ in {
ui = { ui = {
enable = mkEnableOption "UI extension for nvim-dap"; enable = mkEnableOption "UI extension for nvim-dap";
autoStart = mkOption { autoStart = mkOption {
type = types.bool; type = bool;
default = true; default = true;
description = "Automatically Opens and Closes DAP-UI upon starting/closing a debugging session"; description = "Automatically Opens and Closes DAP-UI upon starting/closing a debugging session";
}; };
@ -16,7 +18,7 @@ in {
sources = mkOption { sources = mkOption {
default = {}; default = {};
description = "List of debuggers to install"; description = "List of debuggers to install";
type = with types; attrsOf str; type = attrsOf str;
}; };
mappings = { mappings = {

View file

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

View file

@ -4,14 +4,16 @@
pkgs, pkgs,
... ...
}: let }: let
inherit (lib) mkIf mkMerge mkBinding nvim boolToString; inherit (lib.strings) optionalString;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.trivial) boolToString;
inherit (lib.nvim.binds) mkBinding;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) listToLuaTable expToLua;
cfg = config.vim.filetree.nvimTree; cfg = config.vim.filetree.nvimTree;
self = import ./nvimtree.nix { self = import ./nvimtree.nix {inherit pkgs lib;};
inherit pkgs; inherit (self.options.vim.filetree.nvimTree) mappings;
lib = lib;
};
mappings = self.options.vim.filetree.nvimTree.mappings;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim.startPlugins = ["nvim-tree-lua"]; vim.startPlugins = ["nvim-tree-lua"];
@ -23,9 +25,9 @@ in {
(mkBinding cfg.mappings.focus ":NvimTreeFocus<cr>" mappings.focus.description) (mkBinding cfg.mappings.focus ":NvimTreeFocus<cr>" mappings.focus.description)
]; ];
vim.luaConfigRC.nvimtreelua = nvim.dag.entryAnywhere '' vim.luaConfigRC.nvimtreelua = entryAnywhere ''
${ ${
lib.optionalString (cfg.disableNetrw) '' lib.optionalString cfg.disableNetrw ''
-- disable netrew completely -- disable netrew completely
vim.g.loaded_netrw = 1 vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1 vim.g.loaded_netrwPlugin = 1
@ -44,7 +46,7 @@ in {
hijack_unnamed_buffer_when_opening = ${boolToString cfg.hijackUnnamedBufferWhenOpening}, hijack_unnamed_buffer_when_opening = ${boolToString cfg.hijackUnnamedBufferWhenOpening},
hijack_cursor = ${boolToString cfg.hijackCursor}, hijack_cursor = ${boolToString cfg.hijackCursor},
root_dirs = ${nvim.lua.listToLuaTable cfg.rootDirs}, root_dirs = ${listToLuaTable cfg.rootDirs},
prefer_startup_root = ${boolToString cfg.preferStartupRoot}, prefer_startup_root = ${boolToString cfg.preferStartupRoot},
sync_root_with_cwd = ${boolToString cfg.syncRootWithCwd}, sync_root_with_cwd = ${boolToString cfg.syncRootWithCwd},
reload_on_bufenter = ${boolToString cfg.reloadOnBufEnter}, reload_on_bufenter = ${boolToString cfg.reloadOnBufEnter},
@ -58,12 +60,12 @@ in {
update_focused_file = { update_focused_file = {
enable = ${boolToString cfg.updateFocusedFile.enable}, enable = ${boolToString cfg.updateFocusedFile.enable},
update_root = ${boolToString cfg.updateFocusedFile.updateRoot}, update_root = ${boolToString cfg.updateFocusedFile.updateRoot},
ignore_list = ${nvim.lua.listToLuaTable cfg.updateFocusedFile.ignoreList}, ignore_list = ${listToLuaTable cfg.updateFocusedFile.ignoreList},
}, },
system_open = { system_open = {
cmd = "${cfg.systemOpen.cmd}", cmd = "${cfg.systemOpen.cmd}",
args = ${nvim.lua.listToLuaTable cfg.systemOpen.args}, args = ${listToLuaTable cfg.systemOpen.args},
}, },
diagnostics = { diagnostics = {
@ -85,7 +87,7 @@ in {
enable = ${boolToString cfg.git.enable}, enable = ${boolToString cfg.git.enable},
show_on_dirs = ${boolToString cfg.git.showOnDirs}, show_on_dirs = ${boolToString cfg.git.showOnDirs},
show_on_open_dirs = ${boolToString cfg.git.showOnOpenDirs}, show_on_open_dirs = ${boolToString cfg.git.showOnOpenDirs},
disable_for_dirs = ${nvim.lua.listToLuaTable cfg.git.disableForDirs}, disable_for_dirs = ${listToLuaTable cfg.git.disableForDirs},
timeout = ${toString cfg.git.timeout}, timeout = ${toString cfg.git.timeout},
}, },
@ -98,7 +100,7 @@ in {
filesystem_watchers = { filesystem_watchers = {
enable = ${boolToString cfg.filesystemWatchers.enable}, enable = ${boolToString cfg.filesystemWatchers.enable},
debounce_delay = ${toString cfg.filesystemWatchers.debounceDelay}, debounce_delay = ${toString cfg.filesystemWatchers.debounceDelay},
ignore_dirs = ${nvim.lua.listToLuaTable cfg.filesystemWatchers.ignoreDirs}, ignore_dirs = ${listToLuaTable cfg.filesystemWatchers.ignoreDirs},
}, },
select_prompts = ${boolToString cfg.selectPrompts}, select_prompts = ${boolToString cfg.selectPrompts},
@ -107,7 +109,7 @@ in {
centralize_selection = ${boolToString cfg.view.centralizeSelection}, centralize_selection = ${boolToString cfg.view.centralizeSelection},
cursorline = ${boolToString cfg.view.cursorline}, cursorline = ${boolToString cfg.view.cursorline},
debounce_delay = ${toString cfg.view.debounceDelay}, debounce_delay = ${toString cfg.view.debounceDelay},
width = ${nvim.lua.expToLua cfg.view.width}, width = ${expToLua cfg.view.width},
side = "${cfg.view.side}", side = "${cfg.view.side}",
preserve_window_proportions = ${boolToString cfg.view.preserveWindowProportions}, preserve_window_proportions = ${boolToString cfg.view.preserveWindowProportions},
number = ${boolToString cfg.view.number}, number = ${boolToString cfg.view.number},
@ -134,15 +136,15 @@ in {
highlight_git = ${boolToString cfg.renderer.highlightGit}, highlight_git = ${boolToString cfg.renderer.highlightGit},
highlight_opened_files = ${cfg.renderer.highlightOpenedFiles}, highlight_opened_files = ${cfg.renderer.highlightOpenedFiles},
highlight_modified = ${cfg.renderer.highlightModified}, highlight_modified = ${cfg.renderer.highlightModified},
root_folder_label = ${nvim.lua.expToLua cfg.renderer.rootFolderLabel}, root_folder_label = ${expToLua cfg.renderer.rootFolderLabel},
indent_width = ${toString cfg.renderer.indentWidth}, indent_width = ${toString cfg.renderer.indentWidth},
indent_markers = { indent_markers = {
enable = ${boolToString cfg.renderer.indentMarkers.enable}, enable = ${boolToString cfg.renderer.indentMarkers.enable},
inline_arrows = ${boolToString cfg.renderer.indentMarkers.inlineArrows}, inline_arrows = ${boolToString cfg.renderer.indentMarkers.inlineArrows},
icons = ${nvim.lua.expToLua cfg.renderer.indentMarkers.icons}, icons = ${expToLua cfg.renderer.indentMarkers.icons},
}, },
special_files = ${nvim.lua.listToLuaTable cfg.renderer.specialFiles}, special_files = ${listToLuaTable cfg.renderer.specialFiles},
symlink_destination = ${boolToString cfg.renderer.symlinkDestination}, symlink_destination = ${boolToString cfg.renderer.symlinkDestination},
icons = { icons = {
@ -194,7 +196,7 @@ in {
dotfiles = ${boolToString cfg.filters.dotfiles}, dotfiles = ${boolToString cfg.filters.dotfiles},
git_clean = ${boolToString cfg.filters.gitClean}, git_clean = ${boolToString cfg.filters.gitClean},
no_buffer = ${boolToString cfg.filters.noBuffer}, no_buffer = ${boolToString cfg.filters.noBuffer},
exclude = ${nvim.lua.listToLuaTable cfg.filters.exclude}, exclude = ${listToLuaTable cfg.filters.exclude},
}, },
trash = { trash = {
@ -211,11 +213,11 @@ in {
expand_all = { expand_all = {
max_folder_discovery = ${toString cfg.actions.expandAll.maxFolderDiscovery}, max_folder_discovery = ${toString cfg.actions.expandAll.maxFolderDiscovery},
exclude = ${nvim.lua.listToLuaTable cfg.actions.expandAll.exclude}, exclude = ${listToLuaTable cfg.actions.expandAll.exclude},
}, },
file_popup = { file_popup = {
open_win_config = ${nvim.lua.expToLua cfg.actions.filePopup.openWinConfig}, open_win_config = ${expToLua cfg.actions.filePopup.openWinConfig},
}, },
open_file = { open_file = {
@ -227,8 +229,8 @@ in {
picker = "${cfg.actions.openFile.windowPicker.picker}", picker = "${cfg.actions.openFile.windowPicker.picker}",
chars = "${cfg.actions.openFile.windowPicker.chars}", chars = "${cfg.actions.openFile.windowPicker.chars}",
exclude = { exclude = {
filetype = ${nvim.lua.listToLuaTable cfg.actions.openFile.windowPicker.exclude.filetype}, filetype = ${listToLuaTable cfg.actions.openFile.windowPicker.exclude.filetype},
buftype = ${nvim.lua.listToLuaTable cfg.actions.openFile.windowPicker.exclude.buftype}, buftype = ${listToLuaTable cfg.actions.openFile.windowPicker.exclude.buftype},
}, },
}, },
}, },
@ -247,7 +249,7 @@ in {
sync = { sync = {
open = ${boolToString cfg.tab.sync.open}, open = ${boolToString cfg.tab.sync.open},
close = ${boolToString cfg.tab.sync.close}, close = ${boolToString cfg.tab.sync.close},
ignore = ${nvim.lua.listToLuaTable cfg.tab.sync.ignore}, ignore = ${listToLuaTable cfg.tab.sync.ignore},
}, },
}, },
@ -264,9 +266,9 @@ in {
}, },
}) })
-- autostart behaviour
${ ${
lib.optionalString (cfg.openOnSetup) '' optionalString cfg.openOnSetup ''
-- autostart behaviour
-- Open on startup has been deprecated -- Open on startup has been deprecated
-- see https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup -- see https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup

View file

@ -4,11 +4,13 @@
... ...
}: let }: let
inherit (builtins) toJSON; inherit (builtins) toJSON;
inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetExprBinding mkSetLuaBinding nvim; inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetExprBinding mkSetLuaBinding;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.git; cfg = config.vim.git;
self = import ./git.nix {inherit lib;}; self = import ./git.nix {inherit lib config;};
gsMappingDefinitions = self.options.vim.git.gitsigns.mappings; gsMappingDefinitions = self.options.vim.git.gitsigns.mappings;
gsMappings = addDescriptionsToMappings cfg.gitsigns.mappings gsMappingDefinitions; gsMappings = addDescriptionsToMappings cfg.gitsigns.mappings gsMappingDefinitions;
@ -61,7 +63,7 @@ in {
(mkSetLuaBinding gsMappings.resetHunk "function() package.loaded.gitsigns.reset_hunk {vim.fn.line('.'), vim.fn.line('v')} end") (mkSetLuaBinding gsMappings.resetHunk "function() package.loaded.gitsigns.reset_hunk {vim.fn.line('.'), vim.fn.line('v')} end")
]; ];
vim.luaConfigRC.gitsigns = nvim.dag.entryAnywhere '' vim.luaConfigRC.gitsigns = entryAnywhere ''
require('gitsigns').setup{} require('gitsigns').setup{}
''; '';
} }

View file

@ -1,4 +1,4 @@
{...}: { {
imports = [ imports = [
./config.nix ./config.nix
./git.nix ./git.nix

View file

@ -1,11 +1,16 @@
{lib, ...}: let {
inherit (lib) mkEnableOption mkMappingOption; config,
lib,
...
}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption;
in { in {
options.vim.git = { options.vim.git = {
enable = mkEnableOption "git tools via gitsigns"; enable = mkEnableOption "git integration";
gitsigns = { gitsigns = {
enable = mkEnableOption "gitsigns"; enable = mkEnableOption "gitsigns" // {default = config.vim.git.enable;};
mappings = { mappings = {
nextHunk = mkMappingOption "Next hunk [Gitsigns]" "]c"; nextHunk = mkMappingOption "Next hunk [Gitsigns]" "]c";

View file

@ -5,7 +5,10 @@
... ...
}: let }: let
inherit (builtins) attrNames; inherit (builtins) attrNames;
inherit (lib) mkOption mkEnableOption types isList nvim; inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.lists) isList;
inherit (lib.types) enum either package listOf str bool;
inherit (lib.nvim.lua) expToLua;
cfg = config.vim.languages.bash; cfg = config.vim.languages.bash;
@ -19,7 +22,7 @@
on_attach = default_on_attach; on_attach = default_on_attach;
cmd = ${ cmd = ${
if isList cfg.lsp.package if isList cfg.lsp.package
then nvim.lua.expToLua cfg.lsp.package then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/bash-language-server", "start"}'' else ''{"${cfg.lsp.package}/bin/bash-language-server", "start"}''
}; };
} }
@ -70,14 +73,14 @@ in {
server = mkOption { server = mkOption {
description = "Bash LSP server to use"; description = "Bash LSP server to use";
type = with types; enum (attrNames servers); type = enum (attrNames servers);
default = defaultServer; default = defaultServer;
}; };
package = mkOption { package = mkOption {
description = "bash-language-server package, or the command to run as a list of strings"; description = "bash-language-server package, or the command to run as a list of strings";
example = lib.literalExpression ''[lib.getExe pkgs.nodePackages.bash-language-server "start"]''; example = literalExpression ''[lib.getExe pkgs.nodePackages.bash-language-server "start"]'';
type = with types; either package (listOf str); type = either package (listOf str);
default = pkgs.nodePackages.bash-language-server; default = pkgs.nodePackages.bash-language-server;
}; };
}; };
@ -85,25 +88,24 @@ in {
format = { format = {
enable = mkOption { enable = mkOption {
description = "Enable Bash formatting"; description = "Enable Bash formatting";
type = types.bool; type = bool;
default = config.vim.languages.enableFormat; default = config.vim.languages.enableFormat;
}; };
type = mkOption { type = mkOption {
description = "Bash formatter to use"; description = "Bash formatter to use";
type = with types; enum (attrNames formats); type = enum (attrNames formats);
default = defaultFormat; default = defaultFormat;
}; };
package = mkOption { package = mkOption {
description = "Bash formatter package"; description = "Bash formatter package";
type = types.package; type = package;
default = formats.${cfg.format.type}.package; default = formats.${cfg.format.type}.package;
}; };
}; };
extraDiagnostics = { extraDiagnostics = {
enable = mkEnableOption "extra Bash diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;}; enable = mkEnableOption "extra Bash diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;};
types = lib.nvim.types.diagnostics { types = lib.nvim.types.diagnostics {
langDesc = "Bash"; langDesc = "Bash";
inherit diagnostics; inherit diagnostics;

View file

@ -4,7 +4,9 @@
lib, lib,
... ...
}: let }: let
inherit (lib) isList nvim mkIf mkMerge; inherit (lib.lists) isList;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.lua) expToLua;
cfg = config.vim.languages.bash; cfg = config.vim.languages.bash;
diagnostics = { diagnostics = {
@ -44,7 +46,7 @@
on_attach = default_on_attach; on_attach = default_on_attach;
cmd = ${ cmd = ${
if isList cfg.lsp.package if isList cfg.lsp.package
then nvim.lua.expToLua cfg.lsp.package then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/bash-language-server", "start"}'' else ''{"${cfg.lsp.package}/bin/bash-language-server", "start"}''
}; };
} }

View file

@ -1,4 +1,4 @@
_: { {
imports = [ imports = [
./bash.nix ./bash.nix
./config.nix ./config.nix

View file

@ -4,7 +4,12 @@
pkgs, pkgs,
... ...
}: let }: let
inherit (lib) isList nvim mkIf mkMerge optionalString boolToString; inherit (lib.lists) isList;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.strings) optionalString;
inherit (lib.trivial) boolToString;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.languages.dart; cfg = config.vim.languages.dart;
ftcfg = cfg.flutter-tools; ftcfg = cfg.flutter-tools;
@ -17,7 +22,7 @@
on_attach=default_on_attach; on_attach=default_on_attach;
cmd = ${ cmd = ${
if isList cfg.lsp.package if isList cfg.lsp.package
then nvim.lua.expToLua cfg.lsp.package then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/dart", "language-server", "--protocol=lsp"}'' else ''{"${cfg.lsp.package}/bin/dart", "language-server", "--protocol=lsp"}''
}; };
${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.dartOpts}"} ${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.dartOpts}"}
@ -38,13 +43,13 @@ in {
vim.lsp.lspconfig.sources.dart-lsp = servers.${cfg.lsp.server}.lspConfig; vim.lsp.lspconfig.sources.dart-lsp = servers.${cfg.lsp.server}.lspConfig;
}) })
(mkIf (ftcfg.enable) { (mkIf ftcfg.enable {
vim.startPlugins = vim.startPlugins =
if ftcfg.enableNoResolvePatch if ftcfg.enableNoResolvePatch
then ["flutter-tools-patched"] then ["flutter-tools-patched"]
else ["flutter-tools"]; else ["flutter-tools"];
vim.luaConfigRC.flutter-tools = nvim.dag.entryAnywhere '' vim.luaConfigRC.flutter-tools = entryAnywhere ''
require('flutter-tools').setup { require('flutter-tools').setup {
lsp = { lsp = {
color = { -- show the derived colours for dart variables color = { -- show the derived colours for dart variables

View file

@ -5,7 +5,12 @@
... ...
}: let }: let
inherit (builtins) attrNames; inherit (builtins) attrNames;
inherit (lib) isList nvim mkEnableOption mkOption types optionalString; inherit (lib.lists) isList;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) enum either listOf package nullOr str bool;
inherit (lib.strings) optionalString;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.types) mkGrammarOption;
cfg = config.vim.languages.dart; cfg = config.vim.languages.dart;
defaultServer = "dart"; defaultServer = "dart";
@ -18,7 +23,7 @@
on_attach=default_on_attach; on_attach=default_on_attach;
cmd = ${ cmd = ${
if isList cfg.lsp.package if isList cfg.lsp.package
then nvim.lua.expToLua cfg.lsp.package then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/dart", "language-server", "--protocol=lsp"}'' else ''{"${cfg.lsp.package}/bin/dart", "language-server", "--protocol=lsp"}''
}; };
${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.dartOpts}"} ${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.dartOpts}"}
@ -32,25 +37,25 @@ in {
treesitter = { treesitter = {
enable = mkEnableOption "Dart treesitter" // {default = config.vim.languages.enableTreesitter;}; enable = mkEnableOption "Dart treesitter" // {default = config.vim.languages.enableTreesitter;};
package = nvim.types.mkGrammarOption pkgs "dart"; package = mkGrammarOption pkgs "dart";
}; };
lsp = { lsp = {
enable = mkEnableOption "Dart LSP support"; enable = mkEnableOption "Dart LSP support";
server = mkOption { server = mkOption {
description = "The Dart LSP server to use"; description = "The Dart LSP server to use";
type = with types; enum (attrNames servers); type = enum (attrNames servers);
default = defaultServer; default = defaultServer;
}; };
package = mkOption { package = mkOption {
description = "Dart LSP server package, or the command to run as a list of strings"; description = "Dart LSP server package, or the command to run as a list of strings";
example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]''; example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]'';
type = with types; either package (listOf str); type = either package (listOf str);
default = servers.${cfg.lsp.server}.package; default = servers.${cfg.lsp.server}.package;
}; };
opts = mkOption { opts = mkOption {
description = "Options to pass to Dart LSP server"; description = "Options to pass to Dart LSP server";
type = with types; nullOr str; type = nullOr str;
default = null; default = null;
}; };
}; };
@ -58,7 +63,7 @@ in {
dap = { dap = {
enable = mkOption { enable = mkOption {
description = "Enable Dart DAP support via flutter-tools"; description = "Enable Dart DAP support via flutter-tools";
type = types.bool; type = bool;
default = config.vim.languages.enableDAP; default = config.vim.languages.enableDAP;
}; };
}; };
@ -66,7 +71,7 @@ in {
flutter-tools = { flutter-tools = {
enable = mkOption { enable = mkOption {
description = "Enable flutter-tools for flutter support"; description = "Enable flutter-tools for flutter support";
type = types.bool; type = bool;
default = config.vim.languages.enableLSP; default = config.vim.languages.enableLSP;
}; };
@ -76,7 +81,7 @@ in {
This is required if you want to use a flutter package built with nix. This is required if you want to use a flutter package built with nix.
If you are using a flutter SDK installed from a different source and encounter the error "`dart` missing from PATH", disable this option. If you are using a flutter SDK installed from a different source and encounter the error "`dart` missing from PATH", disable this option.
''; '';
type = types.bool; type = bool;
default = true; default = true;
}; };
@ -84,13 +89,13 @@ in {
enable = mkEnableOption "Whether or mot to highlight color variables at all"; enable = mkEnableOption "Whether or mot to highlight color variables at all";
highlightBackground = mkOption { highlightBackground = mkOption {
type = types.bool; type = bool;
default = false; default = false;
description = "Highlight the background"; description = "Highlight the background";
}; };
highlightForeground = mkOption { highlightForeground = mkOption {
type = types.bool; type = bool;
default = false; default = false;
description = "Highlight the foreground"; description = "Highlight the foreground";
}; };
@ -99,7 +104,7 @@ in {
enable = mkEnableOption "Show the highlight using virtual text"; enable = mkEnableOption "Show the highlight using virtual text";
character = mkOption { character = mkOption {
type = types.str; type = str;
default = ""; default = "";
description = "Virtual text character to highlight"; description = "Virtual text character to highlight";
}; };

View file

@ -1,4 +1,4 @@
_: { {
imports = [ imports = [
./dart.nix ./dart.nix
./config.nix ./config.nix

View file

@ -4,7 +4,9 @@
pkgs, pkgs,
... ...
}: let }: let
inherit (lib) nvim mkIf getExe; inherit (lib.modules) mkIf;
inherit (lib.meta) getExe;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.languages.elixir; cfg = config.vim.languages.elixir;
in { in {
@ -13,14 +15,12 @@ in {
"elixir-tools" "elixir-tools"
]; ];
vim.luaConfigRC.elixir-tools = nvim.dag.entryAnywhere '' vim.luaConfigRC.elixir-tools = entryAnywhere ''
local elixir = require("elixir") local elixir = require("elixir")
local elixirls = require("elixir.elixirls") local elixirls = require("elixir.elixirls")
elixir.setup { elixir.setup {
elixirls = { elixirls = {
-- alternatively, point to an existing elixir-ls installation (optional) -- alternatively, point to an existing elixir-ls installation (optional)
-- not currently supported by elixirls, but can be a table if you wish to pass other args `{"path/to/elixirls", "--foo"}` -- not currently supported by elixirls, but can be a table if you wish to pass other args `{"path/to/elixirls", "--foo"}`
cmd = "${getExe pkgs.elixir-ls}", cmd = "${getExe pkgs.elixir-ls}",
@ -51,6 +51,7 @@ in {
vim.keymap.set("n", "<space>K", "<cmd>lua vim.lsp.buf.hover()<cr>", map_opts) vim.keymap.set("n", "<space>K", "<cmd>lua vim.lsp.buf.hover()<cr>", map_opts)
vim.keymap.set("n", "<space>gD","<cmd>lua vim.lsp.buf.implementation()<cr>", map_opts) vim.keymap.set("n", "<space>gD","<cmd>lua vim.lsp.buf.implementation()<cr>", map_opts)
vim.keymap.set("n", "<space>1gD","<cmd>lua vim.lsp.buf.type_definition()<cr>", map_opts) vim.keymap.set("n", "<space>1gD","<cmd>lua vim.lsp.buf.type_definition()<cr>", map_opts)
-- keybinds for fzf-lsp.nvim: https://github.com/gfanto/fzf-lsp.nvim -- keybinds for fzf-lsp.nvim: https://github.com/gfanto/fzf-lsp.nvim
-- you could also use telescope.nvim: https://github.com/nvim-telescope/telescope.nvim -- you could also use telescope.nvim: https://github.com/nvim-telescope/telescope.nvim
-- there are also core vim.lsp functions that put the same data in the loclist -- there are also core vim.lsp functions that put the same data in the loclist

View file

@ -1,4 +1,4 @@
_: { {
imports = [ imports = [
./config.nix ./config.nix
./elixir-tools.nix ./elixir-tools.nix

View file

@ -1,9 +1,5 @@
{ {lib, ...}: let
config, inherit (lib.options) mkEnableOption;
lib,
...
}: let
inherit (lib) mkEnableOption;
in { in {
options.vim.languages.elixir = { options.vim.languages.elixir = {
enable = mkEnableOption "Elixir language support"; enable = mkEnableOption "Elixir language support";