Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings
nvim-java

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

nvim-java with NvChad v2.5#308

Jamie-505 started this conversation inShow and tell
Sep 26, 2024· 1 comments· 1 reply
Discussion options

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

You must be logged in to vote

Replies: 1 comment 1 reply

Comment options

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:

filetree

  • init.lua file (central point for loading all my plugins):
-- 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
  • then i havenvim-java.lua file:

nvimjava

  • also the file i store theconfigslike you do:
    (i used to have both in the same file but i saw your setup and wanted to try it out)

configjava

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:

  • Lazy installs the packages needed when i first open it up, but..
  • commands aint working and those wont pop up on autocomplete;
  • treesitter appears to be partially working (e.g., syntax highlighting seems okay), but I'm unsure if it's fully integrated for Java features as I'm new to it.
  • the debugger does not appear when I attempt to run the commands shown in nvim-java demos.
    etc.

could you help over please! 🙏

You must be logged in to vote
1 reply
@CodEssence
Comment options

Update: i added my fdk path to lua/config/nvim-java.lua file i had.But it still doesnt work :(
now it looks like this:

-- 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 :(

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Labels
None yet
2 participants
@Jamie-505@CodEssence

[8]ページ先頭

©2009-2025 Movatter.jp