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
81 changes: 65 additions & 16 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ do
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 Down Expand Up @@ -371,6 +371,7 @@ do
spec = {
{ '<leader>s', group = '[S]earch', mode = { 'n', 'v' } },
{ '<leader>t', group = '[T]oggle' },
{ '<leader>l', group = '[L]aTeX' }, -- VimTeX maps (see lua/custom/plugins/vimtex.lua)
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } }, -- Enable gitsigns recommended keymaps first
{ 'gr', group = 'LSP Actions', mode = { 'n' } },
},
Expand Down Expand Up @@ -705,6 +706,38 @@ do

stylua = {}, -- Used to format Lua code

-- Java: jdtls is installed via Mason (it's a key here so mason-tool-installer
-- picks it up), but its LSP config and `vim.lsp.enable` are owned by nvim-java
-- (see lua/custom/plugins/nvim-java.lua). We therefore SKIP jdtls in the
-- config/enable loop below so nvim-java's jdtls bootstrap is the one that wins
-- and there is no competing vanilla jdtls setup.
jdtls = {},

-- ty: Astral's Python type checker. Not yet shipped by nvim-lspconfig, so we
-- define the whole config here (ported from the old `lspconfig.configs.ty`
-- approach to the new `vim.lsp.config` API). Installed separately via uv, so
-- it is excluded from Mason below.
ty = {
cmd = { 'ty', 'server' },
filetypes = { 'python' },
root_markers = { 'pyproject.toml', 'ty.toml', '.git' },
},

-- ruff: Python linter/formatter LSP. nvim-lspconfig ships the base `ruff`
-- config (cmd, etc.); this only overlays init_options. Installed separately
-- via uv, so it is excluded from Mason below.
ruff = {
init_options = {
settings = {
fixAll = true,
},
},
},

-- texlab: LaTeX language server (completion/refs/diagnostics). VimTeX does not
-- provide this. Installed via Mason.
texlab = {},

-- Special Lua Config, as recommended by neovim help docs
lua_ls = {
on_init = function(client)
Expand Down Expand Up @@ -758,15 +791,23 @@ do
--
-- You can press `g?` for help in this menu.
local ensure_installed = vim.tbl_keys(servers or {})
-- ty and ruff are installed separately via uv (~/.local/bin), so exclude them
-- from Mason auto-install.
ensure_installed = vim.tbl_filter(function(name) return name ~= 'ty' and name ~= 'ruff' end, ensure_installed)
vim.list_extend(ensure_installed, {
-- You can add other tools here that you want Mason to install
})

require('mason-tool-installer').setup { ensure_installed = ensure_installed }

for name, server in pairs(servers) do
vim.lsp.config(name, server)
vim.lsp.enable(name)
-- jdtls is configured and enabled by nvim-java (lua/custom/plugins/nvim-java.lua),
-- which must run `require('java').setup()` before `vim.lsp.enable('jdtls')`.
-- Skip it here to avoid a second, competing jdtls setup.
if name ~= 'jdtls' then
vim.lsp.config(name, server)
vim.lsp.enable(name)
end
end
end

Expand Down Expand Up @@ -796,12 +837,20 @@ do
},
-- You can also specify external formatters in here.
formatters_by_ft = {
-- rust = { 'rustfmt' },
-- Conform can also run multiple formatters sequentially
-- python = { "isort", "black" },
--
lua = { 'stylua' },
-- ruff handles BOTH import-sorting and formatting (black/isort are not
-- installed; ruff is). Organize imports first, then format.
python = { 'ruff_organize_imports', 'ruff_format' },
-- You can use 'stop_after_first' to run the first available formatter from the list
-- javascript = { "prettierd", "prettier", stop_after_first = true },
javascript = { 'prettierd', 'prettier', stop_after_first = true },
-- conform matches the lowercase `vim.bo.filetype`, so the key must be `sql`
-- (an uppercase `SQL` key would never fire). The formatter id is
-- `sql_formatter` (conform's name); it wraps the `sql-formatter` executable.
sql = { 'sql_formatter' },
-- Wire in installed-but-previously-unused Mason tools:
java = { 'google-java-format' },
tex = { 'latexindent' },
plaintex = { 'latexindent' },
},
}

Expand Down Expand Up @@ -904,7 +953,7 @@ do
vim.pack.add { { src = gh 'nvim-treesitter/nvim-treesitter', version = 'main' } }

-- Ensure basic parsers are installed
local parsers = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }
local parsers = { 'bash', 'c', 'diff', 'html', 'latex', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }
require('nvim-treesitter').install(parsers)

---@param buf integer
Expand Down Expand Up @@ -966,17 +1015,17 @@ do
-- 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 recommended 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 recommended keymaps

-- NOTE: You can add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
--
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
-- require 'custom.plugins'
require 'custom.plugins'
end

-- The line beneath this is called `modeline`. See `:help modeline`
Expand Down
29 changes: 29 additions & 0 deletions lua/custom/plugins/nvim-java.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
-- nvim-java: full Java IDE layer on top of jdtls (tests, DAP, refactors, Spring Boot).
-- https://github.com/nvim-java/nvim-java
--
-- This file is loaded by the custom-plugins loader (lua/custom/plugins/init.lua),
-- which runs in Section 10 of init.lua -- AFTER the LSP section (Section 6). The LSP
-- section deliberately SKIPS jdtls in its `vim.lsp.config`/`vim.lsp.enable` loop, so
-- this is the single place jdtls is configured and enabled. That guarantees the
-- required order (`require('java').setup()` before `vim.lsp.enable('jdtls')`) and
-- avoids a second, competing vanilla jdtls setup.
--
-- Requirements (nvim-java README, vim.pack install): Neovim 0.11.5+. jdtls,
-- java-debug-adapter and java-test are provided via Mason -- jdtls from the LSP
-- section's mason-tool-installer, java-debug-adapter + java-test from
-- lua/kickstart/plugins/debug.lua (mason-nvim-dap). nvim-dap and nui.nvim are also
-- pulled in by debug.lua / neo-tree.lua respectively; re-listing them here is
-- idempotent and keeps this spec self-contained per the README.
vim.pack.add {
{ src = 'https://github.com/JavaHello/spring-boot.nvim', version = '218c0c26c14d99feca778e4d13f5ec3e8b1b60f0' },
'https://github.com/MunifTanjim/nui.nvim',
'https://github.com/mfussenegger/nvim-dap',
'https://github.com/nvim-java/nvim-java',
}

-- Must run BEFORE jdtls is enabled: it patches the jdtls config so the language
-- server is launched with the java-test / java-debug-adapter bundles.
require('java').setup()

-- Enable jdtls using the config nvim-java just registered (the new Neovim 0.11+ API).
vim.lsp.enable 'jdtls'
27 changes: 27 additions & 0 deletions lua/custom/plugins/vimtex.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-- VimTeX: LaTeX support (compile, view, errors)
-- https://github.com/lervag/vimtex
--
-- Ported from the user's lazy.nvim spec (lazy = false) to this base's `vim.pack`
-- imperative style. VimTeX reads its `vim.g.vimtex_*` settings when it is sourced,
-- so we set them BEFORE `vim.pack.add` loads the plugin (the equivalent of the old
-- lazy `init` hook).

-- Viewer settings (adjust based on your PDF viewer)
vim.g.vimtex_view_method = 'zathura' -- Use 'skim' on macOS, 'sumatra' on Windows, etc.

-- Compiler settings
vim.g.vimtex_compiler_method = 'latexmk' -- Default compiler backend

-- Optional: Disable some features if you don't need them
vim.g.vimtex_quickfix_enabled = 1 -- Enable quickfix window for errors
vim.g.vimtex_syntax_enabled = 1 -- Syntax highlighting (works with Tree-sitter too)

-- Set TeX flavor (usually not needed, but good to know)
vim.g.tex_flavor = 'latex'

vim.pack.add { 'https://github.com/lervag/vimtex' }

-- LaTeX keymaps (which-key group label is defined in init.lua: `<leader>l` = [L]aTeX)
vim.keymap.set('n', '<leader>ll', '<cmd>VimtexCompile<CR>', { desc = 'Compile LaTeX' })
vim.keymap.set('n', '<leader>lv', '<cmd>VimtexView<CR>', { desc = 'View PDF' })
vim.keymap.set('n', '<leader>le', '<cmd>VimtexErrors<CR>', { desc = 'Show Errors' })
2 changes: 2 additions & 0 deletions lua/kickstart/plugins/debug.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ require('mason-nvim-dap').setup {
ensure_installed = {
-- Update this to ensure that you have the debuggers for the langs you want
'delve',
'java-debug-adapter',
'java-test',
},
}

Expand Down
4 changes: 3 additions & 1 deletion lua/kickstart/plugins/lint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ vim.pack.add { 'https://github.com/mfussenegger/nvim-lint' }

local lint = require 'lint'
lint.linters_by_ft = {
markdown = { 'markdownlint' }, -- Make sure to install `markdownlint` via mason / npm
-- Only enable markdownlint if it is actually installed (it is not installed here),
-- otherwise nvim-lint errors on every markdown buffer.
markdown = vim.fn.executable 'markdownlint' == 1 and { 'markdownlint' } or {},
}

-- To allow other plugins to add linters to require('lint').linters_by_ft,
Expand Down
Loading