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',
description = 'Fuzzy File',
},
SYMBOLS = {
mode = 'n',
shortcut = '<leader>fs',
description = 'Find Symbols',
},
GLOBAL_FIND_FILE = {
mode = 'n',
shortcut = '<leader>gff',

View file

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

View file

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

View file

@ -1,52 +1,69 @@
local K = require('core.keymap')
return {
'nvim-telescope/telescope.nvim',
tag = '0.1.5',
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-telescope/telescope-ui-select.nvim',
},
config = function()
-- Setup --
require('telescope').setup({
extensions = {
['ui-select'] = {
require('telescope.themes').get_dropdown({}),
{
'nvim-telescope/telescope.nvim',
tag = '0.1.5',
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-telescope/telescope-ui-select.nvim',
},
config = function()
-- Setup --
require('telescope').setup({
extensions = {
['ui-select'] = {
require('telescope.themes').get_dropdown({}),
},
},
},
})
require('telescope').load_extension('ui-select')
})
require('telescope').load_extension('ui-select')
-- Keybinding --
local function setTelescopeBinding(mapping, method, search_global)
local function binding()
local path = search_global and '~'
or require('neo-tree.sources.manager').get_state(
'filesystem'
).path
method({ search_dirs = { path } })
-- Keybinding --
local function setTelescopeBinding(mapping, method, search_global)
local function binding()
local path = search_global and '~'
or require('neo-tree.sources.manager').get_state(
'filesystem'
).path
method({ search_dirs = { path } })
end
vim.keymap.set(
mapping.mode,
mapping.shortcut,
binding,
{ desc = mapping.description }
)
end
vim.keymap.set(
mapping.mode,
mapping.shortcut,
binding,
{ desc = mapping.description }
local telescope = require('telescope.builtin')
setTelescopeBinding(K.SEARCH.FIND_FILE, telescope.find_files, false)
setTelescopeBinding(K.SEARCH.FUZZY_FIND, telescope.live_grep, false)
setTelescopeBinding(
K.SEARCH.GLOBAL_FIND_FILE,
telescope.find_files,
true
)
end
setTelescopeBinding(
K.SEARCH.GLOBAL_FUZZY_FIND,
telescope.live_grep,
true
)
end,
},
{
'ibhagwan/fzf-lua',
dependencies = { 'nvim-tree/nvim-web-devicons' },
config = function()
local fzf = require('fzf-lua')
fzf.setup({})
local telescope = require('telescope.builtin')
setTelescopeBinding(K.SEARCH.FIND_FILE, telescope.find_files, false)
setTelescopeBinding(K.SEARCH.FUZZY_FIND, telescope.live_grep, false)
setTelescopeBinding(
K.SEARCH.GLOBAL_FIND_FILE,
telescope.find_files,
true
)
setTelescopeBinding(
K.SEARCH.GLOBAL_FUZZY_FIND,
telescope.live_grep,
true
)
end,
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.web').setup()
require('toolchain.angular').setup()
require('toolchain.java').setup()
end
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