Neovim PDE — Java

Configure a PDE for Java programming.

alpha2phi

--

Neovim PDE — Java

In this article, we will set up a development environment for Java.

This article is part of the Neovim PDE series.

The Neovim configuration files are available in this repository.

Getting Started

We have already set up the development environments for Lua, Python, C/C++, Go, and Rust. In this article, we will focus on setting up a Java development environment in a single file using lazy.nvim, encompassing LSP completion and DAP debugging.

Java PDE

The Java development environment is configured in the lua/pde/java.lua file.

First and foremost, we check if the environment should be enabled or disabled (line 1 — line 3).

if not require("config").pde.java then
return {}
end

nvim-treesitter

For nvim-treesitter, we ensure the Java parser is installed.

{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
vim.list_extend(opts.ensure_installed, { "java" })
end,
},

mason.nvim

For mason.nvim, we make sure the following components are installed.

{
"williamboman/mason.nvim",
opts = function(_, opts)
vim.list_extend(opts.ensure_installed, { "jdtls", "java-debug-adapter", "java-test", "google-java-format" })
end,
},

null-ls.nvim

For null-ls.nvim, we configure the google-java-format formatter.

{
"jose-elias-alvarez/null-ls.nvim",
opts = function(_, opts)
local nls = require "null-ls"
table.insert(opts.sources…

--

--

alpha2phi

Software engineer, Data Science and ML practitioner.