From 4953057603157a029390de7790bc2f55a023db08 Mon Sep 17 00:00:00 2001 From: Soliprem Date: Wed, 9 Oct 2024 07:30:29 +0200 Subject: [PATCH] neorg: init --- configuration.nix | 1 + flake.lock | 68 +++++++++++++++++++++++++ flake.nix | 20 ++++++++ modules/plugins/notes/default.nix | 1 + modules/plugins/notes/neorg/config.nix | 55 ++++++++++++++++++++ modules/plugins/notes/neorg/default.nix | 6 +++ modules/plugins/notes/neorg/neorg.nix | 41 +++++++++++++++ 7 files changed, 192 insertions(+) create mode 100644 modules/plugins/notes/neorg/config.nix create mode 100644 modules/plugins/notes/neorg/default.nix create mode 100644 modules/plugins/notes/neorg/neorg.nix diff --git a/configuration.nix b/configuration.nix index b21b26aa..81b176fd 100644 --- a/configuration.nix +++ b/configuration.nix @@ -173,6 +173,7 @@ isMaximal: { notes = { obsidian.enable = false; # FIXME: neovim fails to build if obsidian is enabled + neorg.enable = true; orgmode.enable = false; mind-nvim.enable = isMaximal; todo-comments.enable = true; diff --git a/flake.lock b/flake.lock index 3e267311..91014b9b 100644 --- a/flake.lock +++ b/flake.lock @@ -812,6 +812,22 @@ "type": "github" } }, + "plugin-lua-utils-nvim": { + "flake": false, + "locked": { + "lastModified": 1708177208, + "narHash": "sha256-9ildzQEMkXKZ3LHq+khGFgRQFxlIXQclQ7QU3fcU1C4=", + "owner": "nvim-neorg", + "repo": "lua-utils.nvim", + "rev": "e565749421f4bbb5d2e85e37c3cef9d56553d8bd", + "type": "github" + }, + "original": { + "owner": "nvim-neorg", + "repo": "lua-utils.nvim", + "type": "github" + } + }, "plugin-lualine": { "flake": false, "locked": { @@ -924,6 +940,38 @@ "type": "github" } }, + "plugin-neorg": { + "flake": false, + "locked": { + "lastModified": 1727821831, + "narHash": "sha256-yfWQ6yKytu1jkWUtRZTVICslUWej6jVYv7frmSB7/6Q=", + "owner": "nvim-neorg", + "repo": "neorg", + "rev": "afc9a37bf021acb0853e95714c4c6436e1588286", + "type": "github" + }, + "original": { + "owner": "nvim-neorg", + "repo": "neorg", + "type": "github" + } + }, + "plugin-neorg-telescope": { + "flake": false, + "locked": { + "lastModified": 1722358034, + "narHash": "sha256-ei4uUqpIQjGKzu5ryu0Hlmis9TS9FJsYnjt4J4QdWlw=", + "owner": "nvim-neorg", + "repo": "neorg-telescope", + "rev": "ddb2556644cae922699a239bbb0fe16e25b084b7", + "type": "github" + }, + "original": { + "owner": "nvim-neorg", + "repo": "neorg-telescope", + "type": "github" + } + }, "plugin-new-file-template-nvim": { "flake": false, "locked": { @@ -1421,6 +1469,22 @@ "type": "github" } }, + "plugin-pathlib-nvim": { + "flake": false, + "locked": { + "lastModified": 1724943804, + "narHash": "sha256-YhCJeNKlcjgg3q51UWFhuIEPzNueC8YTpeuPPJDndvw=", + "owner": "pysan3", + "repo": "pathlib.nvim", + "rev": "57e5598af6fe253761c1b48e0b59b7cd6699e2c1", + "type": "github" + }, + "original": { + "owner": "pysan3", + "repo": "pathlib.nvim", + "type": "github" + } + }, "plugin-plenary-nvim": { "flake": false, "locked": { @@ -1858,6 +1922,7 @@ "plugin-lsp-signature": "plugin-lsp-signature", "plugin-lspkind": "plugin-lspkind", "plugin-lspsaga": "plugin-lspsaga", + "plugin-lua-utils-nvim": "plugin-lua-utils-nvim", "plugin-lualine": "plugin-lualine", "plugin-mind-nvim": "plugin-mind-nvim", "plugin-minimap-vim": "plugin-minimap-vim", @@ -1865,6 +1930,8 @@ "plugin-neo-tree-nvim": "plugin-neo-tree-nvim", "plugin-neocord": "plugin-neocord", "plugin-neodev-nvim": "plugin-neodev-nvim", + "plugin-neorg": "plugin-neorg", + "plugin-neorg-telescope": "plugin-neorg-telescope", "plugin-new-file-template-nvim": "plugin-new-file-template-nvim", "plugin-noice-nvim": "plugin-noice-nvim", "plugin-none-ls": "plugin-none-ls", @@ -1896,6 +1963,7 @@ "plugin-orgmode-nvim": "plugin-orgmode-nvim", "plugin-otter-nvim": "plugin-otter-nvim", "plugin-oxocarbon": "plugin-oxocarbon", + "plugin-pathlib-nvim": "plugin-pathlib-nvim", "plugin-plenary-nvim": "plugin-plenary-nvim", "plugin-project-nvim": "plugin-project-nvim", "plugin-registers": "plugin-registers", diff --git a/flake.nix b/flake.nix index c4a1a2a8..a1e58476 100644 --- a/flake.nix +++ b/flake.nix @@ -636,6 +636,26 @@ flake = false; }; + plugin-lua-utils-nvim = { + url = "github:nvim-neorg/lua-utils.nvim"; + flake = false; + }; + + plugin-pathlib-nvim = { + url = "github:pysan3/pathlib.nvim"; + flake = false; + }; + + plugin-neorg = { + url = "github:nvim-neorg/neorg"; + flake = false; + }; + + plugin-neorg-telescope = { + url = "github:nvim-neorg/neorg-telescope"; + flake = false; + }; + plugin-nui-nvim = { # (required by noice.nvim) url = "github:MunifTanjim/nui.nvim"; diff --git a/modules/plugins/notes/default.nix b/modules/plugins/notes/default.nix index 88a70924..6c342728 100644 --- a/modules/plugins/notes/default.nix +++ b/modules/plugins/notes/default.nix @@ -2,6 +2,7 @@ imports = [ ./obsidian ./orgmode + ./neorg ./mind-nvim ./todo-comments ]; diff --git a/modules/plugins/notes/neorg/config.nix b/modules/plugins/notes/neorg/config.nix new file mode 100644 index 00000000..df41cf52 --- /dev/null +++ b/modules/plugins/notes/neorg/config.nix @@ -0,0 +1,55 @@ +{ + config, + lib, + ... +}: let + inherit (lib.modules) mkIf mkMerge; + inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.binds) pushDownDefault; + inherit (lib.nvim.lua) toLuaObject; + + cfg = config.vim.notes.neorg; +in { + config = mkIf cfg.enable (mkMerge [ + { + vim = { + startPlugins = [ + "lua-utils-nvim" + "nui-nvim" + "nvim-nio" + "pathlib-nvim" + "plenary-nvim" + "neorg" + "neorg-telescope" + ]; + + binds.whichKey.register = pushDownDefault { + "o" = "+Notes"; + }; + + pluginRC.neorg = entryAnywhere '' + -- 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 = {'neorg'}, + }, + } + + require('neorg').setup(${toLuaObject cfg.setupOpts}) + ''; + }; + } + + (mkIf cfg.treesitter.enable { + vim.treesitter.enable = true; + + vim.treesitter.grammars = [cfg.treesitter.norgPackage]; + }) + ]); +} diff --git a/modules/plugins/notes/neorg/default.nix b/modules/plugins/notes/neorg/default.nix new file mode 100644 index 00000000..409cee31 --- /dev/null +++ b/modules/plugins/notes/neorg/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./neorg.nix + ./config.nix + ]; +} diff --git a/modules/plugins/notes/neorg/neorg.nix b/modules/plugins/notes/neorg/neorg.nix new file mode 100644 index 00000000..756c7daa --- /dev/null +++ b/modules/plugins/notes/neorg/neorg.nix @@ -0,0 +1,41 @@ +{ + config, + lib, + pkgs, + ... +}: let + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.types) str; + inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption; +in { + options.vim.notes.neorg = { + enable = mkEnableOption "neorg: Neovim plugin for Neorg"; + + setupOpts = mkPluginSetupOption "Neorg" { + setup = mkOption { + type = str; + default = '' + load = { + ['core.defaults'] = {}, -- Loads default behaviour + ['core.concealer'] = {}, -- Adds pretty icons to your documents + ['core.export'] = {}, -- Adds export options + ['core.integrations.telescope'] = {}, -- Telescope integration + ['core.dirman'] = { -- Manages Neorg workspaces + config = { + workspaces = { + notes = '~/Documents/neorg', + }, + }, + }, + }, + ''; + description = "Neorg configuration"; + }; + }; + + treesitter = { + enable = mkEnableOption "Neorg treesitter" // {default = config.vim.languages.enableTreesitter;}; + norgPackage = mkGrammarOption pkgs "norg"; + }; + }; +}