From 7f055761ba0d94a562ead5ff85352c4c67b51f67 Mon Sep 17 00:00:00 2001 From: Sidhanth Rathod Date: Tue, 1 Oct 2024 21:50:38 +0530 Subject: [PATCH] Clean (#3006) * refactor(cmp) : use cmp module from ui repo https://github.com/NvChad/ui/commit/c4576d8b5bbb6305de53ec017cd6ffad863c98ee I moved it to the ui repo so non nvchad users could achieve the CMP look from NvChad * remove: cc blankline mapping * replace: nvim-colorizer plugin with ui.colorify (BREAKING CHANGE) https://github.com/NvChad/ui/blob/v2.5/lua/nvconfig.lua#L106 * misc: load nvchad module in config func of ui instead of plugin/ in ui repo * clean up * remove un-needed configs/lazy_nvim.lua file * rm gitsigns mappings as it gets frustrating for users to override them * rm un-needed options var in plugin configs * add branch name for ui plugin * trim some loc! * feat: use modern theme picker for th * feat: add volt plugins --- lua/nvchad/configs/cmp.lua | 68 ++----------------------------- lua/nvchad/configs/gitsigns.lua | 18 +------- lua/nvchad/configs/lazy_nvim.lua | 47 --------------------- lua/nvchad/configs/lspconfig.lua | 5 +-- lua/nvchad/configs/mason.lua | 4 +- lua/nvchad/configs/nvimtree.lua | 4 +- lua/nvchad/configs/telescope.lua | 4 +- lua/nvchad/configs/treesitter.lua | 4 +- lua/nvchad/mappings.lua | 22 +++------- lua/nvchad/options.lua | 5 --- lua/nvchad/plugins/init.lua | 48 ++++++---------------- 11 files changed, 27 insertions(+), 202 deletions(-) delete mode 100644 lua/nvchad/configs/lazy_nvim.lua diff --git a/lua/nvchad/configs/cmp.lua b/lua/nvchad/configs/cmp.lua index 3eb7697..28071ae 100644 --- a/lua/nvchad/configs/cmp.lua +++ b/lua/nvchad/configs/cmp.lua @@ -1,73 +1,16 @@ -local cmp = require "cmp" - dofile(vim.g.base46_cache .. "cmp") -local cmp_ui = require("nvconfig").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 cmp = require "cmp" local options = { - completion = { - completeopt = "menu,menuone", - }, + 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 = { [""] = cmp.mapping.select_prev_item(), [""] = cmp.mapping.select_next_item(), @@ -101,6 +44,7 @@ local options = { end end, { "i", "s" }), }, + sources = { { name = "nvim_lsp" }, { name = "luasnip" }, @@ -110,8 +54,4 @@ local options = { }, } -if cmp_style ~= "atom" and cmp_style ~= "atom_colored" then - options.window.completion.border = border "CmpBorder" -end - -return options +return vim.tbl_deep_extend("force", options, require "nvchad.cmp") diff --git a/lua/nvchad/configs/gitsigns.lua b/lua/nvchad/configs/gitsigns.lua index 3ae0264..421348b 100644 --- a/lua/nvchad/configs/gitsigns.lua +++ b/lua/nvchad/configs/gitsigns.lua @@ -1,24 +1,8 @@ dofile(vim.g.base46_cache .. "git") -local options = { +return { signs = { delete = { text = "󰍵" }, changedelete = { text = "󱕖" }, }, - - on_attach = function(bufnr) - local gs = package.loaded.gitsigns - - local function opts(desc) - return { buffer = bufnr, desc = desc } - end - - local map = vim.keymap.set - - map("n", "rh", gs.reset_hunk, opts "Reset Hunk") - map("n", "ph", gs.preview_hunk, opts "Preview Hunk") - map("n", "gb", gs.blame_line, opts "Blame Line") - end, } - -return options diff --git a/lua/nvchad/configs/lazy_nvim.lua b/lua/nvchad/configs/lazy_nvim.lua deleted file mode 100644 index cd170bd..0000000 --- a/lua/nvchad/configs/lazy_nvim.lua +++ /dev/null @@ -1,47 +0,0 @@ -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/lua/nvchad/configs/lspconfig.lua b/lua/nvchad/configs/lspconfig.lua index 5100a3d..25e7eed 100644 --- a/lua/nvchad/configs/lspconfig.lua +++ b/lua/nvchad/configs/lspconfig.lua @@ -19,10 +19,7 @@ M.on_attach = function(_, bufnr) end, opts "List workspace folders") map("n", "D", vim.lsp.buf.type_definition, opts "Go to type definition") - - map("n", "ra", function() - require "nvchad.lsp.renamer"() - end, opts "NvRenamer") + map("n", "ra", require "nvchad.lsp.renamer", opts "NvRenamer") map({ "n", "v" }, "ca", vim.lsp.buf.code_action, opts "Code action") map("n", "gr", vim.lsp.buf.references, opts "Show references") diff --git a/lua/nvchad/configs/mason.lua b/lua/nvchad/configs/mason.lua index 53fc33a..f3288b6 100644 --- a/lua/nvchad/configs/mason.lua +++ b/lua/nvchad/configs/mason.lua @@ -1,6 +1,6 @@ dofile(vim.g.base46_cache .. "mason") -local options = { +return { PATH = "skip", ui = { @@ -13,5 +13,3 @@ local options = { max_concurrent_installers = 10, } - -return options diff --git a/lua/nvchad/configs/nvimtree.lua b/lua/nvchad/configs/nvimtree.lua index 7e9f52a..20b3ac5 100644 --- a/lua/nvchad/configs/nvimtree.lua +++ b/lua/nvchad/configs/nvimtree.lua @@ -1,6 +1,6 @@ dofile(vim.g.base46_cache .. "nvimtree") -local options = { +return { filters = { dotfiles = false }, disable_netrw = true, hijack_cursor = true, @@ -32,5 +32,3 @@ local options = { }, }, } - -return options diff --git a/lua/nvchad/configs/telescope.lua b/lua/nvchad/configs/telescope.lua index 7dc87f5..58f4a72 100644 --- a/lua/nvchad/configs/telescope.lua +++ b/lua/nvchad/configs/telescope.lua @@ -1,6 +1,6 @@ dofile(vim.g.base46_cache .. "telescope") -local options = { +return { defaults = { prompt_prefix = "  ", selection_caret = " ", @@ -22,5 +22,3 @@ local options = { extensions_list = { "themes", "terms" }, extensions = {}, } - -return options diff --git a/lua/nvchad/configs/treesitter.lua b/lua/nvchad/configs/treesitter.lua index e8697b6..5b9818b 100644 --- a/lua/nvchad/configs/treesitter.lua +++ b/lua/nvchad/configs/treesitter.lua @@ -3,7 +3,7 @@ pcall(function() dofile(vim.g.base46_cache .. "treesitter") end) -local options = { +return { ensure_installed = { "lua", "luadoc", "printf", "vim", "vimdoc" }, highlight = { @@ -13,5 +13,3 @@ local options = { indent = { enable = true }, } - -return options diff --git a/lua/nvchad/mappings.lua b/lua/nvchad/mappings.lua index c700308..99ad8c3 100644 --- a/lua/nvchad/mappings.lua +++ b/lua/nvchad/mappings.lua @@ -61,7 +61,11 @@ map("n", "fz", "Telescope current_buffer_fuzzy_find", { desc = map("n", "cm", "Telescope git_commits", { desc = "telescope git commits" }) map("n", "gt", "Telescope git_status", { desc = "telescope git status" }) map("n", "pt", "Telescope terms", { desc = "telescope pick hidden term" }) -map("n", "th", "Telescope themes", { desc = "telescope nvchad themes" }) + +map("n", "th", function() + require("nvchad.themes").open() +end, { desc = "telescope nvchad themes" }) + map("n", "ff", "Telescope find_files", { desc = "telescope find files" }) map( "n", @@ -101,19 +105,3 @@ map("n", "wK", "WhichKey ", { desc = "whichkey all keymaps" }) map("n", "wk", function() vim.cmd("WhichKey " .. vim.fn.input "WhichKey: ") end, { desc = "whichkey query lookup" }) - --- blankline -map("n", "cc", function() - local config = { scope = {} } - config.scope.exclude = { language = {}, node_type = {} } - config.scope.include = { node_type = {} } - local node = require("ibl.scope").get(vim.api.nvim_get_current_buf(), config) - - if node then - local start_row, _, end_row, _ = node:range() - if start_row ~= end_row then - vim.api.nvim_win_set_cursor(vim.api.nvim_get_current_win(), { start_row + 1, 0 }) - vim.api.nvim_feedkeys("_", "n", true) - end - end -end, { desc = "blankline jump to current context" }) diff --git a/lua/nvchad/options.lua b/lua/nvchad/options.lua index 745388a..88270f1 100644 --- a/lua/nvchad/options.lua +++ b/lua/nvchad/options.lua @@ -2,9 +2,6 @@ local opt = vim.opt local o = vim.o local g = vim.g --------------------------------------- globals ----------------------------------------- -g.toggle_theme_icon = "  " - -------------------------------------- options ------------------------------------------ o.laststatus = 3 o.showmode = false @@ -46,8 +43,6 @@ o.updatetime = 250 -- when cursor reaches end/beginning of line opt.whichwrap:append "<>[]hl" --- g.mapleader = " " - -- disable some default providers g.loaded_node_provider = 0 g.loaded_python3_provider = 0 diff --git a/lua/nvchad/plugins/init.lua b/lua/nvchad/plugins/init.lua index e12e2f1..9d5036f 100644 --- a/lua/nvchad/plugins/init.lua +++ b/lua/nvchad/plugins/init.lua @@ -2,17 +2,24 @@ return { "nvim-lua/plenary.nvim", { - "NvChad/base46", + "nvchad/base46", build = function() require("base46").load_all_highlights() end, }, { - "NvChad/ui", + "nvchad/ui", lazy = false, + config = function() + require "nvchad" + end, }, + "nvchad/volt", + "nvchad/minty", + "nvchad/menu", + { "nvim-tree/nvim-web-devicons", opts = function() @@ -52,9 +59,9 @@ return { "folke/which-key.nvim", keys = { "", "", "", '"', "'", "`", "c", "v", "g" }, cmd = "WhichKey", - config = function(_, opts) + opts = function() dofile(vim.g.base46_cache .. "whichkey") - require("which-key").setup(opts) + return {} end, }, @@ -62,9 +69,7 @@ return { { "stevearc/conform.nvim", opts = { - formatters_by_ft = { - lua = { "stylua" }, - }, + formatters_by_ft = { lua = { "stylua" } }, }, }, @@ -163,35 +168,6 @@ return { opts = function() return require "nvchad.configs.telescope" end, - config = function(_, opts) - local telescope = require "telescope" - telescope.setup(opts) - - -- load extensions - for _, ext in ipairs(opts.extensions_list) do - telescope.load_extension(ext) - end - end, - }, - - { - "NvChad/nvim-colorizer.lua", - event = "User FilePost", - opts = { - user_default_options = { names = false }, - filetypes = { - "*", - "!lazy", - }, - }, - 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, }, {