diff options
| -rw-r--r-- | nvim/ftplugin/lua.lua | 6 | ||||
| -rw-r--r-- | nvim/init.lua | 8 | ||||
| -rw-r--r-- | nvim/lua/config/autocmds.lua | 56 | ||||
| -rw-r--r-- | nvim/lua/config/keymaps.lua | 94 | ||||
| -rw-r--r-- | nvim/lua/config/lazy.lua | 29 | ||||
| -rw-r--r-- | nvim/lua/config/options.lua | 110 | ||||
| -rw-r--r-- | nvim/lua/plugins/editing.lua | 20 | ||||
| -rw-r--r-- | nvim/lua/plugins/git.lua | 7 | ||||
| -rw-r--r-- | nvim/lua/plugins/lsp.lua | 29 | ||||
| -rw-r--r-- | nvim/lua/plugins/telescope.lua | 9 | ||||
| -rw-r--r-- | nvim/lua/plugins/treesitter.lua | 29 | ||||
| -rw-r--r-- | nvim/lua/plugins/ui.lua | 58 |
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 @@ | |||
| 1 | local opt = vim.opt_local | ||
| 2 | |||
| 3 | opt.expandtab = true | ||
| 4 | opt.shiftwidth = 2 | ||
| 5 | opt.tabstop = 2 | ||
| 6 | opt.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 @@ | |||
| 1 | require("config.options") | ||
| 2 | |||
| 3 | local keymaps = require("config.keymaps") | ||
| 4 | keymaps.global() | ||
| 5 | keymaps.telescope() | ||
| 6 | |||
| 7 | require("config.autocmds") | ||
| 8 | require("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 | ||
| 2 | vim.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 | ||
| 13 | vim.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 | ||
| 31 | vim.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 | |||
| 50 | vim.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 @@ | |||
| 1 | local M = {} | ||
| 2 | |||
| 3 | local map = vim.keymap.set | ||
| 4 | |||
| 5 | function 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 | ||
| 24 | end | ||
| 25 | |||
| 26 | function 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) | ||
| 51 | end | ||
| 52 | |||
| 53 | function 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" }) | ||
| 92 | end | ||
| 93 | |||
| 94 | return 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 | |||
| 3 | local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" | ||
| 4 | if 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 | ||
| 16 | end | ||
| 17 | vim.opt.rtp:prepend(lazypath) | ||
| 18 | |||
| 19 | require("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 @@ | |||
| 1 | local opt = vim.opt | ||
| 2 | local g = vim.g | ||
| 3 | |||
| 4 | -- Allgemeine Einstellungen | ||
| 5 | opt.number = true | ||
| 6 | opt.cursorline = true | ||
| 7 | opt.shortmess:append("I") | ||
| 8 | opt.wrap = false | ||
| 9 | opt.wildmenu = true | ||
| 10 | opt.splitright = true | ||
| 11 | opt.splitbelow = true | ||
| 12 | opt.signcolumn = "yes" | ||
| 13 | opt.termguicolors = true | ||
| 14 | |||
| 15 | -- Rechtschreibprüfung | ||
| 16 | opt.spelllang = { "de", "en" } | ||
| 17 | opt.spell = true | ||
| 18 | |||
| 19 | -- Optionen für ^n-Vervollständigung | ||
| 20 | opt.complete = { ".", "w", "b", "u", "t", "i" } | ||
| 21 | |||
| 22 | -- bessere Suche | ||
| 23 | opt.hlsearch = true | ||
| 24 | opt.incsearch = true | ||
| 25 | opt.ignorecase = true | ||
| 26 | opt.smartcase = true | ||
| 27 | |||
| 28 | -- Sonderzeichen anzeigen | ||
| 29 | opt.list = true | ||
| 30 | opt.listchars = { | ||
| 31 | tab = "> ", | ||
| 32 | trail = "-", | ||
| 33 | extends = ">", | ||
| 34 | precedes = "<", | ||
| 35 | nbsp = "+" | ||
| 36 | } | ||
| 37 | opt.matchpairs:append("<:>") | ||
| 38 | |||
| 39 | -- automatisches Einlesen geänderter Dateien | ||
| 40 | opt.autoread = true | ||
| 41 | |||
| 42 | -- Suche rekursiv | ||
| 43 | opt.path:append("**") | ||
| 44 | |||
| 45 | -- Tabs | ||
| 46 | opt.expandtab = false | ||
| 47 | opt.tabstop = 4 | ||
| 48 | opt.shiftwidth = 4 | ||
| 49 | opt.softtabstop = 0 | ||
| 50 | |||
| 51 | -- Einrückungen | ||
| 52 | opt.smartindent = true | ||
| 53 | opt.autoindent = true | ||
| 54 | opt.cindent = true | ||
| 55 | |||
| 56 | -- Faltungen | ||
| 57 | opt.foldlevel = 1000 | ||
| 58 | opt.foldcolumn = "0" | ||
| 59 | |||
| 60 | -- Autovervollständigung | ||
| 61 | opt.completeopt = { "longest", "menuone", "noselect", "popup" } | ||
| 62 | |||
| 63 | -- externe Programme | ||
| 64 | opt.makeprg = "gmake" | ||
| 65 | opt.autowrite = true | ||
| 66 | |||
| 67 | -- Guifont | ||
| 68 | opt.guifont = "JetBrains Mono Semibold:h12" | ||
| 69 | |||
| 70 | -- Provider | ||
| 71 | g.python3_host_prog = "/usr/local/bin/python" | ||
| 72 | |||
| 73 | -- Provider aeaktivieren | ||
| 74 | g.loaded_node_provider = 0 | ||
| 75 | g.loaded_ruby_provider = 0 | ||
| 76 | g.loaded_perl_provider = 0 | ||
| 77 | g.loaded_luarocks_provider = 0 | ||
| 78 | |||
| 79 | -- Swap files und Undo | ||
| 80 | opt.swapfile = false | ||
| 81 | opt.undofile = true | ||
| 82 | opt.undolevels = 10000 | ||
| 83 | opt.undoreload = 10000 | ||
| 84 | |||
| 85 | -- Clipboard | ||
| 86 | opt.clipboard = "unnamedplus" | ||
| 87 | |||
| 88 | -- netrw deaktivieren | ||
| 89 | g.loaded_netrw = 1 | ||
| 90 | g.loaded_netrwPlugin = 1 | ||
| 91 | |||
| 92 | g.mapleader = "," | ||
| 93 | g.maplocalleader = "\\" | ||
| 94 | |||
| 95 | vim.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 | |||
| 104 | vim.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 | ||
| 110 | end)(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 @@ | |||
| 1 | return { | ||
| 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 @@ | |||
| 1 | return { | ||
| 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 @@ | |||
| 1 | return { | ||
| 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 @@ | |||
| 1 | return { | ||
| 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 | |||
| 3 | return { | ||
| 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 @@ | |||
| 1 | return { | ||
| 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 | } | ||
