added Mason for lsp management

This commit is contained in:
2026-04-08 01:46:06 +02:00
parent 31501f1737
commit fdb4f984d6
3 changed files with 125 additions and 67 deletions

176
init.lua
View File

@@ -1,6 +1,8 @@
-- ~/.config/nvim/init.lua -- ~/.config/nvim/init.lua
-- 1. BOOTSTRAP PAQ (Der Manager selbst) -- =============================================================================
-- 1. BOOTSTRAP PAQ (Plugin Manager Installation)
-- =============================================================================
local data_path = vim.fn.stdpath("data") .. "/site/pack/paqs/start/" local data_path = vim.fn.stdpath("data") .. "/site/pack/paqs/start/"
local paq_path = data_path .. "paq-nvim" local paq_path = data_path .. "paq-nvim"
@@ -10,104 +12,158 @@ if vim.fn.empty(vim.fn.glob(paq_path)) > 0 then
vim.cmd("packadd paq-nvim") vim.cmd("packadd paq-nvim")
end end
-- 2. PLUGINS LADEN -- =============================================================================
-- 2. PLUGINS LADEN & AUTO-INSTALL
-- =============================================================================
local plugins = require("plugins") local plugins = require("plugins")
local paq = require("paq") local paq = require("paq")
paq(plugins) paq(plugins)
-- 3. AUTO-CHECK FÜR NEUE PLUGINS
local missing_plugins = false local missing_plugins = false
for _, plugin in ipairs(plugins) do for _, plugin in ipairs(plugins) do
local name = plugin:match(".*/(.*)") local plugin_name = type(plugin) == "table" and plugin[1] or plugin
local name = plugin_name:match(".*/(.*)")
if name and vim.fn.empty(vim.fn.glob(data_path .. name)) > 0 then if name and vim.fn.empty(vim.fn.glob(data_path .. name)) > 0 then
missing_plugins = true missing_plugins = true
break break
end end
end end
if missing_plugins then paq.install() end
-- 4. DEINE RUHE-OPTIONEN (A11y / Screenreader optimiert) if missing_plugins then
local opt = vim.opt print("Neue Plugins gefunden. Installiere... Bitte danach Neovim neu starten.")
opt.number = false -- Keine Zeilennummern paq.install()
opt.relativenumber = false -- Keine relativen Nummern
opt.showcmd = false -- Keine Anzeige unfertiger Befehle
opt.laststatus = 0 -- Statuszeile aus (weniger Lärm)
opt.ruler = false -- Keine Cursor-Position unten rechts
opt.showmode = false -- "-- INSERT --" Anzeige aus
opt.mouse = "" -- Maus deaktiviert
opt.shortmess:append("atI") -- Kürzere Meldungen, kein Intro-Screen
opt.hidden = true -- Buffer im Hintergrund erlauben
-- 5. LSP SCHUTZ & DIAGNOSTICS
local ok_lsp, lspconfig = pcall(require, "lspconfig")
if ok_lsp then
vim.diagnostic.config({
virtual_text = false, -- Verhindert, dass Text in der Zeile "schwebt"
underline = true, -- Fehler werden unterstrichen
signs = false, -- Keine Icons am Rand
})
end end
-- 6. KEYMAPS (LEADER-TASTE) -- =============================================================================
-- 3. EDITOR OPTIONEN (A11y / Screenreader optimiert)
-- =============================================================================
local opt = vim.opt
opt.number = false
opt.relativenumber = false
opt.showcmd = false
opt.laststatus = 0
opt.ruler = false
opt.showmode = false
opt.mouse = ""
opt.shortmess:append("atI")
opt.hidden = true
opt.termguicolors = true -- Wichtig für moderne LSPs/UI
-- =============================================================================
-- 4. DIAGNOSTICS (Fehleranzeige)
-- =============================================================================
vim.diagnostic.config({
virtual_text = false, -- Kein Text-Rauschen in der Zeile
underline = true, -- Fehler werden unterstrichen
signs = false, -- Keine Icons am Rand (weniger Lärm)
update_in_insert = false,
})
-- =============================================================================
-- 5. KEYMAPS (Leader: Leertaste)
-- =============================================================================
vim.g.mapleader = " " vim.g.mapleader = " "
vim.keymap.set("n", "<leader>e", vim.diagnostic.setqflist) -- Fehler in Liste zeigen
-- Leertaste + b öffnet das Dashboard -- Fehlerliste (Quickfix) öffnen
vim.keymap.set("n", "<leader>e", vim.diagnostic.setqflist, { desc = "Fehlerliste zeigen" })
-- Dashboard öffnen
vim.keymap.set("n", "<leader>b", function() vim.keymap.set("n", "<leader>b", function()
local ok, dashboard = pcall(require, "config.dashboard") local ok, dashboard = pcall(require, "config.dashboard")
if ok then if ok then dashboard.open() else print("Dashboard nicht gefunden!") end
dashboard.open()
else
print("Dashboard konnte nicht geladen werden!")
end
end, { desc = "Zurück zum Dashboard" }) end, { desc = "Zurück zum Dashboard" })
local updater =require("core.update")
-- Core Update
local ok_up, updater = pcall(require, "core.update")
if ok_up then
vim.keymap.set("n", "<leader>U", updater.update, { desc = "Update MonoVim Core" }) vim.keymap.set("n", "<leader>U", updater.update, { desc = "Update MonoVim Core" })
-- 7. MINI.BUFREMOVE SETUP
local ok_mini, bufremove = pcall(require, "mini.bufremove")
if ok_mini then
bufremove.setup({})
end end
-- 8. DASHBOARD LOGIK (VERHINDERT LEERE BUFFER) -- =============================================================================
-- 6. MASON & LSP SETUP (VERZÖGERT FÜR STABILITÄT)
-- =============================================================================
vim.schedule(function()
local ok_mason, mason = pcall(require, "mason")
local ok_mason_lsp, mason_lspconfig = pcall(require, "mason-lspconfig")
local ok_lspconfig, lspconfig = pcall(require, "lspconfig")
if ok_mason and ok_mason_lsp and ok_lspconfig then
mason.setup({
ui = { border = "rounded" }
})
mason_lspconfig.setup({
ensure_installed = { "basedpyright", "rust_analyzer", "lua_ls" },
})
-- Sicherheitscheck: Existiert die Funktion wirklich?
if mason_lspconfig.setup_handlers then
mason_lspconfig.setup_handlers({
-- Standard-Handler für jeden installierten Server
function(server_name)
local opts = {}
-- Falls nvim-cmp für Autovervollständigung genutzt wird
local ok_cmp, cmp_lsp = pcall(require, "cmp_nvim_lsp")
if ok_cmp then
opts.capabilities = cmp_lsp.default_capabilities()
end
lspconfig[server_name].setup(opts)
end,
-- Spezial-Konfiguration für Lua (verhindert 'vim' Warnungen)
["lua_ls"] = function()
lspconfig.lua_ls.setup({
settings = {
Lua = {
diagnostics = { globals = { "vim" } }
}
}
})
end,
})
end
end
end)
-- =============================================================================
-- 7. BUFFER MANAGEMENT & DASHBOARD LOGIK
-- =============================================================================
local ok_mini, bufremove = pcall(require, "mini.bufremove")
if ok_mini then bufremove.setup({}) end
local function force_dashboard() local function force_dashboard()
vim.schedule(function() vim.schedule(function()
local listed = vim.fn.getbufinfo({buflisted = 1}) local listed = vim.fn.getbufinfo({buflisted = 1})
-- Wenn keine Buffer mehr da sind ODER nur noch ein leerer Buffer existiert
if #listed == 0 or (#listed == 1 and listed[1].name == "" and vim.bo[listed[1].bufnr].filetype == "") then if #listed == 0 or (#listed == 1 and listed[1].name == "" and vim.bo[listed[1].bufnr].filetype == "") then
local ok_dash, dashboard = pcall(require, "config.dashboard") local ok_dash, dashboard = pcall(require, "config.dashboard")
if ok_dash then if ok_dash then dashboard.open() end
dashboard.open()
end
end end
end) end)
end end
-- LAZYVIM-STYLE CLOSE: Leertaste + d -- Buffer schließen (Speichern-Abfrage integriert)
vim.keymap.set("n", "<leader>d", function() vim.keymap.set("n", "<leader>d", function()
if vim.bo.modified then if vim.bo.modified then
local choice = vim.fn.confirm("Änderungen speichern?", "&Ja\n&Nein\n&Abbrechen", 1) local choice = vim.fn.confirm("Änderungen speichern?", "&Ja\n&Nein\n&Abbrechen", 1)
if choice == 1 then if choice == 1 then
vim.cmd("write") vim.cmd("write")
if ok_mini then bufremove.delete(0, false) else vim.cmd("bd") end elseif choice == 3 then
elseif choice == 2 then return
if ok_mini then bufremove.delete(0, true) else vim.cmd("bd!") end
end end
else
if ok_mini then bufremove.delete(0, false) else vim.cmd("bd") end
end end
end, { desc = "Buffer schließen und Dashboard prüfen" })
-- 9. AUTOCMDS FÜR DAS DASHBOARD if ok_mini then
-- Beim Starten ohne Datei bufremove.delete(0, true)
vim.api.nvim_create_autocmd("VimEnter", { else
vim.cmd("bd!")
end
end, { desc = "Buffer schließen" })
-- Autocommands für Dashboard (beim Start und beim Löschen von Buffern)
vim.api.nvim_create_autocmd({ "VimEnter", "BufDelete" }, {
callback = function() callback = function()
if vim.fn.argc() == 0 and vim.api.nvim_buf_get_name(0) == "" then
force_dashboard() force_dashboard()
end end
end,
})
-- Wenn ein Buffer gelöscht wird (z.B. durch :bd oder <leader>d)
vim.api.nvim_create_autocmd("BufDelete", {
callback = force_dashboard
}) })

BIN
lua/.DS_Store vendored

Binary file not shown.

View File

@@ -2,6 +2,8 @@ return {
"savq/paq-nvim", -- Der Manager selbst "savq/paq-nvim", -- Der Manager selbst
"neovim/nvim-lspconfig", -- LSP Support "neovim/nvim-lspconfig", -- LSP Support
"nvim-treesitter/nvim-treesitter", -- Syntax Highlighting "nvim-treesitter/nvim-treesitter", -- Syntax Highlighting
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
"tpope/vim-fugitive", "tpope/vim-fugitive",
"echasnovski/mini.nvim", "echasnovski/mini.nvim",
} }