add core back
This commit is contained in:
parent
16b3eeb1fa
commit
4aca543656
|
@ -0,0 +1,92 @@
|
|||
local M = {}
|
||||
|
||||
M.options = {
|
||||
nvchad_branch = "v2.0",
|
||||
}
|
||||
|
||||
M.ui = {
|
||||
------------------------------- base46 -------------------------------------
|
||||
-- hl = highlights
|
||||
hl_add = {},
|
||||
hl_override = {},
|
||||
changed_themes = {},
|
||||
theme_toggle = { "onedark", "one_light" },
|
||||
theme = "onedark", -- default theme
|
||||
transparency = false,
|
||||
lsp_semantic_tokens = false, -- needs nvim v0.9, just adds highlight groups for lsp semantic tokens
|
||||
|
||||
-- https://github.com/NvChad/base46/tree/v2.0/lua/base46/extended_integrations
|
||||
extended_integrations = {}, -- these aren't compiled by default, ex: "alpha", "notify"
|
||||
|
||||
-- cmp themeing
|
||||
cmp = {
|
||||
icons = true,
|
||||
lspkind_text = true,
|
||||
style = "default", -- default/flat_light/flat_dark/atom/atom_colored
|
||||
border_color = "grey_fg", -- only applicable for "default" style, use color names from base30 variables
|
||||
selected_item_bg = "colored", -- colored / simple
|
||||
},
|
||||
|
||||
telescope = { style = "borderless" }, -- borderless / bordered
|
||||
|
||||
------------------------------- nvchad_ui modules -----------------------------
|
||||
statusline = {
|
||||
theme = "default", -- default/vscode/vscode_colored/minimal
|
||||
-- default/round/block/arrow separators work only for default statusline theme
|
||||
-- round and block will work for minimal theme only
|
||||
separator_style = "default",
|
||||
overriden_modules = nil,
|
||||
},
|
||||
|
||||
-- lazyload it when there are 1+ buffers
|
||||
tabufline = {
|
||||
show_numbers = false,
|
||||
enabled = true,
|
||||
lazyload = true,
|
||||
overriden_modules = nil,
|
||||
},
|
||||
|
||||
-- nvdash (dashboard)
|
||||
nvdash = {
|
||||
load_on_startup = false,
|
||||
|
||||
header = {
|
||||
" ▄ ▄ ",
|
||||
" ▄ ▄▄▄ ▄ ▄▄▄ ▄ ▄ ",
|
||||
" █ ▄ █▄█ ▄▄▄ █ █▄█ █ █ ",
|
||||
" ▄▄ █▄█▄▄▄█ █▄█▄█▄▄█▄▄█ █ ",
|
||||
" ▄ █▄▄█ ▄ ▄▄ ▄█ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ",
|
||||
" █▄▄▄▄ ▄▄▄ █ ▄ ▄▄▄ ▄ ▄▄▄ ▄ ▄ █ ▄",
|
||||
"▄ █ █▄█ █▄█ █ █ █▄█ █ █▄█ ▄▄▄ █ █",
|
||||
"█▄█ ▄ █▄▄█▄▄█ █ ▄▄█ █ ▄ █ █▄█▄█ █",
|
||||
" █▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█ █▄█▄▄▄█ ",
|
||||
},
|
||||
|
||||
buttons = {
|
||||
{ " Find File", "Spc f f", "Telescope find_files" },
|
||||
{ " Recent Files", "Spc f o", "Telescope oldfiles" },
|
||||
{ " Find Word", "Spc f w", "Telescope live_grep" },
|
||||
{ " Bookmarks", "Spc m a", "Telescope marks" },
|
||||
{ " Themes", "Spc t h", "Telescope themes" },
|
||||
{ " Mappings", "Spc c h", "NvCheatsheet" },
|
||||
},
|
||||
},
|
||||
|
||||
cheatsheet = { theme = "grid" }, -- simple/grid
|
||||
|
||||
lsp = {
|
||||
-- show function signatures i.e args as you type
|
||||
signature = {
|
||||
disabled = false,
|
||||
silent = true, -- silences 'no signature help available' message from appearing
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
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.mappings = require "core.mappings"
|
||||
|
||||
return M
|
|
@ -0,0 +1,115 @@
|
|||
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 "data" .. "/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.fn.stdpath "data" .. "/mason/bin" .. (is_windows and ";" or ":") .. vim.env.PATH
|
||||
|
||||
-------------------------------------- autocmds ------------------------------------------
|
||||
local autocmd = vim.api.nvim_create_autocmd
|
||||
|
||||
-- dont list quickfix buffers
|
||||
autocmd("FileType", {
|
||||
pattern = "qf",
|
||||
callback = function()
|
||||
vim.opt_local.buflisted = false
|
||||
end,
|
||||
})
|
||||
|
||||
-- reload some chadrc options on-save
|
||||
autocmd("BufWritePost", {
|
||||
pattern = vim.tbl_map(function(path)
|
||||
return vim.fs.normalize(vim.loop.fs_realpath(path))
|
||||
end, vim.fn.glob(vim.fn.stdpath "config" .. "/lua/custom/**/*.lua", true, true, true)),
|
||||
group = vim.api.nvim_create_augroup("ReloadNvChad", {}),
|
||||
|
||||
callback = function(opts)
|
||||
local fp = vim.fn.fnamemodify(vim.fs.normalize(vim.api.nvim_buf_get_name(opts.buf)), ":r") --[[@as string]]
|
||||
local app_name = vim.env.NVIM_APPNAME and vim.env.NVIM_APPNAME or "nvim"
|
||||
local module = string.gsub(fp, "^.*/" .. app_name .. "/lua/", ""):gsub("/", ".")
|
||||
|
||||
require("plenary.reload").reload_module "base46"
|
||||
require("plenary.reload").reload_module(module)
|
||||
require("plenary.reload").reload_module "custom.chadrc"
|
||||
|
||||
config = require("core.utils").load_config()
|
||||
|
||||
vim.g.nvchad_theme = config.ui.theme
|
||||
vim.g.transparency = config.ui.transparency
|
||||
|
||||
-- statusline
|
||||
require("plenary.reload").reload_module("nvchad.statusline." .. config.ui.statusline.theme)
|
||||
vim.opt.statusline = "%!v:lua.require('nvchad.statusline." .. config.ui.statusline.theme .. "').run()"
|
||||
|
||||
-- tabufline
|
||||
if config.ui.tabufline.enabled then
|
||||
require("plenary.reload").reload_module "nvchad.tabufline.modules"
|
||||
vim.opt.tabline = "%!v:lua.require('nvchad.tabufline.modules').run()"
|
||||
end
|
||||
|
||||
require("base46").load_all_highlights()
|
||||
-- vim.cmd("redraw!")
|
||||
end,
|
||||
})
|
||||
|
||||
-------------------------------------- commands ------------------------------------------
|
||||
local new_cmd = vim.api.nvim_create_user_command
|
||||
|
||||
new_cmd("NvChadUpdate", function()
|
||||
require "nvchad.updater"()
|
||||
end, {})
|
|
@ -0,0 +1,118 @@
|
|||
local M = {}
|
||||
local merge_tb = vim.tbl_deep_extend
|
||||
|
||||
M.load_config = function()
|
||||
local config = require "core.default_config"
|
||||
local chadrc_path = vim.api.nvim_get_runtime_file("lua/custom/chadrc.lua", false)[1]
|
||||
|
||||
if chadrc_path then
|
||||
local chadrc = dofile(chadrc_path)
|
||||
|
||||
config.mappings = M.remove_disabled_keys(chadrc.mappings, config.mappings)
|
||||
config = merge_tb("force", config, chadrc)
|
||||
config.mappings.disabled = nil
|
||||
end
|
||||
|
||||
return config
|
||||
end
|
||||
|
||||
M.remove_disabled_keys = function(chadrc_mappings, default_mappings)
|
||||
if not chadrc_mappings then
|
||||
return default_mappings
|
||||
end
|
||||
|
||||
-- store keys in a array with true value to compare
|
||||
local keys_to_disable = {}
|
||||
for _, mappings in pairs(chadrc_mappings) do
|
||||
for mode, section_keys in pairs(mappings) do
|
||||
if not keys_to_disable[mode] then
|
||||
keys_to_disable[mode] = {}
|
||||
end
|
||||
section_keys = (type(section_keys) == "table" and section_keys) or {}
|
||||
for k, _ in pairs(section_keys) do
|
||||
keys_to_disable[mode][k] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- make a copy as we need to modify default_mappings
|
||||
for section_name, section_mappings in pairs(default_mappings) do
|
||||
for mode, mode_mappings in pairs(section_mappings) do
|
||||
mode_mappings = (type(mode_mappings) == "table" and mode_mappings) or {}
|
||||
for k, _ in pairs(mode_mappings) do
|
||||
-- if key if found then remove from default_mappings
|
||||
if keys_to_disable[mode] and keys_to_disable[mode][k] then
|
||||
default_mappings[section_name][mode][k] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return default_mappings
|
||||
end
|
||||
|
||||
M.load_mappings = function(section, mapping_opt)
|
||||
vim.schedule(function()
|
||||
local function set_section_map(section_values)
|
||||
if section_values.plugin then
|
||||
return
|
||||
end
|
||||
|
||||
section_values.plugin = nil
|
||||
|
||||
for mode, mode_values in pairs(section_values) do
|
||||
local default_opts = merge_tb("force", { mode = mode }, mapping_opt or {})
|
||||
for keybind, mapping_info in pairs(mode_values) do
|
||||
-- merge default + user opts
|
||||
local opts = merge_tb("force", default_opts, mapping_info.opts or {})
|
||||
|
||||
mapping_info.opts, opts.mode = nil, nil
|
||||
opts.desc = mapping_info[2]
|
||||
|
||||
vim.keymap.set(mode, keybind, mapping_info[1], opts)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local mappings = require("core.utils").load_config().mappings
|
||||
|
||||
if type(section) == "string" then
|
||||
mappings[section]["plugin"] = nil
|
||||
mappings = { mappings[section] }
|
||||
end
|
||||
|
||||
for _, sect in pairs(mappings) do
|
||||
set_section_map(sect)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
M.lazy_load = function(plugin)
|
||||
vim.api.nvim_create_autocmd({ "BufRead", "BufWinEnter", "BufNewFile" }, {
|
||||
group = vim.api.nvim_create_augroup("BeLazyOnFileOpen" .. plugin, {}),
|
||||
callback = function()
|
||||
local file = vim.fn.expand "%"
|
||||
local condition = file ~= "NvimTree_1" and file ~= "[lazy]" and file ~= ""
|
||||
|
||||
if condition then
|
||||
vim.api.nvim_del_augroup_by_name("BeLazyOnFileOpen" .. plugin)
|
||||
|
||||
-- dont defer for treesitter as it will show slow highlighting
|
||||
-- This deferring only happens only when we do "nvim filename"
|
||||
if plugin ~= "nvim-treesitter" then
|
||||
vim.schedule(function()
|
||||
require("lazy").load { plugins = plugin }
|
||||
|
||||
if plugin == "nvim-lspconfig" then
|
||||
vim.cmd "silent! do FileType"
|
||||
end
|
||||
end, 0)
|
||||
else
|
||||
require("lazy").load { plugins = plugin }
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
Loading…
Reference in New Issue