Neovim Java plugin manager and host
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Ensar Sarajcic d1651c78cd chore: add git dependency for test workflow 5 months ago
.gitea/ISSUE_TEMPLATE chore: update docs and CI for codeberg 5 months ago
.woodpecker chore: add git dependency for test workflow 5 months ago
doc chore: update docs and CI for codeberg 5 months ago
lua/java_plugin_host fix: fix plugin_host_directory jars classpath entry 6 months ago
scripts Initial commit 6 months ago
tests Initial commit 6 months ago
.editorconfig Initial commit 6 months ago
.gitignore Initial commit 6 months ago
.luacheckrc Initial commit 6 months ago
CONTRIBUTING.md chore: update docs and CI for codeberg 5 months ago
LICENSE Initial commit 6 months ago
README.md chore: update docs and CI for codeberg 5 months ago

README.md

Java plugin host

Plugin enabling configuration of Neovim using Java and running JAR plugins.

WORK IN PROGRESS - EXPERIMENTAL, USE AT YOUR OWN RISK!

Requirements

Installation

Install using favourite plugin manager.

e.g. Using Packer.nvim

use { 'https://codeberg.org/neovim-java/neovim-java-plugin-host' }

Usage

Call setup function and define plugins in it. The following shows default options:

require("java_plugin_host").setup {
  rplugins = {
    load_hosted = true, -- set to false to prevent loading hosted plugins from rplugin/hosted-jar
    load_standalone = false, -- set to true to automatically load and start all plugins from rplugin/jar as standalone plugins
    load_class = false, -- set to true to also load .class files from rplugin/java - useful for quick plugins
    compile_java = false, -- set to true to compile .java files from rplugin/java - set load_class to true to also load them
  },
  common_host = {
    enabled = true, -- set to false to disable common host and hosted plugins
    -- Change to override default common plugins host
    -- This is an executable jar which will be started and host all other plugins
    -- Should be based on com.ensarsarajcic.neovim.java:plugin-host to work properly
    -- Or it should be able to properly process annotations used for plugins
    -- This field can also be defined as string, e.g. "com.ensarsarajcic.neovim.java:plugins-common-host:0.4.6"
    name = {
      group_id = "com.ensarsarajcic.neovim.java",
      artifact_id = "plugins-common-host",
      version = "0.4.6"
    },
    -- When changing common_host.name, this should also be changed to the main class
    -- of the other artifact used as common host
    main_class_name = "com.ensarsarajcic.neovim.java.commonhost.CommonPluginHost",
    -- List hosted plugins here - artifacts from system default maven repositories
    hosted_plugins = {
    -- Example:
    -- {
    --   group_id = "com.ensarsarajcic.neovim.java",
    --   artifact_id = "rplugin-hosted-example",
    --   version = "0.4.2"
    -- },
    -- or:
    -- "com.ensarsarajcic.neovim.java:rplugin-hosted-example:0.4.2"
    },
    -- Custom repositories
    custom_repositories = {
    -- Example:
    -- {
    --   id = "github",
    --   url = "https://maven.pkg.github.com/OWNER/REPOSITORY"
    -- }
    }
  },
  -- Extend with a list of strings - additional classpath entries
  -- If all classpath entries generated by the plugin are not enough
  classpath_extras = {},
  -- Library logging level - also affects storing of logs from the hosted plugins
  log_level = "info",
  autostart = true, -- set to false to prevent automatic start of plugins - must call start() then
}

NOTE: When adding .java classes directly in rplugin/java, make sure to create directories for packages starting from rplugin/java as root. This means that any .java classes found in rplugin/java directly should have no package at all (implicit root package).

Functions

  • require("java_plugin_host").setup() - main function for configuring the plugin, must be called before using any other function
  • require("java_plugin_host").start() - start common plugin host and all standalone plugins - needed only if autostart = false or explicitly stopped
  • require("java_plugin_host").stop() - stop common plugin host and all standalone plugins
  • require("java_plugin_host").restart() - restart common plugin host and all standalone plugins - works only if already running
  • require("java_plugin_host").open_logs(key) - open plugin logs - if key is omitted, shows common host logs, otherwise opends standalone plugin based on key - also mapped to NeovimJavaLogs - autocomplete is provided for keys
  • require("java_plugin_host").rebuild_classpath(callback) - rebuild classpath used by the plugin and call callback with new classpath - can be useful to recompile all config and then restart the plugin
  • require("java_plugin_host").request(...) - shortcut for rpcrequest which uses common host job id - example: require("java_plugin_host").request("my_custom_request_handler", "arg1")
  • require("java_plugin_host").notify(...) - shortcut for rpcnotify which uses common host job id - example: require("java_plugin_host").notify("my_custom_notification_handler", "arg1")
  • require("java_plugin_host").get_standalone_jobs() - returns table with all running standalone jobs

Classpath can also be directly accessed with require("java_plugin_host").classpath (only after setup() call).

Configuring nvim-jdtls

If using nvim-jdtls, it can be configured to add classpath of the common host. This enables writing configuration directly in nvim config rplugin/java directory, as any other configuration file. It is recommended to keep separate nvim-jdtls configuration for nvim config, to prevent showing plugin autocomplete suggestions in other Java code. Example configuration can be found in my dotfiles.

config.settings = {
  java = {
    ...
    project = {
      referencedLibraries = require("java_plugin_host").classpath,
    },
    ...
  },
}

Writing plugins for the host

Check out examples and templates:

Contributing

Check out contributing guidelines.

License

MIT