From c28dd3e9a97ba723aafc2f5e360291a2360e7739 Mon Sep 17 00:00:00 2001 From: agryphus Date: Wed, 11 Dec 2024 14:54:20 -0500 Subject: [PATCH] nvim bump + switch from packer -> lazy --- .gitignore | 2 +- after/plugin/colors.lua | 2 +- after/plugin/dashboard.lua | 60 +++++++--------- after/plugin/fugative.lua | 2 +- after/plugin/lsp.lua | 14 ++-- after/plugin/nvimtree.lua | 20 +++--- after/plugin/telescope.lua | 13 ++-- after/plugin/whichkey.lua | 11 +-- lua/andrew/init.lua | 2 +- lua/andrew/lazy.lua | 119 ++++++++++++++++++++++++++++++++ lua/andrew/packer.lua | 138 ------------------------------------- lua/andrew/remap.lua | 29 ++++++++ 12 files changed, 209 insertions(+), 203 deletions(-) create mode 100644 lua/andrew/lazy.lua delete mode 100644 lua/andrew/packer.lua diff --git a/.gitignore b/.gitignore index ef02d0c..8b55343 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -/plugin/ +lazy-lock.json diff --git a/after/plugin/colors.lua b/after/plugin/colors.lua index 4f38b16..64bc395 100644 --- a/after/plugin/colors.lua +++ b/after/plugin/colors.lua @@ -200,7 +200,7 @@ hl(0, 'NvimTreeCursorLine', { fg = palette.yellow }) hl(0, 'NvimTreeEndOfBuffer', { fg = palette.medium_gray }) hl(0, 'NvimTreeIndentMarker', { fg = palette.medium_gray }) hl(0, 'NvimTreeFolderIcon', { fg = palette.yellow }) -hl(0, 'WhichKeyFloat', { bg = nil }) +hl(0, 'WhichKeyBorder', { fg = palette.medium_gray, bg = palette.accent }) hl(0, 'WhichKeyDesc', { link = "function" }) hl(0, 'WhichKey', { fg = palette.medium_gray_blue }) hl(0, 'WhichKeyGroup', { fg = palette.gray_blue, bold = true }) diff --git a/after/plugin/dashboard.lua b/after/plugin/dashboard.lua index 711ee35..dcf4114 100644 --- a/after/plugin/dashboard.lua +++ b/after/plugin/dashboard.lua @@ -1,52 +1,44 @@ local alpha = require("alpha") local dashboard = require("alpha.themes.dashboard") -math.randomseed(os.time()) - -local function pick_color() - local colors = {"String", "Identifier", "Keyword", "Number"} - return colors[math.random(#colors)] -end - local function footer() - local total_plugins = #vim.tbl_keys(packer_plugins) - local version = vim.version() - local nvim_version_info = " NVIM v" .. version.major .. "." .. version.minor .. "." .. version.patch - - return nvim_version_info .. " 󰏖 " .. total_plugins .. " plugins" + local total_plugins = #require("lazy").plugins() + local version = vim.version() + local nvim_version_info = " NVIM v" .. version.major .. "." .. version.minor .. "." .. version.patch + return nvim_version_info .. " 󰏖 " .. total_plugins .. " plugins" end -- Set header dashboard.section.header.val = { - " ⣴⣶⣤⡤⠦⣤⣀⣤⠆ ⣈⣭⣭⣿⣶⣿⣦⣼⣆ ", - " ⠉⠻⢿⣿⠿⣿⣿⣶⣦⠤⠄⡠⢾⣿⣿⡿⠋⠉⠉⠻⣿⣿⡛⣦ ", - " ⠈ ⠈⢿⣿⣟⠦⠄⣾⣿⣿⣷ ⠻⠿⢿⣿⣧⣄ ", - " ⣸⣿⣿⢧⠄⢻⠻⣿⣿⣷⣄⣀⠄⠢⣀⡀⠈⠙⠿⠄ ", - " ⢠⣿⣿⣿⠈ ⠡⠌⣻⣿⣿⣿⣿⣿⣿⣿⣛⣳⣤⣀⣀ ", - " ⢠⣧⣶⣥⡤⢄ ⣸⣿⣿⠘ ⢀⣴⣿⣿⡿⠛⣿⣿⣧⠈⢿⠿⠟⠛⠻⠿ ", - " ⣰⣿⣿⠛⠻⣿⣿⡦⢹⣿⣷⠄ ⢊⣿⣿⡏ ⢸⣿⣿⡇ ⢀⣠⣄⣾⠄ ", - "⣠⣿⠿⠛ ⢀⣿⣿⣷⠘⢿⣿⣦⡀ ⢸⢿⣿⣿⣄ ⣸⣿⣿⡇⣪⣿⡿⠿⣿⣷⡄ ", - "⠙⠃ ⣼⣿⡟⠌ ⠈⠻⣿⣿⣦⣌⡇⠻⣿⣿⣷⣿⣿⣿⠐⣿⣿⡇ ⠛⠻⢷⣄", - " ⢻⣿⣿⣄ ⠈⠻⣿⣿⣿⣷⣿⣿⣿⣿⣿⡟ ⠫⢿⣿⡆ ⠁", - " ⠻⣿⣿⣿⣿⣶⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣀⣤⣾⡿⠃ ", - "⢀⣀⠀⣠⣀⣠⣾⣿⣿⡿⠛⠋⠉⠉⠉ ⠉⠉⠉⠉⠛⠻⣿⣿⣷⣄⣀⢿⡽⢻⣦", - "⠻⠶⠾⠿⠿⠿⠋⠉ N E O V I M ⠉⠻⠿⠿⠿⠿⠿⠋", + " ⣴⣶⣤⡤⠦⣤⣀⣤⠆ ⣈⣭⣭⣿⣶⣿⣦⣼⣆ ", + " ⠉⠻⢿⣿⠿⣿⣿⣶⣦⠤⠄⡠⢾⣿⣿⡿⠋⠉⠉⠻⣿⣿⡛⣦ ", + " ⠈ ⠈⢿⣿⣟⠦⠄⣾⣿⣿⣷ ⠻⠿⢿⣿⣧⣄ ", + " ⣸⣿⣿⢧⠄⢻⠻⣿⣿⣷⣄⣀⠄⠢⣀⡀⠈⠙⠿⠄ ", + " ⢠⣿⣿⣿⠈ ⠡⠌⣻⣿⣿⣿⣿⣿⣿⣿⣛⣳⣤⣀⣀ ", + " ⢠⣧⣶⣥⡤⢄ ⣸⣿⣿⠘ ⢀⣴⣿⣿⡿⠛⣿⣿⣧⠈⢿⠿⠟⠛⠻⠿ ", + " ⣰⣿⣿⠛⠻⣿⣿⡦⢹⣿⣷⠄ ⢊⣿⣿⡏ ⢸⣿⣿⡇ ⢀⣠⣄⣾⠄ ", + "⣠⣿⠿⠛ ⢀⣿⣿⣷⠘⢿⣿⣦⡀ ⢸⢿⣿⣿⣄ ⣸⣿⣿⡇⣪⣿⡿⠿⣿⣷⡄ ", + "⠙⠃ ⣼⣿⡟⠌ ⠈⠻⣿⣿⣦⣌⡇⠻⣿⣿⣷⣿⣿⣿⠐⣿⣿⡇ ⠛⠻⢷⣄", + " ⢻⣿⣿⣄ ⠈⠻⣿⣿⣿⣷⣿⣿⣿⣿⣿⡟ ⠫⢿⣿⡆ ⠁", + " ⠻⣿⣿⣿⣿⣶⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣀⣤⣾⡿⠃ ", + "⢀⣀⠀⣠⣀⣠⣾⣿⣿⡿⠛⠋⠉⠉⠉ ⠉⠉⠉⠉⠛⠻⣿⣿⣷⣄⣀⢿⡽⢻⣦", + "⠻⠶⠾⠿⠿⠿⠋⠉ N E O V I M ⠉⠻⠿⠿⠿⠿⠿⠋", } -- Set menu dashboard.section.buttons.val = { - dashboard.button( "e", " New file" , ":ene startinsert "), - dashboard.button( "q", "󰩈 Quit NVIM", ":qa"), + dashboard.button( "e", " New file" , ":ene startinsert "), + dashboard.button( "q", "󰩈 Quit NVIM", ":qa"), } vim.api.nvim_create_autocmd("VimEnter", { - once = true, - callback = function() - math.randomseed(os.time()) - local fg_color = tostring(math.random(0, 12)) - local hi_setter = "hi AlphaHeader ctermfg=" - vim.cmd(hi_setter .. fg_color) - end + once = true, + callback = function() + math.randomseed(os.time()) + local fg_color = tostring(math.random(0, 12)) + local hi_setter = "hi AlphaHeader ctermfg=" + vim.cmd(hi_setter .. fg_color) + end }) dashboard.section.footer.val = footer() diff --git a/after/plugin/fugative.lua b/after/plugin/fugative.lua index 12b6d67..9aa8d81 100644 --- a/after/plugin/fugative.lua +++ b/after/plugin/fugative.lua @@ -1,4 +1,4 @@ local wk = require("which-key") -wk.register({g = { name = "git" }, prefix = ""}) +-- wk.add({g = { name = "git" }, prefix = ""}) vim.keymap.set("n", "gs", vim.cmd.Git, { desc = "Git status" }) diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua index 541b066..3c075d2 100644 --- a/after/plugin/lsp.lua +++ b/after/plugin/lsp.lua @@ -59,11 +59,13 @@ cmp.setup({ } }) --- DIAGNOSTICS - -- Show all diagnostics on current line in floating window -vim.api.nvim_set_keymap( - 'n', 'gl', ':lua vim.diagnostic.open_float()', - { noremap = true, silent = true } -) +vim.keymap.set("n", "gl", ":lua vim.diagnostic.open_float()", + { noremap = true, silent = true }) + +vim.keymap.set("n", "le", ":LspStop", + { desc = "LSP Stop" }) + +vim.keymap.set("n", "ls", ":LspStart", + { desc = "LSP Start" }) diff --git a/after/plugin/nvimtree.lua b/after/plugin/nvimtree.lua index 4643fac..c7fb634 100644 --- a/after/plugin/nvimtree.lua +++ b/after/plugin/nvimtree.lua @@ -1,10 +1,10 @@ --- set termguicolors to enable highlight groups -vim.opt.termguicolors = true - -require("nvim-tree").setup() - -vim.keymap.set("n", "pt", vim.cmd.NvimTreeToggle) - --- sets transparent background -vim.cmd[[hi NvimTreeNormal guibg=NONE ctermbg=NONE]] - +-- -- set termguicolors to enable highlight groups +-- vim.opt.termguicolors = true +-- +-- require("nvim-tree").setup() +-- +-- vim.keymap.set("n", "pt", vim.cmd.NvimTreeToggle) +-- +-- -- sets transparent background +-- vim.cmd[[hi NvimTreeNormal guibg=NONE ctermbg=NONE]] +-- diff --git a/after/plugin/telescope.lua b/after/plugin/telescope.lua index c9edaeb..4f6234d 100644 --- a/after/plugin/telescope.lua +++ b/after/plugin/telescope.lua @@ -8,19 +8,20 @@ require("telescope").setup{ local wk = require("which-key") --- p -wk.register({p = { name = "project" }, prefix = ""}) +vim.keymap.set("n", "p", "", {desc = "Project"}) vim.keymap.set("n", "pf", builtin.find_files, {desc = "Project find"}) -vim.keymap.set("n", "ps", function () +vim.keymap.set("n", "ps", + function () builtin.grep_string({ search = vim.fn.input("Grep > ") }) - end , {desc = "Project search"}) + end, + { desc = "Project search" }) -- f -wk.register({f = { name = "find" }, prefix = ""}) +-- wk.add({f = { name = "find" }, prefix = ""}) vim.keymap.set("n", "fr", builtin.oldfiles, { desc = "Find recent" }) -- h -wk.register({h = { name = "help" }, prefix = ""}) +-- wk.add({h = { name = "help" }, prefix = ""}) vim.keymap.set("n", "ht", builtin.colorscheme, { desc = "Load theme" }) vim.keymap.set("n", "hf", builtin.commands , { desc = "Describe function" }) vim.keymap.set("n", "hk", builtin.keymaps , { desc = "Describe key" }) diff --git a/after/plugin/whichkey.lua b/after/plugin/whichkey.lua index f1fd478..07541e0 100644 --- a/after/plugin/whichkey.lua +++ b/after/plugin/whichkey.lua @@ -1,11 +1,11 @@ require("which-key").setup({ - window = { + win = { border = "single", -- none, single, double, shadow - position = "bottom", -- bottom, top - margin = { 0, 0, 0, 0 }, -- extra window margin [top, right, bottom, left]. When between 0 and 1, will be treated as a percentage of the screen size. - padding = { 0, 2, 0, 2 }, -- extra window padding [top, right, bottom, left] - winblend = 0, -- value between 0-100 0 for fully opaque and 100 for fully transparent + padding = { 0, 0, 0, 0 }, -- extra window padding [top, right, bottom, left] zindex = 1000, -- positive value to position WhichKey above other floating windows. + wo = { + winblend = 0, -- value between 0-100 0 for fully opaque and 100 for fully transparent + }, }, layout = { height = { min = 4, max = 25 }, -- min and max height of the columns @@ -14,3 +14,4 @@ require("which-key").setup({ align = "left", -- align columns left, center or right }, }) + diff --git a/lua/andrew/init.lua b/lua/andrew/init.lua index 180a9a4..375ca3c 100644 --- a/lua/andrew/init.lua +++ b/lua/andrew/init.lua @@ -1,4 +1,4 @@ require("andrew.remap") -require("andrew.packer") +require("andrew.lazy") require("andrew.set") diff --git a/lua/andrew/lazy.lua b/lua/andrew/lazy.lua new file mode 100644 index 0000000..d31952f --- /dev/null +++ b/lua/andrew/lazy.lua @@ -0,0 +1,119 @@ +-- 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({ + -- Terminal file manager support + -- "DreamMaoMao/yazi.nvim", + { + "mikavilpas/yazi.nvim", + event = "VeryLazy", + }, + + -- Dashboard buffer + { + "goolord/alpha-nvim", + -- dependencies = { 'echasnovski/mini.icons' }, + dependencies = { 'nvim-tree/nvim-web-devicons' }, + }, + + -- Zen mode + "folke/zen-mode.nvim", + + -- Show valid keys mid key chord + "folke/which-key.nvim", + -- config = function() + -- vim.o.timeout = true + -- vim.o.timeoutlen = 300 + -- end + + -- Find files and strings + { + 'nvim-telescope/telescope.nvim', tag = '0.1.8', + dependencies = { 'nvim-lua/plenary.nvim' }, + }, + + { + "nvim-treesitter/nvim-treesitter", + run = ":TSUpdate" + }, + + -- Themes + "aktersnurra/no-clown-fiesta.nvim", + "ellisonleao/gruvbox.nvim", + { 'rose-pine/neovim', as = 'rose-pine' }, + 'Mofiqul/vscode.nvim', + + -- Referencing a hex code highlights it in that color + "norcalli/nvim-colorizer.lua", + + -- Relative line numbers disappear when not actively in buffer + "jeffkreeftmeijer/vim-numbertoggle", + + -- History visualizer + "mbbill/undotree", + + -- See function signatures when typing them + { + "ray-x/lsp_signature.nvim", + event = "VeryLazy", + opts = {}, + config = function(_, opts) require'lsp_signature'.setup(opts) end + }, + + -- Left-side file tree dispaly + { + "nvim-tree/nvim-tree.lua", + requires = { + "nvim-tree/nvim-web-devicons", -- for file icons + }, + }, + + -- Shows current mode on bottom of screen + "itchyny/lightline.vim", + + -- LSP + {'VonHeikemen/lsp-zero.nvim', branch = 'v4.x'}, + {'neovim/nvim-lspconfig'}, + {'hrsh7th/cmp-nvim-lsp'}, + {'hrsh7th/nvim-cmp'}, + + -- Better diagnostics + { + "folke/trouble.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + }, + + -- Linting + "jose-elias-alvarez/null-ls.nvim", + + -- Git wrapper + "tpope/vim-fugitive", + + -- Latex editing in vim + "lervag/vimtex", + + -- Auto comment + "numToStr/Comment.nvim", +}) + diff --git a/lua/andrew/packer.lua b/lua/andrew/packer.lua deleted file mode 100644 index cee7773..0000000 --- a/lua/andrew/packer.lua +++ /dev/null @@ -1,138 +0,0 @@ -local ensure_packer = function() - local fn = vim.fn - local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim' - if fn.empty(fn.glob(install_path)) > 0 then - fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path}) - vim.cmd [[packadd packer.nvim]] - return true - end - return false -end - -local packer_bootstrap = ensure_packer() - -return require("packer").startup(function(use) - use "wbthomason/packer.nvim" - - -- QML syntax highlighting - use "peterhoeg/vim-qml" - - -- Terminal file manager support - use "DreamMaoMao/yazi.nvim" - - -- Coq support - use "whonore/Coqtail" - - -- Dashboard buffer - use "goolord/alpha-nvim" - - -- Show valid keys mid key chord - use { - "folke/which-key.nvim", - config = function() - vim.o.timeout = true - vim.o.timeoutlen = 300 - end - } - - -- File manager in nvim - use { - "ptzz/lf.vim", - requires = { {"voldikss/vim-floaterm"} }, - } - vim.cmd("let g:lf_map_keys = 0") -- Need to put here or else doesn't work - - -- Zen mode - use "folke/zen-mode.nvim" - - -- Find files and strings - use { - "nvim-telescope/telescope.nvim", tag = "0.1.4", - requires = { {"nvim-lua/plenary.nvim"} } - } - - -- Treesitter - use({"nvim-treesitter/nvim-treesitter", run = ":TSUpdate"}) - - -- Themes - use "aktersnurra/no-clown-fiesta.nvim" - use "ellisonleao/gruvbox.nvim" - use { 'rose-pine/neovim', as = 'rose-pine' } - use 'Mofiqul/vscode.nvim' - - -- Referencing a hex code highlights it in that color - use "norcalli/nvim-colorizer.lua" - - -- Relative line numbers disappear when not actively in buffer - use "jeffkreeftmeijer/vim-numbertoggle" - - -- History visualizer - use "mbbill/undotree" - - -- See function signatures when typing them - use "ray-x/lsp_signature.nvim" - require "lsp_signature".setup({}) - - -- Left-side file tree dispaly - use { - "nvim-tree/nvim-tree.lua", - requires = { - "nvim-tree/nvim-web-devicons", -- for file icons - }, - tag = "nightly" -- optional, updated every week - } - - -- Shows current mode on bottom of screen - use "itchyny/lightline.vim" - - -- LSP - use { - 'VonHeikemen/lsp-zero.nvim', - branch = 'v3.x', - requires = { - -- LSP Support - {'neovim/nvim-lspconfig'}, -- Required - - -- Autocompletion - {'hrsh7th/nvim-cmp'}, -- Required - {'hrsh7th/cmp-nvim-lsp'}, -- Required - {'hrsh7th/cmp-buffer'}, -- Optional - {'hrsh7th/cmp-path'}, -- Optional - {'saadparwaiz1/cmp_luasnip'}, -- Optional - {'hrsh7th/cmp-nvim-lua'}, -- Optional - - -- Snippets - {'L3MON4D3/LuaSnip'}, -- Required - {'rafamadriz/friendly-snippets'}, -- Optional - } - } - - -- Better diagnostics - use { - "folke/trouble.nvim", - dependencies = { "nvim-tree/nvim-web-devicons" }, - } - - -- Linting - use "jose-elias-alvarez/null-ls.nvim" - - -- Git wrapper - use("tpope/vim-fugitive") - - -- Latex editing in vim - use "lervag/vimtex" - - -- Auto comment - use "numToStr/Comment.nvim" - - -- Jupyter notebook integration - -- use { - -- "glacambre/firenvim", - -- run = function() vim.fn["firenvim#install"](0) end - -- } - - if packer_bootstrap then - require('packer').sync() - end -end) - diff --git a/lua/andrew/remap.lua b/lua/andrew/remap.lua index c620ac3..9185372 100644 --- a/lua/andrew/remap.lua +++ b/lua/andrew/remap.lua @@ -46,6 +46,35 @@ vim.keymap.set("n", "tc", end, {desc = "Toggle color column"}) +vim.keymap.set("n", "t", "", {desc = "Toggle"}) +vim.keymap.set("n", "tl", + function () + if vim.wo.number == false and vim.wo.relativenumber == false then + vim.wo.number = true + print("absolute numbers") + elseif vim.wo.number == true and vim.wo.relativenumber == false then + vim.wo.relativenumber = true + print("relative line numbers") + else + vim.wo.number = false + vim.wo.relativenumber = false + print("no line numbers") + end + end, + {desc = "Toggle line numbers"}) + +vim.keymap.set("n", "tw", + function () + if vim.wo.wrap then + vim.wo.wrap = false + print("nowrap") + else + vim.wo.wrap = true + print("wrap") + end + end, + {desc = "Toggle line wrapping"}) + -- case insensitive search vim.keymap.set("n", "/", "/\\c") vim.keymap.set("n", "?", "?\\c")