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