mirror of
https://github.com/mfussenegger/nvim-jdtls
synced 2024-09-08 02:35:49 +02:00
Fix nvim-0.11 deprecation warnings
This commit is contained in:
parent
8995b4056c
commit
29255ea26d
4 changed files with 27 additions and 8 deletions
|
@ -138,7 +138,10 @@ local config = {
|
|||
-- 💀
|
||||
-- This is the default if not provided, you can remove it. Or adjust as needed.
|
||||
-- One dedicated LSP server & client will be started per unique root_dir
|
||||
root_dir = require('jdtls.setup').find_root({'.git', 'mvnw', 'gradlew'}),
|
||||
--
|
||||
-- vim.fs.root requires Neovim 0.10.
|
||||
-- If you're using an earlier version, use: require('jdtls.setup').find_root({'.git', 'mvnw', 'gradlew'}),
|
||||
root_dir = vim.fs.root(0, {".git", "mvnw", "gradlew"})
|
||||
|
||||
-- Here you can configure eclipse.jdt.ls specific settings
|
||||
-- See https://github.com/eclipse/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request
|
||||
|
|
|
@ -35,7 +35,7 @@ local M = {
|
|||
---
|
||||
---@param config table<string, any> configuration. See |vim.lsp.start_client|
|
||||
---@param opts? jdtls.start.opts
|
||||
---@param start_opts? lsp.StartOpts options passed to vim.lsp.start
|
||||
---@param start_opts? vim.lsp.start.Opts options passed to vim.lsp.start
|
||||
---@return integer|nil client_id
|
||||
function M.start_or_attach(config, opts, start_opts)
|
||||
return setup.start_or_attach(config, opts, start_opts)
|
||||
|
@ -877,7 +877,6 @@ local function on_build_result(err, result, ctx)
|
|||
vim.fn.setqflist({}, 'r', { title = 'jdtls'; items = {} })
|
||||
print('Compile successful')
|
||||
else
|
||||
vim.tbl_add_reverse_lookup(CompileWorkspaceStatus)
|
||||
local project_config_errors = {}
|
||||
local compile_errors = {}
|
||||
local ns = vim.lsp.diagnostic.get_namespace(ctx.client_id)
|
||||
|
@ -899,7 +898,13 @@ local function on_build_result(err, result, ctx)
|
|||
local items = #project_config_errors > 0 and project_config_errors or compile_errors
|
||||
vim.fn.setqflist({}, 'r', { title = 'jdtls'; items = vim.diagnostic.toqflist(items) })
|
||||
if #items > 0 then
|
||||
print(string.format('Compile error. (%s)', CompileWorkspaceStatus[result]))
|
||||
local reverse_status = {
|
||||
[0] = "FAILED",
|
||||
[1] = "SUCCEEDED",
|
||||
[2] = "WITHERROR",
|
||||
[3] = "CANCELLED",
|
||||
}
|
||||
print(string.format('Compile error. (%s)', reverse_status[result]))
|
||||
vim.cmd('copen')
|
||||
else
|
||||
print("Compile error, but no error diagnostics available."
|
||||
|
|
|
@ -5,6 +5,9 @@ local is_windows = vim.loop.os_uname().version:match('Windows')
|
|||
M.sep = is_windows and '\\' or '/'
|
||||
|
||||
function M.join(...)
|
||||
if vim.fs.joinpath then
|
||||
return vim.fs.joinpath(...)
|
||||
end
|
||||
local result = table.concat(vim.tbl_flatten {...}, M.sep):gsub(M.sep .. '+', M.sep)
|
||||
return result
|
||||
end
|
||||
|
|
|
@ -74,10 +74,9 @@ local function attach_to_active_buf(bufnr, client_name)
|
|||
return nil
|
||||
end
|
||||
|
||||
|
||||
function M.find_root(markers, bufname)
|
||||
bufname = bufname or api.nvim_buf_get_name(api.nvim_get_current_buf())
|
||||
local dirname = vim.fn.fnamemodify(bufname, ':p:h')
|
||||
local function find_root(source, markers)
|
||||
source = source or api.nvim_buf_get_name(api.nvim_get_current_buf())
|
||||
local dirname = vim.fn.fnamemodify(source, ':p:h')
|
||||
local getparent = function(p)
|
||||
return vim.fn.fnamemodify(p, ':h')
|
||||
end
|
||||
|
@ -92,6 +91,15 @@ function M.find_root(markers, bufname)
|
|||
end
|
||||
|
||||
|
||||
function M.find_root(markers, bufname)
|
||||
if vim.fs.root then
|
||||
return vim.fs.root(bufname or 0, markers)
|
||||
else
|
||||
return find_root(bufname, markers)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
M.extendedClientCapabilities = {
|
||||
classFileContentsSupport = true,
|
||||
generateToStringPromptSupport = true,
|
||||
|
|
Loading…
Reference in a new issue