-- VIM OPTIONS START -- local vim = vim vim.o.number = true vim.o.relativenumber = true vim.o.tabstop = 4 vim.o.shiftwidth = 4 vim.o.expandtab = true vim.o.signcolumn = "yes" vim.o.swapfile = false vim.g.mapleader = " " vim.o.winborder = "single" -- Make 'j' and 'k' navigate visual lines (not logical lines) vim.keymap.set("n", "j", "gj", { noremap = true, silent = true }) vim.keymap.set("n", "k", "gk", { noremap = true, silent = true }) vim.keymap.set("v", "j", "gj", { noremap = true, silent = true }) vim.keymap.set("v", "k", "gk", { noremap = true, silent = true }) -- VIM OPTIONS END -- -- PLUGINS START -- vim.pack.add({ { src = "https://github.com/ellisonleao/gruvbox.nvim" }, { src = "https://github.com/stevearc/oil.nvim" }, { src = "https://github.com/echasnovski/mini.pick" }, { src = "https://github.com/neovim/nvim-lspconfig" }, { src = "https://github.com/nvim-treesitter/nvim-treesitter" }, { src = "https://github.com/Saghen/blink.cmp", version = "v1.6.0", }, { src = "https://github.com/mason-org/mason.nvim" }, { src = "https://github.com/dimitry-ishenko-neovim/lualine-nvim" }, { src = "https://github.com/chomosuke/typst-preview.nvim" }, { src = "https://github.com/kosayoda/nvim-lightbulb" }, { src = "https://codeberg.org/mfussenegger/nvim-jdtls.git" }, { src = "https://github.com/m4xshen/autoclose.nvim" }, { src = "https://codeberg.org/mfussenegger/nvim-dap.git" }, }) vim.cmd("colorscheme gruvbox") require("oil").setup() require("mini.pick").setup() require("blink.cmp").setup({ keymap = { preset = "super-tab" }, }) require("nvim-treesitter.configs").setup({ auto_install = true, highlight = { enable = true }, indent = { enable = true }, }) require("mason").setup() require("lualine").setup { options = { theme = "gruvbox_dark", } } require("typst-preview").setup() require("nvim-lightbulb").setup({ autocmd = { enabled = true } }) require("autoclose").setup() -- PLUGINS END -- -- LSP START -- vim.lsp.enable({ "lua_ls", "ts_ls", "svelte", "tailwindcss", "cssls", "bashls", "rust_analyzer", "clangd", "clang-format", "taplo", "sourcekit", "lemminx", "tinymist", "jsonls" }) vim.lsp.config["tinymist"] = { cmd = { "tinymist" }, filetypes = { "typst" }, settings = { formatterMode = "typstyle", }, } vim.lsp.config("jdtls", { root_dir = vim.fn.getcwd(), settings = { java = { }, }, }) vim.api.nvim_create_autocmd('FileType', { pattern = 'java', callback = function(args) local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":p:h:t") local workspace_dir = vim.fn.stdpath("data") .. package.config:sub(1, 1) .. "jdtls-workspace" .. package.config:sub(1, 1) .. project_name local os_name = vim.loop.os_uname().sysname local config = { -- The command that starts the language server -- See: https://github.com/eclipse/eclipse.jdt.ls#running-from-the-command-line cmd = { -- 💀 "java", -- or '/path/to/java17_or_newer/bin/java' -- depends on if `java` is in your $PATH env variable and if it points to the right version. "-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", -- 💀 "-jar", vim.fn.stdpath("data") .. package.config:sub(1, 1) .. "mason" .. package.config:sub(1, 1) .. "packages" .. package.config:sub(1, 1) .. "jdtls" .. package.config:sub(1, 1) .. "plugins" .. package.config:sub(1, 1) .. "org.eclipse.equinox.launcher_1.7.100.v20251014-1222.jar", -- Must point to the Change this to -- eclipse.jdt.ls installation the actual version -- 💀 "-configuration", vim.fn.stdpath("data") .. package.config:sub(1, 1) .. "mason" .. package.config:sub(1, 1) .. "packages" .. package.config:sub(1, 1) .. "jdtls" .. package.config:sub(1, 1) .. "config_" .. (os_name == "Windows_NT" and "win" or os_name == "Linux" and "linux" or "mac"), -- eclipse.jdt.ls installation Depending on your system. -- 💀 -- See `data directory configuration` section in the README "-data", workspace_dir, }, -- 💀 -- This is the default if not provided, you can remove it. Or adjust as needed. -- One dedicated LSP server & client will be started per unique root_dir root_dir = require("jdtls.setup").find_root({ ".git", "mvnw", "gradlew" }), -- Here you can configure eclipse.jdt.ls specific settings -- See https://github.com/eclipse/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request -- for a list of options settings = { java = {}, }, -- Language server `initializationOptions` -- You need to extend the `bundles` with paths to jar files -- if you want to use additional eclipse.jdt.ls plugins. -- -- See https://github.com/mfussenegger/nvim-jdtls#java-debug-installation -- -- If you don't plan on using the debugger or other eclipse.jdt.ls plugins you can remove this init_options = { bundles = { vim.fn.glob("/home/jannikdonker/.local/share/nvim/mason/share/java-debug-adapter/com.microsoft.java.debug.plugin.jar", 1) }, }, } -- This starts a new client & server, -- or attaches to an existing client & server depending on the `root_dir`. require("jdtls").start_or_attach(config) end }) -- LSP END -- -- KEYMAP START -- vim.keymap.set("n", "gf", vim.lsp.buf.format) vim.keymap.set("n", "gd", vim.lsp.buf.definition) vim.keymap.set("n", "gD", vim.lsp.buf.declaration) vim.keymap.set("n", "ca", vim.lsp.buf.code_action, { desc = "Code Action" }) vim.keymap.set("n", "rn", vim.lsp.buf.rename, { desc = "Rename symbol" }) vim.keymap.set("n", "", ":Pick files") vim.keymap.set("n", "", ":Pick grep_live") vim.keymap.set("n", "", ":Pick help") vim.keymap.set("n", "", ":Oil") vim.keymap.set("n", "dg", function() vim.diagnostic.setqflist() vim.cmd("copen") end, { desc = "Show diagnostics in quickfix list" }) vim.keymap.set("n", "qf>", function() local qf_win = vim.fn.getwininfo(vim.fn.getqflist({ winid = 0 }).winid) if not qf_win or #qf_win == 0 then vim.cmd("copen") else vim.cmd("cclose") end end, { desc = "Toggle quickfix list" }) -- KEYMAP END -- vim.diagnostic.config({ virtual_text = { prefix = "●", spacing = 2, source = "if_many", }, severity_sort = true, }) -- Toggle spell check with sc vim.keymap.set("n", "sc", function() vim.wo.spell = not vim.wo.spell print("Spell checking: " .. (vim.wo.spell and "ON" or "OFF")) end, { desc = "Toggle spell checking" }) -- Switch between English and German with sl vim.keymap.set("n", "sl", function() local current = vim.opt.spelllang:get()[1] or "" local new_lang = current == "en" and "de" or "en" vim.opt.spelllang = new_lang print("Spell language: " .. new_lang) end, { desc = "Switch spell language" })