From 0aafb002b58ac937f6d37bbd1dc38e2312c13a0b Mon Sep 17 00:00:00 2001 From: siduck Date: Wed, 8 Mar 2023 18:57:54 +0530 Subject: [PATCH] misc & cleanup --- lua/core/bootstrap.lua | 23 +++++++++++++++++----- lua/core/init.lua | 35 ++++++++++------------------------ lua/core/mappings.lua | 23 +++------------------- lua/plugins/configs/others.lua | 5 +---- lua/plugins/init.lua | 2 +- 5 files changed, 33 insertions(+), 55 deletions(-) diff --git a/lua/core/bootstrap.lua b/lua/core/bootstrap.lua index 9080d3c..c75ef4b 100644 --- a/lua/core/bootstrap.lua +++ b/lua/core/bootstrap.lua @@ -16,12 +16,11 @@ M.lazy = function(install_path) -- install plugins + compile their configs require "plugins" - require("lazy").load { plugins = { "nvim-treesitter" } } - -- install binaries from mason.nvim & tsparsers on LazySync - vim.schedule(function() + vim.api.nvim_buf_delete(0, { force = true }) -- close lazy window + + vim.defer_fn(function() vim.cmd "silent! MasonInstallAll" - -- print success message end, 0) end @@ -31,7 +30,6 @@ M.gen_chadrc_template = function() vim.cmd "redraw|echo ''" if input == "y" then - -- clone example_config repo print "cloning chadrc starter template repo...." vim.fn.system { @@ -50,6 +48,21 @@ M.gen_chadrc_template = function() vim.loop.fs_rmdir(vim.fn.stdpath "config" .. "/lua/custom/.git") vim.notify "successfully installed chadrc template!" vim.cmd "redraw|echo ''" + else + local custom_dir = vim.fn.stdpath "config" .. "/lua/custom/" + vim.fn.mkdir(custom_dir, "p") + + local str = [[ + local M = {} + M.ui = { + theme = "onedark", + } + return M + ]] + + local file = io.open(custom_dir .. "chadrc.lua", "w") + file:write(str) + file:close() end end end diff --git a/lua/core/init.lua b/lua/core/init.lua index 6ba5109..e41a4b6 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -5,7 +5,7 @@ vim.env.PATH = vim.env.PATH .. (is_windows and ";" or ":") .. vim.fn.stdpath "da local new_cmd = vim.api.nvim_create_user_command new_cmd("NvChadUpdate", function() - require("nvchad").update_nvchad() + require "nvchad.update"() end, {}) -- autocmds @@ -19,37 +19,22 @@ autocmd("FileType", { end, }) -local sep = vim.loop.os_uname().sysname:find "windows" and "\\" or "/" - vim.api.nvim_create_autocmd("BufWritePost", { - pattern = vim.fn.glob( - table.concat({ - vim.fn.stdpath "config", - "lua", - "custom", - "**", - "*.lua", - }, sep), - true, - true, - true - ), - + pattern = "chadrc.lua", group = vim.api.nvim_create_augroup("ReloadNvChad", {}), - callback = function(opts) + callback = function() require("plenary.reload").reload_module "base46" - local file = string - .gsub(vim.fn.fnamemodify(opts.file, ":r"), vim.fn.stdpath "config" .. sep .. "lua" .. sep, "") - :gsub(sep, ".") - require("plenary.reload").reload_module(file) - require("plenary.reload").reload_module "custom.chadrc" + local config = require("core.utils").load_config() - local config = require("core.utils").load_config().ui + vim.opt.statusline = "%!v:lua.require('nvchad_ui.statusline." .. config.ui.statusline.theme .. "').run()" + vim.g.nvchad_theme = config.ui.theme + vim.g.transparency = config.ui.transparency - vim.opt.statusline = "%!v:lua.require('nvchad_ui.statusline." .. config.statusline.theme .. "').run()" + -- reload cmp stuff + require("plenary.reload").reload_module "plugins.configs.cmp" + require("cmp").setup(require "plugins.configs.cmp") require("base46").load_all_highlights() - -- vim.cmd("redraw!") end, }) diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index 2b52096..cee387f 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -1,9 +1,5 @@ -- n, v, i, t = mode names -local function termcodes(str) - return vim.api.nvim_replace_termcodes(str, true, true, true) -end - local M = {} M.general = { @@ -20,8 +16,6 @@ M.general = { }, n = { - [""] = { " noh ", "no highlight" }, - -- switch between windows [""] = { "h", "window left" }, [""] = { "l", "window right" }, @@ -38,16 +32,6 @@ M.general = { ["n"] = { " set nu! ", "toggle line number" }, ["rn"] = { " set rnu! ", "toggle relative number" }, - -- update nvchad - ["uu"] = { " :NvChadUpdate ", "update nvchad" }, - - ["tt"] = { - function() - require("base46").toggle_theme() - end, - "toggle theme", - }, - -- Allow moving the cursor through wrapped lines with j, k, and -- http://www.reddit.com/r/vim/comments/2k4cbr/problem_with_gj_and_gk/ -- empty mode is same as using :map @@ -61,7 +45,9 @@ M.general = { ["b"] = { " enew ", "new buffer" }, }, - t = { [""] = { termcodes "", "escape terminal mode" } }, + t = { + [""] = { vim.api.nvim_replace_termcodes("", true, true, true), "escape terminal mode" }, + }, v = { [""] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "move up", opts = { expr = true } }, @@ -96,9 +82,6 @@ M.tabufline = { "goto prev buffer", }, - -- pick buffers via numbers - [""] = { " TbufPick ", "Pick buffer" }, - -- close buffer + hide terminal buffer ["x"] = { function() diff --git a/lua/plugins/configs/others.lua b/lua/plugins/configs/others.lua index 0c1fffd..4c06290 100644 --- a/lua/plugins/configs/others.lua +++ b/lua/plugins/configs/others.lua @@ -21,10 +21,7 @@ M.blankline = { } M.luasnip = function() - local options = { - history = true, - updateevents = "TextChanged,TextChangedI", - } + local options = { history = true, updateevents = "TextChanged,TextChangedI" } require("luasnip").config.set_config(options) diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 981c3c6..710d1de 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -99,7 +99,7 @@ local default_plugins = { if vim.v.shell_error == 0 then vim.api.nvim_del_augroup_by_name "GitSignsLazyLoad" vim.schedule(function() - require("lazy").load { plugins = "gitsigns.nvim" } + require("lazy").load { plugins = { "gitsigns.nvim" } } end) end end,