From f33ecb78ee47d50e6759cc79a437743b07028f56 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Sat, 20 Sep 2025 22:03:23 +0200 Subject: [PATCH] neovim: Replace packer with lazy.nvim --- .config/nvim/init.lua | 70 +--------- .config/nvim/lua/config/lazy.lua | 35 +++++ .config/nvim/lua/config/plugins.lua | 68 ++++++++++ .config/nvim/lua/plugins.lua | 202 ---------------------------- .config/nvim/lua/plugins/all.lua | 190 ++++++++++++++++++++++++++ 5 files changed, 295 insertions(+), 270 deletions(-) create mode 100644 .config/nvim/lua/config/lazy.lua create mode 100644 .config/nvim/lua/config/plugins.lua delete mode 100644 .config/nvim/lua/plugins.lua create mode 100644 .config/nvim/lua/plugins/all.lua diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index a6bb431..cab7d30 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -28,79 +28,13 @@ vim.opt.mouse = 'a' -- " Enable mouse in all modes. -- -- Packer -- -vim.cmd [[packadd packer.nvim]] - -require'packer'.startup(function() - -- Packer can manage itself - use 'wbthomason/packer.nvim' - - use 'mfussenegger/nvim-dap' - use 'airblade/vim-gitgutter' - use 'neovim/nvim-lspconfig' - use 'dense-analysis/ale' - use 'liuchengxu/vista.vim' -- Tag bar. - use { - 'nvim-treesitter/nvim-treesitter', - run = ':TSUpdate' - } - - -- Git. - use 'tpope/vim-fugitive' - use { - 'sindrets/diffview.nvim', - requires = {'nvim-lua/plenary.nvim'} - } - - -- File browser. - use { - 'kyazdani42/nvim-tree.lua', - requires = {'nvim-tree/nvim-web-devicons'} -- optional, for file icon - } - use { - 'nvim-telescope/telescope.nvim', - requires = {'nvim-lua/plenary.nvim'} - } - use 'nvim-telescope/telescope-ui-select.nvim' - use { - 'kevinhwang91/nvim-ufo', - requires = {'kevinhwang91/promise-async'} - } - - -- Theme. - use 'sainnhe/sonokai' - use { - 'nvim-lualine/lualine.nvim', - requires = {'nvim-tree/nvim-web-devicons'} -- optional, for status line icons - } - - -- Syntax. - use 'leafOfTree/vim-vue-plugin' - use 'mfussenegger/nvim-jdtls' - use 'dart-lang/dart-vim-plugin' - use { - 'akinsho/flutter-tools.nvim', - requires = { - 'nvim-lua/plenary.nvim' - } - } - use 'vim-vdebug/vdebug' - - -- nvim-cmp - use 'dcampos/nvim-snippy' - use 'hrsh7th/cmp-nvim-lsp' - use 'hrsh7th/nvim-cmp' - use 'dcampos/cmp-snippy' - use 'hrsh7th/cmp-path' - use 'hrsh7th/cmp-buffer' -end) - -require'plugins' +require("config.lazy") +require("config.plugins") require'lspserver' -- -- Theme -- -vim.cmd('colorscheme sonokai') vim.opt.termguicolors = true -- Mappings. diff --git a/.config/nvim/lua/config/lazy.lua b/.config/nvim/lua/config/lazy.lua new file mode 100644 index 0000000..f5ee74c --- /dev/null +++ b/.config/nvim/lua/config/lazy.lua @@ -0,0 +1,35 @@ +-- 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) + +-- Make sure to setup `mapleader` and `maplocalleader` before +-- loading lazy.nvim so that mappings are correct. +-- This is also a good place to setup other settings (vim.opt) +vim.g.mapleader = " " +vim.g.maplocalleader = "\\" + +-- 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/config/plugins.lua b/.config/nvim/lua/config/plugins.lua new file mode 100644 index 0000000..d51beaa --- /dev/null +++ b/.config/nvim/lua/config/plugins.lua @@ -0,0 +1,68 @@ +-- +-- ALE +-- +-- Run linters only on save +vim.g.ale_lint_on_text_changed = 'never' +vim.g.ale_lint_on_insert_leave = 0 + +-- Include the linter name (e.g. 'hack' or 'hhast'), code, and message in errors +vim.g.ale_echo_msg_format = '[%linter%] %s' +vim.g.ale_linters = { + hack = {'hack', 'hhast'}, + haskell = {"hlint"}, + javascript = {'eslint'}, + d = {'dmd'}, + php = {'phpcs', 'phpstan'}, + ruby = {'rubocop'}, + cpp = {}, + asm = {}, +} +vim.g.ale_ruby_rubocop_executable = 'bundle' +vim.g.ale_cpp_cc_options = '-std=c++17 -Wall' + +vim.g.ale_open_list = 1 +vim.g.ale_disable_lsp = 1 + +-- Setup lspconfig. +local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()) +capabilities.textDocument.foldingRange = { + dynamicRegistration = false, + lineFoldingOnly = true +} + +-- +-- Telescope +-- +require('telescope').setup { + extensions = { + ["ui-select"] = { + require("telescope.themes").get_dropdown { + } + } + } +} +require("telescope").load_extension("ui-select") + +vim.api.nvim_set_keymap('n', 'ff', "lua require('telescope.builtin').find_files()", + { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'fg', "lua require('telescope.builtin').live_grep()", + { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'fb', "lua require('telescope.builtin').buffers()", + { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'fh', "lua require('telescope.builtin').help_tags()", + { noremap = true, silent = true }) + +-- +-- Vista +-- +vim.g.vista_default_executive = 'nvim_lsp' + +-- +-- Vdebug +-- +vim.g.vdebug_options = { port = '9000' } + +-- +-- sonokai +-- +vim.g.sonokai_style = "shusia" diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua deleted file mode 100644 index 65342bf..0000000 --- a/.config/nvim/lua/plugins.lua +++ /dev/null @@ -1,202 +0,0 @@ --- --- ALE --- --- Run linters only on save -vim.g.ale_lint_on_text_changed = 'never' -vim.g.ale_lint_on_insert_leave = 0 - --- Include the linter name (e.g. 'hack' or 'hhast'), code, and message in errors -vim.g.ale_echo_msg_format = '[%linter%] %s' -vim.g.ale_linters = { - hack = {'hack', 'hhast'}, - haskell = {"hlint"}, - javascript = {'eslint'}, - d = {'dmd'}, - php = {'phpcs', 'phpstan'}, - ruby = {'rubocop'}, - cpp = {}, - asm = {}, -} -vim.g.ale_ruby_rubocop_executable = 'bundle' -vim.g.ale_cpp_cc_options = '-std=c++17 -Wall' - -vim.g.ale_open_list = 1 -vim.g.ale_disable_lsp = 1 - --- --- nvim-cmp --- -local cmp = require'cmp' - -cmp.setup({ - snippet = { - -- REQUIRED - you must specify a snippet engine - expand = function(args) - require'snippy'.expand_snippet(args.body) - end, - }, - mapping = { - [''] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), - [''] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), - [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), - -- Specify `cmp.config.disable` if you want to remove the default `` mapping. - [''] = cmp.config.disable, - [''] = cmp.mapping({ - i = cmp.mapping.abort(), - c = cmp.mapping.close(), - }), - [''] = cmp.mapping.confirm({ select = false }), - }, - sources = cmp.config.sources({ - { name = 'nvim_lsp' }, - { name = 'snippy' }, - }, { - { name = 'path' }, - }, { - { name = 'buffer' }, - }), - view = { - entries = 'native', - }, -}) - --- Setup lspconfig. -local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()) -capabilities.textDocument.foldingRange = { - dynamicRegistration = false, - lineFoldingOnly = true -} - --- --- Telescope --- -require('telescope').setup { - extensions = { - ["ui-select"] = { - require("telescope.themes").get_dropdown { - } - } - } -} -require("telescope").load_extension("ui-select") - -vim.api.nvim_set_keymap('n', 'ff', "lua require('telescope.builtin').find_files()", - { noremap = true, silent = true }) -vim.api.nvim_set_keymap('n', 'fg', "lua require('telescope.builtin').live_grep()", - { noremap = true, silent = true }) -vim.api.nvim_set_keymap('n', 'fb', "lua require('telescope.builtin').buffers()", - { noremap = true, silent = true }) -vim.api.nvim_set_keymap('n', 'fh', "lua require('telescope.builtin').help_tags()", - { noremap = true, silent = true }) - --- --- NvimTree --- -require('nvim-tree').setup {} - -vim.api.nvim_set_keymap('n', '', ':NvimTreeToggle', { noremap = true }) -vim.api.nvim_set_keymap('n', 'r', ':NvimTreeRefresh', { noremap = true }) -vim.api.nvim_set_keymap('n', 'n', ':NvimTreeFindFile', { noremap = true }) - --- --- Lualine --- -require('lualine').setup { - options = { - theme = 'sonokai' - }, - extensions = {'quickfix', 'nvim-tree', 'fugitive'}, - sections = { - lualine_c = { - 'filename' - } - } -} - --- --- Diffview.nvim --- -require('diffview').setup {} - --- --- Vista --- -vim.g.vista_default_executive = 'nvim_lsp' - --- --- nvim-ufo --- -vim.wo.foldcolumn = '1' -vim.wo.foldlevel = 99 -- feel free to decrease the value -vim.wo.foldenable = true - -require('ufo').setup() - --- --- nvim-dap --- -vim.keymap.set('n', '', function() require('dap').continue() end) -vim.keymap.set('n', '', function() require('dap').step_over() end) -vim.keymap.set('n', '', function() require('dap').step_into() end) -vim.keymap.set('n', '', function() require('dap').step_out() end) -vim.keymap.set('n', 'b', function() require('dap').toggle_breakpoint() end) -vim.keymap.set('n', 'B', function() require('dap').set_breakpoint() end) -vim.keymap.set('n', 'lp', function() require('dap').set_breakpoint(nil, nil, vim.fn.input('Log point message: ')) end) -vim.keymap.set('n', 'dr', function() require('dap').repl.open() end) -vim.keymap.set('n', 'dl', function() require('dap').run_last() end) -vim.keymap.set({'n', 'v'}, 'dh', function() - require('dap.ui.widgets').hover() -end) -vim.keymap.set({'n', 'v'}, 'dp', function() - require('dap.ui.widgets').preview() -end) -vim.keymap.set('n', 'df', function() - local widgets = require('dap.ui.widgets') - widgets.centered_float(widgets.frames) -end) -vim.keymap.set('n', 'ds', function() - local widgets = require('dap.ui.widgets') - widgets.centered_float(widgets.scopes) -end) - -local dap = require("dap") -dap.adapters.gdb = { - type = "executable", - command = "gdb", - args = { "-i", "dap" } -} -dap.configurations.cpp = { - { - name = "Launch", - type = "gdb", - request = "launch", - program = function() - return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') - end, - cwd = "${workspaceFolder}", - stopAtBeginningOfMainSubprogram = false, - }, -} - --- --- Vdebug --- -vim.g.vdebug_options = { port = '9000' } - --- --- Treesitter --- -require'nvim-treesitter.configs'.setup { - ensure_installed = { - 'haskell', 'php', 'lua', 'css', 'dockerfile', 'html', 'javascript', 'markdown', 'ruby', 'vue' - }, - highlight = { - enable = true, - additional_vim_regex_highlighting = true - } -} - --- --- sonokai --- -vim.g.sonokai_style = "shusia" diff --git a/.config/nvim/lua/plugins/all.lua b/.config/nvim/lua/plugins/all.lua new file mode 100644 index 0000000..e289994 --- /dev/null +++ b/.config/nvim/lua/plugins/all.lua @@ -0,0 +1,190 @@ +return { + { + 'mfussenegger/nvim-dap', + config = function() + vim.keymap.set('n', '', function() require('dap').continue() end) + vim.keymap.set('n', '', function() require('dap').step_over() end) + vim.keymap.set('n', '', function() require('dap').step_into() end) + vim.keymap.set('n', '', function() require('dap').step_out() end) + vim.keymap.set('n', 'b', function() require('dap').toggle_breakpoint() end) + vim.keymap.set('n', 'B', function() require('dap').set_breakpoint() end) + vim.keymap.set('n', 'lp', function() require('dap').set_breakpoint(nil, nil, vim.fn.input('Log point message: ')) end) + vim.keymap.set('n', 'dr', function() require('dap').repl.open() end) + vim.keymap.set('n', 'dl', function() require('dap').run_last() end) + vim.keymap.set({'n', 'v'}, 'dh', function() + require('dap.ui.widgets').hover() + end) + vim.keymap.set({'n', 'v'}, 'dp', function() + require('dap.ui.widgets').preview() + end) + vim.keymap.set('n', 'df', function() + local widgets = require('dap.ui.widgets') + widgets.centered_float(widgets.frames) + end) + vim.keymap.set('n', 'ds', function() + local widgets = require('dap.ui.widgets') + widgets.centered_float(widgets.scopes) + end) + + local dap = require("dap") + dap.adapters.gdb = { + type = "executable", + command = "gdb", + args = { "-i", "dap" } + } + dap.configurations.cpp = { + { + name = "Launch", + type = "gdb", + request = "launch", + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + cwd = "${workspaceFolder}", + stopAtBeginningOfMainSubprogram = false, + }, + } + end + }, + { 'airblade/vim-gitgutter' }, + { 'neovim/nvim-lspconfig' }, + { 'dense-analysis/ale' }, + { 'liuchengxu/vista.vim' }, -- Tag bar. + { + 'nvim-treesitter/nvim-treesitter', + lazy = false, + build = ':TSUpdate', + config = function() + require'nvim-treesitter.configs'.setup { + ensure_installed = { + 'haskell', 'php', 'lua', 'css', 'dockerfile', 'html', 'javascript', 'markdown', 'ruby', 'vue' + }, + highlight = { + enable = true, + additional_vim_regex_highlighting = true + } + } + end + }, + + -- Git. + { 'tpope/vim-fugitive' }, + { + 'sindrets/diffview.nvim', + dependencies = {'nvim-lua/plenary.nvim'}, + opts = {} + }, + + -- File browser. + { + 'kyazdani42/nvim-tree.lua', + dependencies = {'nvim-tree/nvim-web-devicons'}, + lazy = false, + keys = { + { "", ":NvimTreeToggle" }, + { "r", ":NvimTreeRefresh" }, + { "n", ":NvimTreeFindFile" }, + }, + opts = {} + }, -- optional, for file icon + { + 'nvim-telescope/telescope.nvim', + dependencies = {'nvim-lua/plenary.nvim'}, + lazy = false, + config = function() + end + }, + { 'nvim-telescope/telescope-ui-select.nvim', lazy = false }, + { + 'kevinhwang91/nvim-ufo', + dependencies = {'kevinhwang91/promise-async'}, + config = function() + vim.wo.foldcolumn = '1' + vim.wo.foldlevel = 99 -- feel free to decrease the value + vim.wo.foldenable = true + + require('ufo').setup() + end + }, + + -- Theme. + { + 'sainnhe/sonokai', + config = function() + vim.cmd('colorscheme sonokai') + end + }, + { + 'nvim-lualine/lualine.nvim', + dependencies = {'nvim-tree/nvim-web-devicons'}, + opts = { + options = { + theme = 'sonokai' + }, + extensions = {'quickfix', 'nvim-tree', 'fugitive'}, + sections = { + lualine_c = { + 'filename' + } + } + } + }, -- optional, for status line icons + + -- Syntax. + { 'leafOfTree/vim-vue-plugin' }, + { 'mfussenegger/nvim-jdtls' }, + { 'dart-lang/dart-vim-plugin' }, + { + 'akinsho/flutter-tools.nvim', + dependencies = { 'nvim-lua/plenary.nvim' } + }, + { 'vim-vdebug/vdebug' }, + + -- nvim-cmp + { 'dcampos/nvim-snippy' }, + { + 'hrsh7th/nvim-cmp', + dependencies = { + 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/cmp-path', + 'hrsh7th/cmp-buffer', + 'dcampos/cmp-snippy' + }, + lazy = false, + config = function() + local cmp = require'cmp' + + cmp.setup({ + snippet = { + -- REQUIRED - you must specify a snippet engine + expand = function(args) + require'snippy'.expand_snippet(args.body) + end, + }, + mapping = { + [''] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), + -- Specify `cmp.config.disable` if you want to remove the default `` mapping. + [''] = cmp.config.disable, + [''] = cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }), + [''] = cmp.mapping.confirm({ select = false }), + }, + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'snippy' }, + }, { + { name = 'path' }, + }, { + { name = 'buffer' }, + }), + view = { + entries = 'native', + }, + }) + end + } +}