commit d329e8ee9f130e62aaeafdc12115bc1afb5af744
parent acf411a09c08495f7cb76fe70cb47daf0e087605
Author: Michael Neuper <michael@michaelneuper.com>
Date: Fri, 8 Aug 2025 12:02:53 +0200
seperate nvim config into multiple files
Diffstat:
12 files changed, 398 insertions(+), 145 deletions(-)
diff --git a/.config/nvim/ftplugin/c.lua b/.config/nvim/ftplugin/c.lua
@@ -0,0 +1 @@
+vim.bo.expandtab = false
diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua
@@ -1,145 +1,4 @@
--- OPTIONS
-vim.opt.number = true
-vim.opt.relativenumber = true
-vim.opt.expandtab = true
-vim.opt.tabstop = 2
-vim.opt.softtabstop = 2
-vim.opt.shiftwidth = 2
-
-vim.opt.smartcase = true
-vim.opt.ignorecase = true
-vim.opt.hlsearch = false
-vim.opt.clipboard = "unnamedplus"
-vim.opt.swapfile = false
-
--- auto remove trailing whitespace
-vim.api.nvim_create_autocmd("BufWritePre", {
- pattern = "*",
- callback = function()
- local save_cursor = vim.fn.getpos(".")
- vim.cmd([[%s/\s\+$//e]])
- vim.fn.setpos(".", save_cursor)
- end,
-})
-
--- PACKAGE MANAGER
-local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
-if not (vim.uv or vim.loop).fs_stat(lazypath) then
- local lazyrepo = "https://github.com/folke/lazy.nvim.git"
- local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
- if vim.v.shell_error ~= 0 then
- vim.api.nvim_echo({
- { "Failed to clone lazy.nvim:\n", "ErrorMsg" },
- { out, "WarningMsg" },
- { "\nPress any key to exit..." },
- }, true, {})
- vim.fn.getchar()
- os.exit(1)
- end
-end
-vim.opt.rtp:prepend(lazypath)
-
-require("lazy").setup({
- { "ellisonleao/gruvbox.nvim" },
- { "nvim-telescope/telescope.nvim",
- tag = "0.1.6",
- dependencies = {
- "nvim-lua/plenary.nvim"
- } },
- { "nvim-lualine/lualine.nvim",
- dependencies = {
- "nvim-tree/nvim-web-devicons"
- } },
- { "nvim-treesitter/nvim-treesitter",
- build = ":TSUpdate" },
- { "windwp/nvim-autopairs",
- event = "InsertEnter",
- config = true },
-})
-
--- vim.pack.add( {
--- "ellisonleao/gruvbox.nvim",
--- "nvim-lualine/lualine.nvim",
--- "nvim-lua/plenary.nvim",
--- "nvim-telescope/telescope.nvim",
--- "nvim-tree/nvim-web-devicons",
--- "nvim-treesitter/nvim-treesitter",
--- "windwp/nvim-autopairs",
--- })
-
--- KEYBINDINGS
-vim.g.mapleader = vim.keycode("<Space>")
-
-vim.keymap.set("n", "<leader>fs", ":w<CR>", { noremap = true, silent = true })
-vim.keymap.set("n", "<leader>qq", ":q<CR>", { noremap = true, silent = true })
-vim.keymap.set("n", "<leader>w", "<C-w>", { noremap = true, silent = true })
-vim.keymap.set({ "i", "v", "c" }, "<C-g>", "<Esc>", { noremap = true, silent = true })
-vim.keymap.set("n", "<leader>ot", ":botright split | resize 10 | terminal<CR>",{
- noremap = true, silent = true, desc = "Open terminal"
-})
-
-local builtin = require("telescope.builtin")
-vim.keymap.set("n", "<leader>ff", builtin.find_files, { desc = "Find File" })
-
--- UI
-vim.opt.termguicolors = true
-
-require("gruvbox").setup({
- terminal_colors = false,
-
- underline = true,
- italic = {
- strings = false,
- comments = true,
- folds = true,
- },
-})
-
-vim.cmd.colorscheme("gruvbox")
-
-require'nvim-treesitter.configs'.setup {
- highlight = {
- enable = true,
- },
-}
-
-require("lualine").setup({
- options = {
- icons_enabled = true,
- theme = "auto",
- component_separators = { left = "", right = "" },
- section_separators = { left = "", right = "" },
- disabled_filetypes = {
- statusline = {},
- winbar = {},
- },
- always_divide_middle = true,
- globalstatus = true,
- refresh = {
- statusline = 1000,
- tabline = 1000,
- winbar = 1000,
- },
- },
- sections = {
- lualine_a = { "mode" },
- lualine_b = { "filename" },
- lualine_c = { "location", "progress" },
-
- lualine_x = { "encoding", "filetype" },
- lualine_y = { "diff" },
- lualine_z = { "branch" },
- },
-
- inactive_sections = {
- lualine_a = {},
- lualine_b = { "filename" },
- lualine_c = { "location" },
- lualine_x = {},
- lualine_y = {},
- lualine_z = {},
- },
-
- tabline = {},
- extensions = {},
-})
+require("config.options")
+require("config.keybindings")
+require("config.custom")
+require("config.lazy")
diff --git a/.config/nvim/lua/config/custom.lua b/.config/nvim/lua/config/custom.lua
@@ -0,0 +1,10 @@
+-- auto remove trailing whitespace
+vim.api.nvim_create_autocmd("BufWritePre", {
+ pattern = "*",
+ callback = function()
+ local save_cursor = vim.fn.getpos(".")
+ vim.cmd([[%s/\s\+$//e]])
+ vim.fn.setpos(".", save_cursor)
+ end,
+})
+
diff --git a/.config/nvim/lua/config/keybindings.lua b/.config/nvim/lua/config/keybindings.lua
@@ -0,0 +1,9 @@
+vim.g.mapleader = " "
+
+vim.keymap.set("n", "<leader>fs", ":w<CR>", { noremap = true, silent = true })
+vim.keymap.set("n", "<leader>qq", ":q<CR>", { noremap = true, silent = true })
+vim.keymap.set("n", "<leader>w", "<C-w>", { noremap = true, silent = true })
+vim.keymap.set({ "i", "v", "c" }, "<C-g>", "<Esc>", { noremap = true, silent = true })
+-- vim.keymap.set("n", "<leader>ot", ":botright split | resize 10 | terminal<CR>",{
+-- noremap = true, silent = true, desc = "Open terminal"
+-- })
diff --git a/.config/nvim/lua/config/lazy.lua b/.config/nvim/lua/config/lazy.lua
@@ -0,0 +1,21 @@
+local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
+if not (vim.uv or vim.loop).fs_stat(lazypath) then
+ local lazyrepo = "https://github.com/folke/lazy.nvim.git"
+ local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
+ if vim.v.shell_error ~= 0 then
+ vim.api.nvim_echo({
+ { "Failed to clone lazy.nvim:\n", "ErrorMsg" },
+ { out, "WarningMsg" },
+ { "\nPress any key to exit..." },
+ }, true, {})
+ vim.fn.getchar()
+ os.exit(1)
+ end
+end
+vim.opt.rtp:prepend(lazypath)
+
+require("lazy").setup({
+ spec = {
+ { import = "plugins" },
+ },
+})
diff --git a/.config/nvim/lua/config/options.lua b/.config/nvim/lua/config/options.lua
@@ -0,0 +1,17 @@
+vim.opt.number = true
+vim.opt.relativenumber = true
+
+vim.opt.expandtab = true
+vim.opt.tabstop = 4
+vim.opt.softtabstop = 4
+vim.opt.shiftwidth = 4
+
+vim.opt.smartcase = true
+vim.opt.ignorecase = true
+vim.opt.hlsearch = false
+vim.opt.clipboard = "unnamedplus"
+vim.opt.swapfile = false
+
+vim.opt.termguicolors = true
+
+vim.cmd("filetype plugin on")
diff --git a/.config/nvim/lua/plugins/colorscheme.lua b/.config/nvim/lua/plugins/colorscheme.lua
@@ -0,0 +1,16 @@
+return {
+ "ellisonleao/gruvbox.nvim",
+ config = function()
+ vim.cmd.colorscheme("gruvbox")
+
+ require("gruvbox").setup({
+ terminal_colors = false,
+ underline = true,
+ italic = {
+ strings = false,
+ comments = true,
+ folds = true,
+ },
+ })
+ end
+}
diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua
@@ -0,0 +1,227 @@
+return {
+ -- 'neovim/nvim-lspconfig',
+ -- dependencies = {
+ -- 'williamboman/mason.nvim',
+ -- 'williamboman/mason-lspconfig.nvim',
+ -- -- Autocompletion
+ -- 'hrsh7th/nvim-cmp',
+ -- 'hrsh7th/cmp-buffer',
+ -- 'hrsh7th/cmp-path',
+ -- 'saadparwaiz1/cmp_luasnip',
+ -- 'hrsh7th/cmp-nvim-lsp',
+ -- 'hrsh7th/cmp-nvim-lua',
+ -- -- Snippets
+ -- 'L3MON4D3/LuaSnip',
+ -- 'rafamadriz/friendly-snippets',
+ -- },
+ -- config = function()
+ -- local autoformat_filetypes = {
+ -- "lua",
+ -- }
+ -- -- Create a keymap for vim.lsp.buf.implementation
+ -- vim.api.nvim_create_autocmd('LspAttach', {
+ -- callback = function(args)
+ -- local client = vim.lsp.get_client_by_id(args.data.client_id)
+ -- if not client then return end
+ -- if vim.tbl_contains(autoformat_filetypes, vim.bo.filetype) then
+ -- vim.api.nvim_create_autocmd("BufWritePre", {
+ -- buffer = args.buf,
+ -- callback = function()
+ -- vim.lsp.buf.format({
+ -- formatting_options = { tabSize = 4, insertSpaces = true },
+ -- bufnr = args.buf,
+ -- id = client.id
+ -- })
+ -- end
+ -- })
+ -- end
+ -- end
+ -- })
+ --
+ -- -- Add borders to floating windows
+ -- vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(
+ -- vim.lsp.handlers.hover,
+ -- { border = 'rounded' }
+ -- )
+ -- vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(
+ -- vim.lsp.handlers.signature_help,
+ -- { border = 'rounded' }
+ -- )
+ --
+ -- -- Configure error/warnings interface
+ -- vim.diagnostic.config({
+ -- virtual_text = true,
+ -- severity_sort = true,
+ -- float = {
+ -- style = 'minimal',
+ -- border = 'rounded',
+ -- header = '',
+ -- prefix = '',
+ -- },
+ -- signs = {
+ -- text = {
+ -- [vim.diagnostic.severity.ERROR] = '✘',
+ -- [vim.diagnostic.severity.WARN] = '▲',
+ -- [vim.diagnostic.severity.HINT] = '⚑',
+ -- [vim.diagnostic.severity.INFO] = '»',
+ -- },
+ -- },
+ -- })
+ --
+ -- -- Add cmp_nvim_lsp capabilities settings to lspconfig
+ -- -- This should be executed before you configure any language server
+ -- local lspconfig_defaults = require('lspconfig').util.default_config
+ -- lspconfig_defaults.capabilities = vim.tbl_deep_extend(
+ -- 'force',
+ -- lspconfig_defaults.capabilities,
+ -- require('cmp_nvim_lsp').default_capabilities()
+ -- )
+ --
+ -- -- This is where you enable features that only work
+ -- -- if there is a language server active in the file
+ -- vim.api.nvim_create_autocmd('LspAttach', {
+ -- callback = function(event)
+ -- local opts = { buffer = event.buf }
+ --
+ -- vim.keymap.set('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>', opts)
+ -- vim.keymap.set('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>', opts)
+ -- vim.keymap.set('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>', opts)
+ -- vim.keymap.set('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>', opts)
+ -- vim.keymap.set('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>', opts)
+ -- vim.keymap.set('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>', opts)
+ -- vim.keymap.set('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<cr>', opts)
+ -- vim.keymap.set('n', 'gl', '<cmd>lua vim.diagnostic.open_float()<cr>', opts)
+ -- vim.keymap.set('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<cr>', opts)
+ -- vim.keymap.set({ 'n', 'x' }, '<F3>', '<cmd>lua vim.lsp.buf.format({async = true})<cr>', opts)
+ -- vim.keymap.set('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<cr>', opts)
+ -- end,
+ -- })
+ --
+ -- require('mason').setup({})
+ -- require('mason-lspconfig').setup({
+ -- ensure_installed = {
+ -- "clangd"
+ -- },
+ -- handlers = {
+ -- -- this first function is the "default handler"
+ -- -- it applies to every language server without a custom handler
+ -- function(server_name)
+ -- require('lspconfig')[server_name].setup({})
+ -- end,
+ --
+ -- -- this is the "custom handler" for `lua_ls`
+ -- lua_ls = function()
+ -- require('lspconfig').lua_ls.setup({
+ -- settings = {
+ -- Lua = {
+ -- runtime = {
+ -- version = 'LuaJIT',
+ -- },
+ -- diagnostics = {
+ -- globals = { 'vim' },
+ -- },
+ -- workspace = {
+ -- library = { vim.env.VIMRUNTIME },
+ -- },
+ -- },
+ -- },
+ -- })
+ -- end,
+ -- },
+ -- })
+ --
+ -- local cmp = require('cmp')
+ --
+ -- require('luasnip.loaders.from_vscode').lazy_load()
+ --
+ -- vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
+ --
+ -- cmp.setup({
+ -- preselect = 'item',
+ -- completion = {
+ -- completeopt = 'menu,menuone,noinsert'
+ -- },
+ -- window = {
+ -- documentation = cmp.config.window.bordered(),
+ -- },
+ -- sources = {
+ -- { name = 'path' },
+ -- { name = 'nvim_lsp' },
+ -- { name = 'buffer', keyword_length = 3 },
+ -- { name = 'luasnip', keyword_length = 2 },
+ -- },
+ -- snippet = {
+ -- expand = function(args)
+ -- require('luasnip').lsp_expand(args.body)
+ -- end,
+ -- },
+ -- formatting = {
+ -- fields = { 'abbr', 'menu', 'kind' },
+ -- format = function(entry, item)
+ -- local n = entry.source.name
+ -- if n == 'nvim_lsp' then
+ -- item.menu = '[LSP]'
+ -- else
+ -- item.menu = string.format('[%s]', n)
+ -- end
+ -- return item
+ -- end,
+ -- },
+ -- mapping = cmp.mapping.preset.insert({
+ -- -- confirm completion item
+ -- ['<CR>'] = cmp.mapping.confirm({ select = false }),
+ --
+ -- -- scroll documentation window
+ -- ['<C-f>'] = cmp.mapping.scroll_docs(5),
+ -- ['<C-u>'] = cmp.mapping.scroll_docs(-5),
+ --
+ -- -- toggle completion menu
+ -- ['<C-e>'] = cmp.mapping(function(fallback)
+ -- if cmp.visible() then
+ -- cmp.abort()
+ -- else
+ -- cmp.complete()
+ -- end
+ -- end),
+ --
+ -- -- tab complete
+ -- ['<Tab>'] = cmp.mapping(function(fallback)
+ -- local col = vim.fn.col('.') - 1
+ --
+ -- if cmp.visible() then
+ -- cmp.select_next_item({ behavior = 'select' })
+ -- elseif col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then
+ -- fallback()
+ -- else
+ -- cmp.complete()
+ -- end
+ -- end, { 'i', 's' }),
+ --
+ -- -- go to previous item
+ -- ['<S-Tab>'] = cmp.mapping.select_prev_item({ behavior = 'select' }),
+ --
+ -- -- navigate to next snippet placeholder
+ -- ['<C-d>'] = cmp.mapping(function(fallback)
+ -- local luasnip = require('luasnip')
+ --
+ -- if luasnip.jumpable(1) then
+ -- luasnip.jump(1)
+ -- else
+ -- fallback()
+ -- end
+ -- end, { 'i', 's' }),
+ --
+ -- -- navigate to the previous snippet placeholder
+ -- ['<C-b>'] = cmp.mapping(function(fallback)
+ -- local luasnip = require('luasnip')
+ --
+ -- if luasnip.jumpable(-1) then
+ -- luasnip.jump(-1)
+ -- else
+ -- fallback()
+ -- end
+ -- end, { 'i', 's' }),
+ -- }),
+ -- })
+ -- end
+}
diff --git a/.config/nvim/lua/plugins/lualine.lua b/.config/nvim/lua/plugins/lualine.lua
@@ -0,0 +1,46 @@
+return {
+ "nvim-lualine/lualine.nvim",
+ dependencies = { "nvim-tree/nvim-web-devicons" },
+ config = function()
+ require("lualine").setup({
+ options = {
+ icons_enabled = false,
+ theme = "auto",
+ component_separators = { left = "", right = "" },
+ section_separators = { left = "", right = "" },
+ disabled_filetypes = {
+ statusline = {},
+ winbar = {},
+ },
+ always_divide_middle = true,
+ globalstatus = true,
+ refresh = {
+ statusline = 1000,
+ tabline = 1000,
+ winbar = 1000,
+ },
+ },
+ sections = {
+ lualine_a = { "mode" },
+ lualine_b = { "filename" },
+ lualine_c = { "location", "progress" },
+
+ lualine_x = { "encoding", "filetype" },
+ lualine_y = { "diff" },
+ lualine_z = { "branch" },
+ },
+
+ inactive_sections = {
+ lualine_a = {},
+ lualine_b = { "filename" },
+ lualine_c = { "location" },
+ lualine_x = {},
+ lualine_y = {},
+ lualine_z = {},
+ },
+
+ tabline = {},
+ extensions = {},
+ })
+ end
+}
diff --git a/.config/nvim/lua/plugins/oneliners.lua b/.config/nvim/lua/plugins/oneliners.lua
@@ -0,0 +1,24 @@
+return {
+ {
+ "windwp/nvim-autopairs",
+ event = "InsertEnter",
+ config = true,
+ },
+ {
+ "akinsho/toggleterm.nvim",
+ version = "*",
+ config = function()
+ require("toggleterm").setup({
+ open_mapping = [[<leader>ot]],
+ size = 20,
+ hide_numbers = true,
+ shade_terminals = false,
+ start_in_insert = true,
+ persist_size = true,
+ direction = "horizontal",
+ close_on_exit = true,
+ shell = vim.o.shell,
+ })
+ end,
+ },
+}
diff --git a/.config/nvim/lua/plugins/telescope.lua b/.config/nvim/lua/plugins/telescope.lua
@@ -0,0 +1,11 @@
+return {
+ "nvim-telescope/telescope.nvim",
+ tag = "0.1.6",
+ dependencies = { "nvim-lua/plenary.nvim" },
+ config = function()
+ local builtin = require("telescope.builtin")
+ vim.keymap.set("n", "<leader>ff", builtin.find_files, { desc = "Find File" })
+ vim.keymap.set("n", "<leader>sb", builtin.live_grep, { desc = "Search Buffer" })
+ vim.keymap.set("n", "<leader>bb", builtin.buffers, { desc = "Switch Buffer" })
+ end
+}
diff --git a/.config/nvim/lua/plugins/treesitter.lua b/.config/nvim/lua/plugins/treesitter.lua
@@ -0,0 +1,12 @@
+return {
+ "nvim-treesitter/nvim-treesitter",
+ build = ":TSUpdate",
+ config = function()
+ local configs = require("nvim-treesitter.configs")
+ configs.setup({
+ highlight = { enable = true, },
+ indent = { enable = true },
+ ensure_installed = { "lua", "c" },
+ })
+ end
+}