nvim-java with NvChad v2.5#308
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
After almost pulling my hair out because nvchads mason config did not play nicely with the extensions from nvim-java I found thisreddit post Credit:@Omixxx so I figured I post this somewhere more easily to find. here is thelua/plugins/myPlugins.lua section: {'nvim-java/nvim-java',lazy=false,dependencies= {'nvim-java/lua-async-await','nvim-java/nvim-java-core','nvim-java/nvim-java-test','nvim-java/nvim-java-dap','MunifTanjim/nui.nvim','neovim/nvim-lspconfig','mfussenegger/nvim-dap', {'williamboman/mason.nvim',opts= {registries= {'github:nvim-java/mason-registry','github:mason-org/mason-registry', }, }, }, },config=function()require('configs.java')end, },and thelua/configs/java.lua file I use to store the configuration localconfig=require('nvchad.configs.lspconfig')localon_attach=config.on_attachlocalcapabilities=config.capabilitiesrequire('java').setup({})require('lspconfig').jdtls.setup({on_attach=on_attach,capabilities=capabilities,filetypes= {'java'},}) hope this serves useful for someone |
BetaWas this translation helpful?Give feedback.
All reactions
❤️ 4
Replies: 1 comment 1 reply
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Hey mate! i also came accross this issue, but i use latest version ofnvchad. here i share my setup: note: nvchad config structure canged since then and now custom folder is no longer available. but i like to use a structure similar to custom folder. here is my config file structure:
-- Updated config ---- ~/.config/nvim/lua/plugins/init.lua-- Create an empty table to hold all plugin specificationslocalplugins= {}-- Helper function to extend the 'plugins' table with configurations from other fileslocalfunctionextend_plugins(t)for_,vinipairs(t)dotable.insert(plugins,v)endend--- Load existing plugins from your original init.lua directly into the 'plugins' table ----- These are the plugins you had directly listed in your original init.lua.-- Add them to the 'plugins' table here.table.insert(plugins, {"stevearc/conform.nvim",-- event = 'BufWritePre', -- uncomment for format on saveopts=require"configs.conform",})table.insert(plugins, {"neovim/nvim-lspconfig",config=function()require"configs.lspconfig"end,})-- Uncomment and add other plugins you had directly here, for example:-- table.insert(plugins, { import = "nvchad.blink.lazyspec" })-- table.insert(plugins, {-- "nvim-treesitter/nvim-treesitter",-- opts = {-- ensure_installed = {-- "vim", "lua", "vimdoc",-- "html", "css"-- },-- -- Ensure folding is enabled if you plan to use Treesitter folding-- folding = { enable = true },-- },-- })-- == uncommented: ==table.insert(plugins, {import="nvchad.blink.lazyspec"})table.insert(plugins, {"nvim-treesitter/nvim-treesitter",opts= {ensure_installed= {"vim","lua","vimdoc","html","css","java","python" },-- Ensure folding is enabled if you plan to use Treesitter foldingfolding= {enable=true }, }, })-- Add Mason and Mason-LSPConfig heretable.insert(plugins, {"williamboman/mason.nvim",cmd="Mason",build=":MasonUpdate",config=function()require("mason").setup({-- Add any global mason settings here if needed-- e.g., ensure that the "bin" directory is in your system PATH })end})table.insert(plugins, {"williamboman/mason-lspconfig.nvim",dependencies= {"williamboman/mason.nvim","neovim/nvim-lspconfig"},config=function()require("mason-lspconfig").setup({ensure_installed= {"jdtls",-- Ensure JDTLS is always installed by Mason"lua_ls",-- Ensure Lua LS is installed"cssls",-- Ensure CSS LS is installed"html"-- Ensure HTML LS is installed },-- Automatically setup lspconfig for servers installed by masonautomatic_installation=true, })end})--- Load plugins from different groups (your new structure) ----- Load plugins from the 'note-taking' groupextend_plugins(require("plugins.note-taking.telekasten"))extend_plugins(require("plugins.note-taking.render-markdown"))-- Load plugins from the 'java' development groupextend_plugins(require("plugins.java.nvim-java"))-- Add more groups as you create them, for example:-- extend_plugins(require("plugins.utility.harpoon"))-- extend_plugins(require("plugins.lsp.nvim-lspconfig"))-- Finally, return the combined list of all plugin specifications for lazy.nvim to processreturnplugins
Long story short i wanted to learn java and got nvchad, tweaked it for a week or so now i am trying to make java working. but after long hours of trying to set this up in nvchad it wont still work. i got the configurations from that archved post onreddit, then i saw your post, and tried that, but it still is not working:
could you help over please! 🙏 |
BetaWas this translation helpful?Give feedback.
All reactions
👀 1
-
Update: i added my fdk path to lua/config/nvim-java.lua file i had.But it still doesnt work :( -- File: ~/.config/nvim/lua/configs/nvim-java.lualocalconfig=require('nvchad.configs.lspconfig')localon_attach=config.on_attachlocalcapabilities=config.capabilitiesrequire('java').setup({})require('lspconfig').jdtls.setup({settings= {java= {configuration= {runtimes= { {name="JavaSE-22",path="/usr/lib/jvm/jdk-22-oracle-x64",default=true, }, }, }, }, },on_attach=function(client,bufnr)require('java').dap.on_attach(client,bufnr)on_attach(client,bufnr)end,capabilities=capabilities,filetypes= {'java'},}) But it still doesnt work :( |
BetaWas this translation helpful?Give feedback.
All reactions
👀 1


