wrote source code
This commit is contained in:
113
init.lua
Normal file
113
init.lua
Normal file
@@ -0,0 +1,113 @@
|
||||
-- ~/.config/nvim/init.lua
|
||||
|
||||
-- 1. BOOTSTRAP PAQ (Der Manager selbst)
|
||||
local data_path = vim.fn.stdpath("data") .. "/site/pack/paqs/start/"
|
||||
local paq_path = data_path .. "paq-nvim"
|
||||
|
||||
if vim.fn.empty(vim.fn.glob(paq_path)) > 0 then
|
||||
print("Installiere Paq...")
|
||||
vim.fn.system({ "git", "clone", "--depth=1", "https://github.com/savq/paq-nvim.git", paq_path })
|
||||
vim.cmd("packadd paq-nvim")
|
||||
end
|
||||
|
||||
-- 2. PLUGINS LADEN
|
||||
local plugins = require("plugins")
|
||||
local paq = require("paq")
|
||||
paq(plugins)
|
||||
|
||||
-- 3. AUTO-CHECK FÜR NEUE PLUGINS
|
||||
local missing_plugins = false
|
||||
for _, plugin in ipairs(plugins) do
|
||||
local name = plugin:match(".*/(.*)")
|
||||
if name and vim.fn.empty(vim.fn.glob(data_path .. name)) > 0 then
|
||||
missing_plugins = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if missing_plugins then paq.install() end
|
||||
|
||||
-- 4. DEINE RUHE-OPTIONEN (A11y / Screenreader optimiert)
|
||||
local opt = vim.opt
|
||||
opt.number = false -- Keine Zeilennummern
|
||||
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
|
||||
|
||||
-- 6. KEYMAPS (LEADER-TASTE)
|
||||
vim.g.mapleader = " "
|
||||
vim.keymap.set("n", "<leader>e", vim.diagnostic.setqflist) -- Fehler in Liste zeigen
|
||||
-- Leertaste + b öffnet das Dashboard
|
||||
vim.keymap.set("n", "<leader>b", function()
|
||||
local ok, dashboard = pcall(require, "config.dashboard")
|
||||
if ok then
|
||||
dashboard.open()
|
||||
else
|
||||
print("Dashboard konnte nicht geladen werden!")
|
||||
end
|
||||
end, { desc = "Zurück zum Dashboard" })
|
||||
local updater =require("core.update")
|
||||
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
|
||||
|
||||
-- 8. DASHBOARD LOGIK (VERHINDERT LEERE BUFFER)
|
||||
local function force_dashboard()
|
||||
vim.schedule(function()
|
||||
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
|
||||
local ok_dash, dashboard = pcall(require, "config.dashboard")
|
||||
if ok_dash then
|
||||
dashboard.open()
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
-- LAZYVIM-STYLE CLOSE: Leertaste + d
|
||||
vim.keymap.set("n", "<leader>d", function()
|
||||
if vim.bo.modified then
|
||||
local choice = vim.fn.confirm("Änderungen speichern?", "&Ja\n&Nein\n&Abbrechen", 1)
|
||||
if choice == 1 then
|
||||
vim.cmd("write")
|
||||
if ok_mini then bufremove.delete(0, false) else vim.cmd("bd") end
|
||||
elseif choice == 2 then
|
||||
if ok_mini then bufremove.delete(0, true) else vim.cmd("bd!") end
|
||||
end
|
||||
else
|
||||
if ok_mini then bufremove.delete(0, false) else vim.cmd("bd") end
|
||||
end
|
||||
end, { desc = "Buffer schließen und Dashboard prüfen" })
|
||||
|
||||
-- 9. AUTOCMDS FÜR DAS DASHBOARD
|
||||
-- Beim Starten ohne Datei
|
||||
vim.api.nvim_create_autocmd("VimEnter", {
|
||||
callback = function()
|
||||
if vim.fn.argc() == 0 and vim.api.nvim_buf_get_name(0) == "" then
|
||||
force_dashboard()
|
||||
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
Normal file
BIN
lua/.DS_Store
vendored
Normal file
Binary file not shown.
67
lua/config/dashboard.lua
Normal file
67
lua/config/dashboard.lua
Normal file
@@ -0,0 +1,67 @@
|
||||
local M = {}
|
||||
|
||||
-- Hilfsfunktion zum Zeichnen des Menüs
|
||||
local function draw_menu(lines, keymaps)
|
||||
local buf = vim.api.nvim_create_buf(false, true)
|
||||
vim.api.nvim_buf_set_lines(buf, 0, -1, false, lines)
|
||||
vim.api.nvim_set_current_buf(buf)
|
||||
|
||||
-- Lokale Einstellungen für das Menü-Fenster
|
||||
vim.opt_local.number = false
|
||||
vim.opt_local.relativenumber = false
|
||||
vim.opt_local.buftype = "nofile"
|
||||
vim.opt_local.bufhidden = "wipe"
|
||||
vim.opt_local.cursorline = true
|
||||
|
||||
-- Keymaps für dieses Menü setzen
|
||||
local opts = { buffer = buf, noremap = true, silent = true }
|
||||
for key, cmd in pairs(keymaps) do
|
||||
vim.keymap.set("n", key, cmd, opts)
|
||||
end
|
||||
end
|
||||
|
||||
-- Das Plugin-Untermenü (wird bei 'p' aufgerufen)
|
||||
function M.open_plugins_menu()
|
||||
local lines = {
|
||||
" PLUGINS VERWALTEN",
|
||||
"========================",
|
||||
"",
|
||||
" [u] Update (Sync)",
|
||||
" [i] Install",
|
||||
" [a] Add (Öffne Liste)",
|
||||
" [b] Zurück",
|
||||
"",
|
||||
"========================",
|
||||
}
|
||||
local keys = {
|
||||
u = ":PaqSync<CR>",
|
||||
i = ":PaqInstall<CR>",
|
||||
a = ":edit ~/.config/nvim/lua/plugins.lua<CR>",
|
||||
b = function() M.open() end, -- Geht zurück zum Hauptmenü
|
||||
}
|
||||
draw_menu(lines, keys)
|
||||
end
|
||||
|
||||
-- Das Hauptmenü
|
||||
function M.open()
|
||||
local lines = {
|
||||
" Mono VIM - 0.16",
|
||||
"========================",
|
||||
"",
|
||||
" [n] New File",
|
||||
" [r] Recent Files",
|
||||
" [p] Plugins...",
|
||||
" [q] Quit",
|
||||
"",
|
||||
"========================",
|
||||
}
|
||||
local keys = {
|
||||
n = ":ene | startinsert<CR>",
|
||||
r = ":oldfiles<CR>",
|
||||
p = function() M.open_plugins_menu() end,
|
||||
q = ":q!<CR>",
|
||||
}
|
||||
draw_menu(lines, keys)
|
||||
end
|
||||
|
||||
return M
|
||||
18
lua/core/update.lua
Normal file
18
lua/core/update.lua
Normal file
@@ -0,0 +1,18 @@
|
||||
-- ~/.config/nvim/lua/monovim/updater.lua
|
||||
local M = {}
|
||||
|
||||
M.update = function()
|
||||
print("MonoVim Core wird aktualisiert...")
|
||||
local config_path = vim.fn.stdpath("config")
|
||||
local handle = io.popen("cd " .. config_path .. " && git pull 2>&1")
|
||||
local result = handle:read("*a")
|
||||
handle:close()
|
||||
|
||||
if result:find("Already up to date") then
|
||||
print("MonoVim ist bereits aktuell.")
|
||||
else
|
||||
print("Update erfolgreich! Bitte neu starten.")
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
7
lua/plugins.lua
Normal file
7
lua/plugins.lua
Normal file
@@ -0,0 +1,7 @@
|
||||
return {
|
||||
"savq/paq-nvim", -- Der Manager selbst
|
||||
"neovim/nvim-lspconfig", -- LSP Support
|
||||
"nvim-treesitter/nvim-treesitter", -- Syntax Highlighting
|
||||
"tpope/vim-fugitive",
|
||||
"echasnovski/mini.nvim",
|
||||
}
|
||||
Reference in New Issue
Block a user