Compare commits
8 changed files with 125 additions and 107 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -18,6 +18,3 @@ mimeapps.list
|
||||||
|
|
||||||
# htmlhint config, not a part of nvim config
|
# htmlhint config, not a part of nvim config
|
||||||
.htmlhintrc
|
.htmlhintrc
|
||||||
|
|
||||||
# jar for java testing
|
|
||||||
*.jar
|
|
||||||
|
|
|
||||||
116
nvim/ftplugin/java.lua
Normal file
116
nvim/ftplugin/java.lua
Normal file
|
|
@ -0,0 +1,116 @@
|
||||||
|
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)
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
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" },
|
{ "clangd", "clangd" },
|
||||||
{ "lua_ls", "lua_ls" },
|
{ "lua_ls", "lua_ls" },
|
||||||
{ "tinymist", "tinymist" },
|
{ "tinymist", "tinymist" },
|
||||||
{ nil, "jdtls" },
|
{ "jdtls", nil },
|
||||||
{ "html", nil },
|
{ "html", nil },
|
||||||
{ "dockerls", nil },
|
{ "dockerls", nil },
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ return {
|
||||||
"neovim/nvim-lspconfig",
|
"neovim/nvim-lspconfig",
|
||||||
-- lsp completions
|
-- lsp completions
|
||||||
"hrsh7th/cmp-nvim-lsp",
|
"hrsh7th/cmp-nvim-lsp",
|
||||||
'nvim-java/nvim-java',
|
|
||||||
},
|
},
|
||||||
lazy = false,
|
lazy = false,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,56 +0,0 @@
|
||||||
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,7 +2,6 @@
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"nvim-treesitter/nvim-treesitter",
|
"nvim-treesitter/nvim-treesitter",
|
||||||
branch = "master",
|
|
||||||
build = ':TSUpdate',
|
build = ':TSUpdate',
|
||||||
lazy = false,
|
lazy = false,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
function M.setup()
|
function M.setup()
|
||||||
local is_ok, tree_sitter_config = pcall(require, "nvim-treesitter.configs")
|
local is_ok, tree_sitter_configs = pcall(require, "nvim-treesitter.config")
|
||||||
if not is_ok then
|
if not is_ok then
|
||||||
vim.notify("couldn't find tree sitter")
|
vim.notify("couldn't find tree sitter")
|
||||||
return
|
return
|
||||||
|
|
@ -15,10 +15,14 @@ function M.setup()
|
||||||
{ "dockerfile", nil },
|
{ "dockerfile", nil },
|
||||||
"fish",
|
"fish",
|
||||||
{ "gitignore", "gitignore" },
|
{ "gitignore", "gitignore" },
|
||||||
|
-- { "diff", nil },
|
||||||
|
-- { "git_rebase", nil },
|
||||||
|
-- { "gitcommit", "git/COMMIT_EDITMSG" },
|
||||||
{ "haskell", "hs" },
|
{ "haskell", "hs" },
|
||||||
"html",
|
"html",
|
||||||
{ "javascript", "js" },
|
{ "javascript", "js" },
|
||||||
{ "typescript", "ts" },
|
{ "typescript", "ts" },
|
||||||
|
"jsx",
|
||||||
"tsx",
|
"tsx",
|
||||||
"json",
|
"json",
|
||||||
"lua",
|
"lua",
|
||||||
|
|
@ -30,9 +34,10 @@ function M.setup()
|
||||||
{ "rust", "rs" },
|
{ "rust", "rs" },
|
||||||
"sql",
|
"sql",
|
||||||
"toml",
|
"toml",
|
||||||
{ "vim", nil },
|
"vim",
|
||||||
{ "vimdoc", nil },
|
{ "vimdoc", nil },
|
||||||
"xml",
|
"xml",
|
||||||
|
{ "ant", nil },
|
||||||
"nu",
|
"nu",
|
||||||
"java",
|
"java",
|
||||||
"yaml",
|
"yaml",
|
||||||
|
|
@ -72,7 +77,7 @@ function M.setup()
|
||||||
enable = true, -- false will disable the whole extension
|
enable = true, -- false will disable the whole extension
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
tree_sitter_config.setup(opts)
|
tree_sitter_configs.setup(opts)
|
||||||
|
|
||||||
vim.cmd.TSUpdate()
|
vim.cmd.TSUpdate()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue