From 0947ab38c0bc79780eec599161306157b8de74a3 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Tue, 8 Oct 2024 11:16:19 +0200 Subject: [PATCH 1/9] configuration: enable lua for maximal (#411) * configuration: enable lua for maximal --- Co-authored-by: raf --- configuration.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/configuration.nix b/configuration.nix index b21b26a..f56061b 100644 --- a/configuration.nix +++ b/configuration.nix @@ -54,6 +54,7 @@ isMaximal: { ts.enable = isMaximal; svelte.enable = isMaximal; go.enable = isMaximal; + lua.enable = isMaximal; elixir.enable = isMaximal; zig.enable = isMaximal; ocaml.enable = isMaximal; From c0790c549468f78d6b3598f8f2851cd59fcb6c07 Mon Sep 17 00:00:00 2001 From: Soliprem <73885403+Soliprem@users.noreply.github.com> Date: Thu, 10 Oct 2024 20:14:52 +0200 Subject: [PATCH 2/9] languages/kotlin: init (#390) * merge * created otter file merge * update merge * update merge * committing flake.lock merge * merge * haskell: added LSP and treesitter * haskell: default to isMaximal * haskell: haskell support * kotlin: LSP and treesitter * haskell: LSP cmd definition * haskell: LSP cmd definition (currently broken) * kotlin: LSP and treesitter working * removing haskell from kotlin branch * merge * merge * kotlin: capitalisation * kotlin: implemented formatter * kotlin: cleanup * kotlin: formatter and linter both work * kotlin: cleanup * kotlin: massive speedup in loadtimes for lsp * otter: cleanup * kotlin: changelog entry * flake.lock: reverting accidental formatting * kotlin: removed redundant description * kotlin: fixed typo * kotlin: using symlinkjoin better * kotlin: moved wrapper to example * kotlin: cleaning up and fixing docs render --------- Co-authored-by: raf --- configuration.nix | 1 + docs/release-notes/rl-0.7.md | 2 + modules/plugins/languages/default.nix | 1 + modules/plugins/languages/kotlin.nix | 107 ++++++++++++++++++++++++++ 4 files changed, 111 insertions(+) create mode 100644 modules/plugins/languages/kotlin.nix diff --git a/configuration.nix b/configuration.nix index 797edba..2ef5e64 100644 --- a/configuration.nix +++ b/configuration.nix @@ -51,6 +51,7 @@ isMaximal: { css.enable = isMaximal; sql.enable = isMaximal; java.enable = isMaximal; + kotlin.enable = isMaximal; ts.enable = isMaximal; svelte.enable = isMaximal; go.enable = isMaximal; diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 673fcff..d5133dd 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -259,6 +259,8 @@ 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 LSP, diagnostics, formatter and Treesitter support for Kotlin under + `vim.languages.kotlin` [Bloxx12](https://github.com/Bloxx12) diff --git a/modules/plugins/languages/default.nix b/modules/plugins/languages/default.nix index 28c1fd8..b46d992 100644 --- a/modules/plugins/languages/default.nix +++ b/modules/plugins/languages/default.nix @@ -8,6 +8,7 @@ in { ./css.nix ./elixir.nix ./go.nix + ./kotlin.nix ./html.nix ./java.nix ./lua.nix diff --git a/modules/plugins/languages/kotlin.nix b/modules/plugins/languages/kotlin.nix new file mode 100644 index 0000000..5637b4f --- /dev/null +++ b/modules/plugins/languages/kotlin.nix @@ -0,0 +1,107 @@ +{ + config, + pkgs, + lib, + ... +}: let + inherit (lib.options) mkEnableOption mkOption literalExpression; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.meta) getExe; + inherit (lib.nvim.languages) diagnosticsToLua; + inherit (lib.types) package; + inherit (lib.nvim.types) mkGrammarOption diagnostics; + inherit (lib.lists) isList; + inherit (lib.nvim.lua) expToLua; + + cfg = config.vim.languages.kotlin; + + defaultDiagnosticsProvider = ["ktlint"]; + diagnosticsProviders = { + ktlint = { + package = pkgs.ktlint; + nullConfig = pkg: '' + table.insert( + ls_sources, + null_ls.builtins.diagnostics.ktlint.with({ + command = "${getExe pkg}", + }) + ) + ''; + }; + }; +in { + options.vim.languages.kotlin = { + enable = mkEnableOption "Kotlin/HCL support"; + + treesitter = { + enable = mkEnableOption "Kotlin treesitter" // {default = config.vim.languages.enableTreesitter;}; + package = mkGrammarOption pkgs "kotlin"; + }; + + lsp = { + enable = mkEnableOption "Kotlin LSP support" // {default = config.vim.languages.enableLSP;}; + + package = mkOption { + description = "kotlin_language_server package with Kotlin runtime"; + type = package; + example = literalExpression '' + pkgs.symlinkJoin { + name = "kotlin-language-server-wrapped"; + paths = [pkgs.kotlin-language-server]; + nativeBuildInputs = [pkgs.makeWrapper]; + postBuild = ''' + wrapProgram $out/bin/kotlin-language-server \ + --prefix PATH : ''${pkgs.kotlin}/bin + '''; + }; + ''; + default = pkgs.kotlin-language-server; + }; + }; + + extraDiagnostics = { + enable = mkEnableOption "extra Kotlin diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;}; + + types = diagnostics { + langDesc = "Kotlin"; + inherit diagnosticsProviders; + inherit defaultDiagnosticsProvider; + }; + }; + }; + config = mkIf cfg.enable (mkMerge [ + (mkIf cfg.treesitter.enable { + vim.treesitter.enable = true; + vim.treesitter.grammars = [cfg.treesitter.package]; + }) + + (mkIf cfg.extraDiagnostics.enable { + vim.lsp.null-ls.enable = true; + vim.lsp.null-ls.sources = diagnosticsToLua { + lang = "kotlin"; + config = cfg.extraDiagnostics.types; + inherit diagnosticsProviders; + }; + }) + + (mkIf cfg.lsp.enable { + vim.lsp.lspconfig.enable = true; + vim.lsp.lspconfig.sources.kotlin_language_server = '' + lspconfig.kotlin_language_server.setup { + capabilities = capabilities, + root_dir = lspconfig.util.root_pattern("main.kt", ".git"), + on_attach=default_on_attach, + init_options = { + -- speeds up the startup time for the LSP + storagePath = vim.fn.stdpath('state') .. '/kotlin', + }, + cmd = ${ + if isList cfg.lsp.package + then expToLua cfg.lsp.package + else ''{"${cfg.lsp.package}/bin/kotlin-language-server"}'' + }, + } + ''; + }) + ]); +} From caaacbf59c2d7514fc0d633f623ad55e005d1096 Mon Sep 17 00:00:00 2001 From: ksonj Date: Sat, 12 Oct 2024 05:43:33 +0200 Subject: [PATCH 3/9] languages/scala: Add scala language support (#399) * languages/scala: Add scala language support Adds LSP support for Scala via nvim-metals * Fix luaInline import * Add changelog entry for Scala support to 0.7 release notes --------- Co-authored-by: raf --- configuration.nix | 1 + docs/release-notes/rl-0.7.md | 4 + flake.lock | 17 +++ flake.nix | 5 + modules/plugins/languages/default.nix | 1 + modules/plugins/languages/scala.nix | 149 ++++++++++++++++++++++++++ 6 files changed, 177 insertions(+) create mode 100644 modules/plugins/languages/scala.nix diff --git a/configuration.nix b/configuration.nix index 2ef5e64..261d555 100644 --- a/configuration.nix +++ b/configuration.nix @@ -69,6 +69,7 @@ isMaximal: { lsp.server = "clangd"; }; + scala.enable = isMaximal; rust = { enable = isMaximal; crates.enable = isMaximal; diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index d5133dd..de0033d 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -267,3 +267,7 @@ everyone. - Add support for [base16 theming](https://github.com/RRethy/base16-nvim) under `vim.theme` - Fix internal breakage in `elixir-tools` setup. + +[ksonj](https://github.com/ksonj): + +- Add LSP support for Scala via [nvim-metals](https://github.com/scalameta/nvim-metals) diff --git a/flake.lock b/flake.lock index ad9efef..843acb2 100644 --- a/flake.lock +++ b/flake.lock @@ -1197,6 +1197,22 @@ "type": "github" } }, + "plugin-nvim-metals": { + "flake": false, + "locked": { + "lastModified": 1728295172, + "narHash": "sha256-ja/+MNxZ3H9io9jDwm5rhE6iKNi86a22eCOY75g19O8=", + "owner": "scalameta", + "repo": "nvim-metals", + "rev": "f861db9fda55939797ac1b05238c49b0dcdc3bdb", + "type": "github" + }, + "original": { + "owner": "scalameta", + "repo": "nvim-metals", + "type": "github" + } + }, "plugin-nvim-navbuddy": { "flake": false, "locked": { @@ -1898,6 +1914,7 @@ "plugin-nvim-docs-view": "plugin-nvim-docs-view", "plugin-nvim-lightbulb": "plugin-nvim-lightbulb", "plugin-nvim-lspconfig": "plugin-nvim-lspconfig", + "plugin-nvim-metals": "plugin-nvim-metals", "plugin-nvim-navbuddy": "plugin-nvim-navbuddy", "plugin-nvim-navic": "plugin-nvim-navic", "plugin-nvim-neoclip": "plugin-nvim-neoclip", diff --git a/flake.nix b/flake.nix index 53e9e93..8a9f93c 100644 --- a/flake.nix +++ b/flake.nix @@ -206,6 +206,11 @@ flake = false; }; + plugin-nvim-metals = { + url = "github:scalameta/nvim-metals"; + flake = false; + }; + # Copying/Registers plugin-registers = { url = "github:tversteeg/registers.nvim"; diff --git a/modules/plugins/languages/default.nix b/modules/plugins/languages/default.nix index b46d992..54a9e1c 100644 --- a/modules/plugins/languages/default.nix +++ b/modules/plugins/languages/default.nix @@ -20,6 +20,7 @@ in { ./python.nix ./r.nix ./rust.nix + ./scala.nix ./sql.nix ./svelte.nix ./tailwind.nix diff --git a/modules/plugins/languages/scala.nix b/modules/plugins/languages/scala.nix new file mode 100644 index 0000000..f769d09 --- /dev/null +++ b/modules/plugins/languages/scala.nix @@ -0,0 +1,149 @@ +{ + config, + pkgs, + lib, + ... +}: let + inherit (lib.generators) mkLuaInline; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.nvim.binds) mkMappingOption; + inherit (lib.nvim.dag) entryAfter; + inherit (lib.nvim.lua) toLuaObject; + inherit (lib.nvim.types) mkGrammarOption luaInline; + inherit (lib.options) mkOption mkEnableOption mkPackageOption; + inherit (lib.strings) optionalString; + inherit (lib.types) attrsOf anything bool; + + listCommandsAction = + if config.vim.telescope.enable + then ''require("telescope").extensions.metals.commands()'' + else ''require("metals").commands()''; + + cfg = config.vim.languages.scala; + + usingDap = config.vim.debugger.nvim-dap.enable && cfg.dap.enable; + usingLualine = config.vim.statusline.lualine.enable; +in { + options.vim.languages.scala = { + enable = mkEnableOption "Scala language support"; + + treesitter = { + enable = mkEnableOption "Scala treesitter" // {default = config.vim.languages.enableTreesitter;}; + package = mkGrammarOption pkgs "scala"; + }; + + lsp = { + enable = mkEnableOption "Scala LSP support (metals)" // {default = config.vim.languages.enableLSP;}; + package = mkPackageOption pkgs "metals" { + default = ["metals"]; + }; + + extraMappings = { + listCommands = mkMappingOption "List Metals commands" "lc"; + }; + + extraSettings = mkOption { + type = attrsOf anything; + description = "Extra settings passed to the metals config. Check nvim-metals docs for available options"; + default = { + showImplicitArguments = true; + showImplicitConversionsAndClasses = true; + showInferredType = true; + excludedPackages = [ + "akka.actor.typed.javadsl" + "com.github.swagger.akka.javadsl" + ]; + }; + }; + }; + + dap = { + enable = mkEnableOption "Scala Debug Adapter support (metals)" // {default = config.vim.languages.enableDAP;}; + config = mkOption { + description = "Lua configuration for dap"; + type = luaInline; + default = mkLuaInline '' + dap.configurations.scala = { + { + type = "scala", + request = "launch", + name = "RunOrTest", + metals = { + runType = "runOrTestFile", + --args = { "firstArg", "secondArg", "thirdArg" }, -- here just as an example + }, + }, + { + type = "scala", + request = "launch", + name = "Test Target", + metals = { + runType = "testTarget", + }, + }, + } + ''; + }; + }; + + fixShortmess = mkOption { + type = bool; + description = "Remove the 'F' flag from shortmess to allow messages to be shown. Without doing this, autocommands that deal with filetypes prohibit messages from being shown"; + default = true; + }; + }; + + config = mkIf cfg.enable ( + mkMerge [ + (mkIf cfg.treesitter.enable { + vim.treesitter.enable = true; + vim.treesitter.grammars = [cfg.treesitter.package]; + }) + (mkIf (cfg.lsp.enable || cfg.dap.enable) { + vim = { + startPlugins = ["nvim-metals"]; + pluginRC.nvim-metals = entryAfter ["lsp-setup"] '' + local metals_caps = capabilities -- from lsp-setup + + local attach_metals_keymaps = function(client, bufnr) + attach_keymaps(client, bufnr) -- from lsp-setup + vim.api.nvim_buf_set_keymap(bufnr, 'n', '${cfg.lsp.extraMappings.listCommands}', 'lua ${listCommandsAction}', {noremap=true, silent=true, desc='Show all Metals commands'}) + end + + metals_config = require('metals').bare_config() + ${optionalString usingLualine "metals_config.init_options.statusBarProvider = 'on'"} + + metals_config.capabilities = metals_caps + metals_config.on_attach = function(client, bufnr) + ${optionalString usingDap "require('metals').setup_dap()"} + attach_metals_keymaps(client, bufnr) + end + + metals_config.settings = ${toLuaObject cfg.lsp.extraSettings} + metals_config.settings.metalsBinaryPath = "${cfg.lsp.package}/bin/metals" + + metals_config.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( + vim.lsp.diagnostic.on_publish_diagnostics, { + virtual_text = { + prefix = '⚠', + } + } + ) + + ${optionalString cfg.fixShortmess ''vim.opt_global.shortmess:remove("F")''} + + local lsp_group = vim.api.nvim_create_augroup('lsp', { clear = true }) + + vim.api.nvim_create_autocmd('FileType', { + group = lsp_group, + pattern = {'java', 'scala', 'sbt'}, + callback = function() + require('metals').initialize_or_attach(metals_config) + end, + }) + ''; + }; + }) + ] + ); +} From f5d33f6a53d52fc2e53e9cea0521ec1be9d0ae19 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Mon, 14 Oct 2024 14:21:35 +0300 Subject: [PATCH 4/9] wrapper: disableDefaultRuntimePaths --- Co-authored-by: NotAShelf --- docs/release-notes/rl-0.7.md | 6 +++- modules/extra/deprecations.nix | 14 +++++++++ modules/wrapper/rc/options.nix | 54 ++++------------------------------ 3 files changed, 25 insertions(+), 49 deletions(-) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index de0033d..f8cec50 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -93,6 +93,9 @@ everyone. - Add dap-go for better dap configurations - Make noice.nvim customizable - Standardize border style options and add custom borders +- Remove `vim.disableDefaultRuntimePaths` in wrapper options. + - As nvf uses `$NVIM_APP_NAME` as of recent changes, we can safely assume any + configuration in `$XDG_CONFIG_HOME/nvf` is intentional. [rust-tools.nvim]: https://github.com/simrat39/rust-tools.nvim [rustaceanvim]: https://github.com/mrcjkb/rustaceanvim @@ -270,4 +273,5 @@ everyone. [ksonj](https://github.com/ksonj): -- Add LSP support for Scala via [nvim-metals](https://github.com/scalameta/nvim-metals) +- Add LSP support for Scala via + [nvim-metals](https://github.com/scalameta/nvim-metals) diff --git a/modules/extra/deprecations.nix b/modules/extra/deprecations.nix index c4ff4d3..779a752 100644 --- a/modules/extra/deprecations.nix +++ b/modules/extra/deprecations.nix @@ -35,5 +35,19 @@ in { vim.snippets.vsnip.enable has been removed in favor of the more modern luasnip. '') (mkRenamedOptionModule ["vim" "lsp" "lspkind" "mode"] ["vim" "lsp" "lspkind" "setupOpts" "mode"]) + + # 2024-10-14 + (mkRemovedOptionModule ["vim" "configRC"] '' + Please migrate your configRC sections to Neovim's Lua format, and + add them to `vim.luaConfigRC`. + + See the v0.7 release notes for more information on why and how to + migrate your existing configurations to the new format. + '') + + (mkRemovedOptionModule ["vim" "disableDefaultRuntimePaths"] '' + Nvf now uses $NVIM_APP_NAME so there is no longer the problem of + (accidental) leaking of user configuration. + '') ]; } diff --git a/modules/wrapper/rc/options.nix b/modules/wrapper/rc/options.nix index 70ab2a8..1159b9f 100644 --- a/modules/wrapper/rc/options.nix +++ b/modules/wrapper/rc/options.nix @@ -3,27 +3,18 @@ lib, ... }: let - inherit (lib.modules) mkRemovedOptionModule; inherit (lib.options) mkOption mkEnableOption literalMD literalExpression; inherit (lib.strings) optionalString; - inherit (lib.types) str attrs lines listOf either path bool; + inherit (lib.types) str attrs lines listOf either path; inherit (lib.nvim.types) dagOf; inherit (lib.nvim.lua) listToLuaTable; cfg = config.vim; in { - imports = [ - (mkRemovedOptionModule ["vim" "configRC"] '' - Please migrate your configRC sections to Neovim's Lua format, and - add them to luaConfigRC. - - See the v0.7 release notes for more information on how to migrate - your existing configurations. - '') - ]; - options.vim = { enableLuaLoader = mkEnableOption '' + [{option}`official documentation`]: https://neovim.io/doc/user/lua.html#vim.loader.enable() + the experimental Lua module loader to speed up the start up process If `true`, this will enable the experimental Lua module loader which: @@ -32,30 +23,12 @@ in { - adds the libs loader - removes the default Neovim loader + ::: {.note} This is disabled by default. Before setting this option, please - take a look at the [{option}`official documentation`](https://neovim.io/doc/user/lua.html#vim.loader.enable()). + take a look at the [{option}`official documentation`]. + ::: ''; - disableDefaultRuntimePaths = mkOption { - type = bool; - default = true; - example = false; - description = '' - Disables the default runtime paths that are set by Neovim - when it starts up. This is useful when you want to have - full control over the runtime paths that are set by Neovim. - - ::: {.note} - To avoid leaking imperative user configuration into your - configuration, this is enabled by default. If you wish - to load configuration from user configuration directories - (e.g. {file}`$HOME/.config/nvim`, {file}`$HOME/.config/nvim/after` - and {file}`$HOME/.local/share/nvim/site`) you may set this - option to true. - ::: - ''; - }; - additionalRuntimePaths = mkOption { type = listOf (either path str); default = []; @@ -180,21 +153,6 @@ in { vim.opt.runtimepath:append(${listToLuaTable cfg.additionalRuntimePaths}) ''} - ${optionalString cfg.disableDefaultRuntimePaths '' - -- Remove default user runtime paths from the - -- `runtimepath` option to avoid leaking user configuration - -- into the final neovim wrapper - local defaultRuntimePaths = { - vim.fn.stdpath('config'), -- $HOME/.config/nvim - vim.fn.stdpath('config') .. "/after", -- $HOME/.config/nvim/after - vim.fn.stdpath('data') .. "/site", -- $HOME/.local/share/nvim/site - } - - for _, path in ipairs(defaultRuntimePaths) do - vim.opt.runtimepath:remove(path) - end - ''} - ${optionalString cfg.enableLuaLoader "vim.loader.enable()"} ''; From 94d2b837cf20899df811dae1dbb02ddbc751b965 Mon Sep 17 00:00:00 2001 From: Soliprem <73885403+Soliprem@users.noreply.github.com> Date: Mon, 14 Oct 2024 22:47:44 +0200 Subject: [PATCH 5/9] leap: changing default binds (#416) * leap: changed default binds * leap: added changelog entry * leap: fixing requested change Co-authored-by: diniamo <55629891+diniamo@users.noreply.github.com> * Revert "leap: added changelog entry" This reverts commit 6aac9b2580d707aa28c6cf008f89580f8973ac48. * leap: added changelog entry * leap: fix inherits --------- Co-authored-by: diniamo <55629891+diniamo@users.noreply.github.com> --- docs/release-notes/rl-0.7.md | 1 + modules/plugins/utility/motion/leap/config.nix | 4 +++- modules/plugins/utility/motion/leap/leap.nix | 8 ++++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index f8cec50..87861e2 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -264,6 +264,7 @@ everyone. ccc - Add LSP, diagnostics, formatter and Treesitter support for Kotlin under `vim.languages.kotlin` +- changed default keybinds for leap.nvim to avoid altering expected behavior [Bloxx12](https://github.com/Bloxx12) diff --git a/modules/plugins/utility/motion/leap/config.nix b/modules/plugins/utility/motion/leap/config.nix index 9ede98f..687ed24 100644 --- a/modules/plugins/utility/motion/leap/config.nix +++ b/modules/plugins/utility/motion/leap/config.nix @@ -3,7 +3,7 @@ lib, ... }: let - inherit (lib.modules) mkIf mkMerge; + inherit (lib.modules) mkIf mkMerge mkDefault; inherit (lib.nvim.binds) mkBinding; inherit (lib.nvim.dag) entryAnywhere; @@ -37,6 +37,8 @@ in { (mkBinding cfg.mappings.leapFromWindow "(leap-from-window)" "Leap from window") ]; + vim.binds.whichKey.register."s" = mkDefault "+Leap"; + vim.pluginRC.leap-nvim = entryAnywhere '' require('leap').opts = { max_phase_one_targets = nil, diff --git a/modules/plugins/utility/motion/leap/leap.nix b/modules/plugins/utility/motion/leap/leap.nix index a5d7243..4e98f20 100644 --- a/modules/plugins/utility/motion/leap/leap.nix +++ b/modules/plugins/utility/motion/leap/leap.nix @@ -9,22 +9,22 @@ in { leapForwardTo = mkOption { type = nullOr str; description = "Leap forward to"; - default = "s"; + default = "ss"; }; leapBackwardTo = mkOption { type = nullOr str; description = "Leap backward to"; - default = "S"; + default = "sS"; }; leapForwardTill = mkOption { type = nullOr str; description = "Leap forward till"; - default = "x"; + default = "sx"; }; leapBackwardTill = mkOption { type = nullOr str; description = "Leap backward till"; - default = "X"; + default = "sX"; }; leapFromWindow = mkOption { type = nullOr str; From a7e0542fd028cc5648c988b3da9493f3e745a81e Mon Sep 17 00:00:00 2001 From: Soliprem <73885403+Soliprem@users.noreply.github.com> Date: Tue, 15 Oct 2024 17:31:18 +0200 Subject: [PATCH 6/9] neorg: init (#413) * neorg: init * neorg: setupOpts work * neorg: disable by default * neorg: added changelog entry * neorg: setupOpts setup correctly * neorg: sane default for setupOpts * neorg: changed description and removed reduntant treesitter activation * neorg: added vim.treesitter.enable * neorg: fixing capitalisation * neorg: adding descriptions * neorg: formatting * neorg: added newline at the end of docs --- configuration.nix | 1 + docs/release-notes/rl-0.7.md | 2 + flake.lock | 68 +++++++++++++++++++++++++ flake.nix | 20 ++++++++ modules/plugins/notes/default.nix | 1 + modules/plugins/notes/neorg/config.nix | 41 +++++++++++++++ modules/plugins/notes/neorg/default.nix | 6 +++ modules/plugins/notes/neorg/neorg.nix | 50 ++++++++++++++++++ 8 files changed, 189 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 df0b2b1..832bf95 100644 --- a/configuration.nix +++ b/configuration.nix @@ -174,6 +174,7 @@ isMaximal: { notes = { obsidian.enable = false; # FIXME: neovim fails to build if obsidian is enabled + neorg.enable = false; orgmode.enable = false; mind-nvim.enable = isMaximal; todo-comments.enable = true; diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 87861e2..7cbdbaa 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -262,6 +262,7 @@ 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` - Add LSP, diagnostics, formatter and Treesitter support for Kotlin under `vim.languages.kotlin` - changed default keybinds for leap.nvim to avoid altering expected behavior @@ -276,3 +277,4 @@ everyone. - Add LSP support for Scala via [nvim-metals](https://github.com/scalameta/nvim-metals) + diff --git a/flake.lock b/flake.lock index 843acb2..34a2243 100644 --- a/flake.lock +++ b/flake.lock @@ -828,6 +828,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": { @@ -956,6 +972,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": { @@ -1469,6 +1517,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": { @@ -1891,6 +1955,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-luasnip": "plugin-luasnip", "plugin-mind-nvim": "plugin-mind-nvim", @@ -1899,6 +1964,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", @@ -1931,6 +1998,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 8a9f93c..d12bdc5 100644 --- a/flake.nix +++ b/flake.nix @@ -646,6 +646,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..fab5079 --- /dev/null +++ b/modules/plugins/notes/neorg/config.nix @@ -0,0 +1,41 @@ +{ + 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 '' + 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..6b5cf18 --- /dev/null +++ b/modules/plugins/notes/neorg/neorg.nix @@ -0,0 +1,50 @@ +{ + config, + lib, + pkgs, + ... +}: let + 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: An intuitive note-taking and organization tool with a structured nested syntax. + ''; + + setupOpts = mkPluginSetupOption "Neorg" { + load = { + "core.defaults" = mkOption { + default = {}; + description = '' + all of the most important modules that any user would want to have a "just works" experience + ''; + + type = submodule { + options = { + enable = mkEnableOption '' + all of the most important modules that any user would want to have a "just works" experience + ''; + config = { + disable = mkOption { + description = '' + list of modules from to be disabled from core.defaults + ''; + type = listOf str; + default = []; + example = ["core.autocommands" "core.itero"]; + }; + }; + }; + }; + }; + }; + }; + + treesitter = { + enable = mkEnableOption "Neorg treesitter" // {default = config.vim.languages.enableTreesitter;}; + norgPackage = mkGrammarOption pkgs "norg"; + }; + }; +} From 54ec473039f5337bd2be66a040528eebab15f11f Mon Sep 17 00:00:00 2001 From: diniamo <55629891+diniamo@users.noreply.github.com> Date: Tue, 15 Oct 2024 18:05:05 +0200 Subject: [PATCH 7/9] comment-nvim: fix visual mappings (#417) --- modules/plugins/comments/comment-nvim/config.nix | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/plugins/comments/comment-nvim/config.nix b/modules/plugins/comments/comment-nvim/config.nix index e70e918..e228d92 100644 --- a/modules/plugins/comments/comment-nvim/config.nix +++ b/modules/plugins/comments/comment-nvim/config.nix @@ -12,9 +12,7 @@ inherit (self.options.vim.comments.comment-nvim) mappings; in { config = mkIf cfg.enable { - vim.startPlugins = [ - "comment-nvim" - ]; + vim.startPlugins = ["comment-nvim"]; vim.maps.normal = mkMerge [ (mkBinding cfg.mappings.toggleOpLeaderLine "(comment_toggle_linewise)" mappings.toggleOpLeaderLine.description) @@ -36,7 +34,7 @@ in { mappings.toggleCurrentBlock.description) ]; - vim.maps.visualOnly = mkMerge [ + vim.maps.visual = mkMerge [ (mkBinding cfg.mappings.toggleSelectedLine "(comment_toggle_linewise_visual)" mappings.toggleSelectedLine.description) (mkBinding cfg.mappings.toggleSelectedBlock "(comment_toggle_blockwise_visual)" mappings.toggleSelectedBlock.description) ]; From ff9b0eeb1f8fa095c21a77b0f5c25b9c56405ea3 Mon Sep 17 00:00:00 2001 From: diniamo <55629891+diniamo@users.noreply.github.com> Date: Thu, 17 Oct 2024 07:57:29 +0200 Subject: [PATCH 8/9] nvim-cmp: fix rewrite remnants (#419) * fix: bad cmp confirm * nvim-cmp: simplify confirm bind and mapping definitions --------- Co-authored-by: Pei Yang Ching <59727193+horriblename@users.noreply.github.com> --- .../plugins/completion/nvim-cmp/config.nix | 41 ++++--------------- 1 file changed, 9 insertions(+), 32 deletions(-) diff --git a/modules/plugins/completion/nvim-cmp/config.nix b/modules/plugins/completion/nvim-cmp/config.nix index ffd15fe..5d20242 100644 --- a/modules/plugins/completion/nvim-cmp/config.nix +++ b/modules/plugins/completion/nvim-cmp/config.nix @@ -6,17 +6,13 @@ inherit (lib.modules) mkIf; inherit (lib.strings) optionalString; inherit (lib.generators) mkLuaInline; - inherit (lib.nvim.binds) addDescriptionsToMappings; inherit (lib.nvim.dag) entryAfter; inherit (lib.nvim.lua) toLuaObject; inherit (builtins) attrNames; cfg = config.vim.autocomplete.nvim-cmp; luasnipEnable = config.vim.snippets.luasnip.enable; - - self = import ./nvim-cmp.nix {inherit lib config;}; - mappingDefinitions = self.options.vim.autocomplete.nvim-cmp.mappings; - mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions; + inherit (cfg) mappings; in { config = mkIf cfg.enable { vim = { @@ -45,39 +41,20 @@ in { }; pluginRC.nvim-cmp = mkIf cfg.enable (entryAfter ["autopairs" "luasnip"] '' - local luasnip = require("luasnip") + ${optionalString luasnipEnable "local luasnip = require('luasnip')"} local cmp = require("cmp") cmp.setup(${toLuaObject cfg.setupOpts}) ''); # `cmp` and `luasnip` are defined above, in the `nvim-cmp` section autocomplete.nvim-cmp.setupOpts.mapping = { - ${mappings.complete.value} = mkLuaInline "cmp.mapping.complete()"; - ${mappings.close.value} = mkLuaInline "cmp.mapping.abort()"; - ${mappings.scrollDocsUp.value} = mkLuaInline "cmp.mapping.scroll_docs(-4)"; - ${mappings.scrollDocsDown.value} = mkLuaInline "cmp.mapping.scroll_docs(4)"; + ${mappings.complete} = mkLuaInline "cmp.mapping.complete()"; + ${mappings.close} = mkLuaInline "cmp.mapping.abort()"; + ${mappings.scrollDocsUp} = mkLuaInline "cmp.mapping.scroll_docs(-4)"; + ${mappings.scrollDocsDown} = mkLuaInline "cmp.mapping.scroll_docs(4)"; + ${mappings.confirm} = mkLuaInline "cmp.mapping.confirm({ select = true })"; - ${mappings.confirm.value} = mkLuaInline '' - cmp.mapping(function(fallback) - if cmp.visible() then - ${ - if luasnipEnable - then '' - if luasnip.expandable() then - luasnip.expand() - else - cmp.confirm({ select = true }) - end - '' - else "cmp.confirm({ select = true })" - } - else - fallback() - end - end) - ''; - - ${mappings.next.value} = mkLuaInline '' + ${mappings.next} = mkLuaInline '' cmp.mapping(function(fallback) local has_words_before = function() local line, col = unpack(vim.api.nvim_win_get_cursor(0)) @@ -98,7 +75,7 @@ in { end) ''; - ${mappings.previous.value} = mkLuaInline '' + ${mappings.previous} = mkLuaInline '' cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() From 3c4eced9d17ec977b061b278e91d9e8b98a153e1 Mon Sep 17 00:00:00 2001 From: diniamo <55629891+diniamo@users.noreply.github.com> Date: Thu, 17 Oct 2024 15:19:37 +0200 Subject: [PATCH 9/9] docs: add missing deprecation notes (#420) --- docs/release-notes/rl-0.7.md | 8 ++++++++ modules/extra/deprecations.nix | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 7cbdbaa..9d186d3 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -63,6 +63,14 @@ 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. +### `type` based modules removed {#sec-type-based-modules-removed} + +As part of the autocompletion rewrite, modules that used to use a `type` option +have been replaced by per-plugin modules instead. Since both modules only had +one type, you can simply change +- `vim.autocomplete.*` -> `vim.autocomplete.nvim-cmp.*` +- `vim.autopairs.enable` -> `vim.autopairs.nvim-autopairs.enable` + ## Changelog {#sec-release-0.7-changelog} [ItsSorae](https://github.com/ItsSorae): diff --git a/modules/extra/deprecations.nix b/modules/extra/deprecations.nix index 779a752..5a30ef5 100644 --- a/modules/extra/deprecations.nix +++ b/modules/extra/deprecations.nix @@ -31,6 +31,11 @@ in { vim.autocomplete.type has been removed in favor of per-plugin modules. You can enable nvim-cmp with vim.autocomplete.nvim-cmp.enable instead. '') + (mkRemovedOptionModule ["vim" "autocomplete" "sources"] '' + vim.autocomplete.sources has been removed in favor of per-plugin modules. + You can add nvim-cmp sources with vim.autocomplete.nvim-cmp.sources + instead. + '') (mkRemovedOptionModule ["vim" "snippets" "vsnip" "enable"] '' vim.snippets.vsnip.enable has been removed in favor of the more modern luasnip. '')