diff --git a/.gitignore b/.gitignore index 238d11c..b6d36ab 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ vendor/plenary.nvim +.test_plugins diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..de6d140 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,9 @@ +{ + "tasks": [ + { + "label": "Run Tests", + "type": "shell", + "command": "make test" + } + ] +} diff --git a/README.md b/README.md index 6e3a28c..f7b0356 100644 --- a/README.md +++ b/README.md @@ -1,47 +1,62 @@ -# A Neovim Plugin Template - -![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/ellisonleao/nvim-plugin-template/lint-test.yml?branch=main&style=for-the-badge) -![Lua](https://img.shields.io/badge/Made%20with%20Lua-blueviolet.svg?style=for-the-badge&logo=lua) - -A template repository for Neovim plugins. - -## Using it - -Via `gh`: - -``` -$ gh repo create my-plugin -p ellisonleao/nvim-plugin-template +# nvim-java + +![Neovim](https://img.shields.io/badge/NeoVim-%2357A143.svg?&style=for-the-badge&logo=neovim&logoColor=white) +![Lua](https://img.shields.io/badge/lua-%232C2D72.svg?style=for-the-badge&logo=lua&logoColor=white) +![Java](https://img.shields.io/badge/java-%23ED8B00.svg?style=for-the-badge&logo=openjdk&logoColor=white) +![Gradle](https://img.shields.io/badge/Gradle-02303A.svg?style=for-the-badge&logo=Gradle&logoColor=white) +![Apache Maven](https://img.shields.io/badge/Apache%20Maven-C71A36?style=for-the-badge&logo=Apache%20Maven&logoColor=white) + +No need to put up with [jdtls](https://github.com/eclipse-jdtls/eclipse.jdt.ls) nonsense anymore. +Just install and start writing `public static void main(String[] args)`. + +## Features + +- :white_check_mark: Diagnostics & Auto Completion +- :white_check_mark: Automatic [DAP](https://github.com/mfussenegger/nvim-dap) debug configuration +- :x: Running tests + +## Why + +- Uses [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig) to setup `jdtls` +- Realtime server settings updates is possible using [neoconf](https://github.com/folke/neoconf.nvim) +- Everything necessary will be installed automatically (except JDKs) +- Uses `jdtls` and auto loads `jdtls` plugins from [mason.nvim](https://github.com/williamboman/mason.nvim) + - Supported plugins are, + - `lombok` + - `java-test` + - `java-debug-adapter` +- Typed & documented APIs +- No callback hells I [promise](https://github.com/pyericz/promise-lua) + +## How to Use + +### Install the plugin + +Using [lazy.nvim](https://github.com/folke/lazy.nvim) + +```lua +return { + 'nvim-java/nvim-java', + dependencies = { + 'nvim-java/nvim-java-core', + 'neovim/nvim-lspconfig', + 'williamboman/mason.nvim', + 'mfussenegger/nvim-dap', + }, + event = 'VeryLazy', + opts = {}, +} ``` -Via github web page: +### Setup JDTLS like you would usually do -Click on `Use this template` - -![](https://docs.github.com/assets/cb-36544/images/help/repository/use-this-template-button.png) - -## Features and structure +```lua +require('lspconfig').jdtls.setup({}) +``` -- 100% Lua -- Github actions for: - - running tests using [plenary.nvim](https://github.com/nvim-lua/plenary.nvim) and [busted](https://olivinelabs.com/busted/) - - check for formatting errors (Stylua) - - vimdocs autogeneration from README.md file - - luarocks release (LUAROCKS_API_KEY secret configuration required) +Yep! That's all :) -### Plugin structure +## Projects Acknowledgement -``` -. -├── lua -│   ├── plugin_name -│   │   └── module.lua -│   └── plugin_name.lua -├── Makefile -├── plugin -│   └── plugin_name.lua -├── README.md -├── tests -│   ├── minimal_init.lua -│   └── plugin_name -│   └── plugin_name_spec.lua -``` +[nvim-jdtls](https://github.com/mfussenegger/nvim-jdtls) is a plugin that follows "Keep it simple, stupid!" approach. +If you love customizing things by yourself, then give nvim-jdtls a try. diff --git a/dev/init.lua b/dev/init.lua index 614d990..f3a4440 100644 --- a/dev/init.lua +++ b/dev/init.lua @@ -4,7 +4,7 @@ vim.opt.runtimepath:prepend(cwd) --[[ -- plugin name will be used to reload the loaded modules --]] -local package_name = 'plugin_name' +local package_name = 'java' -- add the escape character to special characters local escape_pattern = function(text) @@ -26,7 +26,7 @@ end local run_action = function() vim.cmd.messages('clear') - require(package_name).hello() + require(package_name).__run() end -- unload and run the function from the package diff --git a/doc/my-template-docs.txt b/doc/my-template-docs.txt deleted file mode 100644 index d6d345a..0000000 --- a/doc/my-template-docs.txt +++ /dev/null @@ -1,70 +0,0 @@ -*my-template-docs.txt* For Neovim >= 0.8.0 Last change: 2023 November 10 - -============================================================================== -Table of Contents *my-template-docs-table-of-contents* - -1. A Neovim Plugin Template |my-template-docs-a-neovim-plugin-template| - - Using it |my-template-docs-a-neovim-plugin-template-using-it| - - Features and structure|my-template-docs-a-neovim-plugin-template-features-and-structure| - -============================================================================== -1. A Neovim Plugin Template *my-template-docs-a-neovim-plugin-template* - - - -A template repository for Neovim plugins. - - -USING IT *my-template-docs-a-neovim-plugin-template-using-it* - -Via `gh` - -> - $ gh repo create my-plugin -p ellisonleao/nvim-plugin-template -< - -Viagithub web page: - -Click on `Use this template` - - - - -FEATURES AND STRUCTURE*my-template-docs-a-neovim-plugin-template-features-and-structure* - -- 100% Lua -- Github actions for: - - running tests using plenary.nvim and busted - - check for formatting errors (Stylua) - - vimdocs autogeneration from README.md file - - luarocks release (LUAROCKS_API_KEY secret configuration required) - - -PLUGIN STRUCTURE ~ - -> - . - ├── lua - │   ├── plugin_name - │   │   └── module.lua - │   └── plugin_name.lua - ├── Makefile - ├── plugin - │   └── plugin_name.lua - ├── README.md - ├── tests - │   ├── minimal_init.lua - │   └── plugin_name - │   └── plugin_name_spec.lua -< - -============================================================================== -2. Links *my-template-docs-links* - -1. *GitHub Workflow Status*: https://img.shields.io/github/actions/workflow/status/ellisonleao/nvim-plugin-template/lint-test.yml?branch=main&style=for-the-badge -2. *Lua*: https://img.shields.io/badge/Made%20with%20Lua-blueviolet.svg?style=for-the-badge&logo=lua -3. **: https://docs.github.com/assets/cb-36544/images/help/repository/use-this-template-button.png - -Generated by panvimdoc - -vim:tw=78:ts=8:noet:ft=help:norl: diff --git a/lua/java.lua b/lua/java.lua new file mode 100644 index 0000000..42d1522 --- /dev/null +++ b/lua/java.lua @@ -0,0 +1,38 @@ +local deps = require('java.dependencies') +local java_mason = require('java.mason') +local java_dap = require('java.dap') +local java_lspconfig = require('java.lspconfig') +local ts = require('java.treesitter') + +local M = {} + +function M.setup() + deps.check() + java_lspconfig.wrap_lspconfig_setup() + java_mason.install_dependencies() + java_dap.setup_dap() +end + +---------------------------------------------------------------------- +-- DAP APIs -- +---------------------------------------------------------------------- +M.dap = {} +M.dap.config_dap = java_dap.config_dap + +---------------------------------------------------------------------- +-- Test APIs -- +---------------------------------------------------------------------- +M.test = {} +M.test.run_current_test_class = java_dap.run_current_test_class + +---------------------------------------------------------------------- +-- Manipulate -- +---------------------------------------------------------------------- +M.manipulate = {} +-- M.manipulate.organize_imports = {} + +function M.__run() + ts.find_main_method() +end + +return M diff --git a/lua/java/dap/dapp.lua b/lua/java/dap/dapp.lua new file mode 100644 index 0000000..5cd30b7 --- /dev/null +++ b/lua/java/dap/dapp.lua @@ -0,0 +1,82 @@ +local log = require('java-core.utils.log') + +local Promise = require('java-core.utils.promise') +local JavaCoreDap = require('java-core.dap') +local JavaCoreTestHelper = require('java-core.ls.helpers.test-helper') + +---@class JavaDap +---@field client LSPClient +---@field test_helper JavaCoreTestHelper +---@field dap_helper JavaCoreDap +local M = {} + +---@param args { client: LSPClient } +---@return JavaDap +function M:new(args) + local o = { + client = args.client, + } + + o.test_helper = JavaCoreTestHelper:new({ + client = args.client, + }) + + o.dap_helper = JavaCoreDap:new({ + client = args.client, + }) + + setmetatable(o, self) + self.__index = self + return o +end + +function M:run_current_test_class() + log.info('running the current class') + + local buffer = vim.api.nvim_get_current_buf() + + self.test_helper + :get_test_class_by_buffer(buffer) + :thenCall(function(classes) + self.test_helper:run_test(classes) + end) + :catch(function(err) + local msg = 'failed to run the current class' + + log.error(msg, err) + error(msg .. err) + end) +end + +function M:config_dap() + return Promise.resolve() + :thenCall(function() + log.debug('set dap adapter callback function') + + -- setting java adapter + require('dap').adapters.java = function(callback) + self.dap_helper:get_dap_adapter():thenCall(callback):catch(function(err) + local msg = 'faild to set DAP adapter' + + error(msg, err) + log.error(msg, err) + end) + end + + -- setting java config + return self.dap_helper:get_dap_config() + end) + :thenCall(function(dap_config) + log.debug('set dap config: ', dap_config) + + require('dap').configurations.java = dap_config + end) + :catch(function(err) + local msg = 'faild to set DAP configuration' + + log.error(msg, err) + error(msg .. err) + end) +end + +return M diff --git a/lua/java/dap/init.lua b/lua/java/dap/init.lua new file mode 100644 index 0000000..b47531b --- /dev/null +++ b/lua/java/dap/init.lua @@ -0,0 +1,49 @@ +local JavaDap = require('java.dap.dapp') + +local log = require('java-core.utils.log') +local state = require('java.state') +local notify = require('java-core.utils.notify') + +local M = {} + +---Setup dap config & adapter on jdtls attach event +function M.setup_dap() + log.info('add LspAttach event handlers to setup dap adapter & config') + + vim.api.nvim_create_autocmd('LspAttach', { + pattern = '*', + callback = M.on_jdtls_attach, + once = true, + group = vim.api.nvim_create_augroup('nvim-java-dap-config', {}), + }) +end + +---Runs the current test class +function M.run_current_test_class() + state.java_dap:run_current_test_class() +end + +---Configures the dap +function M.config_dap() + state.java_dap:config_dap():thenCall(function() + notify.info('DAP configured') + end) +end + +---@private +---@param ev any +function M.on_jdtls_attach(ev) + local client = vim.lsp.get_client_by_id(ev.data.client_id) + + if client.name == 'jdtls' then + state.java_dap = JavaDap:new({ + client = client, + }) + + log.info('setup java dap config & adapter') + + state.java_dap:config_dap() + end +end + +return M diff --git a/lua/java/dependencies.lua b/lua/java/dependencies.lua new file mode 100644 index 0000000..442eb36 --- /dev/null +++ b/lua/java/dependencies.lua @@ -0,0 +1,39 @@ +local log = require('java-core.utils.log') + +local pkgs = { + { + name = 'mason-registry', + err = [[mason.nvim is not installed. nvim-java requires mason.nvim to install dependecies. + Please follow the install guide in https://github.com/nvim-java/nvim-java to install nvim-java]], + }, + { + name = 'dap', + err = [[nvim-dap is not installed. nvim-java requires nvim-dap to setup the debugger. +Please follow the install guide in https://github.com/nvim-java/nvim-java to install nvim-java]], + }, + { + name = 'lspconfig', + err = [[nvim-lspconfig is not installed. nvim-lspconfig requires nvim-lspconfig to show diagnostics & auto completion. +Please follow the install guide in https://github.com/nvim-java/nvim-java to install nvim-java]], + }, +} + +local M = {} + +function M.check() + log.info('check neovim plugin dependencies') + M.neovim_plugin_check() +end + +function M.neovim_plugin_check() + for _, pkg in ipairs(pkgs) do + local ok, _ = pcall(require, pkg.name) + + if not ok then + log.error(pkg.err) + error(pkg.err) + end + end +end + +return M diff --git a/lua/java/lspconfig.lua b/lua/java/lspconfig.lua new file mode 100644 index 0000000..a7589c6 --- /dev/null +++ b/lua/java/lspconfig.lua @@ -0,0 +1,33 @@ +local log = require('java-core.utils.log') +local lspconfig = require('lspconfig') +local server = require('java-core.server') + +local M = {} + +function M.wrap_lspconfig_setup() + log.info('wrap lspconfig.java.setup function to inject a custom java config') + ---@type fun(config: LSPSetupConfig) + local org_setup = lspconfig.jdtls.setup + + lspconfig.jdtls.setup = function(user_config) + local config = server.get_config({ + root_markers = { + 'settings.gradle', + 'settings.gradle.kts', + 'pom.xml', + 'build.gradle', + 'mvnw', + 'gradlew', + 'build.gradle', + 'build.gradle.kts', + '.git', + }, + }) + + config = vim.tbl_deep_extend('force', user_config, config) + + org_setup(config) + end +end + +return M diff --git a/lua/java/mason.lua b/lua/java/mason.lua new file mode 100644 index 0000000..56626b9 --- /dev/null +++ b/lua/java/mason.lua @@ -0,0 +1,57 @@ +local log = require('java-core.utils.log') +local mason_reg = require('mason-registry') + +local M = {} + +local dependecies = { + { name = 'jdtls', version = 'v1.29.0' }, + { name = 'java-test', version = '0.40.1' }, + { name = 'java-debug-adapter', version = '0.52.0' }, +} + +---Install mason package dependencies for nvim-java +function M.install_dependencies() + log.info('check mason dependecies') + + for _, dep in ipairs(dependecies) do + if not M.is_installed(dep.name, dep.version) then + log.fmt_info('installing mason pkg: %s', dep.name) + + local pkg = mason_reg.get_package(dep.name) + + pkg:install({ + version = dep.version, + force = true, + }) + end + end +end + +---Returns true if the package and its expected version is already installed +---@param pkg_name string name of the package +---@param expc_version string expected version of the package +---@return boolean true if the package and its version is already installed +function M.is_installed(pkg_name, expc_version) + local pkg = mason_reg.get_package(pkg_name) + + if not pkg:is_installed() then + return false + end + + ---@type string | nil + local installed_version + + pkg:get_installed_version(function(ok, version) + if ok then + installed_version = version + end + end) + + if installed_version == expc_version then + return true + end + + return false +end + +return M diff --git a/lua/java/state.lua b/lua/java/state.lua new file mode 100644 index 0000000..6b419b7 --- /dev/null +++ b/lua/java/state.lua @@ -0,0 +1,4 @@ +-- One place to keep the global state so every one can access +local M = {} + +return M diff --git a/lua/java/treesitter/init.lua b/lua/java/treesitter/init.lua new file mode 100644 index 0000000..162a5e5 --- /dev/null +++ b/lua/java/treesitter/init.lua @@ -0,0 +1,26 @@ +local queries = require('java.treesitter.queries') + +local M = {} + +---Finds a main method in the given buffer and returns the line number +---@return integer | nil line number of the main method +function M.find_main_method(buffer) + local query = vim.treesitter.query.parse('java', queries.main_class) + local parser = vim.treesitter.get_parser(buffer, 'java') + local root = parser:parse()[1]:root() + + for _, match, _ in query:iter_matches(root, buffer, 0, -1) do + for id, node in pairs(match) do + local capture_name = query.captures[id] + + if capture_name == 'main_method' then + -- first element is the line number + return ({ node:start() })[1] + end + end + end + + return nil +end + +return M diff --git a/lua/java/treesitter/queries.lua b/lua/java/treesitter/queries.lua new file mode 100644 index 0000000..78f419a --- /dev/null +++ b/lua/java/treesitter/queries.lua @@ -0,0 +1,15 @@ +local M = {} + +M.main_class = [[ +(method_declaration + (modifiers) @modifiers (#eq? @modifiers "public static") + type: (void_type) @return_type + name: (identifier) @name (#eq? @name "main") + parameters: (formal_parameters + (formal_parameter + type: (array_type + element: (type_identifier) @arg_type (#eq? @arg_type "String")))) +) @main_method +]] + +return M diff --git a/lua/java/utils/log.lua b/lua/java/utils/log.lua new file mode 100644 index 0000000..836ddcb --- /dev/null +++ b/lua/java/utils/log.lua @@ -0,0 +1,165 @@ +--[[ +--FROM: https://github.com/tjdevries/vlog.nvim +--]] + +-- log.lua +-- +-- Inspired by rxi/log.lua +-- Modified by tjdevries and can be found at github.com/tjdevries/vlog.nvim +-- +-- This library is free software; you can redistribute it and/or modify it +-- under the terms of the MIT license. See LICENSE for details. + +-- User configuration section +local default_config = { + -- Name of the plugin. Prepended to log messages + plugin = 'nvim-java', + + -- Should print the output to neovim while running + use_console = true, + + -- Should highlighting be used in console (using echohl) + highlights = true, + + -- Should write to a file + use_file = true, + + -- Any messages above this level will be logged. + level = 'trace', + + -- Level configuration + modes = { + { name = 'trace', hl = 'Comment' }, + { name = 'debug', hl = 'Comment' }, + { name = 'info', hl = 'None' }, + { name = 'warn', hl = 'WarningMsg' }, + { name = 'error', hl = 'ErrorMsg' }, + { name = 'fatal', hl = 'ErrorMsg' }, + }, + + -- Can limit the number of decimals displayed for floats + float_precision = 0.01, +} + +-- {{{ NO NEED TO CHANGE +local log = {} + +local unpack = unpack or table.unpack + +log.new = function(config, standalone) + config = vim.tbl_deep_extend('force', default_config, config) + + local outfile = string.format( + '%s/%s.log', + vim.api.nvim_call_function('stdpath', { 'data' }), + config.plugin + ) + + local obj + if standalone then + obj = log + else + obj = {} + end + + local levels = {} + for i, v in ipairs(config.modes) do + levels[v.name] = i + end + + local round = function(x, increment) + increment = increment or 1 + x = x / increment + return (x > 0 and math.floor(x + 0.5) or math.ceil(x - 0.5)) * increment + end + + local make_string = function(...) + local t = {} + for i = 1, select('#', ...) do + local x = select(i, ...) + + if type(x) == 'number' and config.float_precision then + x = tostring(round(x, config.float_precision)) + elseif type(x) == 'table' then + x = vim.inspect(x) + else + x = tostring(x) + end + + t[#t + 1] = x + end + return table.concat(t, ' ') + end + + local log_at_level = function(level, level_config, message_maker, ...) + -- Return early if we're below the config.level + if level < levels[config.level] then + return + end + local nameupper = level_config.name:upper() + + local msg = message_maker(...) + local info = debug.getinfo(2, 'Sl') + local lineinfo = info.short_src .. ':' .. info.currentline + + -- Output to console + if config.use_console then + local console_string = string.format( + '[%-6s%s] %s: %s', + nameupper, + os.date('%H:%M:%S'), + lineinfo, + msg + ) + + if config.highlights and level_config.hl then + vim.cmd(string.format('echohl %s', level_config.hl)) + end + + local split_console = vim.split(console_string, '\n') + for _, v in ipairs(split_console) do + vim.cmd( + string.format( + [[echom "[%s] %s"]], + config.plugin, + vim.fn.escape(v, '"') + ) + ) + end + + if config.highlights and level_config.hl then + vim.cmd('echohl NONE') + end + end + + -- Output to log file + if config.use_file then + local fp = io.open(outfile, 'a') + local str = + string.format('[%-6s%s] %s: %s\n', nameupper, os.date(), lineinfo, msg) + fp:write(str) + fp:close() + end + end + + for i, x in ipairs(config.modes) do + obj[x.name] = function(...) + return log_at_level(i, x, make_string, ...) + end + + obj[('fmt_%s'):format(x.name)] = function(...) + local passed = { ... } + return log_at_level(i, x, function() + local fmt = table.remove(passed, 1) + local inspected = {} + for _, v in ipairs(passed) do + table.insert(inspected, vim.inspect(v)) + end + return string.format(fmt, unpack(inspected)) + end) + end + end +end + +log.new(default_config, true) +-- }}} diff --git a/lua/plugin_name.lua b/lua/plugin_name.lua deleted file mode 100644 index f1eb022..0000000 --- a/lua/plugin_name.lua +++ /dev/null @@ -1,27 +0,0 @@ --- main module file -local module = require('plugin_name.module') - ----@class Config ----@field opt string Your config option -local config = { - opt = 'Hello!', -} - ----@class MyModule -local M = {} - ----@type Config -M.config = config - ----@param args Config? --- you can define your setup function here. Usually configurations can be merged, accepting outside params and --- you can also put some validation here for those. -M.setup = function(args) - M.config = vim.tbl_deep_extend('force', M.config, args or {}) -end - -M.hello = function() - print(module.my_first_function()) -end - -return M diff --git a/lua/plugin_name/module.lua b/lua/plugin_name/module.lua deleted file mode 100644 index 5665f79..0000000 --- a/lua/plugin_name/module.lua +++ /dev/null @@ -1,9 +0,0 @@ ----@class CustomModule -local M = {} - ----@return string -M.my_first_function = function() - return 'hello world!' -end - -return M diff --git a/plugin/java.lua b/plugin/java.lua new file mode 100644 index 0000000..11f117b --- /dev/null +++ b/plugin/java.lua @@ -0,0 +1,5 @@ +-- vim.api.nvim_create_user_command( +-- 'MyFirstFunction', +-- require('plugin_name').hello, +-- {} +-- ) diff --git a/plugin/plugin_name.lua b/plugin/plugin_name.lua deleted file mode 100644 index 9f8c5b3..0000000 --- a/plugin/plugin_name.lua +++ /dev/null @@ -1,5 +0,0 @@ -vim.api.nvim_create_user_command( - 'MyFirstFunction', - require('plugin_name').hello, - {} -) diff --git a/tests/plugin_name/java_spec.lua b/tests/plugin_name/java_spec.lua new file mode 100644 index 0000000..b066b85 --- /dev/null +++ b/tests/plugin_name/java_spec.lua @@ -0,0 +1,7 @@ +local plugin = require('java') + +describe('setup', function() + it('setup function', function() + assert('setup function is available', plugin.setup) + end) +end) diff --git a/tests/plugin_name/plugin_name_spec.lua b/tests/plugin_name/plugin_name_spec.lua deleted file mode 100644 index c643145..0000000 --- a/tests/plugin_name/plugin_name_spec.lua +++ /dev/null @@ -1,12 +0,0 @@ -local plugin = require('plugin_name') - -describe('setup', function() - it('works with default', function() - assert('my first function with param = Hello!', plugin.hello()) - end) - - it('works with custom var', function() - plugin.setup({ opt = 'custom' }) - assert('my first function with param = custom', plugin.hello()) - end) -end) diff --git a/tests/prepare-config.lua b/tests/prepare-config.lua index 50c1503..f793c07 100644 --- a/tests/prepare-config.lua +++ b/tests/prepare-config.lua @@ -14,12 +14,27 @@ end vim.opt.rtp:prepend(lazypath) local temp_path = './.test_plugins' +local java_core_path = vim.fn.expand('~/Workspace/nvim-java-core') require('lazy').setup({ { 'nvim-lua/plenary.nvim', lazy = false, }, + { + 'nvim-java/nvim-java-core', + ---@diagnostic disable-next-line: assign-type-mismatch + dir = vim.fn.isdirectory(java_core_path) == 1 and java_core_path or nil, + lazy = false, + }, + { + 'neovim/nvim-lspconfig', + lazy = false, + }, + { + 'williamboman/mason.nvim', + lazy = false, + }, }, { root = temp_path, lockfile = temp_path .. '/lazy-lock.json', diff --git a/tests/test-config.lua b/tests/test-config.lua index aaf76f2..cedc2cb 100644 --- a/tests/test-config.lua +++ b/tests/test-config.lua @@ -1,5 +1,10 @@ -local temp_path = './.test_plugins' +local java_core_path = vim.fn.expand('~/Workspace/nvim-java-core') +local plug_path = './.test_plugins' -vim.opt.rtp:append(temp_path .. '/plenary.nvim') --- vim.opt.rtp:append(temp_path .. '/nvim-lspconfig') --- vim.opt.rtp:append(temp_path .. '/mason.nvim') +java_core_path = (vim.fn.isdirectory(java_core_path) == 1) and java_core_path + or (plug_path .. '/nvim-java-core') + +vim.opt.rtp:append(plug_path .. '/plenary.nvim') +vim.opt.rtp:append(plug_path .. '/nvim-lspconfig') +vim.opt.rtp:append(plug_path .. '/mason.nvim') +vim.opt.rtp:append(java_core_path)