aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Schmucker <ts@its1.de>2025-12-22 17:37:13 +0100
committerThomas Schmucker <ts@its1.de>2025-12-22 17:37:13 +0100
commite8bd36899b88285c94c850f0dfce0754d94cfe24 (patch)
treeaa857a427db278888233ab03cad59b138d16eaa8
parent6f6457b7397247a34e25d4d9bfca434d8306283e (diff)
downloaddotfiles-e8bd36899b88285c94c850f0dfce0754d94cfe24.tar.gz
dotfiles-e8bd36899b88285c94c850f0dfce0754d94cfe24.tar.bz2
dotfiles-e8bd36899b88285c94c850f0dfce0754d94cfe24.zip
Neovim: Neue Konfiguration
-rw-r--r--nvim/ftplugin/lua.lua6
-rw-r--r--nvim/init.lua8
-rw-r--r--nvim/lua/config/autocmds.lua56
-rw-r--r--nvim/lua/config/keymaps.lua94
-rw-r--r--nvim/lua/config/lazy.lua29
-rw-r--r--nvim/lua/config/options.lua110
-rw-r--r--nvim/lua/plugins/editing.lua20
-rw-r--r--nvim/lua/plugins/git.lua7
-rw-r--r--nvim/lua/plugins/lsp.lua29
-rw-r--r--nvim/lua/plugins/telescope.lua9
-rw-r--r--nvim/lua/plugins/treesitter.lua29
-rw-r--r--nvim/lua/plugins/ui.lua58
12 files changed, 455 insertions, 0 deletions
diff --git a/nvim/ftplugin/lua.lua b/nvim/ftplugin/lua.lua
new file mode 100644
index 0000000..0883a50
--- /dev/null
+++ b/nvim/ftplugin/lua.lua
@@ -0,0 +1,6 @@
1local opt = vim.opt_local
2
3opt.expandtab = true
4opt.shiftwidth = 2
5opt.tabstop = 2
6opt.softtabstop = 2
diff --git a/nvim/init.lua b/nvim/init.lua
new file mode 100644
index 0000000..d148f6b
--- /dev/null
+++ b/nvim/init.lua
@@ -0,0 +1,8 @@
1require("config.options")
2
3local keymaps = require("config.keymaps")
4keymaps.global()
5keymaps.telescope()
6
7require("config.autocmds")
8require("config.lazy")
diff --git a/nvim/lua/config/autocmds.lua b/nvim/lua/config/autocmds.lua
new file mode 100644
index 0000000..e11b231
--- /dev/null
+++ b/nvim/lua/config/autocmds.lua
@@ -0,0 +1,56 @@
1-- https://github.com/nvim-treesitter/nvim-treesitter/blob/main/doc/nvim-treesitter.txt
2vim.api.nvim_create_autocmd('FileType', {
3 pattern = { "c", "cpp", "lua", "typescript" },
4 callback = function()
5 vim.treesitter.start()
6 vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
7 vim.wo.foldmethod = 'expr'
8 vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
9 end,
10})
11
12-- https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup
13vim.api.nvim_create_autocmd("VimEnter", {
14 callback = function(data)
15 -- buffer is a real file on the disk
16 local real_file = vim.fn.filereadable(data.file) == 1
17
18 -- buffer is a [No Name]
19 local no_name = data.file == "" and vim.bo[data.buf].buftype == ""
20
21 if not real_file and not no_name then
22 return
23 end
24
25 -- open the tree, find the file but don't focus it
26 require("nvim-tree.api").tree.toggle({ focus = false, find_file = true, })
27 end
28})
29
30-- https://github.com/nvim-tree/nvim-tree.lua/wiki/Auto-Close
31vim.api.nvim_create_autocmd("QuitPre", {
32 callback = function()
33 local invalid_win = {}
34 local wins = vim.api.nvim_list_wins()
35
36 for _, w in ipairs(wins) do
37 local bufname = vim.api.nvim_buf_get_name(vim.api.nvim_win_get_buf(w))
38 if bufname:match("NvimTree_") ~= nil then
39 table.insert(invalid_win, w)
40 end
41 end
42
43 if #invalid_win == #wins - 1 then
44 -- Should quit, so we close all invalid windows.
45 for _, w in ipairs(invalid_win) do vim.api.nvim_win_close(w, true) end
46 end
47 end
48})
49
50vim.api.nvim_create_autocmd("LspAttach", {
51 callback = function(event)
52 local client = vim.lsp.get_client_by_id(event.data.client_id)
53 local keymaps = require("config.keymaps")
54 keymaps.lsp(event.buf, client)
55 end,
56})
diff --git a/nvim/lua/config/keymaps.lua b/nvim/lua/config/keymaps.lua
new file mode 100644
index 0000000..c54247c
--- /dev/null
+++ b/nvim/lua/config/keymaps.lua
@@ -0,0 +1,94 @@
1local M = {}
2
3local map = vim.keymap.set
4
5function M.lsp(buffer, client)
6 local opts = {
7 buffer = buffer,
8 noremap = true,
9 silent = true,
10 }
11
12 map("n", "gd", vim.lsp.buf.definition, opts)
13 map("n", "gD", vim.lsp.buf.declaration, opts)
14 map("n", "gr", vim.lsp.buf.references, opts)
15 map("n", "gi", vim.lsp.buf.implementation, opts)
16 map("n", "K", vim.lsp.buf.hover, opts)
17 map("n", "<leader>rn", vim.lsp.buf.rename, opts)
18 map("n", "<leader>ca", vim.lsp.buf.code_action, opts)
19 map("n", "<leader>cf", function() vim.lsp.buf.format({ async = true; }) end, opts)
20
21 if client and client.name == "clangd" then
22 map("n", "<leader>hs", "<cmd>ClangdSwitchSourceHeader<cr>", opts)
23 end
24end
25
26function M.telescope()
27 local opts = {
28 noremap = true,
29 silent = true,
30 }
31
32 map("n", "<leader>ff", function()
33 require("telescope.builtin").find_files()
34 end, opts)
35
36 map("n", "<leader>fg", function()
37 require("telescope.builtin").live_grep()
38 end, opts)
39
40 map("n", "<leader>fb", function()
41 require("telescope.builtin").buffers()
42 end, opts)
43
44 map("n", "<leader>fh", function()
45 require("telescope.builtin").help_tags()
46 end, opts)
47
48 map("n", "<leader>dd", function()
49 require("telescope.builtin").diagnostics()
50 end, opts)
51end
52
53function M.global()
54 local opts = {
55 noremap = true,
56 silent = true,
57 }
58
59 map("n", "ö", "}", opts)
60 map("n", "ä", "{", opts)
61
62 map("n", "<leader>K", function()
63 vim.diagnostic.open_float({ scope = "cursor", border = "rounded" })
64 end, opts)
65 map("n", "<leader>q", vim.diagnostic.setloclist, opts)
66
67 map("n", "[d", function()
68 vim.diagnostic.jump_prev({ wrap = false })
69 end, opts)
70
71 map("n", "]d", function()
72 vim.diagnostic.jump_next({ wrap = false })
73 end, opts)
74
75 map("n", "[e", function()
76 vim.diagnostic.jump_prev({
77 severity = vim.diagnostic.severity.ERROR,
78 wrap = false
79 })
80 end, opts)
81
82 map("n", "]e", function()
83 vim.diagnostic.jump_next({
84 severity = vim.diagnostic.severity.ERROR,
85 wrap = false
86 })
87 end, opts)
88
89 vim.keymap.set("n", "<leader>ts", function()
90 vim.opt_local.spell = not vim.opt_local.spell:get()
91 end, { desc = "Toggle spell checking" })
92end
93
94return M
diff --git a/nvim/lua/config/lazy.lua b/nvim/lua/config/lazy.lua
new file mode 100644
index 0000000..c798b9d
--- /dev/null
+++ b/nvim/lua/config/lazy.lua
@@ -0,0 +1,29 @@
1-- https://lazy.folke.io/installation
2
3local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
4if not (vim.uv or vim.loop).fs_stat(lazypath) then
5 local lazyrepo = "https://github.com/folke/lazy.nvim.git"
6 local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
7 if vim.v.shell_error ~= 0 then
8 vim.api.nvim_echo({
9 { "Failed to clone lazy.nvim:\n", "ErrorMsg" },
10 { out, "WarningMsg" },
11 { "\nPress any key to exit..." },
12 }, true, {})
13 vim.fn.getchar()
14 os.exit(1)
15 end
16end
17vim.opt.rtp:prepend(lazypath)
18
19require("lazy").setup({
20 spec = {
21 { import = "plugins" },
22 },
23 checker = {
24 enabled = true
25 },
26 rocks = {
27 enabled = false,
28 },
29})
diff --git a/nvim/lua/config/options.lua b/nvim/lua/config/options.lua
new file mode 100644
index 0000000..097e5d6
--- /dev/null
+++ b/nvim/lua/config/options.lua
@@ -0,0 +1,110 @@
1local opt = vim.opt
2local g = vim.g
3
4-- Allgemeine Einstellungen
5opt.number = true
6opt.cursorline = true
7opt.shortmess:append("I")
8opt.wrap = false
9opt.wildmenu = true
10opt.splitright = true
11opt.splitbelow = true
12opt.signcolumn = "yes"
13opt.termguicolors = true
14
15-- Rechtschreibprüfung
16opt.spelllang = { "de", "en" }
17opt.spell = true
18
19-- Optionen für ^n-Vervollständigung
20opt.complete = { ".", "w", "b", "u", "t", "i" }
21
22-- bessere Suche
23opt.hlsearch = true
24opt.incsearch = true
25opt.ignorecase = true
26opt.smartcase = true
27
28-- Sonderzeichen anzeigen
29opt.list = true
30opt.listchars = {
31 tab = "> ",
32 trail = "-",
33 extends = ">",
34 precedes = "<",
35 nbsp = "+"
36}
37opt.matchpairs:append("<:>")
38
39-- automatisches Einlesen geänderter Dateien
40opt.autoread = true
41
42-- Suche rekursiv
43opt.path:append("**")
44
45-- Tabs
46opt.expandtab = false
47opt.tabstop = 4
48opt.shiftwidth = 4
49opt.softtabstop = 0
50
51-- Einrückungen
52opt.smartindent = true
53opt.autoindent = true
54opt.cindent = true
55
56-- Faltungen
57opt.foldlevel = 1000
58opt.foldcolumn = "0"
59
60-- Autovervollständigung
61opt.completeopt = { "longest", "menuone", "noselect", "popup" }
62
63-- externe Programme
64opt.makeprg = "gmake"
65opt.autowrite = true
66
67-- Guifont
68opt.guifont = "JetBrains Mono Semibold:h12"
69
70-- Provider
71g.python3_host_prog = "/usr/local/bin/python"
72
73-- Provider aeaktivieren
74g.loaded_node_provider = 0
75g.loaded_ruby_provider = 0
76g.loaded_perl_provider = 0
77g.loaded_luarocks_provider = 0
78
79-- Swap files und Undo
80opt.swapfile = false
81opt.undofile = true
82opt.undolevels = 10000
83opt.undoreload = 10000
84
85-- Clipboard
86opt.clipboard = "unnamedplus"
87
88-- netrw deaktivieren
89g.loaded_netrw = 1
90g.loaded_netrwPlugin = 1
91
92g.mapleader = ","
93g.maplocalleader = "\\"
94
95vim.diagnostic.config({
96 virtual_text = true,
97 signs = true,
98 underline = true,
99 update_in_insert = false,
100 severity_sort = true,
101 float = { border = "rounded" },
102})
103
104vim.lsp.util.open_floating_preview = (function(orig)
105 return function(contents, syntax, opts, ...)
106 opts = opts or {}
107 opts.border = opts.border or "rounded"
108 return orig(contents, syntax, opts, ...)
109 end
110end)(vim.lsp.util.open_floating_preview)
diff --git a/nvim/lua/plugins/editing.lua b/nvim/lua/plugins/editing.lua
new file mode 100644
index 0000000..44f74c6
--- /dev/null
+++ b/nvim/lua/plugins/editing.lua
@@ -0,0 +1,20 @@
1return {
2 { "tpope/vim-repeat" },
3 { "tpope/vim-surround" },
4
5 {
6 "romainl/vim-cool",
7 event = "VeryLazy",
8 },
9
10 {
11 "windwp/nvim-autopairs",
12 event = "InsertEnter",
13 config = true,
14 },
15
16 {
17 "windwp/nvim-ts-autotag",
18 event = "InsertEnter",
19 },
20}
diff --git a/nvim/lua/plugins/git.lua b/nvim/lua/plugins/git.lua
new file mode 100644
index 0000000..1fd2418
--- /dev/null
+++ b/nvim/lua/plugins/git.lua
@@ -0,0 +1,7 @@
1return {
2 {
3 "lewis6991/gitsigns.nvim",
4 event = { "BufReadPre", "BufNewFile" },
5 config = true,
6 },
7}
diff --git a/nvim/lua/plugins/lsp.lua b/nvim/lua/plugins/lsp.lua
new file mode 100644
index 0000000..e888ae0
--- /dev/null
+++ b/nvim/lua/plugins/lsp.lua
@@ -0,0 +1,29 @@
1return {
2 {
3 "neovim/nvim-lspconfig",
4 lazy = false,
5 config = function()
6 vim.lsp.config.lua_ls = {
7 settings = {
8 Lua = {
9 diagnostics = {
10 globals = { "vim" },
11 },
12 workspace = {
13 checkThirdParty = false,
14 library = {
15 vim.fn.expand("$VIMRUNTIME/lua"),
16 vim.fn.expand("$XDG_CONFIG_HOME") .. "/nvim/lua",
17 },
18 },
19 },
20 },
21 }
22
23 vim.lsp.enable({
24 "clangd", -- pkg install llvm
25 "lua_ls", -- pkg install lua-language-server
26 })
27 end,
28 },
29}
diff --git a/nvim/lua/plugins/telescope.lua b/nvim/lua/plugins/telescope.lua
new file mode 100644
index 0000000..7633892
--- /dev/null
+++ b/nvim/lua/plugins/telescope.lua
@@ -0,0 +1,9 @@
1return {
2 {
3 "nvim-telescope/telescope.nvim",
4 dependencies = {
5 "nvim-lua/plenary.nvim",
6 },
7 lazy = true,
8 },
9}
diff --git a/nvim/lua/plugins/treesitter.lua b/nvim/lua/plugins/treesitter.lua
new file mode 100644
index 0000000..edcaff2
--- /dev/null
+++ b/nvim/lua/plugins/treesitter.lua
@@ -0,0 +1,29 @@
1-- https://github.com/nvim-treesitter/nvim-treesitter/blob/main/README.md
2
3return {
4 {
5 "nvim-treesitter/nvim-treesitter",
6 branch = "main",
7 build = ":TSUpdate",
8 lazy = false,
9 config = function()
10 local treesitter = require("nvim-treesitter")
11
12 treesitter.setup({})
13
14 -- https://github.com/nvim-treesitter/nvim-treesitter/blob/main/SUPPORTED_LANGUAGES.md
15 treesitter.install({
16 "c",
17 "cpp",
18 "html",
19 "python",
20 "vim",
21 "vimdoc",
22 "javascript",
23 "lua",
24 "typescript",
25 "vim",
26 })
27 end,
28 },
29}
diff --git a/nvim/lua/plugins/ui.lua b/nvim/lua/plugins/ui.lua
new file mode 100644
index 0000000..10c4762
--- /dev/null
+++ b/nvim/lua/plugins/ui.lua
@@ -0,0 +1,58 @@
1return {
2
3 {
4 "Mofiqul/vscode.nvim",
5 priority = 1000, -- wichtig: vor anderen UI-Plugins laden
6 lazy = false,
7 config = function()
8 local vscode = require("vscode")
9
10 vscode.setup({
11 style = "dark",
12 transparent = false,
13 italic_comments = true,
14 underline_links = true,
15 disable_nvimtree_bg = true,
16 })
17
18 vscode.load()
19 end,
20 },
21
22 {
23 "nvim-tree/nvim-tree.lua",
24 dependencies = {
25 "nvim-tree/nvim-web-devicons",
26 },
27 cmd = { "NvimTreeToggle", "NvimTreeOpen" },
28 keys = {
29 { "<leader>e", "<cmd>NvimTreeToggle<cr>", desc = "Explorer toggle" },
30 },
31 config = function()
32 require("nvim-tree").setup({
33 view = {
34 width = 30,
35 },
36 renderer = {
37 highlight_git = true,
38 icons = {
39 show = {
40 file = true,
41 folder = true,
42 git = true,
43 },
44 },
45 },
46 filters = {
47 dotfiles = false,
48 },
49 })
50 end,
51 },
52
53 {
54 "RRethy/vim-illuminate",
55 event = "BufReadPost",
56 },
57
58}