better plugin structure

This commit is contained in:
siduck 2024-03-04 08:18:44 +05:30
parent 73bf6c437f
commit e307a4eacf
17 changed files with 300 additions and 278 deletions

10
.gitignore vendored
View File

@ -1,10 +0,0 @@
plugin
custom
spell
ftplugin
syntax
coc-settings.json
.luarc.json
lazy-lock.json
after
**/.DS_Store

View File

@ -1 +0,0 @@
!/lua/custom/

View File

@ -23,13 +23,4 @@ local options = {
end, end,
} }
return { return options
"lewis6991/gitsigns.nvim",
event = "User FilePost",
opts = options,
config = function(_, opts)
dofile(vim.g.base46_cache .. "git")
require("gitsigns").setup(opts)
end,
}

View File

@ -22,7 +22,7 @@ M.on_attach = function(client, bufnr)
map("n", "gd", vim.lsp.buf.definition, opts "Lsp Go to definition") map("n", "gd", vim.lsp.buf.definition, opts "Lsp Go to definition")
map("n", "K", vim.lsp.buf.hover, opts "Lsp hover information") map("n", "K", vim.lsp.buf.hover, opts "Lsp hover information")
map("n", "gi", vim.lsp.buf.implementation, opts "Lsp Go to implementation") map("n", "gi", vim.lsp.buf.implementation, opts "Lsp Go to implementation")
map("n", "<C-k>", vim.lsp.buf.signature_help, opts "Lsp Show signature help") map("n", "<leader>sh", vim.lsp.buf.signature_help, opts "Lsp Show signature help")
map("n", "<leader>wa", vim.lsp.buf.add_workspace_folder, opts "Lsp Add workspace folder") map("n", "<leader>wa", vim.lsp.buf.add_workspace_folder, opts "Lsp Add workspace folder")
map("n", "<leader>wr", vim.lsp.buf.remove_workspace_folder, opts "Lsp Remove workspace folder") map("n", "<leader>wr", vim.lsp.buf.remove_workspace_folder, opts "Lsp Remove workspace folder")

View File

@ -0,0 +1,23 @@
-- vscode format
require("luasnip.loaders.from_vscode").lazy_load()
require("luasnip.loaders.from_vscode").lazy_load { paths = "your path!" }
require("luasnip.loaders.from_vscode").lazy_load { paths = vim.g.vscode_snippets_path or "" }
-- snipmate format
require("luasnip.loaders.from_snipmate").load()
require("luasnip.loaders.from_snipmate").lazy_load { paths = vim.g.snipmate_snippets_path or "" }
-- lua format
require("luasnip.loaders.from_lua").load()
require("luasnip.loaders.from_lua").lazy_load { paths = vim.g.lua_snippets_path or "" }
vim.api.nvim_create_autocmd("InsertLeave", {
callback = function()
if
require("luasnip").session.current_nodes[vim.api.nvim_get_current_buf()]
and not require("luasnip").session.jump_active
then
require("luasnip").unlink_current()
end
end,
})

View File

@ -0,0 +1,28 @@
local options = {
ensure_installed = { "lua-language-server" }, -- not an option from mason.nvim
PATH = "skip",
ui = {
icons = {
package_pending = "",
package_installed = "󰄳 ",
package_uninstalled = " 󰚌",
},
keymaps = {
toggle_server_expand = "<CR>",
install_server = "i",
update_server = "u",
check_server_version = "c",
update_all_servers = "U",
check_outdated_servers = "C",
uninstall_server = "X",
cancel_installation = "<C-c>",
},
},
max_concurrent_installers = 10,
}
return options

View File

@ -74,12 +74,4 @@ local options = {
}, },
} }
return { return options
"nvim-tree/nvim-tree.lua",
cmd = { "NvimTreeToggle", "NvimTreeFocus" },
opts = options,
config = function(_, opts)
dofile(vim.g.base46_cache .. "nvimtree")
require("nvim-tree").setup(opts)
end,
}

View File

@ -0,0 +1,63 @@
local options = {
defaults = {
vimgrep_arguments = {
"rg",
"-L",
"--color=never",
"--no-heading",
"--with-filename",
"--line-number",
"--column",
"--smart-case",
},
prompt_prefix = "",
selection_caret = " ",
entry_prefix = " ",
initial_mode = "insert",
selection_strategy = "reset",
sorting_strategy = "ascending",
layout_strategy = "horizontal",
layout_config = {
horizontal = {
prompt_position = "top",
preview_width = 0.55,
results_width = 0.8,
},
vertical = {
mirror = false,
},
width = 0.87,
height = 0.80,
preview_cutoff = 120,
},
file_sorter = require("telescope.sorters").get_fuzzy_file,
file_ignore_patterns = { "node_modules" },
generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter,
path_display = { "truncate" },
winblend = 0,
border = {},
borderchars = { "", "", "", "", "", "", "", "" },
color_devicons = 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,
-- Developer configurations: Not meant for general override
buffer_previewer_maker = require("telescope.previewers").buffer_previewer_maker,
mappings = {
n = { ["q"] = require("telescope.actions").close },
},
},
extensions_list = { "themes", "terms" },
extensions = {
fzf = {
fuzzy = true,
override_generic_sorter = true,
override_file_sorter = true,
case_mode = "smart_case",
},
},
}
return options

View File

@ -0,0 +1,12 @@
local options = {
ensure_installed = { "lua", "vim", "vimdoc" },
highlight = {
enable = true,
use_languagetree = true,
},
indent = { enable = true },
}
return options

View File

@ -1,64 +0,0 @@
return {
"hrsh7th/nvim-cmp",
event = "InsertEnter",
opts = function()
return require "nvchad.configs.cmp"
end,
config = function(_, opts)
require("cmp").setup(opts)
end,
dependencies = {
{
-- snippet plugin
"L3MON4D3/LuaSnip",
dependencies = "rafamadriz/friendly-snippets",
opts = { history = true, updateevents = "TextChanged,TextChangedI" },
config = function(_, opts)
require("luasnip").config.set_config(opts)
require("luasnip.loaders.from_vscode").lazy_load()
require("luasnip.loaders.from_snipmate").load()
require("luasnip.loaders.from_lua").load()
vim.api.nvim_create_autocmd("InsertLeave", {
callback = function()
if
require("luasnip").session.current_nodes[vim.api.nvim_get_current_buf()]
and not require("luasnip").session.jump_active
then
require("luasnip").unlink_current()
end
end,
})
end,
},
-- autopairing of (){}[] etc
{
"windwp/nvim-autopairs",
opts = {
fast_wrap = {},
disable_filetype = { "TelescopePrompt", "vim" },
},
config = function(_, opts)
require("nvim-autopairs").setup(opts)
-- setup cmp for autopairs
local cmp_autopairs = require "nvim-autopairs.completion.cmp"
require("cmp").event:on("confirm_done", cmp_autopairs.on_confirm_done())
end,
},
-- cmp sources plugins
{
"saadparwaiz1/cmp_luasnip",
"hrsh7th/cmp-nvim-lua",
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
},
},
}

148
lua/nvchad/plugins/init.lua Normal file
View File

@ -0,0 +1,148 @@
return {
"nvim-lua/plenary.nvim",
{
"nvim-treesitter/nvim-treesitter",
event = { "BufReadPost", "BufNewFile" },
cmd = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSModuleInfo" },
build = ":TSUpdate",
opts = function()
return require "nvchad.configs.treesitter"
end,
config = function(_, opts)
dofile(vim.g.base46_cache .. "syntax")
dofile(vim.g.base46_cache .. "treesitter")
require("nvim-treesitter.configs").setup(opts)
end,
},
-- git stuff
{
"lewis6991/gitsigns.nvim",
event = "User FilePost",
opts = function()
return require "nvchad.configs.gitsigns"
end,
config = function(_, opts)
dofile(vim.g.base46_cache .. "git")
require("gitsigns").setup(opts)
end,
},
-- lsp stuff
{
"williamboman/mason.nvim",
cmd = { "Mason", "MasonInstall", "MasonInstallAll", "MasonUpdate" },
opts = function()
return require "nvchad.configs.mason"
end,
config = function(_, opts)
dofile(vim.g.base46_cache .. "mason")
require("mason").setup(opts)
-- custom nvchad cmd to install all mason binaries listed
vim.api.nvim_create_user_command("MasonInstallAll", function()
if opts.ensure_installed and #opts.ensure_installed > 0 then
vim.cmd("MasonInstall " .. table.concat(opts.ensure_installed, " "))
end
end, {})
vim.g.mason_binaries_list = opts.ensure_installed
end,
},
{
"neovim/nvim-lspconfig",
event = "User FilePost",
config = function()
require("nvchad.configs.lspconfig").defaults()
end,
},
-- load luasnips + cmp related in insert mode only
{
"hrsh7th/nvim-cmp",
event = "InsertEnter",
dependencies = {
{
-- snippet plugin
"L3MON4D3/LuaSnip",
dependencies = "rafamadriz/friendly-snippets",
opts = { history = true, updateevents = "TextChanged,TextChangedI" },
config = function(_, opts)
require("luasnip").config.set_config(opts)
require "nvchad.configs.luasnip"
end,
},
-- autopairing of (){}[] etc
{
"windwp/nvim-autopairs",
opts = {
fast_wrap = {},
disable_filetype = { "TelescopePrompt", "vim" },
},
config = function(_, opts)
require("nvim-autopairs").setup(opts)
-- setup cmp for autopairs
local cmp_autopairs = require "nvim-autopairs.completion.cmp"
require("cmp").event:on("confirm_done", cmp_autopairs.on_confirm_done())
end,
},
-- cmp sources plugins
{
"saadparwaiz1/cmp_luasnip",
"hrsh7th/cmp-nvim-lua",
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
},
},
opts = function()
return require "nvchad.configs.cmp"
end,
config = function(_, opts)
require("cmp").setup(opts)
end,
},
{
"numToStr/Comment.nvim",
keys = {
{ "gcc", mode = "n", desc = "Comment toggle current line" },
{ "gc", mode = { "n", "o" }, desc = "Comment toggle linewise" },
{ "gc", mode = "x", desc = "Comment toggle linewise (visual)" },
{ "gbc", mode = "n", desc = "Comment toggle current block" },
{ "gb", mode = { "n", "o" }, desc = "Comment toggle blockwise" },
{ "gb", mode = "x", desc = "Comment toggle blockwise (visual)" },
},
init = function()
vim.g.comment_maps = true
end,
config = function(_, opts)
require("Comment").setup(opts)
end,
},
{
"nvim-telescope/telescope.nvim",
dependencies = { "nvim-treesitter/nvim-treesitter" },
cmd = "Telescope",
opts = function()
return require "nvchad.configs.telescope"
end,
config = function(_, opts)
dofile(vim.g.base46_cache .. "telescope")
local telescope = require "telescope"
telescope.setup(opts)
-- load extensions
for _, ext in ipairs(opts.extensions_list) do
telescope.load_extension(ext)
end
end,
},
}

View File

@ -1,7 +0,0 @@
return {
"neovim/nvim-lspconfig",
event = "User FilePost",
config = function()
require("nvchad.configs.lspconfig").defaults()
end,
}

View File

@ -1,45 +0,0 @@
local options = {
ensure_installed = { "lua-language-server" }, -- not an option from mason.nvim
PATH = "skip",
ui = {
icons = {
package_pending = "",
package_installed = "󰄳 ",
package_uninstalled = " 󰚌",
},
keymaps = {
toggle_server_expand = "<CR>",
install_server = "i",
update_server = "u",
check_server_version = "c",
update_all_servers = "U",
check_outdated_servers = "C",
uninstall_server = "X",
cancel_installation = "<C-c>",
},
},
max_concurrent_installers = 10,
}
return {
"williamboman/mason.nvim",
cmd = { "Mason", "MasonInstall", "MasonInstallAll", "MasonUpdate" },
opts = options,
config = function(_, opts)
dofile(vim.g.base46_cache .. "mason")
require("mason").setup(opts)
-- custom nvchad cmd to install all mason binaries listed
vim.api.nvim_create_user_command("MasonInstallAll", function()
if opts.ensure_installed and #opts.ensure_installed > 0 then
vim.cmd("MasonInstall " .. table.concat(opts.ensure_installed, " "))
end
end, {})
vim.g.mason_binaries_list = opts.ensure_installed
end,
}

View File

@ -1,80 +0,0 @@
return {
"nvim-telescope/telescope.nvim",
dependencies = { "nvim-treesitter/nvim-treesitter" },
cmd = "Telescope",
opts = function()
local options = {
defaults = {
vimgrep_arguments = {
"rg",
"-L",
"--color=never",
"--no-heading",
"--with-filename",
"--line-number",
"--column",
"--smart-case",
},
prompt_prefix = "",
selection_caret = " ",
entry_prefix = " ",
initial_mode = "insert",
selection_strategy = "reset",
sorting_strategy = "ascending",
layout_strategy = "horizontal",
layout_config = {
horizontal = {
prompt_position = "top",
preview_width = 0.55,
results_width = 0.8,
},
vertical = {
mirror = false,
},
width = 0.87,
height = 0.80,
preview_cutoff = 120,
},
file_sorter = require("telescope.sorters").get_fuzzy_file,
file_ignore_patterns = { "node_modules" },
generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter,
path_display = { "truncate" },
winblend = 0,
border = {},
borderchars = { "", "", "", "", "", "", "", "" },
color_devicons = 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,
-- Developer configurations: Not meant for general override
buffer_previewer_maker = require("telescope.previewers").buffer_previewer_maker,
mappings = {
n = { ["q"] = require("telescope.actions").close },
},
},
extensions_list = { "themes", "terms" },
extensions = {
fzf = {
fuzzy = true,
override_generic_sorter = true,
override_file_sorter = true,
case_mode = "smart_case",
},
},
}
return options
end,
config = function(_, opts)
dofile(vim.g.base46_cache .. "telescope")
local telescope = require "telescope"
telescope.setup(opts)
-- load extensions
for _, ext in ipairs(opts.extensions_list) do
telescope.load_extension(ext)
end
end,
}

View File

@ -1,23 +0,0 @@
local config = {
ensure_installed = { "lua", "vim", "vimdoc" },
highlight = {
enable = true,
use_languagetree = true,
},
indent = { enable = true },
}
return {
"nvim-treesitter/nvim-treesitter",
event = { "BufReadPost", "BufNewFile" },
cmd = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSModuleInfo" },
build = ":TSUpdate",
opts = config,
config = function(_, opts)
dofile(vim.g.base46_cache .. "syntax")
dofile(vim.g.base46_cache .. "treesitter")
require("nvim-treesitter.configs").setup(opts)
end,
}

View File

@ -1,5 +1,4 @@
return { return {
"nvim-lua/plenary.nvim",
{ {
"NvChad/base46", "NvChad/base46",
@ -42,40 +41,13 @@ return {
end, end,
}, },
{
"folke/which-key.nvim",
keys = { "<leader>", "<c-r>", "<c-w>", '"', "'", "`", "c", "v", "g" },
cmd = "WhichKey",
config = function(_, opts)
dofile(vim.g.base46_cache .. "whichkey")
require("which-key").setup(opts)
end,
},
{
"numToStr/Comment.nvim",
keys = {
{ "gcc", mode = "n", desc = "Comment toggle current line" },
{ "gc", mode = { "n", "o" }, desc = "Comment toggle linewise" },
{ "gc", mode = "x", desc = "Comment toggle linewise (visual)" },
{ "gbc", mode = "n", desc = "Comment toggle current block" },
{ "gb", mode = { "n", "o" }, desc = "Comment toggle blockwise" },
{ "gb", mode = "x", desc = "Comment toggle blockwise (visual)" },
},
config = function(_, opts)
require("Comment").setup(opts)
end,
},
{ {
"lukas-reineke/indent-blankline.nvim", "lukas-reineke/indent-blankline.nvim",
event = "User FilePost", event = "User FilePost",
opts = { opts = {
indent = { char = "", highlight = "IblChar" }, indent = { char = "", highlight = "IblChar" },
scope = { char = "", highlight = "IblScopeChar" }, scope = { char = "", highlight = "IblScopeChar" },
}, },
config = function(_, opts) config = function(_, opts)
dofile(vim.g.base46_cache .. "blankline") dofile(vim.g.base46_cache .. "blankline")
@ -84,4 +56,27 @@ return {
require("ibl").setup(opts) require("ibl").setup(opts)
end, end,
}, },
-- file managing , picker etc
{
"nvim-tree/nvim-tree.lua",
cmd = { "NvimTreeToggle", "NvimTreeFocus" },
opts = function()
return require "nvchad.configs.nvimtree"
end,
config = function(_, opts)
dofile(vim.g.base46_cache .. "nvimtree")
require("nvim-tree").setup(opts)
end,
},
{
"folke/which-key.nvim",
keys = { "<leader>", "<c-r>", "<c-w>", '"', "'", "`", "c", "v", "g" },
cmd = "WhichKey",
config = function(_, opts)
dofile(vim.g.base46_cache .. "whichkey")
require("which-key").setup(opts)
end,
},
} }