From baceaec43ca63cabd09ade04d09fc828c7003ff5 Mon Sep 17 00:00:00 2001 From: fschildt Date: Tue, 25 Nov 2025 23:30:19 +0100 Subject: nvim config: use 0.12 vim.pack and get rid of lazy --- .config/nvim/init.lua | 172 +++++++++++++++++++++++++- .config/nvim/lazy-lock.json | 18 --- .config/nvim/lua/config/lazy.lua | 30 ----- .config/nvim/lua/plugins/cmp.lua | 93 -------------- .config/nvim/lua/plugins/gruvbox_material.lua | 15 --- .config/nvim/lua/plugins/lspconfig.lua | 5 - .config/nvim/lua/plugins/lualine.lua | 9 -- .config/nvim/lua/plugins/treesitter.lua | 13 -- .config/nvim/lua/plugins/vimtex.lua | 10 -- 9 files changed, 168 insertions(+), 197 deletions(-) delete mode 100644 .config/nvim/lazy-lock.json delete mode 100644 .config/nvim/lua/config/lazy.lua delete mode 100644 .config/nvim/lua/plugins/cmp.lua delete mode 100644 .config/nvim/lua/plugins/gruvbox_material.lua delete mode 100644 .config/nvim/lua/plugins/lspconfig.lua delete mode 100644 .config/nvim/lua/plugins/lualine.lua delete mode 100644 .config/nvim/lua/plugins/treesitter.lua delete mode 100644 .config/nvim/lua/plugins/vimtex.lua diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 732ea40..f140d6a 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -20,13 +20,177 @@ vim.opt.cino = ":0l1(0" vim.opt.signcolumn = "yes" -- LSP diagnostics vim.opt.termguicolors = true -- enable true colors vim.opt.completeopt = { "menu", "menuone", "noselect" } -- required for nvim-cmp - --- plugin manager (set leader key before loading lazy.nvim) vim.g.mapleader = " " -- Set leader to space vim.g.maplocalleader = "\\" -- Set local leader to backslash -require("config.lazy") --- load lsp's + +-- keymap +vim.keymap.set('n', 'gd', vim.lsp.buf.definition, { desc = 'Go to definition' }) + + +-- packages +-- Todo: telescope +-- Todo: finish https://github.com/hrsh7th/nvim-cmp +vim.pack.add({ + { src = 'https://github.com/sainnhe/gruvbox-material' }, + + { src = 'https://github.com/nvim-tree/nvim-web-devicons' }, + { src = 'https://github.com/nvim-lualine/lualine.nvim' }, + + { src = 'https://github.com/nvim-treesitter/nvim-treesitter', version = 'main' }, + { src = 'https://github.com/neovim/nvim-lspconfig' }, + + { src = 'https://github.com/hrsh7th/cmp-nvim-lsp' }, + { src = 'https://github.com/hrsh7th/cmp-buffer' }, + { src = 'https://github.com/hrsh7th/cmp-path' }, + { src = 'https://github.com/hrsh7th/cmp-cmdline' }, + { src = 'https://github.com/hrsh7th/nvim-cmp' }, + { src = 'https://github.com/hrsh7th/cmp-vsnip' }, + { src = 'https://github.com/hrsh7th/vim-vsnip' }, + + { src = 'https://github.com/lervag/vimtex' }, +}) + + + +-- init plugin gruvbox-material +vim.g.gruvbox_material_background = 'hard' +vim.g.gruvbox_material_foreground = 'material' +vim.g.gruvbox_material_enable_italic = true +vim.g.gruvbox_material_disable_italic_comment = false +vim.g.gruvbox_material_better_performance = 1 +vim.cmd.colorscheme('gruvbox-material') + + +-- init plugin lualine +require('lualine').setup { + options = { + icons_enabled = true, + theme = 'auto', + component_separators = { left = '', right = ''}, + section_separators = { left = '', right = ''}, + disabled_filetypes = { + statusline = {}, + winbar = {}, + }, + ignore_focus = {}, + always_divide_middle = true, + always_show_tabline = true, + globalstatus = false, + refresh = { + statusline = 1000, + tabline = 1000, + winbar = 1000, + refresh_time = 16, -- ~60fps + events = { + 'WinEnter', + 'BufEnter', + 'BufWritePost', + 'SessionLoadPost', + 'FileChangedShellPost', + 'VimResized', + 'Filetype', + 'CursorMoved', + 'CursorMovedI', + 'ModeChanged', + }, + } + }, + sections = { + lualine_a = {'mode'}, + lualine_b = {'branch', 'diff', 'diagnostics'}, + lualine_c = {'filename'}, + lualine_x = {'encoding', 'fileformat', 'filetype'}, + lualine_y = {'progress'}, + lualine_z = {'location'} + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = {'filename'}, + lualine_x = {'location'}, + lualine_y = {}, + lualine_z = {} + }, + tabline = {}, + winbar = {}, + inactive_winbar = {}, + extensions = {} +} + + +-- cmp +local cmp = require("cmp") +cmp.setup({ + snippet = { + expand = function(args) + vim.fn["vsnip#anonymous"](args.body) + end, + }, + window = { + -- completion = cmp.config.window.bordered(), + -- documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'vsnip' }, + }, { + { name = 'buffer' }, + }) +}) + +-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline({ '/', '?' }, { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = 'buffer' } + } +}) + +-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline(':', { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }), + matching = { disallow_symbol_nonprefix_matching = false } +}) + + +-- treesitter +require'nvim-treesitter'.install { 'cpp' } + + +-- vimtex +require('lualine').setup { + ft = { "tex", "bib" }, + dependencies = { "nvim-treesitter/nvim-treesitter" }, + config = function() + vim.g.vimtex_view_method = "mupdf" + end +} + + +-- lsp +vim.lsp.config('lua_ls', { + capabilities = capabilities +}) +vim.lsp.config('clangd', { + capabilities = capabilities +}) +vim.lsp.config('pyright', { + capabilities = capabilities +}) + vim.lsp.enable({ 'lua_ls', 'clangd', diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json deleted file mode 100644 index ad87f95..0000000 --- a/.config/nvim/lazy-lock.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "LuaSnip": { "branch": "master", "commit": "73813308abc2eaeff2bc0d3f2f79270c491be9d7" }, - "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, - "cmp-cmdline": { "branch": "main", "commit": "d126061b624e0af6c3a556428712dd4d4194ec6d" }, - "cmp-nvim-lsp": { "branch": "main", "commit": "bd5a7d6db125d4654b50eeae9f5217f24bb22fd3" }, - "cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" }, - "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, - "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, - "gruvbox-material": { "branch": "master", "commit": "834dbf21836862300ced7444db4262b796330ab7" }, - "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, - "lspkind.nvim": { "branch": "master", "commit": "3ddd1b4edefa425fda5a9f95a4f25578727c0bb3" }, - "lualine.nvim": { "branch": "master", "commit": "b8c23159c0161f4b89196f74ee3a6d02cdc3a955" }, - "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, - "nvim-lspconfig": { "branch": "master", "commit": "a844e89ea0e0e4b207ec550c3b51fb6e471881a4" }, - "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, - "nvim-web-devicons": { "branch": "master", "commit": "b8221e42cf7287c4dcde81f232f58d7b947c210d" }, - "vimtex": { "branch": "master", "commit": "2e1bbabeb2c34bb17d7bc8cfdf8f95b16dd0db0c" } -} diff --git a/.config/nvim/lua/config/lazy.lua b/.config/nvim/lua/config/lazy.lua deleted file mode 100644 index b2f67ca..0000000 --- a/.config/nvim/lua/config/lazy.lua +++ /dev/null @@ -1,30 +0,0 @@ --- Bootstrap lazy.nvim -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) - --- Setup lazy.nvim -require("lazy").setup({ - spec = { - -- import your plugins - { import = "plugins" }, - }, - -- Configure any other settings here. See the documentation for more details. - -- colorscheme that will be used when installing plugins. - install = { colorscheme = { "habamax" } }, - -- automatically check for plugin updates - checker = { enabled = true }, -}) - diff --git a/.config/nvim/lua/plugins/cmp.lua b/.config/nvim/lua/plugins/cmp.lua deleted file mode 100644 index 7126173..0000000 --- a/.config/nvim/lua/plugins/cmp.lua +++ /dev/null @@ -1,93 +0,0 @@ -return { - { - "hrsh7th/nvim-cmp", - event = { "InsertEnter", "CmdlineEnter" }, -- Load on insert or cmdline mode - dependencies = { - "hrsh7th/cmp-nvim-lsp", -- LSP completion source - "hrsh7th/cmp-buffer", -- Buffer completion source - "hrsh7th/cmp-path", -- Path completion source - "hrsh7th/cmp-cmdline", -- Cmdline completion source - "L3MON4D3/LuaSnip", -- Snippet engine - "saadparwaiz1/cmp_luasnip", -- LuaSnip completion source - "rafamadriz/friendly-snippets", -- Predefined snippets - "onsails/lspkind.nvim", -- Icons for completion items - }, - config = function() - local cmp = require("cmp") - local luasnip = require("luasnip") - local lspkind = require("lspkind") - - -- Load friendly-snippets - require("luasnip.loaders.from_vscode").lazy_load() - - cmp.setup { - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.scroll_docs(-4), -- Scroll up docs - [""] = cmp.mapping.scroll_docs(4), -- Scroll down docs - [""] = cmp.mapping.complete(), -- Trigger completion - [""] = cmp.mapping.confirm({ select = true }), -- Accept selection - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - else - fallback() - end - end, { "i", "s" }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { "i", "s" }), - }), - sources = cmp.config.sources({ - { name = "nvim_lsp" }, -- LSP completions - { name = "luasnip" }, -- Snippet completions - { name = "buffer" }, -- Buffer completions - { name = "path" }, -- Path completions - }), - formatting = { - format = lspkind.cmp_format({ - mode = "symbol_text", -- Show symbol and text - maxwidth = 50, -- Limit width - ellipsis_char = "...", -- Truncation character - }), - }, - window = { - completion = cmp.config.window.bordered(), -- Bordered completion menu - documentation = cmp.config.window.bordered(), -- Bordered documentation window - }, - experimental = { - ghost_text = true, -- Show ghost text for inline completion - }, - } - - -- Command-line completion for `/` and `?` - cmp.setup.cmdline({ "/", "?" }, { - mapping = cmp.mapping.preset.cmdline(), - sources = { - { name = "buffer" }, - }, - }) - - -- Command-line completion for `:` - cmp.setup.cmdline(":", { - mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources({ - { name = "path" }, - { name = "cmdline" }, - }), - }) - end, - }, -} diff --git a/.config/nvim/lua/plugins/gruvbox_material.lua b/.config/nvim/lua/plugins/gruvbox_material.lua deleted file mode 100644 index 7858be6..0000000 --- a/.config/nvim/lua/plugins/gruvbox_material.lua +++ /dev/null @@ -1,15 +0,0 @@ -return { - { - 'sainnhe/gruvbox-material', - lazy = false, - priority = 1000, - config = function() - vim.g.gruvbox_material_background = "hard" -- hard/medium/soft - vim.g.gruvbox_material_foreground = "material" -- material/mix/original - vim.g.gruvbox_material_enable_italic = true - vim.g.gruvbox_material_disable_italic_comment = 0 - vim.g.gruvbox_material_better_performance = 1 - vim.cmd.colorscheme('gruvbox-material') - end - } -} diff --git a/.config/nvim/lua/plugins/lspconfig.lua b/.config/nvim/lua/plugins/lspconfig.lua deleted file mode 100644 index 4742835..0000000 --- a/.config/nvim/lua/plugins/lspconfig.lua +++ /dev/null @@ -1,5 +0,0 @@ -return { - { - "neovim/nvim-lspconfig" - } -} diff --git a/.config/nvim/lua/plugins/lualine.lua b/.config/nvim/lua/plugins/lualine.lua deleted file mode 100644 index 26e0f4b..0000000 --- a/.config/nvim/lua/plugins/lualine.lua +++ /dev/null @@ -1,9 +0,0 @@ -return { - { - 'nvim-lualine/lualine.nvim', - dependencies = { 'nvim-tree/nvim-web-devicons' }, - config = function() - require('lualine').setup() - end - } -} diff --git a/.config/nvim/lua/plugins/treesitter.lua b/.config/nvim/lua/plugins/treesitter.lua deleted file mode 100644 index a6ffac9..0000000 --- a/.config/nvim/lua/plugins/treesitter.lua +++ /dev/null @@ -1,13 +0,0 @@ -return { - "nvim-treesitter/nvim-treesitter", - build = ":TSUpdate", - config = function() - local configs = require("nvim-treesitter.configs") - configs.setup({ - ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "elixir", "heex", "javascript", "html" }, - sync_install = false, - highlight = { enable = true }, - indent = { enable = true }, - }) - end -} diff --git a/.config/nvim/lua/plugins/vimtex.lua b/.config/nvim/lua/plugins/vimtex.lua deleted file mode 100644 index f14d0ea..0000000 --- a/.config/nvim/lua/plugins/vimtex.lua +++ /dev/null @@ -1,10 +0,0 @@ -return { - { - "lervag/vimtex", - ft = { "tex", "bib" }, - dependencies = { "nvim-treesitter/nvim-treesitter" }, - config = function() - vim.g.vimtex_view_method = "mupdf" - end - } -} -- cgit v1.2.3