From 102f9a5608cbb7b5553cd0d1862b6bd8e40c8075 Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 11 May 2025 00:43:32 +0200 Subject: refractored neovim config --- nvim/lua/plugins.lua | 359 ++++++++++++++++++++++----------------------------- 1 file changed, 156 insertions(+), 203 deletions(-) (limited to 'nvim/lua/plugins.lua') diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua index 79b4c5f..a04187c 100644 --- a/nvim/lua/plugins.lua +++ b/nvim/lua/plugins.lua @@ -1,8 +1,10 @@ --- lazy plugin manager +-- Plugin declarations +-- All plugins used in Neovim are defined here + + +-- Bootstrap lazy.nvim local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not vim.loop.fs_stat(lazypath) then - -- bootstrap lazy.nvim - -- stylua: ignore vim.fn.system({ "git", "clone", @@ -12,245 +14,196 @@ if not vim.loop.fs_stat(lazypath) then lazypath, }) end -vim.opt.rtp:prepend(vim.env.LAZY or lazypath) - -require("lazy").setup({ +vim.opt.rtp:prepend(lazypath) + +-- Initialize lazy.nvim with plugins +require("lazy").setup({ + ------------------------------------------------------------ + -- UI + ------------------------------------------------------------ + -- Colorscheme { "folke/tokyonight.nvim", - init = function() + lazy = false, + priority = 1000, + config = function() vim.cmd.colorscheme("tokyonight-night") - end + end, }, + -- File browser { - 'tpope/vim-fugitive', + 'stevearc/oil.nvim', + dependencies = { "nvim-tree/nvim-web-devicons" }, + cmd = "Oil", }, + -- Terminal { - { - 'VonHeikemen/lsp-zero.nvim', - branch = 'v3.x', - lazy = true, - config = false, - init = function() - -- Disable automatic setup, we are doing it manually - vim.g.lsp_zero_extend_cmp = 0 - vim.g.lsp_zero_extend_lspconfig = 0 - end, - }, - - { - 'williamboman/mason.nvim', - lazy = false, - config = true, - }, - - { - 'neovim/nvim-lspconfig', - dependencies = { - {'hrsh7th/cmp-nvim-lsp'}, - } - }, - - -- Autocompletion - { - 'hrsh7th/nvim-cmp', - event = 'InsertEnter', - dependencies = { - {'L3MON4D3/LuaSnip', - 'hrsh7th/cmp-path', - }, - }, - config = function() - -- Here is where you configure the autocompletion settings. - local lsp_zero = require('lsp-zero') - lsp_zero.extend_cmp() - - -- And you can configure cmp even more, if you want to. - local cmp = require('cmp') - local cmp_action = lsp_zero.cmp_action() - - cmp.setup({ - formatting = lsp_zero.cmp_format(), - sources = { - { name = 'nvim_lsp' }, -- Enable LSP-based completion - { name = 'path' }, -- Enables path completion - { name = 'buffer' }, -- Buffer source for plain text completion - }, - mapping = cmp.mapping.preset.insert({ - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp_action.luasnip_jump_forward(), - [''] = cmp_action.luasnip_jump_backward(), - }), - - -- }, - }) - end - }, - -- LSP - { - 'neovim/nvim-lspconfig', - cmd = {'LspInfo', 'LspInstall', 'LspStart'}, - event = {'BufReadPre', 'BufNewFile'}, - dependencies = { - {'hrsh7th/cmp-nvim-lsp'}, - {'williamboman/mason-lspconfig.nvim'}, - }, - config = function() - -- This is where all the LSP shenanigans will live - local lsp_zero = require('lsp-zero') - lsp_zero.extend_lspconfig() - - lsp_zero.on_attach(function(client, bufnr) - -- see :help lsp-zero-keybindings - -- to learn the available actions - lsp_zero.default_keymaps({buffer = bufnr}) - end) - - - require('mason-lspconfig').setup({ - ensure_installed = {}, - handlers = { - lsp_zero.default_setup, - lua_ls = function() - -- (Optional) Configure lua language server for neovim - local lua_opts = lsp_zero.nvim_lua_ls() - require('lspconfig').lua_ls.setup(lua_opts) - end, - -- ADD THIS SECTION for clangd: - clangd = function() - require('lspconfig').clangd.setup({ - cmd = { "clangd", "--header-insertion=never" }, - -- No root_dir specification that requires compile_commands.json - }) - end, - } - }) - end - } - + 'akinsho/toggleterm.nvim', + version = "*", + cmd = {"ToggleTerm", "ToggleTermSendCurrentLine", "ToggleTermSendVisualLines"}, }, + ------------------------------------------------------------ + -- EDITOR ENHANCEMENTS + ------------------------------------------------------------ + + -- Telescope (fuzzy finder) { 'nvim-telescope/telescope.nvim', - -- or , branch = '0.1.x', - dependencies = { 'nvim-lua/plenary.nvim' } + dependencies = { 'nvim-lua/plenary.nvim' }, + cmd = "Telescope", }, + -- Harpoon (quick file navigation) { - 'nvim-treesitter/nvim-treesitter', - build = ':TSUpdate', - config = function () - local configs = require("nvim-treesitter.configs") - - configs.setup({ - ensure_installed = { "c", "lua", "vim", "vimdoc", "cpp", "python"}, --add "neorg here" - sync_install = false, - highlight = { - enable = true - }, - indent = { - enable = true - }, - }) - end + "ThePrimeagen/harpoon", + branch = "harpoon2", + dependencies = { "nvim-lua/plenary.nvim" }, }, + -- Git integration { - 'mbbill/undotree' + 'tpope/vim-fugitive', + cmd = {"Git", "Gstatus", "Gblame", "Gdiffsplit", "Gread", "Gwrite", "Ggrep", "GMove", "GDelete"}, }, - {'akinsho/toggleterm.nvim', - version = "*", - opts = { - shell = "pwsh.exe -NoLogo", - winbar = { - enabled =false - }, - direction = 'float', - border = 'none', -- No border around the terminal - -- width = function() - -- return vim.o.columns -- Full width of the screen - -- end, - -- height = function() - -- return vim.o.lines -- Full height minus command line - -- end, - -- width = 800, - -- height = 700, - } + -- Undo history visualization + { + 'mbbill/undotree', + cmd = "UndotreeToggle", }, + + ------------------------------------------------------------ + -- CODE EDITING + ------------------------------------------------------------ + + -- Syntax highlighting { - 'windwp/nvim-autopairs', - event = "InsertEnter", - config = true - -- use opts = {} for passing setup options - -- this is equivalent to setup({}) function -}, + 'nvim-treesitter/nvim-treesitter', + build = ':TSUpdate', + event = { "BufReadPost", "BufNewFile" }, + cmd = { "TSUpdateSync", "TSUpdate", "TSInstall" }, + dependencies = { + 'nvim-treesitter/nvim-treesitter-context', + }, + }, + -- Comments { 'numToStr/Comment.nvim', - lazy = false, - opts= { - -- filetype = { - -- seq ={ - -- commentstring ="! %s" - -- } - -- }, - ---Add a space b/w comment and the line - padding = true, - ---Whether the cursor should stay at its position - sticky = true, - ---Lines to be ignored while (un)comment - ignore = nil, - ---LHS of toggle mappings in NORMAL mode - toggler = { - ---Line-comment toggle keymap - line = '/', - ---Block-comment toggle keymap - block = 'gbc', - }, - ---LHS of operator-pending mappings in NORMAL and VISUAL mode - opleader = { - ---Line-comment keymap - line = '/', - ---Block-comment keymap - block = 'gb', - }} + event = { "BufReadPost", "BufNewFile" }, }, - + -- Auto brackets { - 'nvim-treesitter/nvim-treesitter-context' + 'windwp/nvim-autopairs', + event = "InsertEnter", + config = true, }, + + -- LaTeX support { "lervag/vimtex", - lazy = false, -- we don't want to lazy load VimTeX - -- tag = "v2.15", -- uncomment to pin to a specific release + ft = {"tex", "latex"}, init = function() - -- VimTeX configuration goes here, e.g. vim.g.vimtex_view_method = "mupdf" end }, - -- { - -- "nvim-telescope/telescope-file-browser.nvim", - -- dependencies = { "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim" }, - -- - -- }, - + ------------------------------------------------------------ + -- LSP & COMPLETION + ------------------------------------------------------------ + + -- LSP Base { - "ThePrimeagen/harpoon", - branch = "harpoon2", - dependencies = { "nvim-lua/plenary.nvim" } + "mason-org/mason.nvim", + "mason-org/mason-lspconfig.nvim", + "neovim/nvim-lspconfig", +}, + { + "folke/lazydev.nvim", + ft = "lua", -- only load on lua files + opts = { + library = { + -- See the configuration section for more details + -- Load luvit types when the `vim.uv` word is found + { path = "${3rd}/luv/library", words = { "vim%.uv" } }, + }, }, + }, + + -- Autocompletion { - 'stevearc/oil.nvim', - opts = {}, - -- Optional dependencies - -- dependencies = { "echasnovski/mini.icons" }, - dependencies = { "nvim-tree/nvim-web-devicons" }, -- use if prefer nvim-web-devicons - } + 'saghen/blink.cmp', + -- optional: provides snippets for the snippet source + dependencies = { 'rafamadriz/friendly-snippets' }, + + version = '1.*', + opts = { + -- 'default' (recommended) for mappings similar to built-in completions (C-y to accept) + -- 'super-tab' for mappings similar to vscode (tab to accept) + -- 'enter' for enter to accept + -- 'none' for no mappings + -- + -- All presets have the following mappings: + -- C-space: Open menu or open docs if already open + -- C-n/C-p or Up/Down: Select next/previous item + -- C-e: Hide menu + -- C-k: Toggle signature help (if signature.enabled = true) + -- + -- See :h blink-cmp-config-keymap for defining your own keymap + keymap = { preset = 'default' }, + + appearance = { + -- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font' + -- Adjusts spacing to ensure icons are aligned + nerd_font_variant = 'mono' + }, + + -- (Default) Only show the documentation popup when manually triggered + completion = { documentation = { auto_show = true} }, + + -- Default list of enabled providers defined so that you can extend it + -- elsewhere in your config, without redefining it, due to `opts_extend` +sources = { + -- add lazydev to your completion providers + default = { "lazydev", "lsp", "path", "snippets", "buffer" }, + providers = { + lazydev = { + name = "LazyDev", + module = "lazydev.integrations.blink", + -- make lazydev completions top priority (see `:h blink.cmp`) + score_offset = 100, + }, + }, + }, + -- (Default) Rust fuzzy matcher for typo resistance and significantly better performance + -- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation, + -- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"` + -- + -- See the fuzzy documentation for more information + fuzzy = { implementation = "prefer_rust_with_warning" } + }, + opts_extend = { "sources.default" } +}, + +}, { + -- Lazy.nvim options + install = { colorscheme = { "tokyonight-night" } }, + checker = { enabled = true, frequency = 86400 }, -- Check for updates once per day + change_detection = { notify = false }, + performance = { + rtp = { + disabled_plugins = { + "gzip", + "tarPlugin", + "tohtml", + "tutor", + "zipPlugin", + }, + }, + }, }) -- cgit v1.2.3