2023-03-09 07:37:58 -05:00
|
|
|
local opt = vim.opt
|
|
|
|
local g = vim.g
|
|
|
|
local config = require("core.utils").load_config()
|
|
|
|
|
|
|
|
-------------------------------------- globals -----------------------------------------
|
|
|
|
g.nvchad_theme = config.ui.theme
|
2023-03-23 06:39:43 -04:00
|
|
|
g.base46_cache = vim.fn.stdpath "data" .. "/nvchad/base46/"
|
2023-03-09 07:37:58 -05:00
|
|
|
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
|
|
|
|
|
2022-07-25 09:49:33 -04:00
|
|
|
-- add binaries installed by mason.nvim to path
|
2022-07-26 03:22:16 -04:00
|
|
|
local is_windows = vim.loop.os_uname().sysname == "Windows_NT"
|
2023-05-16 16:44:15 -04:00
|
|
|
vim.env.PATH = vim.fn.stdpath "data" .. "/mason/bin" .. (is_windows and ";" or ":") .. vim.env.PATH
|
2022-07-25 09:49:33 -04:00
|
|
|
|
2023-03-09 07:37:58 -05:00
|
|
|
-------------------------------------- autocmds ------------------------------------------
|
2022-05-23 03:24:03 -04:00
|
|
|
local autocmd = vim.api.nvim_create_autocmd
|
|
|
|
|
2022-07-08 09:50:57 -04:00
|
|
|
-- dont list quickfix buffers
|
|
|
|
autocmd("FileType", {
|
2022-07-22 12:00:00 -04:00
|
|
|
pattern = "qf",
|
|
|
|
callback = function()
|
|
|
|
vim.opt_local.buflisted = false
|
|
|
|
end,
|
2022-07-08 09:50:57 -04:00
|
|
|
})
|
2023-02-14 00:42:31 -05:00
|
|
|
|
2023-03-14 04:28:12 -04:00
|
|
|
-- reload some chadrc options on-save
|
2023-03-10 01:10:24 -05:00
|
|
|
vim.api.nvim_create_autocmd("BufWritePost", {
|
2023-03-23 19:05:54 -04:00
|
|
|
pattern = vim.tbl_map(
|
|
|
|
vim.fs.normalize,
|
|
|
|
vim.fn.glob(vim.fn.stdpath "config" .. "/lua/custom/**/*.lua", true, true, true)
|
|
|
|
),
|
2023-02-15 07:07:10 -05:00
|
|
|
group = vim.api.nvim_create_augroup("ReloadNvChad", {}),
|
|
|
|
|
2023-03-10 01:10:24 -05:00
|
|
|
callback = function(opts)
|
2023-03-18 01:14:42 -04:00
|
|
|
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("/", ".")
|
2023-03-23 19:05:54 -04:00
|
|
|
|
2023-02-15 07:07:10 -05:00
|
|
|
require("plenary.reload").reload_module "base46"
|
2023-03-17 23:40:36 -04:00
|
|
|
require("plenary.reload").reload_module(module)
|
2023-03-10 01:10:24 -05:00
|
|
|
require("plenary.reload").reload_module "custom.chadrc"
|
2023-02-15 07:07:10 -05:00
|
|
|
|
2023-03-10 01:19:54 -05:00
|
|
|
config = require("core.utils").load_config()
|
|
|
|
|
2023-03-08 08:27:54 -05:00
|
|
|
vim.g.nvchad_theme = config.ui.theme
|
|
|
|
vim.g.transparency = config.ui.transparency
|
2023-02-15 07:07:10 -05:00
|
|
|
|
2023-03-14 04:28:12 -04:00
|
|
|
-- statusline
|
|
|
|
require("plenary.reload").reload_module("nvchad_ui.statusline." .. config.ui.statusline.theme)
|
2023-03-10 01:10:24 -05:00
|
|
|
vim.opt.statusline = "%!v:lua.require('nvchad_ui.statusline." .. config.ui.statusline.theme .. "').run()"
|
2023-02-14 00:42:31 -05:00
|
|
|
|
2023-02-15 07:07:10 -05:00
|
|
|
require("base46").load_all_highlights()
|
2023-03-10 01:10:24 -05:00
|
|
|
-- vim.cmd("redraw!")
|
2023-02-14 00:42:31 -05:00
|
|
|
end,
|
|
|
|
})
|
2023-03-09 07:37:58 -05:00
|
|
|
|
|
|
|
-------------------------------------- commands ------------------------------------------
|
|
|
|
local new_cmd = vim.api.nvim_create_user_command
|
|
|
|
|
|
|
|
new_cmd("NvChadUpdate", function()
|
|
|
|
require "nvchad.update"()
|
|
|
|
end, {})
|