From dab9171e6426b6eb8f0f8bcd0829a0415d260fcb Mon Sep 17 00:00:00 2001 From: siduck Date: Thu, 9 Mar 2023 18:07:58 +0530 Subject: [PATCH] put all core stuff in core.init only --- init.lua | 1 - lua/core/default_config.lua | 2 +- lua/core/init.lua | 76 ++++++++++++++++++++++++++++++++----- lua/core/options.lua | 55 --------------------------- lua/core/utils.lua | 2 +- 5 files changed, 69 insertions(+), 67 deletions(-) delete mode 100644 lua/core/options.lua diff --git a/init.lua b/init.lua index e595772..f58c94e 100644 --- a/init.lua +++ b/init.lua @@ -1,5 +1,4 @@ require "core" -require "core.options" local custom_init_path = vim.api.nvim_get_runtime_file("lua/custom/init.lua", false)[1] diff --git a/lua/core/default_config.lua b/lua/core/default_config.lua index 7f7004f..7f3eaa2 100644 --- a/lua/core/default_config.lua +++ b/lua/core/default_config.lua @@ -78,6 +78,6 @@ M.plugins = "" -- path i.e "custom.plugins" -> custom/plugins.lua only and not c M.lazy_nvim = {} -- config for lazy.nvim startup options -- these are default mappings, check core.mappings for table structure -M.mappings = require "core.mappings" +M.mappings = {} return M diff --git a/lua/core/init.lua b/lua/core/init.lua index e41a4b6..5205155 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -1,14 +1,66 @@ +local opt = vim.opt +local g = vim.g +local config = require("core.utils").load_config() + +-------------------------------------- globals ----------------------------------------- +g.nvchad_theme = config.ui.theme +g.base46_cache = vim.fn.stdpath "cache" .. "/nvchad/base46/" +g.toggle_theme_icon = "  " +g.transparency = config.ui.transparency + +-------------------------------------- options ------------------------------------------ +opt.laststatus = 3 -- global statusline +opt.showmode = false + +opt.clipboard = "unnamedplus" +opt.cursorline = true + +-- 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.env.PATH .. (is_windows and ";" or ":") .. vim.fn.stdpath "data" .. "/mason/bin" -local new_cmd = vim.api.nvim_create_user_command - -new_cmd("NvChadUpdate", function() - require "nvchad.update"() -end, {}) - --- autocmds +-------------------------------------- autocmds ------------------------------------------ local autocmd = vim.api.nvim_create_autocmd -- dont list quickfix buffers @@ -19,13 +71,12 @@ autocmd("FileType", { end, }) -vim.api.nvim_create_autocmd("BufWritePost", { +autocmd("BufWritePost", { pattern = "chadrc.lua", group = vim.api.nvim_create_augroup("ReloadNvChad", {}), callback = function() require("plenary.reload").reload_module "base46" - local config = require("core.utils").load_config() vim.opt.statusline = "%!v:lua.require('nvchad_ui.statusline." .. config.ui.statusline.theme .. "').run()" vim.g.nvchad_theme = config.ui.theme @@ -38,3 +89,10 @@ vim.api.nvim_create_autocmd("BufWritePost", { require("base46").load_all_highlights() end, }) + +-------------------------------------- commands ------------------------------------------ +local new_cmd = vim.api.nvim_create_user_command + +new_cmd("NvChadUpdate", function() + require "nvchad.update"() +end, {}) diff --git a/lua/core/options.lua b/lua/core/options.lua deleted file mode 100644 index ee8671c..0000000 --- a/lua/core/options.lua +++ /dev/null @@ -1,55 +0,0 @@ -local opt = vim.opt -local g = vim.g -local config = require("core.utils").load_config() - -g.nvchad_theme = config.ui.theme -g.base46_cache = vim.fn.stdpath "cache" .. "/nvchad/base46/" -g.toggle_theme_icon = "  " -g.transparency = config.ui.transparency - -opt.laststatus = 3 -- global statusline -opt.showmode = false - -opt.clipboard = "unnamedplus" -opt.cursorline = true - --- 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 diff --git a/lua/core/utils.lua b/lua/core/utils.lua index ea8edd0..e95078c 100644 --- a/lua/core/utils.lua +++ b/lua/core/utils.lua @@ -8,7 +8,7 @@ M.load_config = function() if chadrc_path then local chadrc = dofile(chadrc_path) - config.mappings = M.remove_disabled_keys(chadrc.mappings, config.mappings) + config.mappings = M.remove_disabled_keys(chadrc.mappings, require "core.mappings") config = merge_tb("force", config, chadrc) end