From 3dddf844ce7d09aeb0c5efc06507cf96d60ca3b2 Mon Sep 17 00:00:00 2001 From: Mykhailo Nikiforov Date: Tue, 6 Jun 2023 16:32:00 +0300 Subject: [PATCH] add groovyls --- flake.lock | 71 +++++++++++++++++++++++++++++++++++++++++++- flake.nix | 10 +++++++ init.lua | 2 +- overlays.nix | 7 +++++ pwnvim/filetypes.lua | 2 +- pwnvim/plugins.lua | 11 +++---- 6 files changed, 95 insertions(+), 8 deletions(-) create mode 100644 overlays.nix diff --git a/flake.lock b/flake.lock index 67d0c04..290dd7a 100644 --- a/flake.lock +++ b/flake.lock @@ -18,7 +18,60 @@ "type": "github" } }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1685518550, + "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "groovyls": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1686055585, + "narHash": "sha256-e+hjiIvQZ6Dmow7cJlGTS0LmJh8vNRhyU/HDHPOIqi0=", + "owner": "miknikif", + "repo": "groovyls", + "rev": "cb877e243f5b3c2e725ac2d50a6f70c184161d4a", + "type": "github" + }, + "original": { + "owner": "miknikif", + "repo": "groovyls", + "type": "github" + } + }, "nixpkgs": { + "locked": { + "lastModified": 1686043861, + "narHash": "sha256-duF1U12b7vVkf2Lt6noPYVeW8dVFw4CwJmQivhyZxYQ=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "96f8f4a038a190f7511da79ef7e77bec5e4b811a", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "release-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { "locked": { "lastModified": 1685539144, "narHash": "sha256-BvIghafqDrQqWSbnWuDVLD6fiPWRE/foLWSupFM+Hho=", @@ -37,7 +90,8 @@ "root": { "inputs": { "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "groovyls": "groovyls", + "nixpkgs": "nixpkgs_2" } }, "systems": { @@ -54,6 +108,21 @@ "repo": "default", "type": "github" } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 70d4924..edb6a67 100644 --- a/flake.nix +++ b/flake.nix @@ -3,16 +3,24 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/release-23.05"; flake-utils.url = "github:numtide/flake-utils"; + groovyls.url = "github:miknikif/groovyls"; }; outputs = inputs @ { self, nixpkgs, flake-utils, + groovyls, ... }: flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; + inherit + (import ./overlays.nix { + inherit inputs; + }) + overlays + ; }; recursiveMerge = attrList: let @@ -51,6 +59,7 @@ vale # linter for prose jdk # for groovy groovy + groovyls # groovy lsp ]; neovim-augmented = recursiveMerge [ pkgs.neovim-unwrapped @@ -70,6 +79,7 @@ '' lua << EOF package.path = "${self}/?.lua;" .. package.path + groovyls_cmd = { "${pkgs.jdk}/bin/java", "-jar", "${pkgs.groovyls}/groovyls-all.jar" } '' + pkgs.lib.readFile ./init.lua + '' diff --git a/init.lua b/init.lua index 2bc4d3b..7ca649e 100644 --- a/init.lua +++ b/init.lua @@ -12,7 +12,7 @@ require('pwnvim.options').gui() require('pwnvim.mappings') require('pwnvim.abbreviations') require('pwnvim.plugins').ui() -require('pwnvim.plugins').diagnostics() +require('pwnvim.plugins').diagnostics(groovyls_cmd) -- groovyls_cmd is dynamically created by nix require('pwnvim.plugins').telescope() require('pwnvim.plugins').completions() require('pwnvim.plugins').notes() diff --git a/overlays.nix b/overlays.nix new file mode 100644 index 0000000..df61624 --- /dev/null +++ b/overlays.nix @@ -0,0 +1,7 @@ +{inputs, ...}: { + overlays = [ + (final: prev: { + inherit (inputs.groovyls.packages.${final.system}) groovyls; + }) + ]; +} diff --git a/pwnvim/filetypes.lua b/pwnvim/filetypes.lua index eadc799..9632abf 100644 --- a/pwnvim/filetypes.lua +++ b/pwnvim/filetypes.lua @@ -36,7 +36,7 @@ M.config = function() autocmd("FileType", { pattern = { "c", "ruby", "php", "php3", "perl", "python", "mason", "vim", "sh", "zsh", "scala", "javascript", - "javascriptreact", "typescript", "typescriptreact", "html", "svelte", "css", "nix", "terraform" }, + "javascriptreact", "typescript", "typescriptreact", "html", "svelte", "css", "nix", "terraform", "groovy", "java" }, callback = function() require('pwnvim.options').programming() end, group = filetypes }) diff --git a/pwnvim/plugins.lua b/pwnvim/plugins.lua index 7b358be..9fa5e9d 100644 --- a/pwnvim/plugins.lua +++ b/pwnvim/plugins.lua @@ -34,7 +34,7 @@ M.ui = function() end -- UI setup ----------------------- DIAGNOSTICS -------------------------------- -M.diagnostics = function() +M.diagnostics = function(groovyls_cmd) -- IMPORTANT: make sure to setup neodev BEFORE lspconfig require("neodev").setup({ -- help for neovim lua api @@ -258,7 +258,8 @@ M.diagnostics = function() codeactions.eslint_d, codeactions.gitsigns, codeactions.statix, -- for nix diagnostics.statix, -- for nix null_ls.builtins.hover.dictionary, codeactions.shellcheck, - diagnostics.shellcheck + diagnostics.shellcheck, + diagnostics.npm_groovy_lint -- removed formatting.rustfmt since rust_analyzer seems to do the same thing }, on_attach = attached @@ -350,9 +351,9 @@ M.diagnostics = function() }, capabilities = capabilities } - lspconfig.terraformls.setup { on_attach = attached, capabilities = capabilities } -- terraform lsp - lspconfig.tflint.setup { on_attach = attached, capabilities = capabilities } -- terraform lsp - lspconfig.groovyls.setup { on_attach = attached, capabilities = capabilities } -- groovy lsp + lspconfig.terraformls.setup { on_attach = attached, capabilities = capabilities } -- terraform lsp + lspconfig.tflint.setup { on_attach = attached, capabilities = capabilities } -- terraform lsp + lspconfig.groovyls.setup { on_attach = attached, capabilities = capabilities, cmd = groovyls_cmd } -- groovy lsp require 'lspsaga'.init_lsp_saga({ use_saga_diagnostic_sign = not SimpleUI,