java-maven-test.nvim

Neovim plugin that allows you to easily search and execute your tests within Neovim, using fuzzy find functionality.

GPL-3.0 License

Stars
2
Committers
1

Table of Contents

The problem āš ļø

You open Neovim, your preferred editor, with the intention of running tests without having to leave your preferred environment.

The solution šŸ†

This Neovim plugin, java-maven-test.nvim, integrates with telescope.nvim and nvim-treesitter to facilitate interactive fuzzy searching and execution of Java tests within a class.

Repository structure šŸ“‚


java-maven-test.nvim/
ā”œā”€ā”€ LICENSE
ā”œā”€ā”€ lua
ā”‚Ā Ā  ā””ā”€ā”€ java-maven-test
ā”‚Ā Ā      ā”œā”€ā”€ commands.lua    # Commands exposed to Neovim
ā”‚Ā Ā      ā”œā”€ā”€ ui.lua          # UI logic (pickers and layout)
ā”‚Ā Ā      ā”œā”€ā”€ init.lua        # Plugin entry point
ā”‚Ā Ā      ā”œā”€ā”€ notify.lua      # Notification-related logic
ā”‚Ā Ā      ā”œā”€ā”€ mvn.lua         # Maven-related logic
ā”‚Ā Ā      ā””ā”€ā”€ util.lua        # Utility functions
ā””ā”€ā”€ README.md


Functionalities ā›ļø

  • Execute test case under the cursor
  • Execute all test in a given class
  • Fuzzy find trough all tests in a class and pick which one to execute
  • Notifications message about test results

Installation ā­

  • Make sure you have Neovim v0.9.0 or greater. ā—
  • Dependecies: treesiter && telescope && plenary (telescope dep)
  • Install using you plugin manager

Vim - Plug

Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim'

Plug 'nvim-treesitter/nvim-treesitter'

Plug 'rcarriga/nvim-notify'

Plug 'jkeresman01/java-maven-test.nvim'

Packer

 use {
  'nvim-telescope/telescope.nvim', tag = '0.1.8',
-- or                            , branch = '0.1.x',
   requires = { {'nvim-lua/plenary.nvim'} }
 }

 use 'nvim-treesitter/nvim-treesitter'
 use 'rcarriga/nvim-notify'

 use 'jkeresman01/java-maven-test.nvim'

Commands šŸŽ¹

Following commands have been exposed to Neovim:

Commands


:MavenTest                  -- Launch picker (select your test case from UI)
:MavenTestAtCursor          -- Execute test at cursor
:MavenTestAllInClass        -- Execute all tests in class

Setup šŸ”§

Set the keymapings as you see fit, here is one example:

require('java-maven-test').setup()

vim.keymap.set("n", "<leader>ft", "<cmd>MavenTest<CR>")
vim.keymap.set("n", "<leader>rt", "<cmd>MavenTestAtCursor<CR>")
vim.keymap.set("n", "<leader>ra", "<cmd>MavenTestAllInClass<CR>")

Key - map Action
<leader>rt Execute test under the cursor
<leader>ra Execute all tests in currently opened class
<leader>ft Fuzzy find trough tests in a given class and execute selected one