mirror of
https://github.com/pojokcodeid/nvim-lazy.git
synced 2025-06-24 09:48:51 +02:00
rollback error jdtls
This commit is contained in:
parent
0adcd0f0aa
commit
530d54d5a6
7 changed files with 223 additions and 75 deletions
|
@ -1,5 +1,5 @@
|
|||
local M = {}
|
||||
if pcode.nvim_dap then
|
||||
if vim.fn.has("win32") == 0 and pcode.nvim_dap then
|
||||
M = {
|
||||
{
|
||||
"rcarriga/nvim-dap-ui",
|
||||
|
@ -15,7 +15,7 @@ if pcode.nvim_dap then
|
|||
},
|
||||
},
|
||||
},
|
||||
-- enabled = vim.fn.has("win32") == 0,
|
||||
enabled = vim.fn.has("win32") == 0,
|
||||
config = function()
|
||||
require("user.dapui")
|
||||
end,
|
||||
|
@ -42,7 +42,7 @@ if pcode.nvim_dap then
|
|||
lazy = true,
|
||||
event = "BufRead",
|
||||
dependencies = { "williamboman/mason.nvim", "mfussenegger/nvim-dap" },
|
||||
-- enabled = vim.fn.has("win32") == 0,
|
||||
enabled = vim.fn.has("win32") == 0,
|
||||
config = function()
|
||||
require("user.mason_dap")
|
||||
end,
|
||||
|
|
|
@ -4,29 +4,6 @@ if pcode.active_java_config.active then
|
|||
-- {
|
||||
-- "mfussenegger/nvim-jdtls",
|
||||
-- },
|
||||
-- {
|
||||
-- "nvim-treesitter/nvim-treesitter",
|
||||
-- opts = function(_, opts)
|
||||
-- opts.ensure_installed = opts.ensure_installed or {}
|
||||
-- vim.list_extend(opts.ensure_installed, { "java" })
|
||||
-- end,
|
||||
-- },
|
||||
-- {
|
||||
-- "williamboman/mason-lspconfig.nvim",
|
||||
-- opts = function(_, opts)
|
||||
-- opts.ensure_installed = opts.ensure_installed or {}
|
||||
-- vim.list_extend(opts.ensure_installed, { "jdtls" })
|
||||
-- end,
|
||||
-- },
|
||||
-- {
|
||||
-- "stevearc/conform.nvim",
|
||||
-- event = "VeryLazy",
|
||||
-- opts = function(_, opts)
|
||||
-- local package="google-java-format"
|
||||
-- require("user.utils.mason").try_install(package)
|
||||
-- opts.formatters_by_ft.java = { package }
|
||||
-- end,
|
||||
-- },
|
||||
{
|
||||
"nvim-neotest/neotest",
|
||||
dependencies = {
|
||||
|
|
136
lua/plugins/lsp.lua
Normal file
136
lua/plugins/lsp.lua
Normal file
|
@ -0,0 +1,136 @@
|
|||
return {
|
||||
{
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
dependencies = {
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
lazy = true,
|
||||
event = "BufRead",
|
||||
cmd = {
|
||||
"LspInfo",
|
||||
"LspInstall",
|
||||
"LspUninstall",
|
||||
},
|
||||
config = function()
|
||||
require("lspconfig.ui.windows").default_options.border = "rounded"
|
||||
end,
|
||||
},
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
lazy = true,
|
||||
cmd = {
|
||||
"Mason",
|
||||
"MasonInstall",
|
||||
"MasonUninstall",
|
||||
"MasonUninstallAll",
|
||||
"MasonLog",
|
||||
},
|
||||
opts = function()
|
||||
local icons = vim.g.pcode_icons.ui
|
||||
return {
|
||||
ui = {
|
||||
-- border = "none",
|
||||
border = icons.Border,
|
||||
icons = {
|
||||
package_pending = icons.DotCircle,
|
||||
package_installed = icons.CheckCircle,
|
||||
package_uninstalled = icons.BlankCircle,
|
||||
},
|
||||
keymaps = {
|
||||
-- Keymap to expand a server in the UI
|
||||
toggle_server_expand = "<CR>",
|
||||
-- Keymap to install the server under the current cursor position
|
||||
install_server = "i",
|
||||
-- Keymap to reinstall/update the server under the current cursor position
|
||||
update_server = "u",
|
||||
-- Keymap to check for new version for the server under the current cursor position
|
||||
check_server_version = "c",
|
||||
-- Keymap to update all installed servers
|
||||
update_all_servers = "U",
|
||||
-- Keymap to check which installed servers are outdated
|
||||
check_outdated_servers = "C",
|
||||
-- Keymap to uninstall a server
|
||||
uninstall_server = "X",
|
||||
},
|
||||
},
|
||||
log_level = vim.log.levels.INFO,
|
||||
max_concurrent_installers = 4,
|
||||
}
|
||||
end,
|
||||
config = function(_, opts)
|
||||
require("mason").setup(opts)
|
||||
end,
|
||||
},
|
||||
},
|
||||
event = "BufReadPre",
|
||||
opts = function()
|
||||
local servers = { "lua_ls" }
|
||||
local mason_install = pcode.mason_ensure_installed or {}
|
||||
vim.list_extend(servers, mason_install)
|
||||
return {
|
||||
ensure_installed = servers,
|
||||
automatic_installation = true,
|
||||
}
|
||||
end,
|
||||
config = function(_, opts)
|
||||
require("mason-lspconfig").setup(opts)
|
||||
|
||||
local option = {}
|
||||
local unregis_lsp = pcode.unregister_lsp or {}
|
||||
require("mason-lspconfig").setup_handlers({
|
||||
function(server_name) -- default handler (optional)
|
||||
local capabilities = require("user.lsp.handlers").capabilities
|
||||
if server_name == "clangd" then
|
||||
capabilities.offsetEncoding = { "utf-16" }
|
||||
end
|
||||
local is_skip = false
|
||||
local my_index = idxOf(unregis_lsp, server_name)
|
||||
if my_index ~= nil then
|
||||
is_skip = true
|
||||
end
|
||||
if not is_skip then
|
||||
option = {
|
||||
on_attach = require("user.lsp.handlers").on_attach,
|
||||
capabilities = capabilities,
|
||||
}
|
||||
|
||||
server_name = vim.split(server_name, "@")[1]
|
||||
|
||||
local require_ok, conf_opts = pcall(require, "user.lsp.settings." .. server_name)
|
||||
if require_ok then
|
||||
option = vim.tbl_deep_extend("force", conf_opts, option)
|
||||
end
|
||||
require("lspconfig")[server_name].setup(option)
|
||||
end
|
||||
end,
|
||||
["jdtls"] = function()
|
||||
require("lspconfig").jdtls.setup({
|
||||
on_attach = require("user.lsp.handlers").on_attach,
|
||||
capabilities = require("user.lsp.handlers").capabilities,
|
||||
cmd = {
|
||||
"jdtls",
|
||||
"-configuration",
|
||||
vim.fn.expand("$HOME") .. "/.cache/jdtls/config",
|
||||
"-data",
|
||||
vim.fn.expand("$HOME") .. "/.cache/jdtls/workspace",
|
||||
},
|
||||
filetypes = { "java" },
|
||||
root_dir = require("lspconfig.util").root_pattern(
|
||||
-- Single-module projects
|
||||
{
|
||||
"build.xml", -- Ant
|
||||
"pom.xml", -- Maven
|
||||
"settings.gradle", -- Gradle
|
||||
"settings.gradle.kts", -- Gradle
|
||||
},
|
||||
-- Multi-module projects
|
||||
{ "build.gradle", "build.gradle.kts" }
|
||||
) or vim.fn.getcwd(),
|
||||
singe_file_support = true,
|
||||
})
|
||||
end,
|
||||
})
|
||||
require("user.lsp.handlers").setup()
|
||||
end,
|
||||
},
|
||||
}
|
|
@ -2,11 +2,9 @@ return {
|
|||
{
|
||||
"nvimtools/none-ls.nvim",
|
||||
lazy = true,
|
||||
enabled = not (pcode.disable_null_ls or false),
|
||||
dependencies = {
|
||||
{
|
||||
"jayp0521/mason-null-ls.nvim",
|
||||
event = "VeryLazy",
|
||||
opts = {
|
||||
ensure_installed = pcode.null_ls_ensure_installed or {},
|
||||
automatic_setup = true,
|
||||
|
@ -19,7 +17,65 @@ return {
|
|||
"nvimtools/none-ls-extras.nvim",
|
||||
},
|
||||
event = "InsertEnter",
|
||||
opts = {},
|
||||
config = true,
|
||||
opts = function()
|
||||
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||
local sources = {}
|
||||
local data_ok, data_sources = pcall(require, "custom.null-ls")
|
||||
if data_ok then
|
||||
for _, cfg in pairs(data_sources.sources) do
|
||||
table.insert(sources, cfg)
|
||||
end
|
||||
end
|
||||
local on_save = pcode.format_on_save or 0
|
||||
if on_save == 1 then
|
||||
return {
|
||||
debug = false,
|
||||
sources = sources,
|
||||
on_attach = function(client, bufnr)
|
||||
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||
local filetype = vim.bo.filetype
|
||||
local n = require("null-ls")
|
||||
local s = require("null-ls.sources")
|
||||
local method = n.methods.FORMATTING
|
||||
local available_formatters = s.get_available(filetype, method)
|
||||
|
||||
if
|
||||
(#available_formatters > 0 and client.name == "null-ls")
|
||||
or client.supports_method("textDocument/formatting")
|
||||
then
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
vim.lsp.buf.format({ bufnr = bufnr, timeout_ms = pcode.format_timeout_ms or 5000 })
|
||||
end,
|
||||
})
|
||||
else
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
vim.lsp.buf.format({ bufnr = bufnr, timeout_ms = pcode.format_timeout_ms or 5000, filter = nil })
|
||||
end,
|
||||
})
|
||||
end
|
||||
end,
|
||||
}
|
||||
else
|
||||
vim.schedule(function()
|
||||
pcall(function()
|
||||
vim.api.nvim_clear_autocmds({ group = "LspFormatting" })
|
||||
end)
|
||||
end)
|
||||
|
||||
return {
|
||||
debug = false,
|
||||
sources = sources,
|
||||
}
|
||||
end
|
||||
end,
|
||||
config = function(_, opts)
|
||||
require("null-ls").setup(opts)
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -37,20 +37,6 @@ _G.idxOf = function(array, value)
|
|||
return nil
|
||||
end
|
||||
|
||||
_G.unique_list = function(list)
|
||||
local seen = {}
|
||||
local result = {}
|
||||
|
||||
for _, val in ipairs(list) do
|
||||
if not seen[val] then
|
||||
table.insert(result, val)
|
||||
seen[val] = true
|
||||
end
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
-- run if rust config true
|
||||
if pcode.active_rust_config then
|
||||
table.insert(pcode.mason_ensure_installed, "rust_analyzer")
|
||||
|
@ -76,7 +62,7 @@ if pcode.active_php_config then
|
|||
end
|
||||
table.insert(pcode.mason_ensure_installed, "intelephense")
|
||||
table.insert(pcode.mason_ensure_installed, "stimulus_ls")
|
||||
table.insert(pcode.null_ls_ensure_installed, "php-cs-fixer")
|
||||
table.insert(pcode.null_ls_ensure_installed, "phpcbf")
|
||||
table.insert(pcode.null_ls_ensure_installed, "blade_formatter")
|
||||
table.insert(pcode.null_ls_ensure_installed, "phpcs")
|
||||
end
|
||||
|
@ -110,11 +96,11 @@ if pcode.active_cpp_config then
|
|||
pcode.nvim_dap = true
|
||||
end
|
||||
-- run if java config true
|
||||
-- if pcode.active_java_config.active then
|
||||
-- table.insert(pcode.treesitter_ensure_installed, "java")
|
||||
-- table.insert(pcode.mason_ensure_installed, "jdtls")
|
||||
-- table.insert(pcode.null_ls_ensure_installed, "google_java_format")
|
||||
-- table.insert(pcode.dap_ensure_installed, "javadbg")
|
||||
-- table.insert(pcode.unregister_lsp, "jdtls")
|
||||
-- end
|
||||
if pcode.active_java_config.active then
|
||||
table.insert(pcode.treesitter_ensure_installed, "java")
|
||||
table.insert(pcode.mason_ensure_installed, "jdtls")
|
||||
table.insert(pcode.null_ls_ensure_installed, "google_java_format")
|
||||
-- table.insert(pcode.dap_ensure_installed, "javadbg")
|
||||
-- table.insert(pcode.unregister_lsp, "jdtls")
|
||||
end
|
||||
return {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue