feat(plugins): Add file tree, Enable Lazy loading

I've tried to lazy load most the plugins to improve start up time.
It has been greatly reduced, from more than 600ms to just around 100ms

Bug: Line that shows up when you are inside a block(block-line) doesn't
have color.
This commit is contained in:
rajvatsal 2024-01-09 16:53:14 +05:30
parent 79b55158e1
commit 23e69634da
19 changed files with 151 additions and 78 deletions

View File

@ -1,43 +1,3 @@
--[[
=====================================================================
==================== READ THIS BEFORE CONTINUING ====================
=====================================================================
Kickstart.nvim is *not* a distribution.
Kickstart.nvim is a template for your own configuration.
The goal is that you can read every line of code, top-to-bottom, understand
what your configuration is doing, and modify it to suit your needs.
Once you've done that, you should start exploring, configuring and tinkering to
explore Neovim!
If you don't know anything about Lua, I recommend taking some time to read through
a guide. One possible example:
- https://learnxinyminutes.com/docs/lua/
And then you can explore or search through `:help lua-guide`
- https://neovim.io/doc/user/lua-guide.html
Kickstart Guide:
I have left several `:help X` comments throughout the init.lua
You should run that command and read that help section for more information.
In addition, I have some `NOTE:` items throughout the file.
These are for you, the reader to help understand what is happening. Feel free to delete
them once you know what you're doing, but they should serve as a guide for when you
are first encountering a few different constructs in your nvim config.
I hope you enjoy your Neovim journey,
- TJ
P.S. You can delete this when you're done too. It's your config now :)
--]]
-- Set <space> as the leader key -- Set <space> as the leader key
-- See `:help mapleader` -- See `:help mapleader`
-- NOTE: Must happen before plugins are required (otherwise wrong leader will be used) -- NOTE: Must happen before plugins are required (otherwise wrong leader will be used)
@ -60,34 +20,17 @@ if not vim.loop.fs_stat(lazypath) then
end end
vim.opt.rtp:prepend(lazypath) vim.opt.rtp:prepend(lazypath)
-- [[ Configure plugins ]] -- Load settings
-- NOTE: Here is where you install your plugins.
-- You can configure plugins using the `config` key.
--
-- You can also configure plugins after the setup call,
-- as they will be available in your neovim runtime.
require('lazy').setup({
-- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart
-- These are some example plugins that I've included in the kickstart repository.
-- Uncomment any of the lines below to enable them.
-- require 'kickstart.plugins.autoformat',
-- require 'kickstart.plugins.debug',
{ import = 'kickstart.plugins' },
-- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
-- You can use this folder to prevent any conflicts with this init.lua if you're interested in keeping
-- up-to-date with whatever is in the kickstart repo.
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
--
-- For additional information see: https://github.com/folke/lazy.nvim#-structuring-your-plugins
{ import = 'custom.plugins' },
}, {})
require('kickstart.settings') require('kickstart.settings')
require('kickstart.keymaps') require('kickstart.keymaps')
require('kickstart.yank-highlight') require('kickstart.yank-highlight')
-- Load plugins
require('lazy').setup({
{ import = 'kickstart.plugins' },
{ import = 'custom.plugins' },
}, {})
-- The line beneath this is called `modeline`. See `:help modeline` -- The line beneath this is called `modeline`. See `:help modeline`
-- vim: ts=2 sts=2 sw=2 et -- vim: ts=2 sts=2 sw=2 et

View File

@ -29,6 +29,7 @@
"nvim-dap-go": { "branch": "main", "commit": "a5cc8dcad43f0732585d4793deb02a25c4afb766" }, "nvim-dap-go": { "branch": "main", "commit": "a5cc8dcad43f0732585d4793deb02a25c4afb766" },
"nvim-dap-ui": { "branch": "master", "commit": "7e5e16427aaf814dc2d58e1b219def9ef2fa2435" }, "nvim-dap-ui": { "branch": "master", "commit": "7e5e16427aaf814dc2d58e1b219def9ef2fa2435" },
"nvim-lspconfig": { "branch": "master", "commit": "796394fd19fb878e8dbc4fd1e9c9c186ed07a5f4" }, "nvim-lspconfig": { "branch": "master", "commit": "796394fd19fb878e8dbc4fd1e9c9c186ed07a5f4" },
"nvim-tree.lua": { "branch": "master", "commit": "b8c3a23e76f861d5f0ff3f6714b9b56388984d0b" },
"nvim-treesitter": { "branch": "master", "commit": "8cd2b230174efbf7b5d9f49fe2f90bda6b5eb16e" }, "nvim-treesitter": { "branch": "master", "commit": "8cd2b230174efbf7b5d9f49fe2f90bda6b5eb16e" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "85b9d0cbd4ff901abcda862b50dbb34e0901848b" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "85b9d0cbd4ff901abcda862b50dbb34e0901848b" },
"nvim-web-devicons": { "branch": "master", "commit": "db0c864375c198cacc171ff373e76bfce2a85045" }, "nvim-web-devicons": { "branch": "master", "commit": "db0c864375c198cacc171ff373e76bfce2a85045" },

View File

@ -291,7 +291,7 @@ end
return { return {
'goolord/alpha-nvim', 'goolord/alpha-nvim',
dependencies = { 'nvim-tree/nvim-web-devicons' }, -- removing fortune from dependencies fixed the highlighting(only for predefined highlights) dependencies = { 'nvim-tree/nvim-web-devicons', config = true },
lazy = false, lazy = false,
config = function() config = function()
local alpha = require("alpha") local alpha = require("alpha")

View File

@ -1,6 +1,6 @@
return { return {
'nvimtools/none-ls.nvim', 'nvimtools/none-ls.nvim',
event = 'VeryLazy', event = { 'BufReadPre', 'BufNewFile' },
config = function() config = function()
local null_ls = require('null-ls') local null_ls = require('null-ls')

View File

@ -1,5 +1,6 @@
return { return {
-- "gc" to comment visual regions/lines -- "gc" to comment visual regions/lines
'numToStr/Comment.nvim', 'numToStr/Comment.nvim',
event = { 'BufReadPre', 'BufNewFile' },
opts = {} opts = {}
} }

View File

@ -7,9 +7,7 @@
-- kickstart.nvim and not kitchen-sink.nvim ;) -- kickstart.nvim and not kitchen-sink.nvim ;)
return { return {
-- NOTE: Yes, you can install new plugins here!
'mfussenegger/nvim-dap', 'mfussenegger/nvim-dap',
-- NOTE: And you can specify dependencies as well
dependencies = { dependencies = {
-- Creates a beautiful debugger UI -- Creates a beautiful debugger UI
'rcarriga/nvim-dap-ui', 'rcarriga/nvim-dap-ui',
@ -21,6 +19,7 @@ return {
-- Add your own debuggers here -- Add your own debuggers here
'leoluz/nvim-dap-go', 'leoluz/nvim-dap-go',
}, },
event = { 'BufReadPre', 'BufNewFile' },
config = function() config = function()
local dap = require 'dap' local dap = require 'dap'
local dapui = require 'dapui' local dapui = require 'dapui'

View File

@ -1,6 +0,0 @@
-- NOTE: First, some plugins that don't require any configuration
return {
-- Git related plugins
'tpope/vim-fugitive',
'tpope/vim-rhubarb',
}

View File

@ -1,6 +1,12 @@
return { return {
-- Adds git related signs to the gutter, as well as utilities for managing changes -- Adds git related signs to the gutter, as well as utilities for managing changes
'lewis6991/gitsigns.nvim', 'lewis6991/gitsigns.nvim',
dependencies = {
-- Git related plugins
'tpope/vim-fugitive',
'tpope/vim-rhubarb',
},
event = { 'BufReadPre', 'BufNewFile' },
opts = { opts = {
-- See `:help gitsigns.txt` -- See `:help gitsigns.txt`
signs = { signs = {

View File

@ -0,0 +1,80 @@
return {
-- Adds git related signs to the gutter, as well as utilities for managing changes
'lewis6991/gitsigns.nvim',
dependencies = {
-- Git related plugins
'tpope/vim-fugitive',
'tpope/vim-rhubarb',
},
event = { 'BufReadPre', 'BufNewFile' },
opts = {
-- See `:help gitsigns.txt`
signs = {
add = { text = '+' },
change = { text = '~' },
delete = { text = '_' },
topdelete = { text = '' },
changedelete = { text = '~' },
},
on_attach = function(bufnr)
local gs = package.loaded.gitsigns
local function map(mode, l, r, opts)
opts = opts or {}
opts.buffer = bufnr
vim.keymap.set(mode, l, r, opts)
end
-- Navigation
map({ 'n', 'v' }, ']c', function()
if vim.wo.diff then
return ']c'
end
vim.schedule(function()
gs.next_hunk()
end)
return '<Ignore>'
end, { expr = true, desc = 'Jump to next hunk' })
map({ 'n', 'v' }, '[c', function()
if vim.wo.diff then
return '[c'
end
vim.schedule(function()
gs.prev_hunk()
end)
return '<Ignore>'
end, { expr = true, desc = 'Jump to previous hunk' })
-- Actions
-- visual mode
map('v', '<leader>hs', function()
gs.stage_hunk { vim.fn.line '.', vim.fn.line 'v' }
end, { desc = 'stage git hunk' })
map('v', '<leader>hr', function()
gs.reset_hunk { vim.fn.line '.', vim.fn.line 'v' }
end, { desc = 'reset git hunk' })
-- normal mode
map('n', '<leader>hs', gs.stage_hunk, { desc = 'git stage hunk' })
map('n', '<leader>hr', gs.reset_hunk, { desc = 'git reset hunk' })
map('n', '<leader>hS', gs.stage_buffer, { desc = 'git Stage buffer' })
map('n', '<leader>hu', gs.undo_stage_hunk, { desc = 'undo stage hunk' })
map('n', '<leader>hR', gs.reset_buffer, { desc = 'git Reset buffer' })
map('n', '<leader>hp', gs.preview_hunk, { desc = 'preview git hunk' })
map('n', '<leader>hb', function()
gs.blame_line { full = false }
end, { desc = 'git blame line' })
map('n', '<leader>hd', gs.diffthis, { desc = 'git diff against index' })
map('n', '<leader>hD', function()
gs.diffthis '~'
end, { desc = 'git diff against last commit' })
-- Toggles
map('n', '<leader>tb', gs.toggle_current_line_blame, { desc = 'toggle git blame line' })
map('n', '<leader>td', gs.toggle_deleted, { desc = 'toggle git show deleted' })
-- Text object
map({ 'o', 'x' }, 'ih', ':<C-U>Gitsigns select_hunk<CR>', { desc = 'select git hunk' })
end,
},
}

View File

@ -3,6 +3,11 @@ return {
'lukas-reineke/indent-blankline.nvim', 'lukas-reineke/indent-blankline.nvim',
-- Enable `lukas-reineke/indent-blankline.nvim` -- Enable `lukas-reineke/indent-blankline.nvim`
-- See `:help ibl` -- See `:help ibl`
event = { 'BufReadPre', 'BufNewFile' },
main = 'ibl', main = 'ibl',
opts = {}, opts = {
exclude = {
filetypes = { 'dashboard', 'alpha', 'help', 'nvim-tree', 'lazy', 'mason' },
},
},
} }

View File

@ -12,6 +12,7 @@ return {
component_separators = { left = '', right = '' }, component_separators = { left = '', right = '' },
section_separators = { left = '', right = '' }, section_separators = { left = '', right = '' },
disabled_filetypes = { disabled_filetypes = {
'NvimTree',
statusline = {}, statusline = {},
winbar = {}, winbar = {},
}, },

View File

@ -13,6 +13,7 @@ return {
-- Adds a number of user-friendly snippets -- Adds a number of user-friendly snippets
'rafamadriz/friendly-snippets', 'rafamadriz/friendly-snippets',
}, },
event = { 'BufReadPre', 'BufNewFile' },
config = function() config = function()
-- [[ Configure nvim-cmp ]] -- [[ Configure nvim-cmp ]]
-- See `:help cmp` -- See `:help cmp`

View File

@ -15,6 +15,7 @@ return {
-- Additional lua configuration, makes nvim stuff amazing! -- Additional lua configuration, makes nvim stuff amazing!
'folke/neodev.nvim', 'folke/neodev.nvim',
}, },
event = { 'BufReadPre', 'BufNewFile' },
config = function() config = function()
-- [[ Configure LSP ]] -- [[ Configure LSP ]]
-- This function gets run when an LSP connects to a particular buffer. -- This function gets run when an LSP connects to a particular buffer.

View File

@ -0,0 +1,33 @@
return {
"nvim-tree/nvim-tree.lua",
lazy = 'true',
cmd = { 'NvimTreeToggle', 'NvimTreeOpen' },
keys = {
{ '<S-t>', '<cmd>NvimTreeToggle .<CR>', { noremap = true, silent = true } }
},
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
"MunifTanjim/nui.nvim",
},
--[[ init = function()
vim.api.nvim_create_autocmd('BufEnter', {
pattern = 'NvimTree',
command = ":lua require('gitsigns').detach()"
})
end, ]]
opts = {
sort = {
sorter = "case_sensitive",
},
view = {
width = 38,
},
renderer = {
group_empty = true,
},
filters = {
dotfiles = true,
},
},
}

View File

@ -5,6 +5,7 @@ return {
'nvim-treesitter/nvim-treesitter-textobjects', 'nvim-treesitter/nvim-treesitter-textobjects',
}, },
build = ':TSUpdate', build = ':TSUpdate',
event = { 'BufReadPre', 'BufNewFile' },
config = function() config = function()
require 'nvim-treesitter.install'.compilers = { 'zig' } require 'nvim-treesitter.install'.compilers = { 'zig' }

View File

@ -17,6 +17,7 @@ return {
end, end,
}, },
}, },
event = 'VeryLazy',
config = function() config = function()
-- [[ Configure Telescope ]] -- [[ Configure Telescope ]]
-- See `:help telescope` and `:help telescope.setup()` -- See `:help telescope` and `:help telescope.setup()`

View File

@ -1,4 +1,5 @@
return { return {
-- Detect tabstop and shiftwidth automatically -- Detect tabstop and shiftwidth automatically
'tpope/vim-sleuth', 'tpope/vim-sleuth',
event = { 'BufReadPre', 'BufNewFile' },
} }

View File

@ -2,6 +2,7 @@ return {
-- Useful plugin to show you pending keybinds. -- Useful plugin to show you pending keybinds.
'folke/which-key.nvim', 'folke/which-key.nvim',
opts = {}, opts = {},
event = 'VeryLazy',
config = function() config = function()
-- document existing key chains -- document existing key chains
require('which-key').register { require('which-key').register {

View File

@ -36,5 +36,9 @@ vim.o.timeoutlen = 300
-- Set completeopt to have a better completion experience -- Set completeopt to have a better completion experience
vim.o.completeopt = 'menuone,noselect' vim.o.completeopt = 'menuone,noselect'
-- NOTE: You should make sure your terminal supports this -- disable netrw at the very start of your init.lua for Nvim-tree plugin
vim.o.termguicolors = true vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
-- set termguicolors to enable highlight groups
vim.opt.termguicolors = true