From 637aecc178ef7081a647375f60bc81b3102af8a8 Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Fri, 21 Feb 2025 00:07:10 +0800 Subject: [PATCH 1/2] feat(lazy.nvim): add lazy.nvim plugin manager --- .config/nvim/lua/config/lazy.lua | 50 +++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/.config/nvim/lua/config/lazy.lua b/.config/nvim/lua/config/lazy.lua index 3a75f32..45b8778 100644 --- a/.config/nvim/lua/config/lazy.lua +++ b/.config/nvim/lua/config/lazy.lua @@ -1,4 +1,52 @@ --- Bootstrap lazy.nvim +-- Bootstrap lazy.nvim -- local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" -- Get the path for the vim install and append /lazy/lazy.nvim to it + +if not (vim.uv or vim.loop).fs_stat(lazypath) then -- Check if the directory does not exist + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + -- vim.fn.system calls a shell command + -- git clone --filter=blob:none only downloads the metadata + -- vim.v.shell_error checks exit code of shell command from last vim.fn.system + -- ~= is != + if vim.v.shell_error ~= 0 then -- check if clone successful + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, + true, -- true here displays it as an echo message, overwriting prev msgs + {}) -- empty list of options + vim.fn.getchar() -- wait for user input + os.exit(1) + end +end + +-- vim.opt.rtp is the runtime path (plugins, syntax files, etc) +-- prepend adds lazypath to the start of the runtime path +vim.opt.rtp:prepend(lazypath) + +-- Set Neovim settings here -- + +-- vim.g is global scope of nvim vars +vim.g.mapleader = " " -- prefix for user defined commands +vim.g.maplocalleader = "\\" -- prefix for buffer local mappings (one backslash only) + +-- Setup lazy.nvim -- + +require("lazy").setup({ -- loads the lazy module + spec = { + -- Import plugins here + { import = "plugins" }, + }, + -- Configure other settings here. + rocks = { + hererocks = true, + }, + install = { + colorscheme = { "habamax" } + }, + -- automatically check for plugin updates + checker = { enabled = true }, +}) From 54c18b649361ccc21fd5d3ec4886a9caf4f4e386 Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Fri, 21 Feb 2025 00:27:30 +0800 Subject: [PATCH 2/2] feat(nvim-tree): add file explorer --- .config/nvim/init.lua | 2 ++ .config/nvim/lua/plugins/init.lua | 11 +++++++++++ 2 files changed, 13 insertions(+) create mode 100644 .config/nvim/lua/plugins/init.lua diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index b45ed2f..d9a344a 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -1,5 +1,7 @@ -- Plugins require("config.lazy") +vim.g.loaded_netrw = 1 -- Disables netrw +vim.g.loaded_newtwPlugin = 1 -- for nvim-tree -- Visual vim.opt.number = true -- Show line numbers diff --git a/.config/nvim/lua/plugins/init.lua b/.config/nvim/lua/plugins/init.lua new file mode 100644 index 0000000..4642112 --- /dev/null +++ b/.config/nvim/lua/plugins/init.lua @@ -0,0 +1,11 @@ +return { -- Lua table + "nvim-tree/nvim-tree.lua", -- github repo + version = "*", -- latest version + lazy = false, -- dont use lazy loading + dependencies = { + "nvim-tree/nvim-web-devicons", + }, + config = function() + require("nvim-tree").setup {} + end, +}