Initial setup for java development in NVIM
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
"noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" },
|
||||
"nui.nvim": { "branch": "main", "commit": "7cd18e73cfbd70e1546931b7268b3eebaeff9391" },
|
||||
"nvim-autopairs": { "branch": "master", "commit": "4d74e75913832866aa7de35e4202463ddf6efd1b" },
|
||||
"nvim-jdtls": { "branch": "master", "commit": "c23f200fee469a415c77265ca55b496feb646992" },
|
||||
"nvim-lint": { "branch": "master", "commit": "b47cbb249351873e3a571751c3fb66ed6369852f" },
|
||||
"nvim-scissors": { "branch": "main", "commit": "8123690127a599b7d5669b074d572e6239222c45" },
|
||||
"nvim-scrollbar": { "branch": "main", "commit": "5b103ef0fd2e8b9b4be3878ed38d224522192c6c" },
|
||||
|
||||
@@ -76,35 +76,46 @@ vim.api.nvim_create_autocmd({ 'FocusGained', 'TermClose', 'TermLeave' }, {
|
||||
})
|
||||
|
||||
-- close some filetypes with <q>
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
group = augroup("close_with_q"),
|
||||
pattern = {
|
||||
"PlenaryTestPopup",
|
||||
"checkhealth",
|
||||
"dbout",
|
||||
"gitsigns-blame",
|
||||
"grug-far",
|
||||
"help",
|
||||
"lspinfo",
|
||||
"neotest-output",
|
||||
"neotest-output-panel",
|
||||
"neotest-summary",
|
||||
"notify",
|
||||
"qf",
|
||||
"startuptime",
|
||||
"tsplayground",
|
||||
},
|
||||
callback = function(event)
|
||||
vim.bo[event.buf].buflisted = false
|
||||
vim.schedule(function()
|
||||
vim.keymap.set("n", "q", function()
|
||||
vim.cmd("close")
|
||||
pcall(vim.api.nvim_buf_delete, event.buf, { force = true })
|
||||
end, {
|
||||
buffer = event.buf,
|
||||
silent = true,
|
||||
desc = "Quit buffer",
|
||||
})
|
||||
end)
|
||||
end,
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
group = augroup('close_with_q'),
|
||||
pattern = {
|
||||
'PlenaryTestPopup',
|
||||
'checkhealth',
|
||||
'dbout',
|
||||
'gitsigns-blame',
|
||||
'grug-far',
|
||||
'help',
|
||||
'lspinfo',
|
||||
'neotest-output',
|
||||
'neotest-output-panel',
|
||||
'neotest-summary',
|
||||
'notify',
|
||||
'qf',
|
||||
'startuptime',
|
||||
'tsplayground',
|
||||
},
|
||||
callback = function(event)
|
||||
vim.bo[event.buf].buflisted = false
|
||||
vim.schedule(function()
|
||||
vim.keymap.set('n', 'q', function()
|
||||
vim.cmd('close')
|
||||
pcall(vim.api.nvim_buf_delete, event.buf, { force = true })
|
||||
end, {
|
||||
buffer = event.buf,
|
||||
silent = true,
|
||||
desc = 'Quit buffer',
|
||||
})
|
||||
end)
|
||||
end,
|
||||
})
|
||||
|
||||
-- Format and organize imports on file save
|
||||
vim.api.nvim_create_autocmd('BufWritePre', {
|
||||
pattern = '*.java',
|
||||
callback = function()
|
||||
if not vim.g.disable_autoformat then
|
||||
require('jdtls').organize_imports()
|
||||
vim.lsp.buf.format({ async = false })
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
11
.config/nvim/lua/plugins/nvim-jdtls.lua
Normal file
11
.config/nvim/lua/plugins/nvim-jdtls.lua
Normal file
@@ -0,0 +1,11 @@
|
||||
return {
|
||||
'mfussenegger/nvim-jdtls',
|
||||
ft = { 'java' },
|
||||
opts = {
|
||||
cmd = { 'jdtls' },
|
||||
root_dir = vim.fs.dirname(vim.fs.find({ 'gradlew', '.git', 'mvnw', 'pom.xml' }, { upward = true })[1]),
|
||||
},
|
||||
config = function(_, opts)
|
||||
require('jdtls').start_or_attach(opts)
|
||||
end,
|
||||
}
|
||||
@@ -31,6 +31,7 @@
|
||||
yaml-language-server
|
||||
# pnpm i -g css-variables-language-server
|
||||
# pnpm install -g gh-actions-language-server
|
||||
jdt-language-server
|
||||
|
||||
# Tools
|
||||
stylua
|
||||
|
||||
Reference in New Issue
Block a user