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:
parent
79b55158e1
commit
23e69634da
73
init.lua
73
init.lua
|
@ -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
|
||||
-- See `:help mapleader`
|
||||
-- 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
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
-- [[ Configure plugins ]]
|
||||
-- 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' },
|
||||
}, {})
|
||||
|
||||
-- Load settings
|
||||
require('kickstart.settings')
|
||||
require('kickstart.keymaps')
|
||||
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`
|
||||
-- vim: ts=2 sts=2 sw=2 et
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
"nvim-dap-go": { "branch": "main", "commit": "a5cc8dcad43f0732585d4793deb02a25c4afb766" },
|
||||
"nvim-dap-ui": { "branch": "master", "commit": "7e5e16427aaf814dc2d58e1b219def9ef2fa2435" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "796394fd19fb878e8dbc4fd1e9c9c186ed07a5f4" },
|
||||
"nvim-tree.lua": { "branch": "master", "commit": "b8c3a23e76f861d5f0ff3f6714b9b56388984d0b" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "8cd2b230174efbf7b5d9f49fe2f90bda6b5eb16e" },
|
||||
"nvim-treesitter-textobjects": { "branch": "master", "commit": "85b9d0cbd4ff901abcda862b50dbb34e0901848b" },
|
||||
"nvim-web-devicons": { "branch": "master", "commit": "db0c864375c198cacc171ff373e76bfce2a85045" },
|
||||
|
|
|
@ -291,7 +291,7 @@ end
|
|||
|
||||
return {
|
||||
'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,
|
||||
config = function()
|
||||
local alpha = require("alpha")
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
return {
|
||||
'nvimtools/none-ls.nvim',
|
||||
event = 'VeryLazy',
|
||||
event = { 'BufReadPre', 'BufNewFile' },
|
||||
config = function()
|
||||
local null_ls = require('null-ls')
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
return {
|
||||
-- "gc" to comment visual regions/lines
|
||||
'numToStr/Comment.nvim',
|
||||
event = { 'BufReadPre', 'BufNewFile' },
|
||||
opts = {}
|
||||
}
|
||||
|
|
|
@ -7,9 +7,7 @@
|
|||
-- kickstart.nvim and not kitchen-sink.nvim ;)
|
||||
|
||||
return {
|
||||
-- NOTE: Yes, you can install new plugins here!
|
||||
'mfussenegger/nvim-dap',
|
||||
-- NOTE: And you can specify dependencies as well
|
||||
dependencies = {
|
||||
-- Creates a beautiful debugger UI
|
||||
'rcarriga/nvim-dap-ui',
|
||||
|
@ -21,6 +19,7 @@ return {
|
|||
-- Add your own debuggers here
|
||||
'leoluz/nvim-dap-go',
|
||||
},
|
||||
event = { 'BufReadPre', 'BufNewFile' },
|
||||
config = function()
|
||||
local dap = require 'dap'
|
||||
local dapui = require 'dapui'
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
-- NOTE: First, some plugins that don't require any configuration
|
||||
return {
|
||||
-- Git related plugins
|
||||
'tpope/vim-fugitive',
|
||||
'tpope/vim-rhubarb',
|
||||
}
|
|
@ -1,6 +1,12 @@
|
|||
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 = {
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
}
|
|
@ -3,6 +3,11 @@ return {
|
|||
'lukas-reineke/indent-blankline.nvim',
|
||||
-- Enable `lukas-reineke/indent-blankline.nvim`
|
||||
-- See `:help ibl`
|
||||
event = { 'BufReadPre', 'BufNewFile' },
|
||||
main = 'ibl',
|
||||
opts = {},
|
||||
opts = {
|
||||
exclude = {
|
||||
filetypes = { 'dashboard', 'alpha', 'help', 'nvim-tree', 'lazy', 'mason' },
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ return {
|
|||
component_separators = { left = '', right = '' },
|
||||
section_separators = { left = '', right = '' },
|
||||
disabled_filetypes = {
|
||||
'NvimTree',
|
||||
statusline = {},
|
||||
winbar = {},
|
||||
},
|
||||
|
|
|
@ -13,6 +13,7 @@ return {
|
|||
-- Adds a number of user-friendly snippets
|
||||
'rafamadriz/friendly-snippets',
|
||||
},
|
||||
event = { 'BufReadPre', 'BufNewFile' },
|
||||
config = function()
|
||||
-- [[ Configure nvim-cmp ]]
|
||||
-- See `:help cmp`
|
||||
|
|
|
@ -15,6 +15,7 @@ return {
|
|||
-- Additional lua configuration, makes nvim stuff amazing!
|
||||
'folke/neodev.nvim',
|
||||
},
|
||||
event = { 'BufReadPre', 'BufNewFile' },
|
||||
config = function()
|
||||
-- [[ Configure LSP ]]
|
||||
-- This function gets run when an LSP connects to a particular buffer.
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
},
|
||||
}
|
|
@ -5,6 +5,7 @@ return {
|
|||
'nvim-treesitter/nvim-treesitter-textobjects',
|
||||
},
|
||||
build = ':TSUpdate',
|
||||
event = { 'BufReadPre', 'BufNewFile' },
|
||||
config = function()
|
||||
require 'nvim-treesitter.install'.compilers = { 'zig' }
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ return {
|
|||
end,
|
||||
},
|
||||
},
|
||||
event = 'VeryLazy',
|
||||
config = function()
|
||||
-- [[ Configure Telescope ]]
|
||||
-- See `:help telescope` and `:help telescope.setup()`
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
return {
|
||||
-- Detect tabstop and shiftwidth automatically
|
||||
'tpope/vim-sleuth',
|
||||
event = { 'BufReadPre', 'BufNewFile' },
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ return {
|
|||
-- Useful plugin to show you pending keybinds.
|
||||
'folke/which-key.nvim',
|
||||
opts = {},
|
||||
event = 'VeryLazy',
|
||||
config = function()
|
||||
-- document existing key chains
|
||||
require('which-key').register {
|
||||
|
|
|
@ -36,5 +36,9 @@ vim.o.timeoutlen = 300
|
|||
-- Set completeopt to have a better completion experience
|
||||
vim.o.completeopt = 'menuone,noselect'
|
||||
|
||||
-- NOTE: You should make sure your terminal supports this
|
||||
vim.o.termguicolors = true
|
||||
-- disable netrw at the very start of your init.lua for Nvim-tree plugin
|
||||
vim.g.loaded_netrw = 1
|
||||
vim.g.loaded_netrwPlugin = 1
|
||||
|
||||
-- set termguicolors to enable highlight groups
|
||||
vim.opt.termguicolors = true
|
||||
|
|
Loading…
Reference in New Issue