Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lua/java-core/jdtls-types.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local M = {}
---@class InitializationOptions
---@field bundles? string
---@field bundles? string[]
---@field workspaceFolders? string
---@field settings? JavaConfigurationSettings

Expand Down
18 changes: 15 additions & 3 deletions lua/java-core/ls/clients/jdtls-client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ local Promise = require('java-core.utils.promise')
---@field client LSPClient
local M = {}

function M:new(o)
o = o or {}
---@param args { client: LSPClient }
---@return JavaCoreJdtlsClient
function M:new(args)
local o = {
client = (args or {}).client,
}

setmetatable(o, self)
self.__index = self
return o
Expand All @@ -16,7 +21,7 @@ end
---@param command string
---@param arguments? string | string[]
---@param buffer? integer
---@return Promise
---@return Promise # Promise<any>
function M:execute_command(command, arguments, buffer)
return Promise.new(function(resolve, reject)
local cmd_info = {
Expand All @@ -36,6 +41,13 @@ function M:execute_command(command, arguments, buffer)
end)
end

---Returns the decompiled class file content
---@param uri string uri of the class file
---@return Promise # Promise<string> - decompiled file content
function M:java_decompile(uri)
return self:execute_command('java.decompile', { uri })
end

function M:get_capability(...)
local capability = self.client.server_capabilities

Expand Down
2 changes: 1 addition & 1 deletion lua/java-core/lspconfig-types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
---@field capabilities table<string, string|table|boolean|function> a table which represents the neovim client capabilities. Useful for broadcasting to the server additional functionality (snippets, off-protocol features) provided by plugins.
---@field cmd string[] a list where each entry corresponds to the blankspace delimited part of the command that launches the server. The first entry is the binary used to run the language server. Additional entries are passed as arguments.
---@field handlers table<string, function> a list of handlers which override the function used to process a response from a given language server. Applied only to the server referenced by setup. See |lsp-handler|.
---@field init_options table<string, string|table|boolean> a table passed during the initialization notification after launching a language server. Equivalent to the `initializationOptions` field found in `InitializeParams` in the LSP specification.
---@field init_options { bundles?: string[], workspaceFolders?: string, settings?: JavaConfigurationSettings, extendedClientCapabilities: table<string, string|boolean|table> }
---@field on_attach fun(client: object, bufnr: number) Callback invoked by Nvim's built-in client when attaching a buffer to a language server. Often used to set Nvim (buffer or global) options or to override the Nvim client properties (`server_capabilities`) after a language server attaches. Most commonly used for settings buffer local keybindings. See |lspconfig-keybindings| for a usage example.
---@field settings table <string, string|table|boolean> The `settings` table is sent in `on_init` via a `workspace/didChangeConfiguration` notification from the Nvim client to the language server. These settings allow a user to change optional runtime settings of the language server.

Expand Down
26 changes: 22 additions & 4 deletions lua/java-core/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ M.plugins = {
{ name = 'java-debug-adapter', path = '/*.jar' },
}

---Returns a configuration for jdtls that you can pass into the setup of nvim-lspconfig
--
---@class JavaGetConfigOptions
---@field root_markers string[] list of files to find the root dir of a project
---Ex:- { 'pom.xml', 'build.gradle', '.git' }
---
--

---Returns a configuration for jdtls that you can pass into the setup of nvim-lspconfig
---@param opts JavaGetConfigOptions
---@return LSPSetupConfig # jdtls setup configuration
function M.get_config(opts)
log.info('generating jdtls config')

Expand Down Expand Up @@ -65,9 +64,28 @@ function M.get_config(opts)
init_options = {
bundles = plugins,
workspace = workspace.get_default_workspace(),
extendedClientCapabilities = {
classFileContentsSupport = true,
generateToStringPromptSupport = true,
hashCodeEqualsPromptSupport = true,
advancedExtractRefactoringSupport = true,
advancedOrganizeImportsSupport = true,
generateConstructorsPromptSupport = true,
generateDelegateMethodsPromptSupport = true,
moveRefactoringSupport = true,
overrideMethodsPromptSupport = true,
executeClientCommandSupport = true,
inferSelectionSupport = {
'extractMethod',
'extractVariable',
'extractConstant',
'extractVariableAllOccurrence',
},
},
},

root_dir = M.get_root_finder(opts.root_markers),
capabilities = vim.lsp.protocol.make_client_capabilities(),
}

log.debug('generated config: ', conf)
Expand Down
2 changes: 1 addition & 1 deletion lua/java-core/utils/log.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ local default_config = {
plugin = 'nvim-java-core',

-- Should print the output to neovim while running
use_console = true,
use_console = false,

-- Should highlighting be used in console (using echohl)
highlights = true,
Expand Down