Skip to content
Closed

Dev #2103

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
8 changes: 0 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,3 @@ test.sh
nvim

spell/

# In your personal fork, you likely want to comment this, since it's recommended to track
# nvim-pack-lock.json in version control - see :help vim.pack-lockfile
# For the official `nvim-lua/kickstart.nvim` git repository, we leave it ignored to avoid unneeded
# merge conflicts.
nvim-pack-lock.json

.DS_Store
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ it's recommended to track it in version control (see `:help vim.pack-lockfile`).
<details><summary> Linux and Mac </summary>

```sh
git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim
git clone https://github.com/GuustTaillieu/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim
```

</details>
Expand All @@ -92,13 +92,13 @@ git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HO
If you're using `cmd.exe`:

```
git clone https://github.com/nvim-lua/kickstart.nvim.git "%localappdata%\nvim"
git clone https://github.com/GuustTaillieu/kickstart.nvim.git "%localappdata%\nvim"
```

If you're using `powershell.exe`

```
git clone https://github.com/nvim-lua/kickstart.nvim.git "${env:LOCALAPPDATA}\nvim"
git clone https://github.com/GuustTaillieu/kickstart.nvim.git "${env:LOCALAPPDATA}\nvim"
```

</details>
Expand Down
157 changes: 157 additions & 0 deletions ftplugin/java.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
-- JDTLS (Java LSP) configuration
local home = vim.env.HOME -- Get the home directory

local jdtls = require 'jdtls'
local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h:t')
local workspace_dir = home .. '/jdtls-workspace/' .. project_name

local system_os = ''

-- Determine OS
if vim.fn.has 'mac' == 1 then
system_os = 'mac'
elseif vim.fn.has 'unix' == 1 then
system_os = 'linux'
elseif vim.fn.has 'win32' == 1 or vim.fn.has 'win64' == 1 then
system_os = 'win'
else
print "OS not found, defaulting to 'linux'"
system_os = 'linux'
end

-- Needed for debugging
local bundles = {
vim.fn.glob(home .. '/.local/share/nvim/mason/share/java-debug-adapter/com.microsoft.java.debug.plugin.jar'),
}

-- Needed for running/debugging unit tests
vim.list_extend(bundles, vim.split(vim.fn.glob(home .. '/.local/share/nvim/mason/share/java-test/*.jar', 1), '\n'))

-- See `:help vim.lsp.start_client` for an overview of the supported `config` options.
local config = {
-- The command that starts the language server
-- See: https://github.com/eclipse/eclipse.jdt.ls#running-from-the-command-line
cmd = {
'java',
'-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',
'-javaagent:' .. home .. '/.local/share/nvim/mason/share/jdtls/lombok.jar',
'-Xmx4g',
'--add-modules=ALL-SYSTEM',
'--add-opens',
'java.base/java.util=ALL-UNNAMED',
'--add-opens',
'java.base/java.lang=ALL-UNNAMED',

-- Eclipse jdtls location
'-jar',
home .. '/.local/share/nvim/mason/share/jdtls/plugins/org.eclipse.equinox.launcher.jar',
'-configuration',
home .. '/.local/share/nvim/mason/packages/jdtls/config_' .. system_os,
'-data',
workspace_dir,
},

-- 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', 'pom.xml', 'build.gradle' },

-- 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
settings = {
java = {
-- TODO Replace this with the absolute path to your main java version (JDTLS requires JDK 21 or higher)
home = '/usr/lib/jvm/java-21-openjdk',
eclipse = {
downloadSources = true,
},
configuration = {
updateBuildConfiguration = 'interactive',
-- TODO Update this by adding any runtimes that you need to support your Java projects and removing any that you don't have installed
-- The runtimes' name parameter needs to match a specific Java execution environments. See https://github.com/eclipse-jdtls/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request and search "ExecutionEnvironment".
runtimes = {
{
name = 'JavaSE-21',
path = '/usr/lib/jvm/java-21-openjdk',
},
{
name = 'JavaSE-25',
path = '/usr/lib/jvm/java-25-openjdk',
},
},
},
maven = {
downloadSources = true,
},
implementationsCodeLens = {
enabled = true,
},
referencesCodeLens = {
enabled = true,
},
references = {
includeDecompiledSources = true,
},
signatureHelp = { enabled = true },
format = {
enabled = true,
-- Formatting works by default, but you can refer to a specific file/URL if you choose
-- settings = {
-- url = "https://github.com/google/styleguide/blob/gh-pages/intellij-java-google-style.xml",
-- profile = "GoogleStyle",
-- },
},
completion = {
favoriteStaticMembers = {
'org.hamcrest.MatcherAssert.assertThat',
'org.hamcrest.Matchers.*',
'org.hamcrest.CoreMatchers.*',
'org.junit.jupiter.api.Assertions.*',
'java.util.Objects.requireNonNull',
'java.util.Objects.requireNonNullElse',
'org.mockito.Mockito.*',
},
importOrder = {
'java',
'javax',
'com',
'org',
},
},
sources = {
organizeImports = {
starThreshold = 9999,
staticStarThreshold = 9999,
},
},
codeGeneration = {
toString = {
template = '${object.className}{${member.name()}=${member.value}, ${otherMembers}}',
},
useBlocks = true,
},
},
},
-- Needed for auto-completion with method signatures and placeholders
capabilities = require('blink-cmp').get_lsp_capabilities(),
flags = {
allow_incremental_sync = true,
},
init_options = {
-- References the bundles defined above to support Debugging and Unit Testing
bundles = bundles,
extendedClientCapabilities = jdtls.extendedClientCapabilities,
},
}

-- Needed for debugging
config['on_attach'] = function(client, bufnr)
jdtls.setup_dap { hotcodereplace = 'auto' }
require('jdtls.dap').setup_dap_main_class_configs()
end

-- This starts a new client & server, or attaches to an existing client & server based on the `root_dir`.
jdtls.start_or_attach(config)
Loading
Loading