Add Java & Some Cleanup

This commit is contained in:
Snoweuph 2025-02-26 22:26:45 +01:00
parent d0ace3c891
commit 073aa72a25
Signed by: snoweuph
GPG key ID: BEFC41DA223CEC55
6 changed files with 126 additions and 45 deletions

View file

@ -99,6 +99,11 @@ K.SEARCH = {
shortcut = '<leader>fz', shortcut = '<leader>fz',
description = 'Fuzzy File', description = 'Fuzzy File',
}, },
SYMBOLS = {
mode = 'n',
shortcut = '<leader>fs',
description = 'Find Symbols',
},
GLOBAL_FIND_FILE = { GLOBAL_FIND_FILE = {
mode = 'n', mode = 'n',
shortcut = '<leader>gff', shortcut = '<leader>gff',

View file

@ -14,6 +14,8 @@ return {
close_if_last_window = false, close_if_last_window = false,
enable_git_status = true, enable_git_status = true,
enable_diagnostics = true, enable_diagnostics = true,
enable_cursor_hijack = true,
hide_root_node = true,
name = { name = {
trailing_slash = false, trailing_slash = false,
use_git_status_colors = true, use_git_status_colors = true,
@ -39,7 +41,10 @@ return {
}, },
filesystem = { filesystem = {
hijack_netrw_behavior = 'open_default', hijack_netrw_behavior = 'open_default',
group_empty_dirs = true,
scan_mode = 'deep',
}, },
popup_border_style = 'rounded',
-- Keybinding -- -- Keybinding --
window = { window = {
mappings = { mappings = {

View file

@ -6,7 +6,12 @@ return {
'williamboman/mason.nvim', 'williamboman/mason.nvim',
lazy = false, lazy = false,
config = function() config = function()
require('mason').setup() require('mason').setup({
registries = {
'github:nvim-java/mason-registry',
'github:mason-org/mason-registry',
},
})
end, end,
}, },
{ {
@ -23,6 +28,9 @@ return {
}, },
{ {
'neovim/nvim-lspconfig', 'neovim/nvim-lspconfig',
dependencies = {
'nvim-java/nvim-java', -- Needs To Be Loaded before lspconfig
},
lazy = false, lazy = false,
config = function() config = function()
-- Setup -- -- Setup --

View file

@ -1,5 +1,6 @@
local K = require('core.keymap') local K = require('core.keymap')
return { return {
{
'nvim-telescope/telescope.nvim', 'nvim-telescope/telescope.nvim',
tag = '0.1.5', tag = '0.1.5',
dependencies = { dependencies = {
@ -49,4 +50,20 @@ return {
true true
) )
end, end,
},
{
'ibhagwan/fzf-lua',
dependencies = { 'nvim-tree/nvim-web-devicons' },
config = function()
local fzf = require('fzf-lua')
fzf.setup({})
vim.keymap.set(
K.SEARCH.SYMBOLS.mode,
K.SEARCH.SYMBOLS.shortcut,
fzf.lsp_live_workspace_symbols,
{ desc = K.SEARCH.SYMBOLS.description }
)
end,
},
} }

View file

@ -135,6 +135,7 @@ function TOOLCHAINS.init()
require('toolchain.text').setup() require('toolchain.text').setup()
require('toolchain.web').setup() require('toolchain.web').setup()
require('toolchain.angular').setup() require('toolchain.angular').setup()
require('toolchain.java').setup()
end end
return TOOLCHAINS return TOOLCHAINS

45
lua/toolchain/java.lua Normal file
View file

@ -0,0 +1,45 @@
local T = require('toolchain')
local M = {}
function M.setup()
T.add_highlighter_autoinstalls('java', 'kotlin')
T.add_lsps(function(lspconfig, capabilities)
local paths = vim.fn.systemlist(
"update-alternatives --display java | grep '^/.*$' | cut -d ' ' -f 1"
)
local runtimes = {}
for _, path in ipairs(paths) do
local version = vim.fn.matchstr(path, '\\v\\d+(\\.\\d+)*')
table.insert(runtimes, {
name = version,
path = path,
})
end
lspconfig.jdtls.setup({
capabilities = capabilities,
settings = {
java = {
configuration = {
runtimes = runtimes,
},
},
},
})
end)
T.add_plugins({
'nvim-java/nvim-java',
config = function()
require('java').setup({
notifications = {
dap = false,
},
jdk = {
auto_install = false,
},
})
end,
})
end
return M