java, rebinds, other new LSPs
This commit is contained in:
parent
c2b97192c5
commit
64f77367a9
|
|
@ -0,0 +1,47 @@
|
|||
local jdtls = require 'jdtls'
|
||||
|
||||
-- 1. Root and Workspace
|
||||
local root_markers = { '.git', 'mvnw', 'gradlew', 'pom.xml', 'build.gradle' }
|
||||
local root_dir = require('jdtls.setup').find_root(root_markers)
|
||||
local project_name = vim.fn.fnamemodify(root_dir, ':p:h:t')
|
||||
local workspace_dir = vim.fn.stdpath 'data' .. '/jdtls-workspace/' .. project_name
|
||||
|
||||
-- 2. Direct path to Mason packages (Avoids the 'nil' API error)
|
||||
local mason_path = vim.fn.stdpath 'data' .. '/mason/packages/'
|
||||
local bundles = {
|
||||
vim.fn.glob(mason_path .. 'java-debug-adapter/extension/server/com.microsoft.java.debug.plugin-*.jar', true),
|
||||
}
|
||||
|
||||
-- Add Java Test bundles
|
||||
local test_jars = vim.fn.glob(mason_path .. 'java-test/extension/server/*.jar', true)
|
||||
if test_jars ~= '' then
|
||||
vim.list_extend(bundles, vim.split(test_jars, '\n'))
|
||||
end
|
||||
|
||||
-- 3. Configuration
|
||||
local config = {
|
||||
cmd = {
|
||||
'jdtls',
|
||||
'-data',
|
||||
workspace_dir,
|
||||
-- Ensure jdtls is in your PATH. If not, use the full path to the executable:
|
||||
-- vim.fn.stdpath("data") .. "/mason/bin/jdtls"
|
||||
},
|
||||
root_dir = root_dir,
|
||||
init_options = {
|
||||
bundles = bundles,
|
||||
},
|
||||
on_attach = function(client, bufnr)
|
||||
-- This links the Debugger to the LSP session
|
||||
jdtls.setup_dap { hotcodereplace = 'auto' }
|
||||
require('jdtls.dap').setup_dap_main_class_configs()
|
||||
|
||||
-- Sync Kickstart highlighting
|
||||
if client.server_capabilities.semanticTokensProvider then
|
||||
vim.lsp.semantic_tokens.start(bufnr, client.id)
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
-- 4. Start
|
||||
jdtls.start_or_attach(config)
|
||||
109
init.lua
109
init.lua
|
|
@ -352,6 +352,14 @@ require('lazy').setup({
|
|||
},
|
||||
},
|
||||
|
||||
{
|
||||
'folke/persistence.nvim',
|
||||
event = 'BufReadPre', -- this will only start session saving when an actual file was opened
|
||||
opts = {
|
||||
-- add any custom options here
|
||||
},
|
||||
},
|
||||
|
||||
-- NOTE: Plugins can specify dependencies.
|
||||
--
|
||||
-- The dependencies are proper plugin specifications as well - anything
|
||||
|
|
@ -413,7 +421,6 @@ require('lazy').setup({
|
|||
-- i = { ['<c-enter>'] = 'to_fuzzy_refine' },
|
||||
-- },
|
||||
-- },
|
||||
-- pickers = {}
|
||||
extensions = {
|
||||
['ui-select'] = {
|
||||
require('telescope.themes').get_dropdown(),
|
||||
|
|
@ -427,17 +434,38 @@ require('lazy').setup({
|
|||
|
||||
-- See `:help telescope.builtin`
|
||||
local builtin = require 'telescope.builtin'
|
||||
vim.keymap.set('n', '<leader>sh', builtin.help_tags, { desc = '[S]earch [H]elp' })
|
||||
vim.keymap.set('n', '<leader>sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' })
|
||||
vim.keymap.set('n', '<leader>sf', builtin.find_files, { desc = '[S]earch [F]iles' })
|
||||
vim.keymap.set('n', '<leader>ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' })
|
||||
vim.keymap.set('n', '<leader>sw', builtin.grep_string, { desc = '[S]earch current [W]ord' })
|
||||
vim.keymap.set('n', '<leader>sg', builtin.live_grep, { desc = '[S]earch by [G]rep' })
|
||||
vim.keymap.set('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' })
|
||||
vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' })
|
||||
vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
|
||||
vim.keymap.set('n', '<leader>fh', builtin.help_tags, { desc = '[H]elp' })
|
||||
vim.keymap.set('n', '<leader>fk', builtin.keymaps, { desc = '[K]eymaps' })
|
||||
vim.keymap.set('n', '<leader>ff', builtin.find_files, { desc = '[F]iles' })
|
||||
vim.keymap.set('n', '<leader>fs', builtin.builtin, { desc = '[S]elect Telescope' })
|
||||
vim.keymap.set('n', '<leader>fw', builtin.grep_string, { desc = 'current [W]ord' })
|
||||
vim.keymap.set('n', '<leader>fg', builtin.live_grep, { desc = 'by [G]rep' })
|
||||
vim.keymap.set('n', '<leader>fd', builtin.diagnostics, { desc = '[D]iagnostics' })
|
||||
vim.keymap.set('n', '<leader>fr', builtin.resume, { desc = '[R]esume' })
|
||||
vim.keymap.set('n', '<leader>f.', builtin.oldfiles, { desc = 'Recent Files ("." for repeat)' })
|
||||
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
|
||||
|
||||
-- Session
|
||||
-- load the session for the current directory
|
||||
vim.keymap.set('n', '<leader>ss', function()
|
||||
require('persistence').load()
|
||||
end, { desc = '[s]ession for the current dir' })
|
||||
|
||||
-- select a session to load
|
||||
vim.keymap.set('n', '<leader>sw', function()
|
||||
require('persistence').select()
|
||||
end, { desc = '[w]hich session to load' })
|
||||
|
||||
-- load the last session
|
||||
vim.keymap.set('n', '<leader>sl', function()
|
||||
require('persistence').load { last = true }
|
||||
end, { desc = '[l]ast session' })
|
||||
|
||||
-- stop Persistence => session won't be saved on exit
|
||||
vim.keymap.set('n', '<leader>sd', function()
|
||||
require('persistence').stop()
|
||||
end, { desc = "[d]on't save this session" })
|
||||
|
||||
-- Slightly advanced example of overriding default behavior and theme
|
||||
vim.keymap.set('n', '<leader>/', function()
|
||||
-- You can pass additional configuration to Telescope to change the theme, layout, etc.
|
||||
|
|
@ -449,33 +477,19 @@ require('lazy').setup({
|
|||
|
||||
-- It's also possible to pass additional configuration options.
|
||||
-- See `:help telescope.builtin.live_grep()` for information about particular keys
|
||||
vim.keymap.set('n', '<leader>s/', function()
|
||||
vim.keymap.set('n', '<leader>f/', function()
|
||||
builtin.live_grep {
|
||||
grep_open_files = true,
|
||||
prompt_title = 'Live Grep in Open Files',
|
||||
}
|
||||
end, { desc = '[S]earch [/] in Open Files' })
|
||||
end, { desc = '[/] in Open Files' })
|
||||
|
||||
-- Shortcut for searching your Neovim configuration files
|
||||
vim.keymap.set('n', '<leader>sn', function()
|
||||
vim.keymap.set('n', '<leader>fn', function()
|
||||
builtin.find_files { cwd = vim.fn.stdpath 'config' }
|
||||
end, { desc = '[S]earch [N]eovim files' })
|
||||
end, { desc = '[N]eovim files' })
|
||||
end,
|
||||
},
|
||||
|
||||
-- LSP Plugins
|
||||
{
|
||||
-- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins
|
||||
-- used for completion, annotations and signatures of Neovim apis
|
||||
'folke/lazydev.nvim',
|
||||
ft = 'lua',
|
||||
opts = {
|
||||
library = {
|
||||
-- Load luvit types when the `vim.uv` word is found
|
||||
{ path = '${3rd}/luv/library', words = { 'vim%.uv' } },
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
-- Main LSP Configuration
|
||||
'neovim/nvim-lspconfig',
|
||||
|
|
@ -672,9 +686,11 @@ require('lazy').setup({
|
|||
-- - settings (table): Override the default settings passed when initializing the server.
|
||||
-- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
|
||||
local servers = {
|
||||
-- clangd = {},
|
||||
-- gopls = {},
|
||||
-- pyright = {},
|
||||
clangd = {},
|
||||
gopls = {},
|
||||
pyright = {},
|
||||
prettier = {},
|
||||
tailwindcss = {},
|
||||
-- rust_analyzer = {},
|
||||
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
|
||||
--
|
||||
|
|
@ -717,12 +733,20 @@ require('lazy').setup({
|
|||
local ensure_installed = vim.tbl_keys(servers or {})
|
||||
vim.list_extend(ensure_installed, {
|
||||
'stylua', -- Used to format Lua code
|
||||
'markdownlint',
|
||||
'hadolint',
|
||||
'clangd',
|
||||
})
|
||||
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
|
||||
|
||||
require('mason-lspconfig').setup {
|
||||
ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer)
|
||||
automatic_installation = false,
|
||||
automatic_enable = {
|
||||
exclude = {
|
||||
'jdtls',
|
||||
},
|
||||
},
|
||||
handlers = {
|
||||
function(server_name)
|
||||
local server = servers[server_name] or {}
|
||||
|
|
@ -743,12 +767,12 @@ require('lazy').setup({
|
|||
cmd = { 'ConformInfo' },
|
||||
keys = {
|
||||
{
|
||||
'<leader>f',
|
||||
'<leader>o',
|
||||
function()
|
||||
require('conform').format { async = true, lsp_format = 'fallback' }
|
||||
end,
|
||||
mode = '',
|
||||
desc = '[F]ormat buffer',
|
||||
desc = 'F[o]rmat buffer',
|
||||
},
|
||||
},
|
||||
opts = {
|
||||
|
|
@ -770,7 +794,9 @@ require('lazy').setup({
|
|||
formatters_by_ft = {
|
||||
lua = { 'stylua' },
|
||||
-- Conform can also run multiple formatters sequentially
|
||||
-- python = { "isort", "black" },
|
||||
python = { 'isort', 'black' },
|
||||
go = { 'goimports', 'gofmt' },
|
||||
css = { 'prettier' },
|
||||
--
|
||||
-- You can use 'stop_after_first' to run the first available formatter from the list
|
||||
-- javascript = { "prettierd", "prettier", stop_after_first = true },
|
||||
|
|
@ -887,6 +913,7 @@ require('lazy').setup({
|
|||
config = function()
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
require('tokyonight').setup {
|
||||
transparent = true,
|
||||
styles = {
|
||||
comments = { italic = false }, -- Disable italics in comments
|
||||
},
|
||||
|
|
@ -974,18 +1001,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 = 'custom.plugins' },
|
||||
--
|
||||
-- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec`
|
||||
-- Or use telescope!
|
||||
|
|
|
|||
|
|
@ -23,6 +23,9 @@ return {
|
|||
|
||||
-- Add your own debuggers here
|
||||
'leoluz/nvim-dap-go',
|
||||
|
||||
-- java
|
||||
'mfussenegger/nvim-jdtls',
|
||||
},
|
||||
keys = {
|
||||
-- Basic debugging keymaps, feel free to change to your liking!
|
||||
|
|
@ -95,6 +98,9 @@ return {
|
|||
ensure_installed = {
|
||||
-- Update this to ensure that you have the debuggers for the langs you want
|
||||
'delve',
|
||||
'cpptools',
|
||||
'java-debug-adapter',
|
||||
'java-test',
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -136,6 +142,16 @@ return {
|
|||
dap.listeners.before.event_terminated['dapui_config'] = dapui.close
|
||||
dap.listeners.before.event_exited['dapui_config'] = dapui.close
|
||||
|
||||
dap.configurations.java = {
|
||||
{
|
||||
type = 'java',
|
||||
request = 'launch',
|
||||
name = 'Debug (Launch) - Current File',
|
||||
mainClass = '${file}', -- This tells it to just try the current file
|
||||
projectName = 'temp-project',
|
||||
},
|
||||
}
|
||||
|
||||
-- Install golang specific config
|
||||
require('dap-go').setup {
|
||||
delve = {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ return {
|
|||
local lint = require 'lint'
|
||||
lint.linters_by_ft = {
|
||||
markdown = { 'markdownlint' },
|
||||
dockerfile = { 'hadolint' },
|
||||
}
|
||||
|
||||
-- To allow other plugins to add linters to require('lint').linters_by_ft,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"name": "nvim",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"devDependencies": {
|
||||
"prettier": "3.7.4"
|
||||
}
|
||||
},
|
||||
"node_modules/prettier": {
|
||||
"version": "3.7.4",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.7.4.tgz",
|
||||
"integrity": "sha512-v6UNi1+3hSlVvv8fSaoUbggEM5VErKmmpGA7Pl3HF8V6uKY7rvClBOJlH6yNwQtfTueNkGVpOv/mtWL9L4bgRA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"prettier": "bin/prettier.cjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"devDependencies": {
|
||||
"prettier": "3.7.4"
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue