Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 46b650dd73 | |||
| 5567e71240 |
8 changed files with 107 additions and 125 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -18,3 +18,6 @@ mimeapps.list
|
|||
|
||||
# htmlhint config, not a part of nvim config
|
||||
.htmlhintrc
|
||||
|
||||
# jar for java testing
|
||||
*.jar
|
||||
|
|
|
|||
|
|
@ -1,116 +0,0 @@
|
|||
local home = os.getenv('HOME')
|
||||
|
||||
local jdtls_dir = os.getenv("JDTLS_PATH")
|
||||
|
||||
local root_dir = require('jdtls.setup').find_root({ 'gradlew', '.git', 'mvnw' })
|
||||
local workspace_folder = home .. "/.local/share/jdtls/" .. vim.fn.fnamemodify(root_dir, ":p:h:t")
|
||||
|
||||
local config_dir = vim.api.nvim_exec2(":echo stdpath('config')", { output = true }).output
|
||||
|
||||
local config = {
|
||||
name = "jdtls",
|
||||
-- `cmd` defines the executable to launch eclipse.jdt.ls.
|
||||
-- `jdtls` must be available in $PATH and you must have Python3.9 for this to work.
|
||||
--
|
||||
-- As alternative you could also avoid the `jdtls` wrapper and launch
|
||||
-- eclipse.jdt.ls via the `java` executable
|
||||
-- See: https://github.com/eclipse/eclipse.jdt.ls#running-from-the-command-line
|
||||
cmd = {
|
||||
jdtls_dir .. '/bin/jdtls',
|
||||
'-Declipse.application=org.eclipse.jdt.ls.core.id1',
|
||||
'-Dosgi.bundles.defaultStartLevel=4',
|
||||
'-Declipse.product=org.eclipse.jdt.ls.core.product',
|
||||
'-Dlog.protocol=true',
|
||||
'-Dlog.level=ALL',
|
||||
'-Xmx1g',
|
||||
'--add-modules=ALL-SYSTEM',
|
||||
'--add-opens', 'java.base/java.util=ALL-UNNAMED',
|
||||
'--add-opens', 'java.base/java.lang=ALL-UNNAMED',
|
||||
|
||||
-- The jar file is located where jdtls was installed. This will need to be updated
|
||||
-- to the location where you installed jdtls
|
||||
'-jar', vim.fn.glob('/opt/homebrew/Cellar/jdtls/1.18.0/libexec/plugins/org.eclipse.equinox.launcher_*.jar'),
|
||||
|
||||
-- The configuration for jdtls is also placed where jdtls was installed. This will
|
||||
-- need to be updated depending on your environment
|
||||
'-configuration', jdtls_dir .. 'config_linux',
|
||||
|
||||
-- Use the workspace_folder defined above to store data for this project
|
||||
'-data', workspace_folder,
|
||||
},
|
||||
-- `root_dir` must point to the root of your project.
|
||||
-- See `:help vim.fs.root`
|
||||
root_dir = root_dir,
|
||||
-- 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
|
||||
-- for a list of options
|
||||
settings = {
|
||||
java = {
|
||||
format = {
|
||||
settings = {
|
||||
-- Use Google Java style guidelines for formatting
|
||||
-- To use, make sure to download the file from https://github.com/google/styleguide/blob/gh-pages/eclipse-java-google-style.xml
|
||||
-- and place it in the ~/.local/share/eclipse directory
|
||||
url = config_dir .. '/other/eclipse-java-google-style.xml',
|
||||
profile = "GoogleStyle",
|
||||
},
|
||||
},
|
||||
signatureHelp = { enabled = true },
|
||||
contentProvider = { preferred = 'fernflower' }, -- Use fernflower to decompile library code
|
||||
-- Specify any completion options
|
||||
completion = {
|
||||
favoriteStaticMembers = {
|
||||
-- ?
|
||||
"org.junit.jupiter.api.Assertions.*",
|
||||
"java.util.Objects.requireNonNull",
|
||||
"java.util.Objects.requireNonNullElse",
|
||||
},
|
||||
filteredTypes = {
|
||||
"com.sun.*",
|
||||
"io.micrometer.shaded.*",
|
||||
"java.awt.*",
|
||||
"jdk.*", "sun.*",
|
||||
},
|
||||
},
|
||||
sources = {
|
||||
organizeImports = {
|
||||
starThreshold = 9999,
|
||||
staticStarThreshold = 9999,
|
||||
},
|
||||
},
|
||||
codeGeneration = {
|
||||
toString = {
|
||||
template = "${object.className}{${member.name()}=${member.value}, ${otherMembers}}"
|
||||
},
|
||||
hashCodeEquals = {
|
||||
useJava7Objects = true,
|
||||
},
|
||||
useBlocks = true,
|
||||
},
|
||||
configuration = {
|
||||
-- See https://github.com/eclipse/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request
|
||||
-- And search for `interface RuntimeOption`
|
||||
-- The `name` is NOT arbitrary, but must match one of the elements from `enum ExecutionEnvironment` in the link above
|
||||
runtimes = {
|
||||
{
|
||||
name = "JavaSE_21",
|
||||
path = "/usr/lib/jvm/java-21-openjdk",
|
||||
default = true,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
-- This sets the `initializationOptions` sent to the language server
|
||||
-- If you plan on using additional eclipse.jdt.ls plugins like java-debug
|
||||
-- you'll need to set the `bundles`
|
||||
--
|
||||
-- See https://codeberg.org/mfussenegger/nvim-jdtls#java-debug-installation
|
||||
--
|
||||
-- If you don't plan on any eclipse.jdt.ls plugins you can remove this
|
||||
init_options = {
|
||||
bundles = {}
|
||||
},
|
||||
}
|
||||
|
||||
require('jdtls').start_or_attach(config)
|
||||
42
nvim/lua/dzu/lsp/jdtls.lua
Normal file
42
nvim/lua/dzu/lsp/jdtls.lua
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
return {
|
||||
settings = {
|
||||
java = {
|
||||
configuration = {
|
||||
runtimes = {
|
||||
{
|
||||
name = "openjdk 21.0.9",
|
||||
path = "/usr/lib/jvm/java-21-openjdk/",
|
||||
default = true,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
capabilities = {
|
||||
textDocument = {
|
||||
completion = {
|
||||
completionItem = {
|
||||
commitCharactersSupport = false,
|
||||
deprecatedSupport = true,
|
||||
insertReplaceSupport = false,
|
||||
insertTextModeSupport = {},
|
||||
labelDetailsSupport = true,
|
||||
preselectSupport = true,
|
||||
resolveSupport = {
|
||||
properties = { "documentation", "additionalTextEdits", "insertTextFormat", "insertTextMode", "command" }
|
||||
},
|
||||
snippetSupport = true,
|
||||
tagSupport = {}
|
||||
},
|
||||
completionList = {
|
||||
itemDefaults = { "commitCharacters", "editRange", "insertTextFormat", "insertTextMode", "data" }
|
||||
},
|
||||
contextSupport = true,
|
||||
dynamicRegistration = false,
|
||||
insertTextMode = 1
|
||||
}
|
||||
}
|
||||
},
|
||||
init_options = {},
|
||||
root_markers = { ".classpath" },
|
||||
}
|
||||
|
|
@ -20,7 +20,7 @@ local servers = {
|
|||
{ "clangd", "clangd" },
|
||||
{ "lua_ls", "lua_ls" },
|
||||
{ "tinymist", "tinymist" },
|
||||
{ "jdtls", nil },
|
||||
{ nil, "jdtls" },
|
||||
{ "html", nil },
|
||||
{ "dockerls", nil },
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ return {
|
|||
"neovim/nvim-lspconfig",
|
||||
-- lsp completions
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
'nvim-java/nvim-java',
|
||||
},
|
||||
lazy = false,
|
||||
}
|
||||
|
|
|
|||
56
nvim/lua/dzu/plugins/nvim-java.lua
Normal file
56
nvim/lua/dzu/plugins/nvim-java.lua
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
return {
|
||||
'nvim-java/nvim-java',
|
||||
config = function()
|
||||
require('java').setup({
|
||||
-- Startup checks
|
||||
checks = {
|
||||
nvim_version = true, -- Check Neovim version
|
||||
nvim_jdtls_conflict = true, -- Check for nvim-jdtls conflict
|
||||
},
|
||||
|
||||
-- JDTLS configuration
|
||||
jdtls = {
|
||||
version = '1.54.0',
|
||||
},
|
||||
|
||||
-- Extensions
|
||||
lombok = {
|
||||
enable = false,
|
||||
version = '1.18.40',
|
||||
},
|
||||
|
||||
java_test = {
|
||||
enable = false,
|
||||
version = '0.40.1',
|
||||
},
|
||||
|
||||
java_debug_adapter = {
|
||||
enable = false,
|
||||
version = '0.58.2',
|
||||
},
|
||||
|
||||
spring_boot_tools = {
|
||||
enable = false,
|
||||
version = '1.55.1',
|
||||
},
|
||||
|
||||
-- JDK installation
|
||||
jdk = {
|
||||
auto_install = false,
|
||||
version = '17',
|
||||
},
|
||||
|
||||
-- Logging
|
||||
log = {
|
||||
use_console = false,
|
||||
use_file = true,
|
||||
level = 'info',
|
||||
log_file = vim.fn.stdpath('state') .. '/nvim-java.log',
|
||||
max_lines = 1000,
|
||||
show_location = false,
|
||||
},
|
||||
})
|
||||
-- vim.lsp.enable('jdtls')
|
||||
end,
|
||||
lazy = false,
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
return {
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
branch = "master",
|
||||
build = ':TSUpdate',
|
||||
lazy = false,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
local M = {}
|
||||
|
||||
function M.setup()
|
||||
local is_ok, tree_sitter_configs = pcall(require, "nvim-treesitter.config")
|
||||
local is_ok, tree_sitter_config = pcall(require, "nvim-treesitter.configs")
|
||||
if not is_ok then
|
||||
vim.notify("couldn't find tree sitter")
|
||||
return
|
||||
|
|
@ -15,14 +15,10 @@ function M.setup()
|
|||
{ "dockerfile", nil },
|
||||
"fish",
|
||||
{ "gitignore", "gitignore" },
|
||||
-- { "diff", nil },
|
||||
-- { "git_rebase", nil },
|
||||
-- { "gitcommit", "git/COMMIT_EDITMSG" },
|
||||
{ "haskell", "hs" },
|
||||
"html",
|
||||
{ "javascript", "js" },
|
||||
{ "typescript", "ts" },
|
||||
"jsx",
|
||||
"tsx",
|
||||
"json",
|
||||
"lua",
|
||||
|
|
@ -34,10 +30,9 @@ function M.setup()
|
|||
{ "rust", "rs" },
|
||||
"sql",
|
||||
"toml",
|
||||
"vim",
|
||||
{ "vim", nil },
|
||||
{ "vimdoc", nil },
|
||||
"xml",
|
||||
{ "ant", nil },
|
||||
"nu",
|
||||
"java",
|
||||
"yaml",
|
||||
|
|
@ -77,7 +72,7 @@ function M.setup()
|
|||
enable = true, -- false will disable the whole extension
|
||||
},
|
||||
}
|
||||
tree_sitter_configs.setup(opts)
|
||||
tree_sitter_config.setup(opts)
|
||||
|
||||
vim.cmd.TSUpdate()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue