[1/4] Refactor: plugins: Add seperate config for each plugins
first commit of Refactor handle require errors move config from other places to proper files don't create a pseudo config function for no reason https://github.com/siduck76/NvChad/pull/156#issuecomment-881453546
This commit is contained in:
parent
0d7345bc44
commit
d16ffabcfd
19
lua/plugins/autopairs.lua
Normal file
19
lua/plugins/autopairs.lua
Normal file
@ -0,0 +1,19 @@
|
||||
local autopairs, autopairs_completion
|
||||
if
|
||||
not pcall(
|
||||
function()
|
||||
autopairs = require "nvim-autopairs"
|
||||
autopairs_completion = require "nvim-autopairs.completion.compe"
|
||||
end
|
||||
)
|
||||
then
|
||||
return
|
||||
end
|
||||
|
||||
autopairs.setup()
|
||||
autopairs_completion.setup(
|
||||
{
|
||||
map_cr = true,
|
||||
map_complete = true -- insert () func completion
|
||||
}
|
||||
)
|
27
lua/plugins/autosave.lua
Normal file
27
lua/plugins/autosave.lua
Normal file
@ -0,0 +1,27 @@
|
||||
-- autosave.nvim plugin disabled by default
|
||||
local autosave
|
||||
if
|
||||
not pcall(
|
||||
function()
|
||||
func = require "autosave"
|
||||
end
|
||||
)
|
||||
then
|
||||
return
|
||||
end
|
||||
|
||||
autosave.setup(
|
||||
{
|
||||
enabled = vim.g.auto_save, -- takes boolean value from init.lua
|
||||
execution_message = "autosaved at : " .. vim.fn.strftime("%H:%M:%S"),
|
||||
events = {"InsertLeave", "TextChanged"},
|
||||
conditions = {
|
||||
exists = true,
|
||||
filetype_is_not = {},
|
||||
modifiable = true
|
||||
},
|
||||
write_all_buffers = true,
|
||||
on_off_commands = true,
|
||||
clean_command_line_interval = 2500
|
||||
}
|
||||
)
|
9
lua/plugins/blankline.lua
Normal file
9
lua/plugins/blankline.lua
Normal file
@ -0,0 +1,9 @@
|
||||
-- blankline config
|
||||
vim.g.indentLine_enabled = 1
|
||||
vim.g.indent_blankline_char = "▏"
|
||||
|
||||
vim.g.indent_blankline_filetype_exclude = {"help", "terminal", "dashboard"}
|
||||
vim.g.indent_blankline_buftype_exclude = {"terminal"}
|
||||
|
||||
vim.g.indent_blankline_show_trailing_blankline_indent = false
|
||||
vim.g.indent_blankline_show_first_indent_level = false
|
@ -1,7 +1,18 @@
|
||||
local global_theme = "themes/" .. vim.g.nvchad_theme
|
||||
local colors = require(global_theme)
|
||||
|
||||
require "bufferline".setup {
|
||||
local bufferline
|
||||
if
|
||||
not pcall(
|
||||
function()
|
||||
bufferline = require "bufferline"
|
||||
end
|
||||
)
|
||||
then
|
||||
return
|
||||
end
|
||||
|
||||
bufferline.setup {
|
||||
options = {
|
||||
offsets = {{filetype = "NvimTree", text = "", padding = 1}},
|
||||
buffer_close_icon = "",
|
||||
|
13
lua/plugins/colorizer.lua
Normal file
13
lua/plugins/colorizer.lua
Normal file
@ -0,0 +1,13 @@
|
||||
local colorizer
|
||||
if
|
||||
not pcall(
|
||||
function()
|
||||
colorizer = require("colorizer")
|
||||
end
|
||||
)
|
||||
then
|
||||
return
|
||||
end
|
||||
|
||||
colorizer.setup()
|
||||
vim.cmd("ColorizerReloadAllBuffers")
|
5
lua/plugins/comment.lua
Normal file
5
lua/plugins/comment.lua
Normal file
@ -0,0 +1,5 @@
|
||||
pcall(
|
||||
function()
|
||||
require("nvim_comment").setup()
|
||||
end
|
||||
)
|
@ -1,7 +1,15 @@
|
||||
local M = {}
|
||||
local compe
|
||||
if
|
||||
not pcall(
|
||||
function()
|
||||
compe = require "compe"
|
||||
end
|
||||
)
|
||||
then
|
||||
return
|
||||
end
|
||||
|
||||
M.config = function()
|
||||
require "compe".setup {
|
||||
compe.setup {
|
||||
enabled = true,
|
||||
autocomplete = true,
|
||||
debug = false,
|
||||
@ -21,18 +29,3 @@ M.config = function()
|
||||
nvim_lua = true
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
M.snippets = function()
|
||||
local ls = require("luasnip")
|
||||
|
||||
ls.config.set_config(
|
||||
{
|
||||
history = true,
|
||||
updateevents = "TextChanged,TextChangedI"
|
||||
}
|
||||
)
|
||||
require("luasnip/loaders/from_vscode").load()
|
||||
end
|
||||
|
||||
return M
|
||||
|
@ -1,6 +1,3 @@
|
||||
local M = {}
|
||||
|
||||
M.config = function()
|
||||
local g = vim.g
|
||||
local fn = vim.fn
|
||||
|
||||
@ -41,6 +38,3 @@ M.config = function()
|
||||
-- "NvChad Loaded " .. plugins_count .. " plugins",
|
||||
"NvChad v0.5"
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
||||
|
@ -1,7 +1,15 @@
|
||||
local M = {}
|
||||
local gitsigns
|
||||
if
|
||||
not pcall(
|
||||
function()
|
||||
gitsigns = require "gitsigns"
|
||||
end
|
||||
)
|
||||
then
|
||||
return
|
||||
end
|
||||
|
||||
M.config = function()
|
||||
require("gitsigns").setup {
|
||||
gitsigns.setup {
|
||||
signs = {
|
||||
add = {hl = "DiffAdd", text = "│", numhl = "GitSignsAddNr"},
|
||||
change = {hl = "DiffChange", text = "│", numhl = "GitSignsChangeNr"},
|
||||
@ -28,6 +36,3 @@ M.config = function()
|
||||
sign_priority = 5,
|
||||
status_formatter = nil -- Use default
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
||||
|
@ -1,10 +1,18 @@
|
||||
local M = {}
|
||||
local icons
|
||||
if
|
||||
not pcall(
|
||||
function()
|
||||
icons = require "nvim-web-devicons"
|
||||
end
|
||||
)
|
||||
then
|
||||
return
|
||||
end
|
||||
|
||||
M.config = function()
|
||||
local global_theme = "themes/" .. vim.g.nvchad_theme
|
||||
local colors = require(global_theme)
|
||||
|
||||
require "nvim-web-devicons".setup {
|
||||
icons.setup {
|
||||
override = {
|
||||
html = {
|
||||
icon = "",
|
||||
@ -118,6 +126,3 @@ M.config = function()
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
||||
|
@ -1,7 +1,14 @@
|
||||
local M = {}
|
||||
|
||||
M.config = function()
|
||||
local lspconf = require("lspconfig")
|
||||
local lspconfig, lspinstall
|
||||
if
|
||||
not pcall(
|
||||
function()
|
||||
lspconfig = require "lspconfig"
|
||||
lspinstall = require "lspinstall"
|
||||
end
|
||||
)
|
||||
then
|
||||
return
|
||||
end
|
||||
|
||||
local function on_attach(client, bufnr)
|
||||
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
|
||||
@ -44,18 +51,18 @@ M.config = function()
|
||||
-- lspInstall + lspconfig stuff
|
||||
|
||||
local function setup_servers()
|
||||
require "lspinstall".setup()
|
||||
local servers = require "lspinstall".installed_servers()
|
||||
lspinstall.setup()
|
||||
local servers = lspinstall.installed_servers()
|
||||
|
||||
for _, lang in pairs(servers) do
|
||||
if lang ~= "lua" then
|
||||
lspconf[lang].setup {
|
||||
lspconfig[lang].setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
root_dir = vim.loop.cwd
|
||||
}
|
||||
elseif lang == "lua" then
|
||||
lspconf[lang].setup {
|
||||
lspconfig[lang].setup {
|
||||
root_dir = vim.loop.cwd,
|
||||
settings = {
|
||||
Lua = {
|
||||
@ -83,7 +90,7 @@ M.config = function()
|
||||
setup_servers()
|
||||
|
||||
-- Automatically reload after `:LspInstall <server>` so we don't have to restart neovim
|
||||
require "lspinstall".post_install_hook = function()
|
||||
lspinstall.post_install_hook = function()
|
||||
setup_servers() -- reload installed servers
|
||||
vim.cmd("bufdo e") -- triggers FileType autocmd that starts the server
|
||||
end
|
||||
@ -93,6 +100,3 @@ M.config = function()
|
||||
vim.fn.sign_define("LspDiagnosticsSignWarning", {text = "", numhl = "LspDiagnosticsDefaultWarning"})
|
||||
vim.fn.sign_define("LspDiagnosticsSignInformation", {text = "", numhl = "LspDiagnosticsDefaultInformation"})
|
||||
vim.fn.sign_define("LspDiagnosticsSignHint", {text = "", numhl = "LspDiagnosticsDefaultHint"})
|
||||
end
|
||||
|
||||
return M
|
||||
|
5
lua/plugins/lspkind.lua
Normal file
5
lua/plugins/lspkind.lua
Normal file
@ -0,0 +1,5 @@
|
||||
pcall(
|
||||
function()
|
||||
require("lspkind").init()
|
||||
end
|
||||
)
|
18
lua/plugins/luasnip.lua
Normal file
18
lua/plugins/luasnip.lua
Normal file
@ -0,0 +1,18 @@
|
||||
local luasnip
|
||||
if
|
||||
not pcall(
|
||||
function()
|
||||
luasnip = require "luasnip"
|
||||
end
|
||||
)
|
||||
then
|
||||
return
|
||||
end
|
||||
|
||||
luasnip.config.set_config(
|
||||
{
|
||||
history = true,
|
||||
updateevents = "TextChanged,TextChangedI"
|
||||
}
|
||||
)
|
||||
require("luasnip/loaders/from_vscode").load()
|
5
lua/plugins/neoscroll.lua
Normal file
5
lua/plugins/neoscroll.lua
Normal file
@ -0,0 +1,5 @@
|
||||
pcall(
|
||||
function()
|
||||
require("neoscroll").setup()
|
||||
end
|
||||
)
|
@ -1,6 +1,14 @@
|
||||
local M = {}
|
||||
local tree_cb
|
||||
if
|
||||
not pcall(
|
||||
function()
|
||||
tree_cb = require "nvim-tree.config".nvim_tree_callback
|
||||
end
|
||||
)
|
||||
then
|
||||
return
|
||||
end
|
||||
|
||||
M.config = function()
|
||||
local g = vim.g
|
||||
|
||||
vim.o.termguicolors = true
|
||||
@ -57,8 +65,6 @@ M.config = function()
|
||||
}
|
||||
}
|
||||
|
||||
local tree_cb = require "nvim-tree.config".nvim_tree_callback
|
||||
|
||||
g.nvim_tree_bindings = {
|
||||
{key = {"<CR>", "o", "<2-LeftMouse>"}, cb = tree_cb("edit")},
|
||||
{key = {"<2-RightMouse>", "<C-}>"}, cb = tree_cb("cd")},
|
||||
@ -92,6 +98,3 @@ M.config = function()
|
||||
{key = "q", cb = tree_cb("close")},
|
||||
{key = "g?", cb = tree_cb("toggle_help")}
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
||||
|
@ -1,9 +1,16 @@
|
||||
local M = {}
|
||||
local gl, condition
|
||||
if
|
||||
not pcall(
|
||||
function()
|
||||
gl = require "galaxyline"
|
||||
condition = require "galaxyline.condition"
|
||||
end
|
||||
)
|
||||
then
|
||||
return
|
||||
end
|
||||
|
||||
M.config = function()
|
||||
local gl = require("galaxyline")
|
||||
local gls = gl.section
|
||||
local condition = require("galaxyline.condition")
|
||||
|
||||
gl.short_line_list = {" "}
|
||||
|
||||
@ -208,5 +215,3 @@ M.config = function()
|
||||
highlight = {colors.green, colors.lightbg}
|
||||
}
|
||||
}
|
||||
end
|
||||
return M
|
||||
|
@ -1,7 +1,16 @@
|
||||
local M = {}
|
||||
local telescope
|
||||
if
|
||||
not pcall(
|
||||
function()
|
||||
telescope = require("telescope")
|
||||
end
|
||||
)
|
||||
then
|
||||
return
|
||||
end
|
||||
|
||||
M.config = function()
|
||||
require("telescope").setup {
|
||||
telescope.setup(
|
||||
{
|
||||
defaults = {
|
||||
vimgrep_arguments = {
|
||||
"rg",
|
||||
@ -32,9 +41,9 @@ M.config = function()
|
||||
height = 0.80,
|
||||
preview_cutoff = 120
|
||||
},
|
||||
file_sorter = require "telescope.sorters".get_fuzzy_file,
|
||||
file_sorter = require("telescope.sorters").get_fuzzy_file,
|
||||
file_ignore_patterns = {},
|
||||
generic_sorter = require "telescope.sorters".get_generic_fuzzy_sorter,
|
||||
generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter,
|
||||
path_display = shorten,
|
||||
winblend = 0,
|
||||
border = {},
|
||||
@ -42,11 +51,11 @@ M.config = function()
|
||||
color_devicons = true,
|
||||
use_less = true,
|
||||
set_env = {["COLORTERM"] = "truecolor"}, -- default = nil,
|
||||
file_previewer = require "telescope.previewers".vim_buffer_cat.new,
|
||||
grep_previewer = require "telescope.previewers".vim_buffer_vimgrep.new,
|
||||
qflist_previewer = require "telescope.previewers".vim_buffer_qflist.new,
|
||||
file_previewer = require("telescope.previewers").vim_buffer_cat.new,
|
||||
grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new,
|
||||
qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new,
|
||||
-- Developer configurations: Not meant for general override
|
||||
buffer_previewer_maker = require "telescope.previewers".buffer_previewer_maker
|
||||
buffer_previewer_maker = require("telescope.previewers").buffer_previewer_maker
|
||||
},
|
||||
extensions = {
|
||||
fzf = {
|
||||
@ -62,9 +71,16 @@ M.config = function()
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
require("telescope").load_extension("fzf")
|
||||
require("telescope").load_extension("media_files")
|
||||
if
|
||||
not pcall(
|
||||
function()
|
||||
telescope.load_extension("fzf")
|
||||
telescope.load_extension("media_files")
|
||||
end
|
||||
)
|
||||
then
|
||||
-- This should only trigger when in need of PackerSync, so better do it
|
||||
vim.cmd("PackerSync")
|
||||
end
|
||||
|
||||
return M
|
||||
|
@ -1,7 +1,13 @@
|
||||
local M = {}
|
||||
|
||||
M.config = function()
|
||||
local ts_config = require("nvim-treesitter.configs")
|
||||
local ts_config
|
||||
if
|
||||
not pcall(
|
||||
function()
|
||||
ts_config = require "nvim-treesitter.configs"
|
||||
end
|
||||
)
|
||||
then
|
||||
return
|
||||
end
|
||||
|
||||
ts_config.setup {
|
||||
ensure_installed = {
|
||||
@ -20,6 +26,3 @@ M.config = function()
|
||||
use_languagetree = true
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
||||
|
@ -1,9 +1,15 @@
|
||||
-- plugins made by @Pocco81 =)
|
||||
|
||||
local M = {}
|
||||
|
||||
M.config = function()
|
||||
local true_zen = require("true-zen")
|
||||
local true_zen
|
||||
if
|
||||
not pcall(
|
||||
function()
|
||||
true_zen = require "true-zen"
|
||||
end
|
||||
)
|
||||
then
|
||||
return
|
||||
end
|
||||
|
||||
true_zen.setup(
|
||||
{
|
||||
@ -55,27 +61,3 @@ M.config = function()
|
||||
}
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
-- autosave.nvim plugin disabled by default
|
||||
M.autoSave = function()
|
||||
local autosave = require("autosave")
|
||||
|
||||
autosave.setup(
|
||||
{
|
||||
enabled = vim.g.auto_save, -- takes boolean value from init.lua
|
||||
execution_message = "autosaved at : " .. vim.fn.strftime("%H:%M:%S"),
|
||||
events = {"InsertLeave", "TextChanged"},
|
||||
conditions = {
|
||||
exists = true,
|
||||
filetype_is_not = {},
|
||||
modifiable = true
|
||||
},
|
||||
write_all_buffers = true,
|
||||
on_off_commands = true,
|
||||
clean_command_line_interval = 2500
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
return M
|
||||
|
Loading…
Reference in New Issue
Block a user