mfussenegger / nvim-jdtls

Extensions for the built-in LSP support in Neovim for eclipse.jdt.ls
GNU General Public License v3.0
1.09k stars 62 forks source link

Java test project-level configurations #351

Closed cladera closed 2 years ago

cladera commented 2 years ago

Problem Statement

As java developer I want to configure java test profiles at project level.

Use case

I have a test suite that use system properties to provide arguments to my tests. For example, my tests use the system property foo which is a comma separated list of strings. I want to run each test for each item in foo.

Running with maven would look like:

mvn clean test -Dfoo=baar,baaaar,baaaaar

Running with nvim-jdtls would like:

local jdtls = require('jdtls')
jdtls.test_class({config_overrides={vmArgs='-ea -Dfoo=baar,baaar,baaaaar'}})

I want to create a mapping for the command above. However that mapping would need to go to my general nvim settings. I would rather have some place at project level to create some sort of java-test profile so when I run jdtls.test_class() it ask me if I want to use any of my project profiles or run with defaults.

Ideas or possible solutions

Inspired in dap-launch.json I created this POC: https://github.com/cladera/lvim/blob/main/lua/user/dap/java.lua

mfussenegger commented 2 years ago

I think project management support is kinda orthogonal to nvim-jdtls. There are some plugins that focus on that already: https://github.com/rockerBOO/awesome-neovim/blob/main/README.md#project

I suspect one of them would allow you to define heuristics to identify the project and then run custom logic that could setup the keymaps accordingly.

Or alternatively you could work with .env files and change the jdtls.test_class keymap to read a env variable itself that it passes along.

Given the many options and different approaches I'd like to keep nvim-jdtls itself un-opinionated and defer handling of this to another system/the user.