rewrite and additions

This commit is contained in:
2026-04-22 20:42:40 +02:00
parent 62f5f79ffd
commit 75d1243d0e
5 changed files with 262 additions and 292 deletions
+81
View File
@@ -0,0 +1,81 @@
local map = vim.keymap.set
local silent = { silent = true }
-- Visual line navigation
for _, mode in ipairs({ "n", "v" }) do
map(mode, "j", "gj", silent)
map(mode, "k", "gk", silent)
end
-- Hover: diagnostics on current line if any, else LSP hover
map("n", "K", function()
local line = vim.api.nvim_win_get_cursor(0)[1] - 1
if #vim.diagnostic.get(0, { lnum = line }) > 0 then
vim.diagnostic.open_float()
else
vim.lsp.buf.hover()
end
end, { desc = "Hover (diagnostic or LSP)" })
-- LSP
map("n", "<leader>gf",
function() require("conform").format({ lsp_format = "fallback" }) end,
{ desc = "Format buffer" })
map("n", "<leader>gd", vim.lsp.buf.definition)
map("n", "<leader>gD", vim.lsp.buf.declaration)
map("n", "<leader>ca", vim.lsp.buf.code_action, { desc = "Code Action" })
map("n", "<leader>rn", vim.lsp.buf.rename, { desc = "Rename symbol" })
-- Trouble
map("n", "<leader>xx", "<cmd>Trouble diagnostics toggle focus=true<cr>",
{ desc = "Diagnostics (Trouble)" })
map("n", "<leader>xX", "<cmd>Trouble diagnostics toggle filter.buf=0 focus=true<cr>",
{ desc = "Buffer Diagnostics (Trouble)" })
map("n", "<leader>xt", "<cmd>Trouble todo toggle<cr>", { desc = "Todo (Trouble)" })
-- Flash
map({ "n", "x", "o" }, "s", function() require("flash").jump() end, { desc = "Flash" })
map({ "n", "x", "o" }, "S", function() require("flash").treesitter() end, { desc = "Flash Treesitter" })
map("o", "r", function() require("flash").remote() end, { desc = "Remote Flash" })
-- Pickers / files
map("n", "<C-f>", "<cmd>Pick files<cr>")
map("n", "<C-g>", "<cmd>Pick grep_live<cr>")
map("n", "<C-h>", "<cmd>Pick help<cr>")
map("n", "<C-e>", "<cmd>Oil<cr>")
-- DAP
map("n", "<leader>duo", function() require("dapui").open() end)
map("n", "<leader>duc", function() require("dapui").close() end)
map("n", "<leader>dbp", function() require("dap").toggle_breakpoint() end)
map("n", "<leader>drc", function() require("dap").run_to_cursor() end)
-- Barbar
local bk = vim.fn.has("macunix") == 1 and "M" or "A"
local bar = {
[","] = "BufferPrevious", ["."] = "BufferNext",
["<"] = "BufferMovePrevious", [">"] = "BufferMoveNext",
["p"] = "BufferPin", ["w"] = "BufferClose",
["0"] = "BufferLast",
}
for k, cmd in pairs(bar) do
map("n", ("<%s-%s>"):format(bk, k), ("<cmd>%s<cr>"):format(cmd), silent)
end
for i = 1, 9 do
map("n", ("<%s-%d>"):format(bk, i), ("<cmd>BufferGoto %d<cr>"):format(i), silent)
end
map("n", "<C-p>", "<cmd>BufferPick<cr>", silent)
map("n", "<C-s-p>", "<cmd>BufferPickDelete<cr>", silent)
-- Spell
map("n", "<leader>sc", function()
vim.wo.spell = not vim.wo.spell
vim.notify("Spell: " .. (vim.wo.spell and "ON" or "OFF"))
end, { desc = "Toggle spell" })
map("n", "<leader>sl", function()
local cur = vim.opt.spelllang:get()[1] or ""
local new = cur == "en" and "de" or "en"
vim.opt.spelllang = new
vim.notify("Spell lang: " .. new)
end, { desc = "Switch spell language" })
+61
View File
@@ -0,0 +1,61 @@
-- Per-server overrides
vim.lsp.config("sourcekit", {
filetypes = { "swift", "objective-c", "objective-c++" },
})
vim.lsp.config("tinymist", {
cmd = { "tinymist" },
filetypes = { "typst" },
settings = { formatterMode = "typstyle" },
})
vim.lsp.enable({
"lua_ls", "ts_ls", "svelte", "tailwindcss", "cssls", "bashls",
"rust_analyzer", "clangd", "taplo", "sourcekit", "lemminx",
"tinymist", "jsonls", "hls", "pylsp", "vala_ls",
})
-- JDTLS (managed manually because it needs per-project workspace)
vim.api.nvim_create_autocmd("FileType", {
pattern = "java",
callback = function()
local jdtls = require("jdtls")
local data = vim.fn.stdpath("data")
local mason_jdtls = vim.fs.joinpath(data, "mason", "packages", "jdtls")
local workspace = vim.fs.joinpath(data, "jdtls-workspace",
vim.fn.fnamemodify(vim.fn.getcwd(), ":p:h:t"))
local sys = vim.uv.os_uname().sysname
local cfg_dir = sys == "Windows_NT" and "config_win"
or sys == "Linux" and "config_linux"
or "config_mac"
local launcher = vim.fn.glob(vim.fs.joinpath(
mason_jdtls, "plugins", "org.eclipse.equinox.launcher_*.jar"))
jdtls.start_or_attach({
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",
"-jar", launcher,
"-configuration", vim.fs.joinpath(mason_jdtls, cfg_dir),
"-data", workspace,
},
root_dir = vim.fs.root(0, { ".git", "mvnw", "gradlew" }),
settings = { java = {} },
init_options = {
bundles = {
vim.fn.glob(vim.fs.joinpath(data, "mason", "share",
"java-debug-adapter", "com.microsoft.java.debug.plugin.jar")),
},
},
})
end,
})
+17
View File
@@ -0,0 +1,17 @@
vim.g.mapleader = " "
local o = vim.o
o.number = true
o.relativenumber = true
o.tabstop = 4
o.shiftwidth = 4
o.expandtab = true
o.signcolumn = "yes"
o.swapfile = false
o.winborder = "single"
o.termguicolors = true
vim.diagnostic.config({
virtual_text = { prefix = "", spacing = 2, source = "if_many" },
severity_sort = true,
})
+99
View File
@@ -0,0 +1,99 @@
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/nvim-treesitter/nvim-treesitter-textobjects" },
{ src = "https://github.com/Saghen/blink.cmp", version = "v1.7.0" },
{ src = "https://github.com/mason-org/mason.nvim" },
{ src = "https://github.com/nvim-lualine/lualine.nvim.git" },
{ src = "https://github.com/chomosuke/typst-preview.nvim" },
{ src = "https://codeberg.org/mfussenegger/nvim-jdtls.git" },
{ src = "https://github.com/windwp/nvim-autopairs" },
{ src = "https://codeberg.org/mfussenegger/nvim-dap.git" },
{ src = "https://github.com/romgrk/barbar.nvim" },
{ src = "https://github.com/nvim-tree/nvim-web-devicons" },
{ src = "https://github.com/echasnovski/mini.ai" },
{ src = "https://github.com/windwp/nvim-ts-autotag" },
{ src = "https://github.com/folke/todo-comments.nvim" },
{ src = "https://github.com/stevearc/conform.nvim" },
{ src = "https://github.com/folke/flash.nvim" },
{ src = "https://github.com/lewis6991/gitsigns.nvim" },
{ src = "https://github.com/folke/trouble.nvim" },
{ src = "https://github.com/nvim-neotest/nvim-nio" },
{ src = "https://github.com/rcarriga/nvim-dap-ui" },
})
pcall(vim.cmd.colorscheme, "gruvbox")
-- Simple setup({}) plugins
for _, name in ipairs({
"oil", "mini.pick", "mason", "typst-preview", "nvim-autopairs",
"trouble", "gitsigns", "nvim-web-devicons", "barbar",
"mini.ai", "nvim-ts-autotag", "todo-comments", "flash",
}) do
pcall(function() require(name).setup() end)
end
require("conform").setup({
formatters_by_ft = {
python = { "black" },
c = { "clang-format" },
cpp = { "clang-format" },
java = { "clang-format" },
javascript = { "prettierd", "prettier", stop_after_first = true },
typescript = { "prettierd", "prettier", stop_after_first = true },
svelte = { "prettierd", "prettier", stop_after_first = true },
css = { "prettierd", "prettier", stop_after_first = true },
html = { "prettierd", "prettier", stop_after_first = true },
json = { "prettierd", "prettier", stop_after_first = true },
},
format_on_save = { timeout_ms = 500, lsp_format = "fallback" },
})
require("lualine").setup({ options = { theme = "gruvbox_dark" } })
require("blink.cmp").setup({ keymap = { preset = "super-tab" } })
-- Treesitter (main branch: no configs.setup; install parsers manually)
require("nvim-treesitter").install({
"lua", "vim", "vimdoc", "bash", "c", "cpp", "rust", "python",
"javascript", "typescript", "tsx", "svelte", "css", "html",
"json", "toml", "yaml", "markdown", "markdown_inline",
"java", "typst", "vala",
})
vim.api.nvim_create_autocmd("FileType", {
callback = function() pcall(vim.treesitter.start) end,
})
-- TS textobjects
local tso = require("nvim-treesitter-textobjects.select")
local textobj = { af = "@function.outer", ["if"] = "@function.inner",
ac = "@class.outer", ic = "@class.inner" }
for lhs, query in pairs(textobj) do
vim.keymap.set({ "x", "o" }, lhs,
function() tso.select_textobject(query, "textobjects") end)
end
-- Mason: ensure tools
local registry = require("mason-registry")
local ensure = {
"bash-language-server", "clang-format", "clangd", "java-debug-adapter",
"jdtls", "json-lsp", "lua-language-server", "rust-analyzer",
"svelte-language-server", "tailwindcss-language-server", "taplo",
"typescript-language-server", "pylsp", "black", "vala",
"prettierd",
}
registry.refresh(function()
for _, tool in ipairs(ensure) do
local ok, pkg = pcall(registry.get_package, tool)
if ok and not pkg:is_installed() then pkg:install() end
end
end)
-- DAP UI wiring
local dap, dapui = require("dap"), require("dapui")
dapui.setup()
dap.listeners.before.attach.dapui_config = function() dapui.open() end
dap.listeners.before.launch.dapui_config = function() dapui.open() end