lazy-nvim plugin and formatting

This commit is contained in:
krolyxon 2023-01-19 16:06:21 +05:30
parent a1919bafc7
commit 8b437e4177
5 changed files with 121 additions and 142 deletions

View File

@ -4,14 +4,14 @@ require("core.utils").load_mappings()
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then if not vim.loop.fs_stat(lazypath) then
vim.fn.system({ vim.fn.system({
"git", "git",
"clone", "clone",
"--filter=blob:none", "--filter=blob:none",
"https://github.com/folke/lazy.nvim.git", "https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release "--branch=stable", -- latest stable release
lazypath, lazypath,
}) })
end end
vim.opt.rtp:prepend(lazypath) vim.opt.rtp:prepend(lazypath)
require "plugins" require "plugins"

View File

@ -1,28 +1,28 @@
local M = {} local M = {}
M.lazy = function(install_path) M.lazy = function(install_path)
print "Bootstrapping lazy.nvim .." print "Bootstrapping lazy.nvim .."
vim.fn.system { vim.fn.system {
"git", "git",
"clone", "clone",
"--filter=blob:none", "--filter=blob:none",
"https://github.com/folke/lazy.nvim.git", "https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release "--branch=stable", -- latest stable release
install_path, install_path,
} }
vim.opt.rtp:prepend(install_path) vim.opt.rtp:prepend(install_path)
-- install plugins + compile their configs -- install plugins + compile their configs
require "plugins" require "plugins"
require("lazy").load { plugins = "nvim-treesitter" } require("lazy").load { plugins = "nvim-treesitter" }
-- install binaries from mason.nvim & tsparsers on LazySync -- install binaries from mason.nvim & tsparsers on LazySync
vim.schedule(function() vim.schedule(function()
vim.cmd "bw | silent! MasonInstallAll" -- close lazy window vim.cmd "bw | silent! MasonInstallAll" -- close lazy window
end, 0) end, 0)
end end
return M return M

View File

@ -7,7 +7,7 @@ M.format_plugins = function(plugins) local final_table = {}
final_table[#final_table + 1] = plugins[key] final_table[#final_table + 1] = plugins[key]
end end
return final_table return final_table
end end
M.close_buffer = function(bufnr) M.close_buffer = function(bufnr)
@ -53,31 +53,31 @@ M.load_mappings = function(section, mapping_opt)
end end
M.lazy_load = function(plugin) M.lazy_load = function(plugin)
vim.api.nvim_create_autocmd({ "BufRead", "BufWinEnter", "BufNewFile" }, { vim.api.nvim_create_autocmd({ "BufRead", "BufWinEnter", "BufNewFile" }, {
group = vim.api.nvim_create_augroup("BeLazyOnFileOpen" .. plugin, {}), group = vim.api.nvim_create_augroup("BeLazyOnFileOpen" .. plugin, {}),
callback = function() callback = function()
local file = vim.fn.expand "%" local file = vim.fn.expand "%"
local condition = file ~= "NvimTree_1" and file ~= "[lazy]" and file ~= "" local condition = file ~= "NvimTree_1" and file ~= "[lazy]" and file ~= ""
if condition then if condition then
vim.api.nvim_del_augroup_by_name("BeLazyOnFileOpen" .. plugin) vim.api.nvim_del_augroup_by_name("BeLazyOnFileOpen" .. plugin)
-- dont defer for treesitter as it will show slow highlighting -- dont defer for treesitter as it will show slow highlighting
-- This deferring only happens only when we do "nvim filename" -- This deferring only happens only when we do "nvim filename"
if plugin ~= "nvim-treesitter" then if plugin ~= "nvim-treesitter" then
vim.schedule(function() vim.schedule(function()
require("lazy").load { plugins = plugin } require("lazy").load { plugins = plugin }
if plugin == "nvim-lspconfig" then if plugin == "nvim-lspconfig" then
vim.cmd "silent! do FileType" vim.cmd "silent! do FileType"
end
end, 0)
else
require("lazy").load { plugins = plugin }
end
end end
end, 0) end,
else })
require("lazy").load { plugins = plugin }
end
end
end,
})
end end
return M return M

View File

@ -1,70 +1,49 @@
return { return {
defaults = { defaults = {
lazy = true, lazy = true,
}, },
-- install = { -- install = {
-- try to load one of these colorschemes when starting an installation during startup -- try to load one of these colorschemes when starting an installation during startup
-- colorscheme = { "rose-pine" }, -- colorscheme = { "rose-pine" },
-- }, -- },
ui = { ui = {
icons = { icons = {
cmd = "", ft = "",
config = "", lazy = "",
event = "", loaded = "",
ft = "", not_loaded = "",
init = "", },
import = "",
keys = "",
lazy = "",
loaded = "",
not_loaded = "",
plugin = "",
runtime = "",
source = "",
start = "",
task = "",
list = {
"",
"",
"",
"",
},
}, },
},
-- performance = { performance = {
-- rtp = { rtp = {
-- disabled_plugins = { disabled_plugins = {
-- "2html_plugin", "2html_plugin",
-- "tohtml", "tohtml",
-- "getscript", "getscript",
-- "getscriptPlugin", "getscriptPlugin",
-- "gzip", "gzip",
-- "logipat", "logipat",
-- -- "netrw", "matchit",
-- -- "netrwPlugin", "tar",
-- -- "netrwSettings", "tarPlugin",
-- -- "netrwFileHandlers", "rrhelper",
-- "matchit", "spellfile_plugin",
-- "tar", "vimball",
-- "tarPlugin", "vimballPlugin",
-- "rrhelper", "zip",
-- "spellfile_plugin", "zipPlugin",
-- "vimball", "tutor",
-- "vimballPlugin", "rplugin",
-- "zip", "syntax",
-- "zipPlugin", "synmenu",
-- "tutor", "optwin",
-- "rplugin", "compiler",
-- "syntax", "bugreport",
-- "synmenu", "ftplugin",
-- "optwin", },
-- "compiler", },
-- "bugreport", },
-- "ftplugin",
-- },
-- },
-- },
} }

View File

@ -48,7 +48,7 @@ local plugins = {
-- lsp stuff -- lsp stuff
["williamboman/mason.nvim"] = { ["williamboman/mason.nvim"] = {
cmd = { "Mason", "MasonInstall", "MasonInstallAll", "MasonUninstall", "MasonUninstallAll", "MasonLog" }, cmd = { "Mason", "MasonInstall", "MasonInstallAll", "MasonUninstall", "MasonUninstallAll", "MasonLog" },
config = function() config = function()
require "plugins.configs.mason" require "plugins.configs.mason"
end, end,
@ -82,40 +82,40 @@ local plugins = {
-- load luasnips + cmp related in insert mode only -- load luasnips + cmp related in insert mode only
["hrsh7th/nvim-cmp"] = { ["hrsh7th/nvim-cmp"] = {
event = "InsertEnter", event = "InsertEnter",
dependencies = { dependencies = {
{ {
-- snippet plugin -- snippet plugin
"L3MON4D3/LuaSnip", "L3MON4D3/LuaSnip",
dependencies = "rafamadriz/friendly-snippets", dependencies = "rafamadriz/friendly-snippets",
config = function() config = function()
require("plugins.configs.others").luasnip() require("plugins.configs.others").luasnip()
end, end,
}, },
-- autopairing of (){}[] etc -- autopairing of (){}[] etc
{ {
"windwp/nvim-autopairs", "windwp/nvim-autopairs",
config = function() config = function()
require("plugins.configs.others").autopairs() require("plugins.configs.others").autopairs()
end, end,
}, },
-- cmp sources plugins -- cmp sources plugins
{ {
"saadparwaiz1/cmp_luasnip", "saadparwaiz1/cmp_luasnip",
"hrsh7th/cmp-nvim-lua", "hrsh7th/cmp-nvim-lua",
"hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer", "hrsh7th/cmp-buffer",
"hrsh7th/cmp-path", "hrsh7th/cmp-path",
}, },
},
config = function()
require "plugins.configs.cmp"
end,
}, },
config = function()
require "plugins.configs.cmp"
end,
},
-- misc -- misc
['vimwiki/vimwiki'] = { ['vimwiki/vimwiki'] = {
@ -198,7 +198,7 @@ plugins = require("core.utils").format_plugins(plugins)
-- pin commits for all default plugins -- pin commits for all default plugins
for _, value in pairs(plugins) do for _, value in pairs(plugins) do
value.pin = true value.pin = true
end end
-- load lazy.nvim options -- load lazy.nvim options