Move Lazy configuration to a separate file
- In lua/lazy-config.lua
This commit is contained in:
parent
c9db10beb8
commit
36bf94705a
204
init.lua
204
init.lua
@ -28,209 +28,7 @@ vim.opt.rtp:prepend(lazypath)
|
|||||||
--
|
--
|
||||||
-- You can also configure plugins after the setup call,
|
-- You can also configure plugins after the setup call,
|
||||||
-- as they will be available in your neovim runtime.
|
-- as they will be available in your neovim runtime.
|
||||||
require('lazy').setup({
|
require('lazy-config')
|
||||||
-- NOTE: First, some plugins that don't require any configuration
|
|
||||||
|
|
||||||
-- Git related plugins
|
|
||||||
'tpope/vim-fugitive',
|
|
||||||
'tpope/vim-rhubarb',
|
|
||||||
|
|
||||||
-- Detect tabstop and shiftwidth automatically
|
|
||||||
'tpope/vim-sleuth',
|
|
||||||
|
|
||||||
-- NOTE: This is where your plugins related to LSP can be installed.
|
|
||||||
-- The configuration is done below. Search for lspconfig to find it below.
|
|
||||||
{
|
|
||||||
-- LSP Configuration & Plugins
|
|
||||||
'neovim/nvim-lspconfig',
|
|
||||||
dependencies = {
|
|
||||||
-- Automatically install LSPs to stdpath for neovim
|
|
||||||
'williamboman/mason.nvim',
|
|
||||||
'williamboman/mason-lspconfig.nvim',
|
|
||||||
|
|
||||||
-- Useful status updates for LSP
|
|
||||||
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
|
|
||||||
{ 'j-hui/fidget.nvim', opts = {} },
|
|
||||||
|
|
||||||
-- Additional lua configuration, makes nvim stuff amazing!
|
|
||||||
'folke/neodev.nvim',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
-- Autocompletion
|
|
||||||
'hrsh7th/nvim-cmp',
|
|
||||||
dependencies = {
|
|
||||||
-- Snippet Engine & its associated nvim-cmp source
|
|
||||||
'L3MON4D3/LuaSnip',
|
|
||||||
'saadparwaiz1/cmp_luasnip',
|
|
||||||
|
|
||||||
-- Adds LSP completion capabilities
|
|
||||||
'hrsh7th/cmp-nvim-lsp',
|
|
||||||
'hrsh7th/cmp-path',
|
|
||||||
|
|
||||||
-- Adds a number of user-friendly snippets
|
|
||||||
'rafamadriz/friendly-snippets',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
-- Useful plugin to show you pending keybinds.
|
|
||||||
{ 'folke/which-key.nvim', opts = {} },
|
|
||||||
{
|
|
||||||
-- Adds git related signs to the gutter, as well as utilities for managing changes
|
|
||||||
'lewis6991/gitsigns.nvim',
|
|
||||||
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,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
-- Theme: Rosé-Pine
|
|
||||||
'rose-pine/neovim',
|
|
||||||
name = 'rose-pine',
|
|
||||||
priority = 1000,
|
|
||||||
config = function()
|
|
||||||
vim.cmd.colorscheme 'rose-pine'
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
-- Set lualine as statusline
|
|
||||||
'nvim-lualine/lualine.nvim',
|
|
||||||
-- See `:help lualine.txt`
|
|
||||||
opts = {
|
|
||||||
options = {
|
|
||||||
icons_enabled = false,
|
|
||||||
theme = 'rose-pine',
|
|
||||||
component_separators = '|',
|
|
||||||
section_separators = '',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
-- Add indentation guides even on blank lines
|
|
||||||
'lukas-reineke/indent-blankline.nvim',
|
|
||||||
-- Enable `lukas-reineke/indent-blankline.nvim`
|
|
||||||
-- See `:help ibl`
|
|
||||||
main = 'ibl',
|
|
||||||
opts = {},
|
|
||||||
},
|
|
||||||
|
|
||||||
-- "gc" to comment visual regions/lines
|
|
||||||
{ 'numToStr/Comment.nvim', opts = {} },
|
|
||||||
|
|
||||||
-- Fuzzy Finder (files, lsp, etc)
|
|
||||||
{
|
|
||||||
'nvim-telescope/telescope.nvim',
|
|
||||||
branch = '0.1.x',
|
|
||||||
dependencies = {
|
|
||||||
'nvim-lua/plenary.nvim',
|
|
||||||
-- Fuzzy Finder Algorithm which requires local dependencies to be built.
|
|
||||||
-- Only load if `make` is available. Make sure you have the system
|
|
||||||
-- requirements installed.
|
|
||||||
{
|
|
||||||
'nvim-telescope/telescope-fzf-native.nvim',
|
|
||||||
-- NOTE: If you are having trouble with this installation,
|
|
||||||
-- refer to the README for telescope-fzf-native for more instructions.
|
|
||||||
build = 'make',
|
|
||||||
cond = function()
|
|
||||||
return vim.fn.executable 'make' == 1
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
-- Highlight, edit, and navigate code
|
|
||||||
'nvim-treesitter/nvim-treesitter',
|
|
||||||
dependencies = {
|
|
||||||
'nvim-treesitter/nvim-treesitter-textobjects',
|
|
||||||
},
|
|
||||||
build = ':TSUpdate',
|
|
||||||
},
|
|
||||||
|
|
||||||
-- 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',
|
|
||||||
|
|
||||||
-- 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' },
|
|
||||||
}, {})
|
|
||||||
|
|
||||||
-- [[ Setting options ]]
|
-- [[ Setting options ]]
|
||||||
-- See `:help vim.o`
|
-- See `:help vim.o`
|
||||||
|
203
lua/lazy-config.lua
Normal file
203
lua/lazy-config.lua
Normal file
@ -0,0 +1,203 @@
|
|||||||
|
require('lazy').setup({
|
||||||
|
-- NOTE: First, some plugins that don't require any configuration
|
||||||
|
|
||||||
|
-- Git related plugins
|
||||||
|
'tpope/vim-fugitive',
|
||||||
|
'tpope/vim-rhubarb',
|
||||||
|
|
||||||
|
-- Detect tabstop and shiftwidth automatically
|
||||||
|
'tpope/vim-sleuth',
|
||||||
|
|
||||||
|
-- NOTE: This is where your plugins related to LSP can be installed.
|
||||||
|
-- The configuration is done below. Search for lspconfig to find it below.
|
||||||
|
{
|
||||||
|
-- LSP Configuration & Plugins
|
||||||
|
'neovim/nvim-lspconfig',
|
||||||
|
dependencies = {
|
||||||
|
-- Automatically install LSPs to stdpath for neovim
|
||||||
|
'williamboman/mason.nvim',
|
||||||
|
'williamboman/mason-lspconfig.nvim',
|
||||||
|
|
||||||
|
-- Useful status updates for LSP
|
||||||
|
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
|
||||||
|
{ 'j-hui/fidget.nvim', opts = {} },
|
||||||
|
|
||||||
|
-- Additional lua configuration, makes nvim stuff amazing!
|
||||||
|
'folke/neodev.nvim',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
-- Autocompletion
|
||||||
|
'hrsh7th/nvim-cmp',
|
||||||
|
dependencies = {
|
||||||
|
-- Snippet Engine & its associated nvim-cmp source
|
||||||
|
'L3MON4D3/LuaSnip',
|
||||||
|
'saadparwaiz1/cmp_luasnip',
|
||||||
|
|
||||||
|
-- Adds LSP completion capabilities
|
||||||
|
'hrsh7th/cmp-nvim-lsp',
|
||||||
|
'hrsh7th/cmp-path',
|
||||||
|
|
||||||
|
-- Adds a number of user-friendly snippets
|
||||||
|
'rafamadriz/friendly-snippets',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Useful plugin to show you pending keybinds.
|
||||||
|
{ 'folke/which-key.nvim', opts = {} },
|
||||||
|
{
|
||||||
|
-- Adds git related signs to the gutter, as well as utilities for managing changes
|
||||||
|
'lewis6991/gitsigns.nvim',
|
||||||
|
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,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
-- Theme: Rosé-Pine
|
||||||
|
'rose-pine/neovim',
|
||||||
|
name = 'rose-pine',
|
||||||
|
priority = 1000,
|
||||||
|
config = function()
|
||||||
|
vim.cmd.colorscheme 'rose-pine'
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
-- Set lualine as statusline
|
||||||
|
'nvim-lualine/lualine.nvim',
|
||||||
|
-- See `:help lualine.txt`
|
||||||
|
opts = {
|
||||||
|
options = {
|
||||||
|
icons_enabled = false,
|
||||||
|
theme = 'rose-pine',
|
||||||
|
component_separators = '|',
|
||||||
|
section_separators = '',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
-- Add indentation guides even on blank lines
|
||||||
|
'lukas-reineke/indent-blankline.nvim',
|
||||||
|
-- Enable `lukas-reineke/indent-blankline.nvim`
|
||||||
|
-- See `:help ibl`
|
||||||
|
main = 'ibl',
|
||||||
|
opts = {},
|
||||||
|
},
|
||||||
|
|
||||||
|
-- "gc" to comment visual regions/lines
|
||||||
|
{ 'numToStr/Comment.nvim', opts = {} },
|
||||||
|
|
||||||
|
-- Fuzzy Finder (files, lsp, etc)
|
||||||
|
{
|
||||||
|
'nvim-telescope/telescope.nvim',
|
||||||
|
branch = '0.1.x',
|
||||||
|
dependencies = {
|
||||||
|
'nvim-lua/plenary.nvim',
|
||||||
|
-- Fuzzy Finder Algorithm which requires local dependencies to be built.
|
||||||
|
-- Only load if `make` is available. Make sure you have the system
|
||||||
|
-- requirements installed.
|
||||||
|
{
|
||||||
|
'nvim-telescope/telescope-fzf-native.nvim',
|
||||||
|
-- NOTE: If you are having trouble with this installation,
|
||||||
|
-- refer to the README for telescope-fzf-native for more instructions.
|
||||||
|
build = 'make',
|
||||||
|
cond = function()
|
||||||
|
return vim.fn.executable 'make' == 1
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
-- Highlight, edit, and navigate code
|
||||||
|
'nvim-treesitter/nvim-treesitter',
|
||||||
|
dependencies = {
|
||||||
|
'nvim-treesitter/nvim-treesitter-textobjects',
|
||||||
|
},
|
||||||
|
build = ':TSUpdate',
|
||||||
|
},
|
||||||
|
|
||||||
|
-- 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',
|
||||||
|
|
||||||
|
-- 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' },
|
||||||
|
}, {})
|
Loading…
Reference in New Issue
Block a user