From 6915c3f7644da6cd233df90700f6e49620eb910a Mon Sep 17 00:00:00 2001 From: Soliprem Date: Fri, 20 Sep 2024 14:29:07 +0200 Subject: [PATCH 01/26] r: implementing lsp --- configuration.nix | 1 + modules/plugins/languages/default.nix | 1 + modules/plugins/languages/r.nix | 82 +++++++++++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 modules/plugins/languages/r.nix diff --git a/configuration.nix b/configuration.nix index b0c613b2..954e811c 100644 --- a/configuration.nix +++ b/configuration.nix @@ -60,6 +60,7 @@ isMaximal: { python.enable = isMaximal; dart.enable = isMaximal; bash.enable = isMaximal; + r.enable = isMaximal; tailwind.enable = isMaximal; typst.enable = isMaximal; clang = { diff --git a/modules/plugins/languages/default.nix b/modules/plugins/languages/default.nix index e86a521b..28c1fd8f 100644 --- a/modules/plugins/languages/default.nix +++ b/modules/plugins/languages/default.nix @@ -17,6 +17,7 @@ in { ./ocaml.nix ./php.nix ./python.nix + ./r.nix ./rust.nix ./sql.nix ./svelte.nix diff --git a/modules/plugins/languages/r.nix b/modules/plugins/languages/r.nix new file mode 100644 index 00000000..6b9be04c --- /dev/null +++ b/modules/plugins/languages/r.nix @@ -0,0 +1,82 @@ +{ + config, + pkgs, + lib, + ... +}: let + inherit (builtins) attrNames; + inherit (lib.options) mkEnableOption mkOption literalExpression; + inherit (lib.meta) getExe; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.lists) isList; + inherit (lib.types) enum either listOf package str bool; + inherit (lib.nvim.lua) expToLua; + + cfg = config.vim.languages.r; + + r-with-languageserver = pkgs.rWrapper.override { + packages = with pkgs.rPackages; [languageserver]; + }; + + defaultServer = "r_language_server"; + servers = { + r_language_server = { + package = pkgs.writeShellScriptBin "r_lsp" '' + ${r-with-languageserver}/bin/R --slave -e "languageserver::run()" + ''; + lspConfig = '' + lspconfig.r_language_server.setup{ + capabilities = capabilities; + on_attach = default_on_attach; + cmd = ${ + if isList cfg.lsp.package + then expToLua cfg.lsp.package + else ''{"${lib.getExe cfg.lsp.package}"}'' + } + } + ''; + }; + }; +in { + options.vim.languages.r = { + enable = mkEnableOption "R language support"; + + treesitter = { + enable = mkEnableOption "R treesitter" // {default = config.vim.languages.enableTreesitter;}; + package = mkOption { + description = "R treesitter grammar to use"; + type = package; + default = pkgs.vimPlugins.nvim-treesitter.builtGrammars.r; + }; + }; + + lsp = { + enable = mkEnableOption "R LSP support" // {default = config.vim.languages.enableLSP;}; + + server = mkOption { + description = "R LSP server to use"; + type = enum (attrNames servers); + default = defaultServer; + }; + + package = mkOption { + description = "R LSP server package, or the command to run as a list of strings"; + example = literalExpression "[ (lib.getExe pkgs.jdt-language-server) \"-data\" \"~/.cache/jdtls/workspace\" ]"; + type = either package (listOf str); + default = servers.${cfg.lsp.server}.package; + }; + }; + }; + + config = mkIf cfg.enable (mkMerge [ + (mkIf cfg.treesitter.enable { + vim.treesitter.enable = true; + vim.treesitter.grammars = [cfg.treesitter.package]; + }) + + (mkIf cfg.lsp.enable { + vim.lsp.lspconfig.enable = true; + vim.lsp.lspconfig.sources.r-lsp = servers.${cfg.lsp.server}.lspConfig; + }) + ]); +} From ae90ed1706c4999c28544516af950bb145124084 Mon Sep 17 00:00:00 2001 From: Soliprem Date: Tue, 24 Sep 2024 12:21:30 +0200 Subject: [PATCH 02/26] r: version bump to context fixes treesitter bug --- flake.lock | 6 +++--- modules/plugins/languages/r.nix | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/flake.lock b/flake.lock index 377c0847..9e11e8ce 100644 --- a/flake.lock +++ b/flake.lock @@ -1280,11 +1280,11 @@ "plugin-nvim-treesitter-context": { "flake": false, "locked": { - "lastModified": 1716388265, - "narHash": "sha256-EY5Si6t7LXcxOP3ubGAAMd3lgbeaCOCIybSKi1Ucx98=", + "lastModified": 1726947805, + "narHash": "sha256-5oN/vyhSqDqjLEzECj01A7A+Yq7U1H1HXLbzkC1Ljqw=", "owner": "nvim-treesitter", "repo": "nvim-treesitter-context", - "rev": "f62bfe19e0fbc13ae95649dfb3cf22f4ff85b683", + "rev": "3d5390c49e3f8fe457b376df2a49aa39d75b7911", "type": "github" }, "original": { diff --git a/modules/plugins/languages/r.nix b/modules/plugins/languages/r.nix index 6b9be04c..7ad1680f 100644 --- a/modules/plugins/languages/r.nix +++ b/modules/plugins/languages/r.nix @@ -6,10 +6,9 @@ }: let inherit (builtins) attrNames; inherit (lib.options) mkEnableOption mkOption literalExpression; - inherit (lib.meta) getExe; inherit (lib.modules) mkIf mkMerge; inherit (lib.lists) isList; - inherit (lib.types) enum either listOf package str bool; + inherit (lib.types) enum either listOf package str; inherit (lib.nvim.lua) expToLua; cfg = config.vim.languages.r; From 42d7294a5e8e78453bed89d4658df44e80292bab Mon Sep 17 00:00:00 2001 From: Soliprem Date: Tue, 24 Sep 2024 12:34:56 +0200 Subject: [PATCH 03/26] r: changing treesitter package definition to mkGrammarOption --- modules/plugins/languages/r.nix | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/modules/plugins/languages/r.nix b/modules/plugins/languages/r.nix index 7ad1680f..27d7c994 100644 --- a/modules/plugins/languages/r.nix +++ b/modules/plugins/languages/r.nix @@ -10,6 +10,7 @@ inherit (lib.lists) isList; inherit (lib.types) enum either listOf package str; inherit (lib.nvim.lua) expToLua; + inherit (lib.nvim.types) mkGrammarOption; cfg = config.vim.languages.r; @@ -42,11 +43,7 @@ in { treesitter = { enable = mkEnableOption "R treesitter" // {default = config.vim.languages.enableTreesitter;}; - package = mkOption { - description = "R treesitter grammar to use"; - type = package; - default = pkgs.vimPlugins.nvim-treesitter.builtGrammars.r; - }; + package = mkGrammarOption pkgs "r"; }; lsp = { From 27c045bc9debc899b66723643682981b086aad88 Mon Sep 17 00:00:00 2001 From: Soliprem Date: Tue, 24 Sep 2024 12:59:42 +0200 Subject: [PATCH 04/26] added changelog entry --- docs/release-notes/rl-0.7.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index cf250e07..efb2da91 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -108,6 +108,7 @@ everyone. plugin's options can now be found under `indentBlankline.setupOpts`, the previous iteration of the module also included out of place/broken options, which have been removed for the time being. These are: + - `listChar` - this was already unused - `fillChar` - this had nothing to do with the plugin, please configure it yourself by adding `vim.opt.listchars:append({ space = '' })` to your @@ -191,3 +192,9 @@ everyone. - Telescope: - Fixed `project-nvim` command and keybinding - Added default ikeybind/command for `Telescope resume` (`fr`) + +[Soliprem](https://github.com/Soliprem) + +- R: + - Added LSP + - Added Treesitter From 3275ab221a65558dda947d6bbe579d50693113e2 Mon Sep 17 00:00:00 2001 From: Soliprem Date: Fri, 27 Sep 2024 09:27:58 +0200 Subject: [PATCH 05/26] created otter file --- modules/plugins/lsp/otter/config.nix | 21 +++++++++++++++++++++ modules/plugins/lsp/otter/default.nix | 9 +++++++++ 2 files changed, 30 insertions(+) create mode 100644 modules/plugins/lsp/otter/config.nix create mode 100644 modules/plugins/lsp/otter/default.nix diff --git a/modules/plugins/lsp/otter/config.nix b/modules/plugins/lsp/otter/config.nix new file mode 100644 index 00000000..8857d328 --- /dev/null +++ b/modules/plugins/lsp/otter/config.nix @@ -0,0 +1,21 @@ +{ + config, + lib, + ... +}: let + inherit (lib.modules) mkIf; + inherit (lib.nvim.dag) entryAnywhere; + + cfg = config.vim.lsp; +in { + config = mkIf (cfg.enable && cfg.otter.enable) { + vim = { + startPlugins = ["otter"]; + + pluginRC.trouble = entryAnywhere '' + -- Enable Otter + require("otter").setup {} + ''; + }; + }; +} diff --git a/modules/plugins/lsp/otter/default.nix b/modules/plugins/lsp/otter/default.nix new file mode 100644 index 00000000..1432d8c6 --- /dev/null +++ b/modules/plugins/lsp/otter/default.nix @@ -0,0 +1,9 @@ +{lib, ...}: let + inherit (lib.options) mkEnableOption; +in { + options.vim.lsp = { + otter = { + enable = mkEnableOption "trouble lsp for markup languages"; + }; + }; +} From d61aba1e122a2e2540c286b94701340ff459384d Mon Sep 17 00:00:00 2001 From: Soliprem Date: Fri, 27 Sep 2024 09:46:30 +0200 Subject: [PATCH 06/26] created otter file --- modules/plugins/lsp/otter/config.nix | 15 ++++++++++++--- modules/plugins/lsp/otter/default.nix | 13 +++++-------- modules/plugins/lsp/otter/otter.nix | 14 ++++++++++++++ 3 files changed, 31 insertions(+), 11 deletions(-) create mode 100644 modules/plugins/lsp/otter/otter.nix diff --git a/modules/plugins/lsp/otter/config.nix b/modules/plugins/lsp/otter/config.nix index 8857d328..3025d455 100644 --- a/modules/plugins/lsp/otter/config.nix +++ b/modules/plugins/lsp/otter/config.nix @@ -3,17 +3,26 @@ lib, ... }: let - inherit (lib.modules) mkIf; + inherit (lib.modules) mkIf mkMerge; inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding; cfg = config.vim.lsp; + + self = import ./otter.nix {inherit lib;}; + mappingDefinitions = self.options.vim.lsp.otter.mappings; + mappings = addDescriptionsToMappings cfg.otter.mappings mappingDefinitions; in { config = mkIf (cfg.enable && cfg.otter.enable) { vim = { startPlugins = ["otter"]; - pluginRC.trouble = entryAnywhere '' - -- Enable Otter + maps.normal = mkMerge [ + (mkSetBinding mappings.toggle "lua require'otter'.activate()") + ]; + + pluginRC.otter = entryAnywhere '' + -- Enable otter diagnostics viewer require("otter").setup {} ''; }; diff --git a/modules/plugins/lsp/otter/default.nix b/modules/plugins/lsp/otter/default.nix index 1432d8c6..935f1447 100644 --- a/modules/plugins/lsp/otter/default.nix +++ b/modules/plugins/lsp/otter/default.nix @@ -1,9 +1,6 @@ -{lib, ...}: let - inherit (lib.options) mkEnableOption; -in { - options.vim.lsp = { - otter = { - enable = mkEnableOption "trouble lsp for markup languages"; - }; - }; +{ + imports = [ + ./otter.nix + ./config.nix + ]; } diff --git a/modules/plugins/lsp/otter/otter.nix b/modules/plugins/lsp/otter/otter.nix new file mode 100644 index 00000000..a352da7e --- /dev/null +++ b/modules/plugins/lsp/otter/otter.nix @@ -0,0 +1,14 @@ +{lib, ...}: let + inherit (lib.options) mkEnableOption; + inherit (lib.nvim.binds) mkMappingOption; +in { + options.vim.lsp = { + trouble = { + enable = mkEnableOption "Otter LSP Injector"; + + mappings = { + toggle = mkMappingOption "Activate LSP on Cursor Position [otter]" "oa"; + }; + }; + }; +} From 06a296a32b98286113d673716793fe86cceb65d6 Mon Sep 17 00:00:00 2001 From: Soliprem Date: Fri, 27 Sep 2024 09:55:03 +0200 Subject: [PATCH 07/26] update --- configuration.nix | 1 + modules/plugins/lsp/default.nix | 1 + modules/plugins/lsp/otter/otter.nix | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/configuration.nix b/configuration.nix index 08b0f9b6..26fbd7ef 100644 --- a/configuration.nix +++ b/configuration.nix @@ -19,6 +19,7 @@ isMaximal: { lspsaga.enable = false; trouble.enable = true; lspSignature.enable = true; + otter.enable = isMaximal; lsplines.enable = isMaximal; nvim-docs-view.enable = isMaximal; }; diff --git a/modules/plugins/lsp/default.nix b/modules/plugins/lsp/default.nix index a5d5163d..421f5fda 100644 --- a/modules/plugins/lsp/default.nix +++ b/modules/plugins/lsp/default.nix @@ -13,6 +13,7 @@ ./trouble ./lsp-signature ./lightbulb + ./otter ./lspkind ./lsplines ./nvim-docs-view diff --git a/modules/plugins/lsp/otter/otter.nix b/modules/plugins/lsp/otter/otter.nix index a352da7e..e8222e6c 100644 --- a/modules/plugins/lsp/otter/otter.nix +++ b/modules/plugins/lsp/otter/otter.nix @@ -3,7 +3,7 @@ inherit (lib.nvim.binds) mkMappingOption; in { options.vim.lsp = { - trouble = { + otter = { enable = mkEnableOption "Otter LSP Injector"; mappings = { From 4f151d63bee77ce07b5d522b0b4b961d119aafd8 Mon Sep 17 00:00:00 2001 From: Soliprem Date: Fri, 27 Sep 2024 10:09:43 +0200 Subject: [PATCH 08/26] update --- flake.lock | 13 +++++++++++++ flake.nix | 5 +++++ modules/plugins/lsp/otter/config.nix | 2 +- modules/plugins/lsp/otter/otter.nix | 1 - 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/flake.lock b/flake.lock index 9e11e8ce..6042a26f 100644 --- a/flake.lock +++ b/flake.lock @@ -1373,6 +1373,18 @@ "type": "github" } }, + "plugin-otter": { + "flake": false, + "locked": { + "narHash": "sha256-BvEhaaP13ZVfzdMcmEii8QbVBZnUMZNrBcyCF0vyiW4=", + "type": "file", + "url": "https://github.com/jmbuhr/otter.nvim" + }, + "original": { + "type": "file", + "url": "https://github.com/jmbuhr/otter.nvim" + } + }, "plugin-oxocarbon": { "flake": false, "locked": { @@ -1861,6 +1873,7 @@ "plugin-obsidian-nvim": "plugin-obsidian-nvim", "plugin-onedark": "plugin-onedark", "plugin-orgmode-nvim": "plugin-orgmode-nvim", + "plugin-otter": "plugin-otter", "plugin-oxocarbon": "plugin-oxocarbon", "plugin-plenary-nvim": "plugin-plenary-nvim", "plugin-project-nvim": "plugin-project-nvim", diff --git a/flake.nix b/flake.nix index c4996fcf..c819a94c 100644 --- a/flake.nix +++ b/flake.nix @@ -156,6 +156,11 @@ flake = false; }; + plugin-otter = { + url = "https://github.com/jmbuhr/otter.nvim"; + flake = false; + }; + # Language support plugin-sqls-nvim = { url = "github:nanotee/sqls.nvim"; diff --git a/modules/plugins/lsp/otter/config.nix b/modules/plugins/lsp/otter/config.nix index 3025d455..4c1a5693 100644 --- a/modules/plugins/lsp/otter/config.nix +++ b/modules/plugins/lsp/otter/config.nix @@ -23,7 +23,7 @@ in { pluginRC.otter = entryAnywhere '' -- Enable otter diagnostics viewer - require("otter").setup {} + require("otter-nvim").setup() ''; }; }; diff --git a/modules/plugins/lsp/otter/otter.nix b/modules/plugins/lsp/otter/otter.nix index e8222e6c..2fd6a0e6 100644 --- a/modules/plugins/lsp/otter/otter.nix +++ b/modules/plugins/lsp/otter/otter.nix @@ -5,7 +5,6 @@ in { options.vim.lsp = { otter = { enable = mkEnableOption "Otter LSP Injector"; - mappings = { toggle = mkMappingOption "Activate LSP on Cursor Position [otter]" "oa"; }; From 66c173748e14b1a9599a4296dd71e18812ac6638 Mon Sep 17 00:00:00 2001 From: Soliprem Date: Fri, 27 Sep 2024 10:32:07 +0200 Subject: [PATCH 09/26] otter: fixing fixing input --- flake.lock | 18 +++++++++++------- flake.nix | 4 ++-- modules/plugins/lsp/otter/config.nix | 4 ++-- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/flake.lock b/flake.lock index 6042a26f..310562a0 100644 --- a/flake.lock +++ b/flake.lock @@ -1373,16 +1373,20 @@ "type": "github" } }, - "plugin-otter": { + "plugin-otter-nvim": { "flake": false, "locked": { - "narHash": "sha256-BvEhaaP13ZVfzdMcmEii8QbVBZnUMZNrBcyCF0vyiW4=", - "type": "file", - "url": "https://github.com/jmbuhr/otter.nvim" + "lastModified": 1724585935, + "narHash": "sha256-euHwoK2WHLF/hrjLY2P4yGrIbYyBN38FL3q4CKNZmLY=", + "owner": "jmbuhr", + "repo": "otter.nvim", + "rev": "ca9ce67d0399380b659923381b58d174344c9ee7", + "type": "github" }, "original": { - "type": "file", - "url": "https://github.com/jmbuhr/otter.nvim" + "owner": "jmbuhr", + "repo": "otter.nvim", + "type": "github" } }, "plugin-oxocarbon": { @@ -1873,7 +1877,7 @@ "plugin-obsidian-nvim": "plugin-obsidian-nvim", "plugin-onedark": "plugin-onedark", "plugin-orgmode-nvim": "plugin-orgmode-nvim", - "plugin-otter": "plugin-otter", + "plugin-otter-nvim": "plugin-otter-nvim", "plugin-oxocarbon": "plugin-oxocarbon", "plugin-plenary-nvim": "plugin-plenary-nvim", "plugin-project-nvim": "plugin-project-nvim", diff --git a/flake.nix b/flake.nix index c819a94c..4813481b 100644 --- a/flake.nix +++ b/flake.nix @@ -156,8 +156,8 @@ flake = false; }; - plugin-otter = { - url = "https://github.com/jmbuhr/otter.nvim"; + plugin-otter-nvim = { + url = "github:jmbuhr/otter.nvim"; flake = false; }; diff --git a/modules/plugins/lsp/otter/config.nix b/modules/plugins/lsp/otter/config.nix index 4c1a5693..fa1f740d 100644 --- a/modules/plugins/lsp/otter/config.nix +++ b/modules/plugins/lsp/otter/config.nix @@ -15,7 +15,7 @@ in { config = mkIf (cfg.enable && cfg.otter.enable) { vim = { - startPlugins = ["otter"]; + startPlugins = ["otter-nvim"]; maps.normal = mkMerge [ (mkSetBinding mappings.toggle "lua require'otter'.activate()") @@ -23,7 +23,7 @@ in { pluginRC.otter = entryAnywhere '' -- Enable otter diagnostics viewer - require("otter-nvim").setup() + require("otter").setup() ''; }; }; From 19ae4946a2f36a18d6f2964b609bd121fcbab60f Mon Sep 17 00:00:00 2001 From: Soliprem Date: Fri, 27 Sep 2024 11:35:39 +0200 Subject: [PATCH 10/26] committing flake.lock --- modules/plugins/lsp/otter/otter.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/plugins/lsp/otter/otter.nix b/modules/plugins/lsp/otter/otter.nix index 2fd6a0e6..109e64c9 100644 --- a/modules/plugins/lsp/otter/otter.nix +++ b/modules/plugins/lsp/otter/otter.nix @@ -6,7 +6,7 @@ in { otter = { enable = mkEnableOption "Otter LSP Injector"; mappings = { - toggle = mkMappingOption "Activate LSP on Cursor Position [otter]" "oa"; + toggle = mkMappingOption "Activate LSP on Cursor Position [otter]" "lo"; }; }; }; From e12c9adec946f7de74394bf74cc39c180238accc Mon Sep 17 00:00:00 2001 From: Soliprem Date: Fri, 27 Sep 2024 14:16:43 +0200 Subject: [PATCH 11/26] fixed typo --- modules/plugins/languages/ts.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/plugins/languages/ts.nix b/modules/plugins/languages/ts.nix index e6e718ed..5ceccecf 100644 --- a/modules/plugins/languages/ts.nix +++ b/modules/plugins/languages/ts.nix @@ -226,7 +226,7 @@ in { { assertion = cfg.lsp.enable -> cfg.lsp.server != "tsserver"; message = '' - As of a recent lspconfig update, he `tsserver` configuration has been renamed + As of a recent lspconfig update, the `tsserver` configuration has been renamed to `ts_ls` to match upstream behaviour of `lspconfig`, and the name `tsserver` is no longer considered valid by nvf. Please set `vim.languages.ts.lsp.server` to `"ts_ls"` instead of to `${cfg.lsp.server}` From 51710d33c6fadf1d18290ec595f4f09d7275eff1 Mon Sep 17 00:00:00 2001 From: Soliprem Date: Fri, 27 Sep 2024 16:20:04 +0200 Subject: [PATCH 12/26] configuration: disabling ccc and enabling otter --- configuration.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configuration.nix b/configuration.nix index 26fbd7ef..79df7868 100644 --- a/configuration.nix +++ b/configuration.nix @@ -19,7 +19,7 @@ isMaximal: { lspsaga.enable = false; trouble.enable = true; lspSignature.enable = true; - otter.enable = isMaximal; + otter.enable = true; lsplines.enable = isMaximal; nvim-docs-view.enable = isMaximal; }; @@ -156,7 +156,7 @@ isMaximal: { }; utility = { - ccc.enable = isMaximal; + ccc.enable = false; vim-wakatime.enable = false; icon-picker.enable = isMaximal; surround.enable = isMaximal; From d8d834be355a7f3c0af35dc076789093116586ce Mon Sep 17 00:00:00 2001 From: Soliprem Date: Fri, 27 Sep 2024 16:20:49 +0200 Subject: [PATCH 13/26] added assertion to make sure ccc and otter aren't enabled at the same time --- modules/plugins/lsp/otter/config.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/plugins/lsp/otter/config.nix b/modules/plugins/lsp/otter/config.nix index fa1f740d..8c4d0b70 100644 --- a/modules/plugins/lsp/otter/config.nix +++ b/modules/plugins/lsp/otter/config.nix @@ -14,6 +14,14 @@ mappings = addDescriptionsToMappings cfg.otter.mappings mappingDefinitions; in { config = mkIf (cfg.enable && cfg.otter.enable) { + assertions = [ + { + assertion = !config.vim.utility.ccc.enable; + message = '' + ccc and otter have a breaking conflict. It's been reported upstream. Until it's fixed, disable one of them + ''; + } + ]; vim = { startPlugins = ["otter-nvim"]; From 5bbc68f5e9c66b6b6522372f7cdc32e29c34ad8f Mon Sep 17 00:00:00 2001 From: Soliprem Date: Fri, 27 Sep 2024 16:27:40 +0200 Subject: [PATCH 14/26] configuration: otter set for isMaximal --- configuration.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configuration.nix b/configuration.nix index 79df7868..6fd10c01 100644 --- a/configuration.nix +++ b/configuration.nix @@ -19,7 +19,7 @@ isMaximal: { lspsaga.enable = false; trouble.enable = true; lspSignature.enable = true; - otter.enable = true; + otter.enable = isMaximal; lsplines.enable = isMaximal; nvim-docs-view.enable = isMaximal; }; From cf8764ff96e22a3bda9da5e9281569130f723cfd Mon Sep 17 00:00:00 2001 From: Soliprem Date: Fri, 27 Sep 2024 16:37:38 +0200 Subject: [PATCH 15/26] otter: changelog --- docs/release-notes/rl-0.7.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index efb2da91..73061ec3 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -198,3 +198,6 @@ everyone. - R: - Added LSP - Added Treesitter +- Otter: + - Added support + - Configured assert to prevent conflict with ccc From c5c026a18559adfe2108253a7db3b61112bfecba Mon Sep 17 00:00:00 2001 From: Soliprem Date: Fri, 27 Sep 2024 16:43:04 +0200 Subject: [PATCH 16/26] otter: better changelog --- docs/release-notes/rl-0.7.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 73061ec3..4a0d282a 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -195,9 +195,6 @@ everyone. [Soliprem](https://github.com/Soliprem) -- R: - - Added LSP - - Added Treesitter -- Otter: - - Added support - - Configured assert to prevent conflict with ccc +- 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 From c942c6ae23143f80b73a1f0686bf31f7cae47af6 Mon Sep 17 00:00:00 2001 From: Soliprem Date: Fri, 27 Sep 2024 16:54:14 +0200 Subject: [PATCH 17/26] haskell: added LSP and treesitter --- modules/plugins/languages/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/plugins/languages/default.nix b/modules/plugins/languages/default.nix index 28c1fd8f..024c65a5 100644 --- a/modules/plugins/languages/default.nix +++ b/modules/plugins/languages/default.nix @@ -8,6 +8,7 @@ in { ./css.nix ./elixir.nix ./go.nix + ./haskell.nix ./html.nix ./java.nix ./lua.nix From be5832cf6589a91f47dcecfad4d59d04e7e205e1 Mon Sep 17 00:00:00 2001 From: Soliprem Date: Fri, 27 Sep 2024 17:43:45 +0200 Subject: [PATCH 18/26] haskell: default to isMaximal --- configuration.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/configuration.nix b/configuration.nix index 6fd10c01..39e8842f 100644 --- a/configuration.nix +++ b/configuration.nix @@ -61,6 +61,7 @@ isMaximal: { dart.enable = isMaximal; bash.enable = isMaximal; r.enable = isMaximal; + haskell.enable = isMaximal; tailwind.enable = isMaximal; typst.enable = isMaximal; clang = { From dd2f73ba843ffaf0de501ed6549f09ad2582141c Mon Sep 17 00:00:00 2001 From: Soliprem Date: Fri, 27 Sep 2024 17:44:23 +0200 Subject: [PATCH 19/26] haskell: haskell support --- modules/plugins/languages/haskell.nix | 49 +++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 modules/plugins/languages/haskell.nix diff --git a/modules/plugins/languages/haskell.nix b/modules/plugins/languages/haskell.nix new file mode 100644 index 00000000..b2df406e --- /dev/null +++ b/modules/plugins/languages/haskell.nix @@ -0,0 +1,49 @@ +{ + config, + pkgs, + lib, + ... +}: let + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.types) package; + inherit (lib.nvim.types) mkGrammarOption; + + cfg = config.vim.languages.haskell; +in { + options.vim.languages.haskell = { + enable = mkEnableOption "Haskell support"; + + treesitter = { + enable = mkEnableOption "Haskell treesitter" // {default = config.vim.languages.enableTreesitter;}; + package = mkGrammarOption pkgs "haskell"; + }; + + lsp = { + enable = mkEnableOption "Haskell LSP support (haskell-language-server)" // {default = config.vim.languages.enableLSP;}; + + package = mkOption { + description = "haskell_ls package"; + type = package; + default = pkgs.haskellPackages.haskell-language-server; + }; + }; + }; + config = mkIf cfg.enable (mkMerge [ + (mkIf cfg.treesitter.enable { + vim.treesitter.enable = true; + vim.treesitter.grammars = [cfg.treesitter.package]; + }) + + (mkIf cfg.lsp.enable { + vim.lsp.lspconfig.enable = true; + vim.lsp.lspconfig.sources.haskell-ls = '' + lspconfig.haskell_ls.setup { + capabilities = capabilities, + on_attach=default_on_attach, + cmd = "${cfg.lsp.package}/bin/haskell-language-server-wrapper", + } + ''; + }) + ]); +} From 1ece52ed42e988017124365b7bf39cc219d29341 Mon Sep 17 00:00:00 2001 From: Soliprem Date: Fri, 27 Sep 2024 18:14:03 +0200 Subject: [PATCH 20/26] kotlin: LSP and treesitter --- configuration.nix | 1 + modules/plugins/languages/default.nix | 1 + modules/plugins/languages/haskell.nix | 4 +- modules/plugins/languages/kotlin.nix | 55 +++++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 modules/plugins/languages/kotlin.nix diff --git a/configuration.nix b/configuration.nix index 39e8842f..b1b4ea2b 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/modules/plugins/languages/default.nix b/modules/plugins/languages/default.nix index 024c65a5..6d12e08b 100644 --- a/modules/plugins/languages/default.nix +++ b/modules/plugins/languages/default.nix @@ -9,6 +9,7 @@ in { ./elixir.nix ./go.nix ./haskell.nix + ./kotlin.nix ./html.nix ./java.nix ./lua.nix diff --git a/modules/plugins/languages/haskell.nix b/modules/plugins/languages/haskell.nix index b2df406e..d2440f3f 100644 --- a/modules/plugins/languages/haskell.nix +++ b/modules/plugins/languages/haskell.nix @@ -20,7 +20,7 @@ in { }; lsp = { - enable = mkEnableOption "Haskell LSP support (haskell-language-server)" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "Haskell LSP support (haskell-language-server)" // {default = true;}; package = mkOption { description = "haskell_ls package"; @@ -41,7 +41,7 @@ in { lspconfig.haskell_ls.setup { capabilities = capabilities, on_attach=default_on_attach, - cmd = "${cfg.lsp.package}/bin/haskell-language-server-wrapper", + cmd = "${cfg.lsp.package}/bin/haskell-language-server", } ''; }) diff --git a/modules/plugins/languages/kotlin.nix b/modules/plugins/languages/kotlin.nix new file mode 100644 index 00000000..14023e57 --- /dev/null +++ b/modules/plugins/languages/kotlin.nix @@ -0,0 +1,55 @@ +{ + config, + pkgs, + lib, + ... +}: let + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.types) package; + inherit (lib.nvim.types) mkGrammarOption; + inherit (lib.lists) isList; + inherit (lib.nvim.lua) expToLua; + + cfg = config.vim.languages.kotlin; +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 (kotlin-ls)" // {default = config.vim.languages.enableLSP;}; + + package = mkOption { + description = "kotlin-ls package"; + type = package; + default = pkgs.kotlin-language-server; + }; + }; + }; + config = mkIf cfg.enable (mkMerge [ + (mkIf cfg.treesitter.enable { + vim.treesitter.enable = true; + vim.treesitter.grammars = [cfg.treesitter.package]; + }) + + (mkIf cfg.lsp.enable { + vim.lsp.lspconfig.enable = true; + vim.lsp.lspconfig.sources.kotlin-ls = '' + lspconfig.kotlinls.setup { + capabilities = capabilities, + on_attach=default_on_attach, + cmd = ${ + if isList cfg.lsp.package + then expToLua cfg.lsp.package + else ''{"${cfg.lsp.package}/bin/kotlin-language-server"}'' + }, + } + ''; + }) + ]); +} From f6fb1ba49833c5ce8c01c724c36d708d900a03a4 Mon Sep 17 00:00:00 2001 From: Soliprem Date: Fri, 27 Sep 2024 18:18:54 +0200 Subject: [PATCH 21/26] haskell: LSP cmd definition --- modules/plugins/languages/haskell.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/plugins/languages/haskell.nix b/modules/plugins/languages/haskell.nix index d2440f3f..52db7d2b 100644 --- a/modules/plugins/languages/haskell.nix +++ b/modules/plugins/languages/haskell.nix @@ -6,6 +6,8 @@ }: let inherit (lib.options) mkEnableOption mkOption; inherit (lib.modules) mkIf mkMerge; + inherit (lib.lists) isList; + inherit (lib.nvim.lua) expToLua; inherit (lib.types) package; inherit (lib.nvim.types) mkGrammarOption; @@ -41,7 +43,11 @@ in { lspconfig.haskell_ls.setup { capabilities = capabilities, on_attach=default_on_attach, - cmd = "${cfg.lsp.package}/bin/haskell-language-server", + cmd = ${ + if isList cfg.lsp.package + then expToLua cfg.lsp.package + else ''{" "${cfg.lsp.package}/bin/haskell-language-server", "}'' + }, } ''; }) From 4163de716c8c3359f3cd69e2860e27a807551a79 Mon Sep 17 00:00:00 2001 From: Soliprem Date: Fri, 27 Sep 2024 20:18:28 +0200 Subject: [PATCH 22/26] haskell: LSP cmd definition (currently broken) --- modules/plugins/languages/haskell.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/plugins/languages/haskell.nix b/modules/plugins/languages/haskell.nix index 52db7d2b..47f122c0 100644 --- a/modules/plugins/languages/haskell.nix +++ b/modules/plugins/languages/haskell.nix @@ -27,7 +27,7 @@ in { package = mkOption { description = "haskell_ls package"; type = package; - default = pkgs.haskellPackages.haskell-language-server; + default = pkgs.haskell-language-server; }; }; }; @@ -39,14 +39,14 @@ in { (mkIf cfg.lsp.enable { vim.lsp.lspconfig.enable = true; - vim.lsp.lspconfig.sources.haskell-ls = '' - lspconfig.haskell_ls.setup { + vim.lsp.lspconfig.sources.hls = '' + lspconfig.hls.setup { capabilities = capabilities, on_attach=default_on_attach, cmd = ${ if isList cfg.lsp.package then expToLua cfg.lsp.package - else ''{" "${cfg.lsp.package}/bin/haskell-language-server", "}'' + else ''{"${cfg.lsp.package}/bin/haskell-language-server-wrapper", "--lsp"}'' }, } ''; From 7b46366e53493c2843f9524e2e80916ea9cea99b Mon Sep 17 00:00:00 2001 From: Soliprem Date: Mon, 30 Sep 2024 12:43:04 +0200 Subject: [PATCH 23/26] kotlin: LSP and treesitter working --- modules/plugins/languages/kotlin.nix | 30 +++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/modules/plugins/languages/kotlin.nix b/modules/plugins/languages/kotlin.nix index 14023e57..f40ff209 100644 --- a/modules/plugins/languages/kotlin.nix +++ b/modules/plugins/languages/kotlin.nix @@ -12,6 +12,21 @@ inherit (lib.nvim.lua) expToLua; cfg = config.vim.languages.kotlin; + + # Creating a version of the LSP with access to the kotlin binary. + # This is necessary for the LSP to load the standard library + kotlinLspWithRuntime = pkgs.symlinkJoin { + name = "kotlin-language-server-with-runtime"; + paths = [ + pkgs.kotlin-language-server + pkgs.kotlin + ]; + buildInputs = [pkgs.makeWrapper]; + postBuild = '' + wrapProgram $out/bin/kotlin-language-server \ + --prefix PATH : ${pkgs.lib.makeBinPath [pkgs.kotlin]} + ''; + }; in { options.vim.languages.kotlin = { enable = mkEnableOption "kotlin/HCL support"; @@ -22,12 +37,12 @@ in { }; lsp = { - enable = mkEnableOption "kotlin LSP support (kotlin-ls)" // {default = config.vim.languages.enableLSP;}; + enable = mkEnableOption "kotlin LSP support (kotlin_language_server)" // {default = config.vim.languages.enableLSP;}; package = mkOption { - description = "kotlin-ls package"; + description = "kotlin_language_server package with Kotlin runtime"; type = package; - default = pkgs.kotlin-language-server; + default = kotlinLspWithRuntime; }; }; }; @@ -39,10 +54,15 @@ in { (mkIf cfg.lsp.enable { vim.lsp.lspconfig.enable = true; - vim.lsp.lspconfig.sources.kotlin-ls = '' - lspconfig.kotlinls.setup { + 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 From b12e24a564825f6c25ce92a54e33985c24ec4f8c Mon Sep 17 00:00:00 2001 From: Soliprem Date: Mon, 30 Sep 2024 14:35:29 +0200 Subject: [PATCH 24/26] removing haskell from kotlin branch --- configuration.nix | 1 - modules/plugins/languages/default.nix | 1 - modules/plugins/languages/haskell.nix | 55 --------------------------- 3 files changed, 57 deletions(-) delete mode 100644 modules/plugins/languages/haskell.nix diff --git a/configuration.nix b/configuration.nix index 7ee86137..e5b9c65a 100644 --- a/configuration.nix +++ b/configuration.nix @@ -62,7 +62,6 @@ isMaximal: { dart.enable = isMaximal; bash.enable = isMaximal; r.enable = isMaximal; - haskell.enable = isMaximal; tailwind.enable = isMaximal; typst.enable = isMaximal; clang = { diff --git a/modules/plugins/languages/default.nix b/modules/plugins/languages/default.nix index 6d12e08b..b46d992c 100644 --- a/modules/plugins/languages/default.nix +++ b/modules/plugins/languages/default.nix @@ -8,7 +8,6 @@ in { ./css.nix ./elixir.nix ./go.nix - ./haskell.nix ./kotlin.nix ./html.nix ./java.nix diff --git a/modules/plugins/languages/haskell.nix b/modules/plugins/languages/haskell.nix deleted file mode 100644 index 47f122c0..00000000 --- a/modules/plugins/languages/haskell.nix +++ /dev/null @@ -1,55 +0,0 @@ -{ - config, - pkgs, - lib, - ... -}: let - inherit (lib.options) mkEnableOption mkOption; - inherit (lib.modules) mkIf mkMerge; - inherit (lib.lists) isList; - inherit (lib.nvim.lua) expToLua; - inherit (lib.types) package; - inherit (lib.nvim.types) mkGrammarOption; - - cfg = config.vim.languages.haskell; -in { - options.vim.languages.haskell = { - enable = mkEnableOption "Haskell support"; - - treesitter = { - enable = mkEnableOption "Haskell treesitter" // {default = config.vim.languages.enableTreesitter;}; - package = mkGrammarOption pkgs "haskell"; - }; - - lsp = { - enable = mkEnableOption "Haskell LSP support (haskell-language-server)" // {default = true;}; - - package = mkOption { - description = "haskell_ls package"; - type = package; - default = pkgs.haskell-language-server; - }; - }; - }; - config = mkIf cfg.enable (mkMerge [ - (mkIf cfg.treesitter.enable { - vim.treesitter.enable = true; - vim.treesitter.grammars = [cfg.treesitter.package]; - }) - - (mkIf cfg.lsp.enable { - vim.lsp.lspconfig.enable = true; - vim.lsp.lspconfig.sources.hls = '' - lspconfig.hls.setup { - capabilities = capabilities, - on_attach=default_on_attach, - cmd = ${ - if isList cfg.lsp.package - then expToLua cfg.lsp.package - else ''{"${cfg.lsp.package}/bin/haskell-language-server-wrapper", "--lsp"}'' - }, - } - ''; - }) - ]); -} From fc08c34b9d9e5ed376adf28a535d06413914e647 Mon Sep 17 00:00:00 2001 From: Soliprem Date: Mon, 30 Sep 2024 14:36:40 +0200 Subject: [PATCH 25/26] removing artifacts from merge --- modules/plugins/lsp/otter/otter.nix | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/modules/plugins/lsp/otter/otter.nix b/modules/plugins/lsp/otter/otter.nix index d46c6d54..79797aaf 100644 --- a/modules/plugins/lsp/otter/otter.nix +++ b/modules/plugins/lsp/otter/otter.nix @@ -1,5 +1,4 @@ {lib, ...}: let -<<<<<<< HEAD inherit (lib.options) mkOption mkEnableOption; inherit (lib.nvim.binds) mkMappingOption; inherit (lib.types) bool str listOf; @@ -59,16 +58,6 @@ in { (eg. in Org files) When true, otter handles these cases fully. ''; }; -======= - inherit (lib.options) mkEnableOption; - inherit (lib.nvim.binds) mkMappingOption; -in { - options.vim.lsp = { - otter = { - enable = mkEnableOption "Otter LSP Injector"; - mappings = { - toggle = mkMappingOption "Activate LSP on Cursor Position [otter]" "lo"; ->>>>>>> 7b46366e53493c2843f9524e2e80916ea9cea99b }; }; }; From a1718bbcd6b208fd9a3d56c5b1932e3c2194d93e Mon Sep 17 00:00:00 2001 From: Soliprem Date: Mon, 30 Sep 2024 14:42:51 +0200 Subject: [PATCH 26/26] kotlin: changelog update --- docs/release-notes/rl-0.7.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 55746f2b..34a78e07 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -204,3 +204,4 @@ 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 and Treesitter support for Kotlin under `vim.languages.kotlin`