From 4953057603157a029390de7790bc2f55a023db08 Mon Sep 17 00:00:00 2001 From: Soliprem Date: Wed, 9 Oct 2024 07:30:29 +0200 Subject: [PATCH 1/7] 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 b21b26a..81b176f 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 3e26731..91014b9 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 c4a1a2a..a1e5847 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 88a7092..6c34272 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 0000000..df41cf5 --- /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 0000000..409cee3 --- /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 0000000..756c7da --- /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"; + }; + }; +} From 286cf1bc7cc665f29d7e981e3c0709ee2a118f81 Mon Sep 17 00:00:00 2001 From: Soliprem Date: Wed, 9 Oct 2024 08:38:31 +0200 Subject: [PATCH 2/7] neorg: setupOpts work --- modules/plugins/notes/neorg/config.nix | 6 ++++- modules/plugins/notes/neorg/neorg.nix | 35 +++++++++++++------------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/modules/plugins/notes/neorg/config.nix b/modules/plugins/notes/neorg/config.nix index df41cf5..c28f594 100644 --- a/modules/plugins/notes/neorg/config.nix +++ b/modules/plugins/notes/neorg/config.nix @@ -41,7 +41,11 @@ in { }, } - require('neorg').setup(${toLuaObject cfg.setupOpts}) + require('neorg').setup{ + ${cfg.setupOpts} + } + + vim.wo.conceallevel = 2 ''; }; } diff --git a/modules/plugins/notes/neorg/neorg.nix b/modules/plugins/notes/neorg/neorg.nix index 756c7da..0904cc6 100644 --- a/modules/plugins/notes/neorg/neorg.nix +++ b/modules/plugins/notes/neorg/neorg.nix @@ -5,32 +5,31 @@ ... }: let inherit (lib.options) mkEnableOption mkOption; - inherit (lib.types) str; + inherit (lib.types) lines; 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', - }, + setupOpts = mkOption { + type = lines; + 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"; - }; + }, + ''; + description = "Neorg configuration"; }; treesitter = { From b272d9fabbd685f52401e6ddd267cadad29c02c0 Mon Sep 17 00:00:00 2001 From: Soliprem Date: Wed, 9 Oct 2024 08:43:14 +0200 Subject: [PATCH 3/7] neorg: disable by default --- configuration.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configuration.nix b/configuration.nix index 81b176f..10a2ab5 100644 --- a/configuration.nix +++ b/configuration.nix @@ -173,7 +173,7 @@ isMaximal: { notes = { obsidian.enable = false; # FIXME: neovim fails to build if obsidian is enabled - neorg.enable = true; + neorg.enable = false; orgmode.enable = false; mind-nvim.enable = isMaximal; todo-comments.enable = true; From eb983c8560cfd8a05727f32d678a411fcc0f5f1e Mon Sep 17 00:00:00 2001 From: Soliprem Date: Wed, 9 Oct 2024 08:51:53 +0200 Subject: [PATCH 4/7] neorg: added changelog entry --- docs/release-notes/rl-0.7.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index bb9f3d3..660db08 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -28,10 +28,11 @@ configuration formats. ### `vim.maps` rewrite {#sec-vim-maps-rewrite} -Instead of specifying map modes using submodules (eg.: `vim.maps.normal`), a new `vim.keymaps` -submodule with support for a `mode` option has been introduced. It can be either a string, or a -list of strings, where a string represents the short-name of the map mode(s), that the mapping -should be set for. See `:help map-modes` for more information. +Instead of specifying map modes using submodules (eg.: `vim.maps.normal`), a new +`vim.keymaps` submodule with support for a `mode` option has been introduced. It +can be either a string, or a list of strings, where a string represents the +short-name of the map mode(s), that the mapping should be set for. See +`:help map-modes` for more information. For example: @@ -62,7 +63,6 @@ Note that we are looking to add more alternatives in the future like dressing.nvim and actions-preview.nvim, in case fastaction doesn't work for everyone. - ## Changelog {#sec-release-0.7-changelog} [ItsSorae](https://github.com/ItsSorae): @@ -150,12 +150,15 @@ everyone. - Replace `vim.lsp.nvimCodeActionMenu` with `vim.ui.fastaction`, see the breaking changes section above for more details -- Add a `setupOpts` option to nvim-surround, which allows modifying options that aren't defined in nvf. Move the alternate nvim-surround keybinds to use `setupOpts`. +- Add a `setupOpts` option to nvim-surround, which allows modifying options that + aren't defined in nvf. Move the alternate nvim-surround keybinds to use + `setupOpts`. [Neovim documentation on `vim.cmd`]: https://neovim.io/doc/user/lua.html#vim.cmd() - Make Neovim's configuration file entirely Lua based. This comes with a few breaking changes: + - `vim.configRC` has been removed. You will need to migrate your entries to Neovim-compliant Lua code, and add them to `vim.luaConfigRC` instead. Existing vimscript configurations may be preserved in `vim.cmd` functions. @@ -242,10 +245,10 @@ everyone. - Add LSP and Treesitter support for R under `vim.languages.R`. - Add Otter support under `vim.lsp.otter` and an assert to prevent conflict with ccc - +- Add Neorg support under `vim.notes.neorg` + [Bloxx12](https://github.com/Bloxx12) - Add support for [base16 theming](https://github.com/RRethy/base16-nvim) under `vim.theme` - Fix internal breakage in `elixir-tools` setup. - From e1d292aac3158e0a69c8544b43b17795ebface57 Mon Sep 17 00:00:00 2001 From: Soliprem Date: Wed, 9 Oct 2024 10:18:12 +0200 Subject: [PATCH 5/7] neorg: setupOpts setup correctly --- modules/plugins/notes/neorg/config.nix | 19 +------------------ modules/plugins/notes/neorg/neorg.nix | 24 ++---------------------- 2 files changed, 3 insertions(+), 40 deletions(-) diff --git a/modules/plugins/notes/neorg/config.nix b/modules/plugins/notes/neorg/config.nix index c28f594..367f256 100644 --- a/modules/plugins/notes/neorg/config.nix +++ b/modules/plugins/notes/neorg/config.nix @@ -28,24 +28,7 @@ in { }; 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{ - ${cfg.setupOpts} - } - - vim.wo.conceallevel = 2 + require('neorg').setup(${toLuaObject cfg.setupOpts}) ''; }; } diff --git a/modules/plugins/notes/neorg/neorg.nix b/modules/plugins/notes/neorg/neorg.nix index 0904cc6..308d5eb 100644 --- a/modules/plugins/notes/neorg/neorg.nix +++ b/modules/plugins/notes/neorg/neorg.nix @@ -4,33 +4,13 @@ pkgs, ... }: let - inherit (lib.options) mkEnableOption mkOption; - inherit (lib.types) lines; + inherit (lib.options) mkEnableOption; inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption; in { options.vim.notes.neorg = { enable = mkEnableOption "neorg: Neovim plugin for Neorg"; - setupOpts = mkOption { - type = lines; - 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"; - }; + setupOpts = mkPluginSetupOption "Neorg" {}; treesitter = { enable = mkEnableOption "Neorg treesitter" // {default = config.vim.languages.enableTreesitter;}; From 90795a506a307cf82fc98c6e003bb76072301e6d Mon Sep 17 00:00:00 2001 From: Soliprem Date: Wed, 9 Oct 2024 10:40:11 +0200 Subject: [PATCH 6/7] neorg: sane default for setupOpts --- modules/plugins/notes/neorg/neorg.nix | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/modules/plugins/notes/neorg/neorg.nix b/modules/plugins/notes/neorg/neorg.nix index 308d5eb..f6ab8ae 100644 --- a/modules/plugins/notes/neorg/neorg.nix +++ b/modules/plugins/notes/neorg/neorg.nix @@ -4,13 +4,32 @@ pkgs, ... }: let - inherit (lib.options) mkEnableOption; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.types) submodule listOf str; inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption; in { options.vim.notes.neorg = { enable = mkEnableOption "neorg: Neovim plugin for Neorg"; - setupOpts = mkPluginSetupOption "Neorg" {}; + setupOpts = mkPluginSetupOption "Neorg" { + load = { + "core.defaults" = mkOption { + default = {}; + + type = submodule { + options = { + enable = mkEnableOption "A wrapper to interface with several different completion engines."; + config = { + disable = mkOption { + type = listOf str; + default = []; + }; + }; + }; + }; + }; + }; + }; treesitter = { enable = mkEnableOption "Neorg treesitter" // {default = config.vim.languages.enableTreesitter;}; From 4508e3922571b5059786e29d9a76d056b4ef7bc1 Mon Sep 17 00:00:00 2001 From: Soliprem Date: Tue, 15 Oct 2024 02:15:18 +0200 Subject: [PATCH 7/7] neorg: changed description and removed reduntant treesitter activation --- modules/plugins/notes/neorg/config.nix | 2 -- modules/plugins/notes/neorg/neorg.nix | 6 ++++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/plugins/notes/neorg/config.nix b/modules/plugins/notes/neorg/config.nix index 367f256..54a6bd8 100644 --- a/modules/plugins/notes/neorg/config.nix +++ b/modules/plugins/notes/neorg/config.nix @@ -34,8 +34,6 @@ in { } (mkIf cfg.treesitter.enable { - vim.treesitter.enable = true; - vim.treesitter.grammars = [cfg.treesitter.norgPackage]; }) ]); diff --git a/modules/plugins/notes/neorg/neorg.nix b/modules/plugins/notes/neorg/neorg.nix index f6ab8ae..eae7a3c 100644 --- a/modules/plugins/notes/neorg/neorg.nix +++ b/modules/plugins/notes/neorg/neorg.nix @@ -9,7 +9,9 @@ inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption; in { options.vim.notes.neorg = { - enable = mkEnableOption "neorg: Neovim plugin for Neorg"; + enable = mkEnableOption '' + Neorg: An intuitive note-taking and organization tool with a structured nested syntax. + ''; setupOpts = mkPluginSetupOption "Neorg" { load = { @@ -18,7 +20,7 @@ in { type = submodule { options = { - enable = mkEnableOption "A wrapper to interface with several different completion engines."; + enable = mkEnableOption "Wrapper to interface with several different completion engines."; config = { disable = mkOption { type = listOf str;