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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ nvim

spell/
lazy-lock.json
node_modules
47 changes: 47 additions & 0 deletions ftplugin/java.lua
Original file line number Diff line number Diff line change
@@ -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)
144 changes: 86 additions & 58 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ 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

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

-- Enable mouse mode, can be useful for resizing splits for example!
vim.o.mouse = 'a'
Expand All @@ -120,6 +120,11 @@ end)

-- Enable break indent
vim.o.breakindent = true
vim.o.expandtab = true -- Convert tabs to spaces
vim.o.shiftwidth = 4 -- Number of spaces to use for each step of (auto)indent
vim.o.softtabstop = 4 -- Number of spaces a <Tab> counts for while performing editing operations
vim.o.autoindent = true -- Indent a new line the same amount as the line just typed
vim.o.smartindent = true -- Smart indentation with braces

-- Save undo history
vim.o.undofile = true
Expand Down Expand Up @@ -151,6 +156,7 @@ vim.o.splitbelow = true
-- and `:help lua-options-guide`
vim.o.list = true
vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' }
vim.opt.tabstop = 4

-- Preview substitutions live, as you type!
vim.o.inccommand = 'split'
Expand Down Expand Up @@ -233,7 +239,6 @@ end
---@type vim.Option
local rtp = vim.opt.rtp
rtp:prepend(lazypath)

-- [[ Configure and install plugins ]]
--
-- To check the current status of your plugins, run
Expand All @@ -247,7 +252,14 @@ rtp:prepend(lazypath)
-- NOTE: Here is where you install your plugins.
require('lazy').setup({
-- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link).
'NMAC427/guess-indent.nvim', -- Detect tabstop and shiftwidth automatically
{
'NMAC427/guess-indent.nvim',
config = function()
require('guess-indent').setup {
auto_cmd = true,
}
end,
},

-- NOTE: Plugins can also be added by using a table,
-- with the first argument being the link and the following
Expand All @@ -271,18 +283,6 @@ require('lazy').setup({
-- options to `gitsigns.nvim`.
--
-- See `:help gitsigns` to understand what the configuration keys do
{ -- Adds git related signs to the gutter, as well as utilities for managing changes
'lewis6991/gitsigns.nvim',
opts = {
signs = {
add = { text = '+' },
change = { text = '~' },
delete = { text = '_' },
topdelete = { text = '‾' },
changedelete = { text = '~' },
},
},
},

-- NOTE: Plugins can also be configured to run Lua code when they are loaded.
--
Expand Down Expand Up @@ -344,13 +344,22 @@ require('lazy').setup({

-- Document existing key chains
spec = {
{ '<leader>s', group = '[S]earch' },
{ '<leader>f', group = '[F]ind' },
{ '<leader>s', group = '[S]ession' },
{ '<leader>t', group = '[T]oggle' },
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
},
},
},

{
'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
Expand Down Expand Up @@ -412,7 +421,6 @@ require('lazy').setup({
-- i = { ['<c-enter>'] = 'to_fuzzy_refine' },
-- },
-- },
-- pickers = {}
extensions = {
['ui-select'] = {
require('telescope.themes').get_dropdown(),
Expand All @@ -426,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.
Expand All @@ -448,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',
Expand Down Expand Up @@ -671,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
--
Expand Down Expand Up @@ -716,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 {}
Expand All @@ -742,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 = {
Expand All @@ -769,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 },
Expand Down Expand Up @@ -886,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
},
Expand Down Expand Up @@ -973,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!
Expand Down
16 changes: 16 additions & 0 deletions lua/kickstart/plugins/debug.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down Expand Up @@ -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',
},
}

Expand Down Expand Up @@ -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 = {
Expand Down
1 change: 1 addition & 0 deletions lua/kickstart/plugins/lint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading
Loading