From 7dc8c6d0b2a4b1bfde745050a3045c91b15f2def Mon Sep 17 00:00:00 2001 From: siduck Date: Thu, 29 Feb 2024 22:03:20 +0530 Subject: [PATCH] initial starter dir structure; --- init.lua | 35 ++- lua/{plugins => }/configs/cmp.lua | 0 .../lazy_nvim.lua => configs/lazy.lua} | 0 lua/{plugins => }/configs/lspconfig.lua | 0 lua/core/{init.lua => autocmds.lua} | 61 ----- lua/core/bootstrap.lua | 23 -- lua/core/options.lua | 60 +++++ lua/nvconfig.lua | 6 - lua/plugins/cmp.lua | 64 +++++ lua/plugins/configs/luasnip.lua | 23 -- lua/plugins/configs/mason.lua | 28 -- lua/plugins/configs/telescope.lua | 63 ----- lua/plugins/configs/treesitter.lua | 12 - lua/plugins/{configs => }/gitsigns.lua | 10 +- lua/plugins/init.lua | 239 ------------------ lua/plugins/lsp.lua | 7 + lua/plugins/mason.lua | 45 ++++ lua/plugins/{configs => }/nvimtree.lua | 10 +- lua/plugins/telescope.lua | 80 ++++++ lua/plugins/treesitter.lua | 23 ++ lua/plugins/ui.lua | 89 +++++++ 21 files changed, 403 insertions(+), 475 deletions(-) rename lua/{plugins => }/configs/cmp.lua (100%) rename lua/{plugins/configs/lazy_nvim.lua => configs/lazy.lua} (100%) rename lua/{plugins => }/configs/lspconfig.lua (100%) rename lua/core/{init.lua => autocmds.lua} (62%) create mode 100644 lua/core/options.lua create mode 100644 lua/plugins/cmp.lua delete mode 100644 lua/plugins/configs/luasnip.lua delete mode 100644 lua/plugins/configs/mason.lua delete mode 100644 lua/plugins/configs/telescope.lua delete mode 100644 lua/plugins/configs/treesitter.lua rename lua/plugins/{configs => }/gitsigns.lua (75%) delete mode 100644 lua/plugins/init.lua create mode 100644 lua/plugins/lsp.lua create mode 100644 lua/plugins/mason.lua rename lua/plugins/{configs => }/nvimtree.lua (87%) create mode 100644 lua/plugins/telescope.lua create mode 100644 lua/plugins/treesitter.lua create mode 100644 lua/plugins/ui.lua diff --git a/init.lua b/init.lua index 9e53d71..2e98038 100644 --- a/init.lua +++ b/init.lua @@ -1,19 +1,18 @@ -require "core" +require "core.options" +require "core.autocmds" +-- +-- local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim" +-- +-- -- bootstrap lazy.nvim! +-- if not vim.loop.fs_stat(lazypath) then +-- require("core.bootstrap").gen_chadrc_template() +-- require("core.bootstrap").lazy(lazypath) +-- end +-- +-- dofile(vim.g.base46_cache .. "defaults") +-- vim.opt.rtp:prepend(lazypath) -pcall(require, 'custom') - -local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim" - --- bootstrap lazy.nvim! -if not vim.loop.fs_stat(lazypath) then - require("core.bootstrap").gen_chadrc_template() - require("core.bootstrap").lazy(lazypath) -end - -dofile(vim.g.base46_cache .. "defaults") -vim.opt.rtp:prepend(lazypath) -require "plugins" - -vim.schedule(function() - require "core.mappings" -end, 0) +-- require("lazy").setup({ +-- { import = "plugins" }, +-- { import = "custom.plugins" }, +-- }, require "configs.lazy") diff --git a/lua/plugins/configs/cmp.lua b/lua/configs/cmp.lua similarity index 100% rename from lua/plugins/configs/cmp.lua rename to lua/configs/cmp.lua diff --git a/lua/plugins/configs/lazy_nvim.lua b/lua/configs/lazy.lua similarity index 100% rename from lua/plugins/configs/lazy_nvim.lua rename to lua/configs/lazy.lua diff --git a/lua/plugins/configs/lspconfig.lua b/lua/configs/lspconfig.lua similarity index 100% rename from lua/plugins/configs/lspconfig.lua rename to lua/configs/lspconfig.lua diff --git a/lua/core/init.lua b/lua/core/autocmds.lua similarity index 62% rename from lua/core/init.lua rename to lua/core/autocmds.lua index 59eaf75..fbc0f36 100644 --- a/lua/core/init.lua +++ b/lua/core/autocmds.lua @@ -1,64 +1,3 @@ -local opt = vim.opt -local g = vim.g - --------------------------------------- globals ----------------------------------------- -g.base46_cache = vim.fn.stdpath "data" .. "/nvchad/base46/" -g.toggle_theme_icon = "  " - --------------------------------------- options ------------------------------------------ -opt.laststatus = 3 -- global statusline -opt.showmode = false - -opt.clipboard = "unnamedplus" -opt.cursorline = true -opt.cursorlineopt = "number" - --- Indenting -opt.expandtab = true -opt.shiftwidth = 2 -opt.smartindent = true -opt.tabstop = 2 -opt.softtabstop = 2 - -opt.fillchars = { eob = " " } -opt.ignorecase = true -opt.smartcase = true -opt.mouse = "a" - --- Numbers -opt.number = true -opt.numberwidth = 2 -opt.ruler = false - --- disable nvim intro -opt.shortmess:append "sI" - -opt.signcolumn = "yes" -opt.splitbelow = true -opt.splitright = true -opt.termguicolors = true -opt.timeoutlen = 400 -opt.undofile = true - --- interval for writing swap file to disk, also used by gitsigns -opt.updatetime = 250 - --- go to previous/next line with h,l,left arrow and right arrow --- when cursor reaches end/beginning of line -opt.whichwrap:append "<>[]hl" - -g.mapleader = " " - --- disable some default providers -for _, provider in ipairs { "node", "perl", "python3", "ruby" } do - vim.g["loaded_" .. provider .. "_provider"] = 0 -end - --- add binaries installed by mason.nvim to path -local is_windows = vim.loop.os_uname().sysname == "Windows_NT" -vim.env.PATH = vim.fn.stdpath "data" .. "/mason/bin" .. (is_windows and ";" or ":") .. vim.env.PATH - --------------------------------------- autocmds ------------------------------------------ local autocmd = vim.api.nvim_create_autocmd -- dont list quickfix buffers diff --git a/lua/core/bootstrap.lua b/lua/core/bootstrap.lua index ee3f37d..2871609 100644 --- a/lua/core/bootstrap.lua +++ b/lua/core/bootstrap.lua @@ -44,27 +44,4 @@ M.lazy = function(install_path) end) end -M.gen_chadrc_template = function() - local path = fn.stdpath "config" .. "/lua/custom" - - if fn.isdirectory(path) ~= 1 then - local input = vim.env.NVCHAD_EXAMPLE_CONFIG or fn.input "Do you want to install example custom config? (y/N): " - - if input:lower() == "y" then - M.echo "Cloning example custom config repo..." - shell_call { "git", "clone", "--depth", "1", "https://github.com/NvChad/example_config", path } - fn.delete(path .. "/.git", "rf") - else - -- use very minimal chadrc - fn.mkdir(path, "p") - - local file = io.open(path .. "/chadrc.lua", "w") - if file then - file:write "---@type ChadrcConfig\nlocal M = {}\n\nM.ui = { theme = 'onedark' }\n\nreturn M" - file:close() - end - end - end -end - return M diff --git a/lua/core/options.lua b/lua/core/options.lua new file mode 100644 index 0000000..bd7f2be --- /dev/null +++ b/lua/core/options.lua @@ -0,0 +1,60 @@ +local opt = vim.opt +local g = vim.g + +-------------------------------------- globals ----------------------------------------- +g.base46_cache = vim.fn.stdpath "data" .. "/nvchad/base46/" +g.toggle_theme_icon = "  " + +-------------------------------------- options ------------------------------------------ +opt.laststatus = 3 -- global statusline +opt.showmode = false + +opt.clipboard = "unnamedplus" +opt.cursorline = true +opt.cursorlineopt = "number" + +-- Indenting +opt.expandtab = true +opt.shiftwidth = 2 +opt.smartindent = true +opt.tabstop = 2 +opt.softtabstop = 2 + +opt.fillchars = { eob = " " } +opt.ignorecase = true +opt.smartcase = true +opt.mouse = "a" + +-- Numbers +opt.number = true +opt.numberwidth = 2 +opt.ruler = false + +-- disable nvim intro +opt.shortmess:append "sI" + +opt.signcolumn = "yes" +opt.splitbelow = true +opt.splitright = true +opt.termguicolors = true +opt.timeoutlen = 400 +opt.undofile = true + +-- interval for writing swap file to disk, also used by gitsigns +opt.updatetime = 250 + +-- go to previous/next line with h,l,left arrow and right arrow +-- when cursor reaches end/beginning of line +opt.whichwrap:append "<>[]hl" + +g.mapleader = " " + +-- disable some default providers +vim.g["loaded_node_provider"] = 0 +vim.g["loaded_python3_provider"] = 0 +vim.g["loaded_perl_provider"] = 0 +vim.g["loaded_ruby_provider"] = 0 + +-- add binaries installed by mason.nvim to path +local is_windows = vim.loop.os_uname().sysname == "Windows_NT" +vim.env.PATH = vim.fn.stdpath "data" .. "/mason/bin" .. (is_windows and ";" or ":") .. vim.env.PATH diff --git a/lua/nvconfig.lua b/lua/nvconfig.lua index bfaebc7..5066ed2 100644 --- a/lua/nvconfig.lua +++ b/lua/nvconfig.lua @@ -1,9 +1,5 @@ local M = {} -M.options = { - nvchad_branch = "v3.0", -} - M.ui = { ------------------------------- base46 ------------------------------------- -- hl = highlights @@ -92,8 +88,6 @@ M.ui = { M.plugins = "" -- path i.e "custom.plugins", so make custom/plugins.lua file -M.lazy_nvim = require "plugins.configs.lazy_nvim" -- config for lazy.nvim startup options - M.base46 = { integrations = { "blankline", diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua new file mode 100644 index 0000000..978d7e7 --- /dev/null +++ b/lua/plugins/cmp.lua @@ -0,0 +1,64 @@ +return { + "hrsh7th/nvim-cmp", + event = "InsertEnter", + + opts = function() + return require "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", + }, + }, +} diff --git a/lua/plugins/configs/luasnip.lua b/lua/plugins/configs/luasnip.lua deleted file mode 100644 index f40672d..0000000 --- a/lua/plugins/configs/luasnip.lua +++ /dev/null @@ -1,23 +0,0 @@ --- 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, -}) diff --git a/lua/plugins/configs/mason.lua b/lua/plugins/configs/mason.lua deleted file mode 100644 index 3692a15..0000000 --- a/lua/plugins/configs/mason.lua +++ /dev/null @@ -1,28 +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 = "", - install_server = "i", - update_server = "u", - check_server_version = "c", - update_all_servers = "U", - check_outdated_servers = "C", - uninstall_server = "X", - cancel_installation = "", - }, - }, - - max_concurrent_installers = 10, -} - -return options diff --git a/lua/plugins/configs/telescope.lua b/lua/plugins/configs/telescope.lua deleted file mode 100644 index 0df500e..0000000 --- a/lua/plugins/configs/telescope.lua +++ /dev/null @@ -1,63 +0,0 @@ -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 diff --git a/lua/plugins/configs/treesitter.lua b/lua/plugins/configs/treesitter.lua deleted file mode 100644 index 897c4e3..0000000 --- a/lua/plugins/configs/treesitter.lua +++ /dev/null @@ -1,12 +0,0 @@ -local options = { - ensure_installed = { "lua", "vim", "vimdoc" }, - - highlight = { - enable = true, - use_languagetree = true, - }, - - indent = { enable = true }, -} - -return options diff --git a/lua/plugins/configs/gitsigns.lua b/lua/plugins/gitsigns.lua similarity index 75% rename from lua/plugins/configs/gitsigns.lua rename to lua/plugins/gitsigns.lua index 27f3105..8f9fb6c 100644 --- a/lua/plugins/configs/gitsigns.lua +++ b/lua/plugins/gitsigns.lua @@ -23,4 +23,12 @@ local options = { end, } -return options +return { + "lewis6991/gitsigns.nvim", + event = "User FilePost", + opts = options, + config = function(_, opts) + dofile(vim.g.base46_cache .. "git") + require("gitsigns").setup(opts) + end, +} diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua deleted file mode 100644 index 645c09b..0000000 --- a/lua/plugins/init.lua +++ /dev/null @@ -1,239 +0,0 @@ --- 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 = "v3.0", - build = function() - require("base46").load_all_highlights() - end, - }, - - { - "NvChad/ui", - branch = "clean", - lazy = false, - config = function() - require "nvchad" - 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", - event = "User FilePost", - opts = { - indent = { char = "│", highlight = "IblChar" }, - scope = { char = "│", highlight = "IblScopeChar" }, - }, - config = function(_, opts) - dofile(vim.g.base46_cache .. "blankline") - - local hooks = require "ibl.hooks" - hooks.register(hooks.type.WHITESPACE, hooks.builtin.hide_first_space_indent_level) - require("ibl").setup(opts) - end, - }, - - { - "nvim-treesitter/nvim-treesitter", - event = { "BufReadPost", "BufNewFile" }, - cmd = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSModuleInfo" }, - build = ":TSUpdate", - opts = function() - return require "plugins.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 "plugins.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 "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").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 "plugins.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 "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() - vim.g.comment_maps = true - end, - config = function(_, opts) - require("Comment").setup(opts) - end, - }, - - -- file managing , picker etc - { - "nvim-tree/nvim-tree.lua", - cmd = { "NvimTreeToggle", "NvimTreeFocus" }, - 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", - 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 = { "", "", "", '"', "'", "`", "c", "v", "g" }, - cmd = "WhichKey", - config = function(_, opts) - dofile(vim.g.base46_cache .. "whichkey") - require("which-key").setup(opts) - end, - }, -} - -local config = require "nvconfig" - -if #config.plugins > 0 then - table.insert(default_plugins, { import = config.plugins }) -end - -require("lazy").setup(default_plugins, config.lazy_nvim) diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua new file mode 100644 index 0000000..b55658f --- /dev/null +++ b/lua/plugins/lsp.lua @@ -0,0 +1,7 @@ +return { + "neovim/nvim-lspconfig", + event = "User FilePost", + config = function() + require("configs.lspconfig").defaults() + end, +} diff --git a/lua/plugins/mason.lua b/lua/plugins/mason.lua new file mode 100644 index 0000000..9f8248f --- /dev/null +++ b/lua/plugins/mason.lua @@ -0,0 +1,45 @@ +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 = "", + install_server = "i", + update_server = "u", + check_server_version = "c", + update_all_servers = "U", + check_outdated_servers = "C", + uninstall_server = "X", + cancel_installation = "", + }, + }, + + 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, +} diff --git a/lua/plugins/configs/nvimtree.lua b/lua/plugins/nvimtree.lua similarity index 87% rename from lua/plugins/configs/nvimtree.lua rename to lua/plugins/nvimtree.lua index c54248e..cf8bdb0 100644 --- a/lua/plugins/configs/nvimtree.lua +++ b/lua/plugins/nvimtree.lua @@ -74,4 +74,12 @@ local options = { }, } -return options +return { + "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, +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..c441438 --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,80 @@ +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, +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 0000000..d940c95 --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,23 @@ +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, +} diff --git a/lua/plugins/ui.lua b/lua/plugins/ui.lua new file mode 100644 index 0000000..6366f45 --- /dev/null +++ b/lua/plugins/ui.lua @@ -0,0 +1,89 @@ +return { + "nvim-lua/plenary.nvim", + + { + "NvChad/base46", + -- branch = "v3.0", + dir = "~/projects/base46/", + build = function() + require("base46").load_all_highlights() + end, + }, + + { + "NvChad/ui", + -- branch = "v3.0", + dir = "~/projects/ui/", + lazy = false, + config = function() + require "nvchad" + 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, + }, + + { + "folke/which-key.nvim", + keys = { "", "", "", '"', "'", "`", "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", + event = "User FilePost", + + opts = { + indent = { char = "│", highlight = "IblChar" }, + scope = { char = "│", highlight = "IblScopeChar" }, + }, + + config = function(_, opts) + dofile(vim.g.base46_cache .. "blankline") + + local hooks = require "ibl.hooks" + hooks.register(hooks.type.WHITESPACE, hooks.builtin.hide_first_space_indent_level) + require("ibl").setup(opts) + end, + }, +}