Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions ftplugin/java.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
local home = os.getenv 'HOME'
local share = '/AppData/Local/nvim-data'
local workspace_path = home .. share .. '/jdtls-workspace/'
local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h:t')
local workspace_dir = workspace_path .. project_name

local status, jdtls = pcall(require, 'jdtls')
if not status then
return
end
local extendedClientCapabilities = jdtls.extendedClientCapabilities

local config = {
cmd = {
'java',
'-Declipse.application=org.eclipse.jdt.ls.core.id1',
'-Dosgi.bundles.defaultStartLevel=4',
'-Declipse.product=org.eclipse.jdt.ls.core.product',
'-Dlog.protocol=true',
'-Dlog.level=ALL',
'-Xmx1g',
'--add-modules=ALL-SYSTEM',
'--add-opens',
'java.base/java.util=ALL-UNNAMED',
'--add-opens',
'java.base/java.lang=ALL-UNNAMED',
'-javaagent:' .. home .. share .. '/mason/packages/jdtls/lombok.jar',
'-jar',
vim.fn.glob(home .. share .. '/mason/packages/jdtls/plugins/org.eclipse.equinox.launcher_*.jar'),
'-configuration',
home .. share .. '/mason/packages/jdtls/config_win',
'-data',
workspace_dir,
},
root_dir = require('jdtls.setup').find_root { '.git', 'mvnw', 'gradlew', 'pom.xml', 'build.gradle' },

settings = {
java = {
home = 'c:/Program Files/Java/jdk-17',
signatureHelp = { enabled = true },
extendedClientCapabilities = extendedClientCapabilities,
maven = {
downloadSources = true,
},
referencesCodeLens = {
enabled = true,
},
references = {
includeDecompiledSources = true,
},
inlayHints = {
parameterNames = {
enabled = 'all', -- literals, all, none
},
},
format = {
enabled = false,
},
},
},

init_options = {
bundles = {},
},
}
require('jdtls').start_or_attach(config)

vim.keymap.set('n', '<leader>co', "<Cmd>lua require'jdtls'.organize_imports()<CR>", { desc = 'Organize Imports' })
vim.keymap.set('n', '<leader>crv', "<Cmd>lua require('jdtls').extract_variable()<CR>", { desc = 'Extract Variable' })
vim.keymap.set('v', '<leader>crv', "<Esc><Cmd>lua require('jdtls').extract_variable(true)<CR>", { desc = 'Extract Variable' })
vim.keymap.set('n', '<leader>crc', "<Cmd>lua require('jdtls').extract_constant()<CR>", { desc = 'Extract Constant' })
vim.keymap.set('v', '<leader>crc', "<Esc><Cmd>lua require('jdtls').extract_constant(true)<CR>", { desc = 'Extract Constant' })
vim.keymap.set('v', '<leader>crm', "<Esc><Cmd>lua require('jdtls').extract_method(true)<CR>", { desc = 'Extract Method' })
57 changes: 45 additions & 12 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,13 @@ vim.g.mapleader = ' '
vim.g.maplocalleader = ' '

-- Set to true if you have a Nerd Font installed and selected in the terminal
vim.g.have_nerd_font = false
vim.g.have_nerd_font = true

-- NOTE: my neovide options
-- [[ Neovide ]]
vim.o.guifont = 'FiraCode Nerd Font'
vim.opt.linespace = 15
vim.g.neovide_scale_factor = 0.7

-- [[ Setting options ]]
-- See `:help vim.opt`
Expand All @@ -102,7 +108,7 @@ vim.g.have_nerd_font = false
vim.opt.number = true
-- You can also add relative line numbers, to help with jumping.
-- Experiment for yourself to see if you like it!
-- vim.opt.relativenumber = true
vim.opt.relativenumber = true

-- Enable mouse mode, can be useful for resizing splits for example!
vim.opt.mouse = 'a'
Expand Down Expand Up @@ -155,7 +161,7 @@ vim.opt.inccommand = 'split'
vim.opt.cursorline = true

-- Minimal number of screen lines to keep above and below the cursor.
vim.opt.scrolloff = 10
vim.opt.scrolloff = 20

-- [[ Basic Keymaps ]]
-- See `:help vim.keymap.set()`
Expand Down Expand Up @@ -437,6 +443,7 @@ require('lazy').setup({
end,
},

{ 'mfussenegger/nvim-jdtls' },
-- LSP Plugins
{
-- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins
Expand Down Expand Up @@ -627,7 +634,23 @@ require('lazy').setup({
-- But for many setups, the LSP (`ts_ls`) will work just fine
-- ts_ls = {},
--

gopls = {
capabilities = capabilities,
cmd = { 'gopls' },
filetypes = { 'go', 'gomod', 'gowork', 'gotmpl' },
settings = {
gopls = {
completeUnimported = true,
usePlaceholders = true,
analyses = {
unusedparams = true,
},
},
},
},
zls = {
cmd = { 'zls' },
},
lua_ls = {
-- cmd = {...},
-- filetypes = { ...},
Expand Down Expand Up @@ -657,6 +680,15 @@ require('lazy').setup({
local ensure_installed = vim.tbl_keys(servers or {})
vim.list_extend(ensure_installed, {
'stylua', -- Used to format Lua code
'gopls',
'jdtls',
'yaml-language-server',
'lua-language-server',
'rust-analyzer',
'marksman',
'xmlformatter',
'lemminx',
'google-java-format',
})
require('mason-tool-installer').setup { ensure_installed = ensure_installed }

Expand Down Expand Up @@ -709,6 +741,7 @@ require('lazy').setup({
end,
formatters_by_ft = {
lua = { 'stylua' },
zig = { 'zig fmt' },
-- Conform can also run multiple formatters sequentially
-- python = { "isort", "black" },
--
Expand Down Expand Up @@ -898,7 +931,7 @@ require('lazy').setup({
main = 'nvim-treesitter.configs', -- Sets main module to use for opts
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
opts = {
ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' },
ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc', 'java' },
-- Autoinstall languages that are not installed
auto_install = true,
highlight = {
Expand Down Expand Up @@ -927,18 +960,18 @@ require('lazy').setup({
-- Here are some example plugins that I've included in the Kickstart repository.
-- Uncomment any of the lines below to enable them (you will need to restart nvim).
--
-- require 'kickstart.plugins.debug',
-- require 'kickstart.plugins.indent_line',
-- require 'kickstart.plugins.lint',
-- require 'kickstart.plugins.autopairs',
-- require 'kickstart.plugins.neo-tree',
-- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
require 'kickstart.plugins.debug',
require 'kickstart.plugins.indent_line',
require 'kickstart.plugins.lint',
require 'kickstart.plugins.autopairs',
require 'kickstart.plugins.neo-tree',
require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps

-- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
-- This is the easiest way to modularize your config.
--
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
-- { import = 'custom.plugins' },
{ import = 'dacekonn.plugins' },
--
-- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec`
-- Or use telescope!
Expand Down
7 changes: 7 additions & 0 deletions lua/dacekonn/plugins/centerpad.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
return {
{ -- Add indentation guides even on blank lines
'smithbm2316/centerpad.nvim',
-- Enable `lukas-reineke/indent-blankline.nvim`
-- See `:help ibl`
},
}
Loading
Loading