1
0
Fork 0
mirror of https://github.com/NotAShelf/neovim-flake.git synced 2024-12-25 04:39:47 +01:00

modules/notes: switch to explicit lib calls

This commit is contained in:
NotAShelf 2024-03-12 03:47:01 +03:00
parent f6db808bfc
commit 2101ac9061
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29
13 changed files with 154 additions and 144 deletions

View file

@ -1,4 +1,4 @@
_: {
{
imports = [
./obsidian
./orgmode

View file

@ -3,27 +3,31 @@
lib,
...
}: let
inherit (lib) mkIf nvim pushDownDefault;
inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.binds) pushDownDefault;
cfg = config.vim.notes.mind-nvim;
in {
config = mkIf (cfg.enable) {
vim.startPlugins = [
"mind-nvim"
];
config = mkIf cfg.enable {
vim = {
startPlugins = [
"mind-nvim"
];
vim.maps.normal = {
"<leader>om" = {action = ":MindOpenMain<CR>";};
"<leader>op" = {action = ":MindOpenProject<CR>";};
"<leader>oc" = {action = ":MindClose<CR>";};
maps.normal = {
"<leader>om" = {action = ":MindOpenMain<CR>";};
"<leader>op" = {action = ":MindOpenProject<CR>";};
"<leader>oc" = {action = ":MindClose<CR>";};
};
binds.whichKey.register = pushDownDefault {
"<leader>o" = "+Notes";
};
luaConfigRC.mind-nvim = entryAnywhere ''
require'mind'.setup()
'';
};
vim.binds.whichKey.register = pushDownDefault {
"<leader>o" = "+Notes";
};
vim.luaConfigRC.mind-nvim = nvim.dag.entryAnywhere ''
require'mind'.setup()
'';
};
}

View file

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

View file

@ -1,11 +1,7 @@
{
config,
lib,
...
}: let
inherit (lib) mkEnableOption;
{lib, ...}: let
inherit (lib.options) mkEnableOption;
in {
options.vim.notes.mind-nvim = {
enable = mkEnableOption "organizer tool for Neovim.";
enable = mkEnableOption "note organizer tool for Neovim [mind-nvim]";
};
}

View file

@ -3,45 +3,49 @@
lib,
...
}: let
inherit (lib) mkIf nvim pushDownDefault;
inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.binds) pushDownDefault;
cfg = config.vim.notes.obsidian;
auto = config.vim.autocomplete;
in {
config = mkIf (cfg.enable) {
vim.startPlugins = [
"obsidian-nvim"
"vim-markdown"
"tabular"
];
config = mkIf cfg.enable {
vim = {
startPlugins = [
"obsidian-nvim"
"vim-markdown"
"tabular"
];
vim.binds.whichKey.register = pushDownDefault {
"<leader>o" = "+Notes";
};
binds.whichKey.register = pushDownDefault {
"<leader>o" = "+Notes";
};
vim.luaConfigRC.obsidian = nvim.dag.entryAnywhere ''
require("obsidian").setup({
dir = "${cfg.dir}",
completion = {
nvim_cmp = ${
if (auto.type == "nvim-cmp")
then "true"
else "false"
}
},
daily_notes = {
folder = ${
if (cfg.daily-notes.folder == "")
then "nil,"
else "'${cfg.daily-notes.folder}',"
}
date_format = ${
if (cfg.daily-notes.date-format == "")
then "nil,"
else "'${cfg.daily-notes.date-format}',"
}
luaConfigRC.obsidian = entryAnywhere ''
require("obsidian").setup({
dir = "${cfg.dir}",
completion = {
nvim_cmp = ${
if (auto.type == "nvim-cmp")
then "true"
else "false"
}
})
'';
},
daily_notes = {
folder = ${
if (cfg.daily-notes.folder == "")
then "nil,"
else "'${cfg.daily-notes.folder}',"
}
date_format = ${
if (cfg.daily-notes.date-format == "")
then "nil,"
else "'${cfg.daily-notes.date-format}',"
}
}
})
'';
};
};
}

View file

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

View file

@ -1,27 +1,24 @@
{
config,
lib,
...
}: let
inherit (lib) mkEnableOption mkOption types;
{lib, ...}: let
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) str bool;
in {
options.vim.notes = {
obsidian = {
enable = mkEnableOption "complementary neovim plugins for Obsidian editor";
dir = mkOption {
type = types.str;
type = str;
default = "~/my-vault";
description = "Obsidian vault directory";
};
daily-notes = {
folder = mkOption {
type = types.str;
type = str;
default = "";
description = "Directory in which daily notes should be created";
};
date-format = mkOption {
type = types.str;
type = str;
default = "";
description = "Date format used for creating daily notes";
};
@ -29,8 +26,7 @@ in {
completion = {
nvim_cmp = mkOption {
# if using nvim-cmp, otherwise set to false
type = types.bool;
type = bool;
description = "If using nvim-cmp, otherwise set to false";
};
};

View file

@ -3,42 +3,46 @@
lib,
...
}: let
inherit (lib) mkIf mkMerge nvim pushDownDefault;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.binds) pushDownDefault;
cfg = config.vim.notes.orgmode;
in {
config = mkIf cfg.enable (mkMerge [
{
vim.startPlugins = [
"orgmode-nvim"
];
vim = {
startPlugins = [
"orgmode-nvim"
];
vim.binds.whichKey.register = pushDownDefault {
"<leader>o" = "+Notes";
binds.whichKey.register = pushDownDefault {
"<leader>o" = "+Notes";
};
luaConfigRC.orgmode = entryAnywhere ''
-- Load custom treesitter grammar for org filetype
require('orgmode').setup_ts_grammar()
-- Treesitter configuration
require('nvim-treesitter.configs').setup {
-- If TS highlights are not enabled at all, or disabled via `disable` prop,
-- highlighting will fallback to default Vim syntax highlighting
highlight = {
enable = true,
-- Required for spellcheck, some LaTex highlights and
-- code block highlights that do not have ts grammar
additional_vim_regex_highlighting = {'org'},
},
}
require('orgmode').setup({
org_agenda_files = ${cfg.orgAgendaFiles},
org_default_notes_file = '${cfg.orgDefaultNotesFile}',
})
'';
};
vim.luaConfigRC.orgmode = nvim.dag.entryAnywhere ''
-- Load custom treesitter grammar for org filetype
require('orgmode').setup_ts_grammar()
-- Treesitter configuration
require('nvim-treesitter.configs').setup {
-- If TS highlights are not enabled at all, or disabled via `disable` prop,
-- highlighting will fallback to default Vim syntax highlighting
highlight = {
enable = true,
-- Required for spellcheck, some LaTex highlights and
-- code block highlights that do not have ts grammar
additional_vim_regex_highlighting = {'org'},
},
}
require('orgmode').setup({
org_agenda_files = ${cfg.orgAgendaFiles},
org_default_notes_file = '${cfg.orgDefaultNotesFile}',
})
'';
}
(mkIf cfg.treesitter.enable {

View file

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

View file

@ -4,27 +4,28 @@
pkgs,
...
}: let
inherit (lib) mkEnableOption types mkOption nvim;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) str;
inherit (lib.nvim.types) mkGrammarOption;
in {
options.vim.notes.orgmode = {
enable = mkEnableOption "nvim-orgmode: Neovim plugin for Emac Orgmode. Get the best of both worlds";
orgAgendaFiles = mkOption {
type = types.str;
type = str;
default = "{'~/Documents/org/*', '~/my-orgs/**/*'}";
description = "List of org files to be used as agenda files.";
};
orgDefaultNotesFile = mkOption {
type = types.str;
type = str;
default = "~/Documents/org/refile.org";
description = "Default org file to be used for notes.";
};
treesitter = {
enable = mkEnableOption "Orgmode treesitter" // {default = config.vim.languages.enableTreesitter;};
orgPackage = nvim.types.mkGrammarOption pkgs "org";
orgPackage = mkGrammarOption pkgs "org";
};
};
}

View file

@ -4,46 +4,49 @@
lib,
...
}: let
inherit (lib) mkMerge mkBinding mkIf;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.binds) mkBinding;
cfg = config.vim.notes.todo-comments;
self = import ./todo-comments.nix {inherit lib;};
mappings = self.options.vim.notes.todo-comments.mappings;
inherit (self.options.vim.notes.todo-comments) mappings;
in {
config = mkIf (cfg.enable) {
vim.startPlugins = [
"todo-comments"
];
config = mkIf cfg.enable {
vim = {
startPlugins = [
"todo-comments"
];
vim.maps.normal = mkMerge [
(mkBinding cfg.mappings.quickFix ":TodoQuickFix<CR>" mappings.quickFix.description)
(mkIf config.vim.telescope.enable (mkBinding cfg.mappings.telescope ":TodoTelescope<CR>" mappings.telescope.description))
(mkIf config.vim.lsp.trouble.enable (mkBinding cfg.mappings.trouble ":TodoTrouble<CR>" mappings.trouble.description))
];
maps.normal = mkMerge [
(mkBinding cfg.mappings.quickFix ":TodoQuickFix<CR>" mappings.quickFix.description)
(mkIf config.vim.telescope.enable (mkBinding cfg.mappings.telescope ":TodoTelescope<CR>" mappings.telescope.description))
(mkIf config.vim.lsp.trouble.enable (mkBinding cfg.mappings.trouble ":TodoTrouble<CR>" mappings.trouble.description))
];
vim.luaConfigRC.todo-comments = ''
require('todo-comments').setup {
highlight = {
before = "", -- "fg" or "bg" or empty
keyword = "bg", -- "fg", "bg", "wide" or empty
after = "fg", -- "fg" or "bg" or empty
pattern = ${cfg.patterns.highlight},
comments_only = true, -- uses treesitter to match keywords in comments only
max_line_len = 400, -- ignore lines longer than this
exclude = {}, -- list of file types to exclude highlighting
},
search = {
command = "${pkgs.ripgrep}/bin/rg",
args = {
"--color=never",
"--no-heading",
"--with-filename",
"--line-number",
"--column",
luaConfigRC.todo-comments = ''
require('todo-comments').setup {
highlight = {
before = "", -- "fg" or "bg" or empty
keyword = "bg", -- "fg", "bg", "wide" or empty
after = "fg", -- "fg" or "bg" or empty
pattern = ${cfg.patterns.highlight},
comments_only = true, -- uses treesitter to match keywords in comments only
max_line_len = 400, -- ignore lines longer than this
exclude = {}, -- list of file types to exclude highlighting
},
pattern = ${cfg.patterns.search},
},
}
'';
search = {
command = "${pkgs.ripgrep}/bin/rg",
args = {
"--color=never",
"--no-heading",
"--with-filename",
"--line-number",
"--column",
},
pattern = ${cfg.patterns.search},
},
}
'';
};
};
}

View file

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

View file

@ -1,18 +1,20 @@
{lib, ...}: let
inherit (lib) mkEnableOption mkOption types mkMappingOption;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) str;
inherit (lib.nvim.binds) mkMappingOption;
in {
options.vim.notes.todo-comments = {
enable = mkEnableOption "todo-comments: highlight and search for todo comments like TODO, HACK, BUG in your code base";
patterns = {
highlight = mkOption {
type = types.str;
type = str;
default = ''[[.*<(KEYWORDS)(\([^\)]*\))?:]]'';
description = "vim regex pattern used for highlighting comments";
};
search = mkOption {
type = types.str;
type = str;
default = ''[[\b(KEYWORDS)(\([^\)]*\))?:]]'';
description = "ripgrep regex pattern used for searching comments";
};