diff options
Diffstat (limited to 'nvim/nvchad/lua/plugins')
-rw-r--r-- | nvim/nvchad/lua/plugins/configs/cmp.lua | 120 | ||||
-rw-r--r-- | nvim/nvchad/lua/plugins/configs/lazy_nvim.lua | 47 | ||||
-rw-r--r-- | nvim/nvchad/lua/plugins/configs/lspconfig.lua | 64 | ||||
-rw-r--r-- | nvim/nvchad/lua/plugins/configs/mason.lua | 28 | ||||
-rw-r--r-- | nvim/nvchad/lua/plugins/configs/nvimtree.lua | 77 | ||||
-rw-r--r-- | nvim/nvchad/lua/plugins/configs/others.lua | 66 | ||||
-rw-r--r-- | nvim/nvchad/lua/plugins/configs/telescope.lua | 55 | ||||
-rw-r--r-- | nvim/nvchad/lua/plugins/configs/treesitter.lua | 12 | ||||
-rw-r--r-- | nvim/nvchad/lua/plugins/init.lua | 253 |
9 files changed, 722 insertions, 0 deletions
diff --git a/nvim/nvchad/lua/plugins/configs/cmp.lua b/nvim/nvchad/lua/plugins/configs/cmp.lua new file mode 100644 index 0000000..444da73 --- /dev/null +++ b/nvim/nvchad/lua/plugins/configs/cmp.lua @@ -0,0 +1,120 @@ +local cmp = require "cmp" + +dofile(vim.g.base46_cache .. "cmp") + +local cmp_ui = require("core.utils").load_config().ui.cmp +local cmp_style = cmp_ui.style + +local field_arrangement = { + atom = { "kind", "abbr", "menu" }, + atom_colored = { "kind", "abbr", "menu" }, +} + +local formatting_style = { + -- default fields order i.e completion word + item.kind + item.kind icons + fields = field_arrangement[cmp_style] or { "abbr", "kind", "menu" }, + + format = function(_, item) + local icons = require "nvchad.icons.lspkind" + local icon = (cmp_ui.icons and icons[item.kind]) or "" + + if cmp_style == "atom" or cmp_style == "atom_colored" then + icon = " " .. icon .. " " + item.menu = cmp_ui.lspkind_text and " (" .. item.kind .. ")" or "" + item.kind = icon + else + icon = cmp_ui.lspkind_text and (" " .. icon .. " ") or icon + item.kind = string.format("%s %s", icon, cmp_ui.lspkind_text and item.kind or "") + end + + return item + end, +} + +local function border(hl_name) + return { + { "╭", hl_name }, + { "─", hl_name }, + { "╮", hl_name }, + { "│", hl_name }, + { "╯", hl_name }, + { "─", hl_name }, + { "╰", hl_name }, + { "│", hl_name }, + } +end + +local options = { + completion = { + completeopt = "menu,menuone", + }, + + window = { + completion = { + side_padding = (cmp_style ~= "atom" and cmp_style ~= "atom_colored") and 1 or 0, + winhighlight = "Normal:CmpPmenu,CursorLine:CmpSel,Search:None", + scrollbar = false, + }, + documentation = { + border = border "CmpDocBorder", + winhighlight = "Normal:CmpDoc", + }, + }, + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + + formatting = formatting_style, + + mapping = { + ["<C-p>"] = cmp.mapping.select_prev_item(), + ["<C-n>"] = cmp.mapping.select_next_item(), + ["<C-d>"] = cmp.mapping.scroll_docs(-4), + ["<C-f>"] = cmp.mapping.scroll_docs(4), + ["<C-Space>"] = cmp.mapping.complete(), + ["<C-e>"] = cmp.mapping.close(), + ["<CR>"] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Insert, + select = true, + }, + ["<Tab>"] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif require("luasnip").expand_or_jumpable() then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-expand-or-jump", true, true, true), "") + else + fallback() + end + end, { + "i", + "s", + }), + ["<S-Tab>"] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif require("luasnip").jumpable(-1) then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-jump-prev", true, true, true), "") + else + fallback() + end + end, { + "i", + "s", + }), + }, + sources = { + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "nvim_lua" }, + { name = "path" }, + }, +} + +if cmp_style ~= "atom" and cmp_style ~= "atom_colored" then + options.window.completion.border = border "CmpBorder" +end + +return options diff --git a/nvim/nvchad/lua/plugins/configs/lazy_nvim.lua b/nvim/nvchad/lua/plugins/configs/lazy_nvim.lua new file mode 100644 index 0000000..cd170bd --- /dev/null +++ b/nvim/nvchad/lua/plugins/configs/lazy_nvim.lua @@ -0,0 +1,47 @@ +return { + defaults = { lazy = true }, + install = { colorscheme = { "nvchad" } }, + + ui = { + icons = { + ft = "", + lazy = " ", + loaded = "", + not_loaded = "", + }, + }, + + performance = { + rtp = { + disabled_plugins = { + "2html_plugin", + "tohtml", + "getscript", + "getscriptPlugin", + "gzip", + "logipat", + "netrw", + "netrwPlugin", + "netrwSettings", + "netrwFileHandlers", + "matchit", + "tar", + "tarPlugin", + "rrhelper", + "spellfile_plugin", + "vimball", + "vimballPlugin", + "zip", + "zipPlugin", + "tutor", + "rplugin", + "syntax", + "synmenu", + "optwin", + "compiler", + "bugreport", + "ftplugin", + }, + }, + }, +} diff --git a/nvim/nvchad/lua/plugins/configs/lspconfig.lua b/nvim/nvchad/lua/plugins/configs/lspconfig.lua new file mode 100644 index 0000000..f824aa0 --- /dev/null +++ b/nvim/nvchad/lua/plugins/configs/lspconfig.lua @@ -0,0 +1,64 @@ +dofile(vim.g.base46_cache .. "lsp") +require "nvchad.lsp" + +local M = {} +local utils = require "core.utils" + +-- export on_attach & capabilities for custom lspconfigs + +M.on_attach = function(client, bufnr) + utils.load_mappings("lspconfig", { buffer = bufnr }) + + if client.server_capabilities.signatureHelpProvider then + require("nvchad.signature").setup(client) + end + + if not utils.load_config().ui.lsp_semantic_tokens and client.supports_method "textDocument/semanticTokens" then + client.server_capabilities.semanticTokensProvider = nil + end +end + +M.capabilities = vim.lsp.protocol.make_client_capabilities() + +M.capabilities.textDocument.completion.completionItem = { + documentationFormat = { "markdown", "plaintext" }, + snippetSupport = true, + preselectSupport = true, + insertReplaceSupport = true, + labelDetailsSupport = true, + deprecatedSupport = true, + commitCharactersSupport = true, + tagSupport = { valueSet = { 1 } }, + resolveSupport = { + properties = { + "documentation", + "detail", + "additionalTextEdits", + }, + }, +} + +require("lspconfig").lua_ls.setup { + on_attach = M.on_attach, + capabilities = M.capabilities, + + settings = { + Lua = { + diagnostics = { + globals = { "vim" }, + }, + workspace = { + library = { + [vim.fn.expand "$VIMRUNTIME/lua"] = true, + [vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true, + [vim.fn.stdpath "data" .. "/lazy/ui/nvchad_types"] = true, + [vim.fn.stdpath "data" .. "/lazy/lazy.nvim/lua/lazy"] = true, + }, + maxPreload = 100000, + preloadFileSize = 10000, + }, + }, + }, +} + +return M diff --git a/nvim/nvchad/lua/plugins/configs/mason.lua b/nvim/nvchad/lua/plugins/configs/mason.lua new file mode 100644 index 0000000..3692a15 --- /dev/null +++ b/nvim/nvchad/lua/plugins/configs/mason.lua @@ -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 diff --git a/nvim/nvchad/lua/plugins/configs/nvimtree.lua b/nvim/nvchad/lua/plugins/configs/nvimtree.lua new file mode 100644 index 0000000..b4a8aee --- /dev/null +++ b/nvim/nvchad/lua/plugins/configs/nvimtree.lua @@ -0,0 +1,77 @@ +local options = { + filters = { + dotfiles = false, + exclude = { vim.fn.stdpath "config" .. "/lua/custom" }, + }, + disable_netrw = true, + hijack_netrw = true, + hijack_cursor = true, + hijack_unnamed_buffer_when_opening = false, + sync_root_with_cwd = true, + update_focused_file = { + enable = true, + update_root = false, + }, + view = { + adaptive_size = false, + side = "left", + width = 30, + preserve_window_proportions = true, + }, + git = { + enable = false, + ignore = true, + }, + filesystem_watchers = { + enable = true, + }, + actions = { + open_file = { + resize_window = true, + }, + }, + renderer = { + root_folder_label = false, + highlight_git = false, + highlight_opened_files = "none", + + indent_markers = { + enable = false, + }, + + icons = { + show = { + file = true, + folder = true, + folder_arrow = true, + git = false, + }, + + glyphs = { + default = "", + symlink = "", + folder = { + default = "", + empty = "", + empty_open = "", + open = "", + symlink = "", + symlink_open = "", + arrow_open = "", + arrow_closed = "", + }, + git = { + unstaged = "✗", + staged = "✓", + unmerged = "", + renamed = "➜", + untracked = "★", + deleted = "", + ignored = "◌", + }, + }, + }, + }, +} + +return options diff --git a/nvim/nvchad/lua/plugins/configs/others.lua b/nvim/nvchad/lua/plugins/configs/others.lua new file mode 100644 index 0000000..dafd5a4 --- /dev/null +++ b/nvim/nvchad/lua/plugins/configs/others.lua @@ -0,0 +1,66 @@ +local M = {} +local utils = require "core.utils" + +M.blankline = { + indentLine_enabled = 1, + filetype_exclude = { + "help", + "terminal", + "lazy", + "lspinfo", + "TelescopePrompt", + "TelescopeResults", + "mason", + "nvdash", + "nvcheatsheet", + "", + }, + buftype_exclude = { "terminal" }, + show_trailing_blankline_indent = false, + show_first_indent_level = false, + show_current_context = true, + show_current_context_start = true, +} + +M.luasnip = function(opts) + require("luasnip").config.set_config(opts) + + -- vscode format + require("luasnip.loaders.from_vscode").lazy_load() + 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, + }) +end + +M.gitsigns = { + signs = { + add = { text = "│" }, + change = { text = "│" }, + delete = { text = "" }, + topdelete = { text = "‾" }, + changedelete = { text = "~" }, + untracked = { text = "│" }, + }, + on_attach = function(bufnr) + utils.load_mappings("gitsigns", { buffer = bufnr }) + end, +} + +return M diff --git a/nvim/nvchad/lua/plugins/configs/telescope.lua b/nvim/nvchad/lua/plugins/configs/telescope.lua new file mode 100644 index 0000000..784fb19 --- /dev/null +++ b/nvim/nvchad/lua/plugins/configs/telescope.lua @@ -0,0 +1,55 @@ +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" }, +} + +return options diff --git a/nvim/nvchad/lua/plugins/configs/treesitter.lua b/nvim/nvchad/lua/plugins/configs/treesitter.lua new file mode 100644 index 0000000..b21b55d --- /dev/null +++ b/nvim/nvchad/lua/plugins/configs/treesitter.lua @@ -0,0 +1,12 @@ +local options = { + ensure_installed = { "lua" }, + + highlight = { + enable = true, + use_languagetree = true, + }, + + indent = { enable = true }, +} + +return options diff --git a/nvim/nvchad/lua/plugins/init.lua b/nvim/nvchad/lua/plugins/init.lua new file mode 100644 index 0000000..bce7140 --- /dev/null +++ b/nvim/nvchad/lua/plugins/init.lua @@ -0,0 +1,253 @@ +-- All plugins have lazy=true by default,to load a plugin on startup just lazy=false +-- List of all default plugins & their definitions +local default_plugins = { + + "nvim-lua/plenary.nvim", + + { + "NvChad/base46", + branch = "v2.0", + build = function() + require("base46").load_all_highlights() + end, + }, + + { + "NvChad/ui", + branch = "v2.0", + lazy = false, + }, + + { + "NvChad/nvterm", + init = function() + require("core.utils").load_mappings "nvterm" + end, + config = function(_, opts) + require "base46.term" + require("nvterm").setup(opts) + end, + }, + + { + "NvChad/nvim-colorizer.lua", + event = "User FilePost", + config = function(_, opts) + require("colorizer").setup(opts) + + -- execute colorizer as soon as possible + vim.defer_fn(function() + require("colorizer").attach_to_buffer(0) + end, 0) + end, + }, + + { + "nvim-tree/nvim-web-devicons", + opts = function() + return { override = require "nvchad.icons.devicons" } + end, + config = function(_, opts) + dofile(vim.g.base46_cache .. "devicons") + require("nvim-web-devicons").setup(opts) + end, + }, + + { + "lukas-reineke/indent-blankline.nvim", + version = "2.20.7", + event = "User FilePost", + opts = function() + return require("plugins.configs.others").blankline + end, + config = function(_, opts) + require("core.utils").load_mappings "blankline" + dofile(vim.g.base46_cache .. "blankline") + require("indent_blankline").setup(opts) + end, + }, + + { + "nvim-treesitter/nvim-treesitter", + event = { "BufReadPost", "BufNewFile" }, + tag = "v0.9.2", + cmd = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSModuleInfo" }, + build = ":TSUpdate", + opts = function() + return require "plugins.configs.treesitter" + end, + config = function(_, opts) + dofile(vim.g.base46_cache .. "syntax") + require("nvim-treesitter.configs").setup(opts) + end, + }, + + -- git stuff + { + "lewis6991/gitsigns.nvim", + event = "User FilePost", + opts = function() + return require("plugins.configs.others").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 "plugins.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 "plugins.configs.lspconfig" + 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("plugins.configs.others").luasnip(opts) + 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 "plugins.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() + require("core.utils").load_mappings "comment" + end, + config = function(_, opts) + require("Comment").setup(opts) + end, + }, + + -- file managing , picker etc + { + "nvim-tree/nvim-tree.lua", + cmd = { "NvimTreeToggle", "NvimTreeFocus" }, + init = function() + require("core.utils").load_mappings "nvimtree" + end, + opts = function() + return require "plugins.configs.nvimtree" + end, + config = function(_, opts) + dofile(vim.g.base46_cache .. "nvimtree") + require("nvim-tree").setup(opts) + end, + }, + + { + "nvim-telescope/telescope.nvim", + dependencies = { "nvim-treesitter/nvim-treesitter" }, + cmd = "Telescope", + init = function() + require("core.utils").load_mappings "telescope" + end, + opts = function() + return require "plugins.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, + }, + + -- Only load whichkey after all the gui + { + "folke/which-key.nvim", + keys = { "<leader>", "<c-r>", "<c-w>", '"', "'", "`", "c", "v", "g" }, + init = function() + require("core.utils").load_mappings "whichkey" + end, + cmd = "WhichKey", + config = function(_, opts) + dofile(vim.g.base46_cache .. "whichkey") + require("which-key").setup(opts) + end, + }, +} + +local config = require("core.utils").load_config() + +if #config.plugins > 0 then + table.insert(default_plugins, { import = config.plugins }) +end + +require("lazy").setup(default_plugins, config.lazy_nvim) |