adding eclipse java support to neovim

This commit is contained in:
2026-09-01 11:00:07 -06:00
parent 7081a75fb0
commit 2e7773cf4b
+32
View File
@@ -7,6 +7,11 @@
vimAlias = true;
defaultEditor = true;
extraPackages = with pkgs; [
jdtls
jdk
];
initLua = ''
vim.opt.number = true
vim.opt.relativenumber = true
@@ -85,6 +90,32 @@
delete = { text = "_" },
},
})
local lspconfig = require('lspconfig')
-- Common keymaps to run when the Eclipse LSP attaches to a Java buffer
local on_attach = function(client, bufnr)
local opts = { buffer = bufnr, silent = true }
-- Eclipse IDE core features mapped to Neovim actions
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, opts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
vim.keymap.set('n', '<leader>f', function() vim.lsp.buf.format { async = true } end, opts)
end
-- Initialize the Eclipse JDTLS Server configuration
-- NixOS patches 'jdtls' wrapper script automatically to point to the correct binary paths
lspconfig.jdtls.setup({
on_attach = on_attach,
cmd = { "jdtls" },
root_dir = lspconfig.util.root_pattern(".git", "pom.xml", "build.gradle"),
})
'';
plugins = with pkgs.vimPlugins; [
@@ -95,6 +126,7 @@
{ plugin = lualine-nvim; }
{ plugin = neocord; }
{ plugin = gitsigns-nvim; }
{ plugin = nvim-lspconfig; }
];
};
}