chore: Added vimtex dependency
This commit is contained in:
parent
dada855b98
commit
71e5c5967a
30 changed files with 0 additions and 3050 deletions
|
@ -1,27 +0,0 @@
|
|||
-- Chadrc overrides this file
|
||||
|
||||
local M = {}
|
||||
|
||||
M.options = {
|
||||
nvChad = {
|
||||
update_url = "https://github.com/NvChad/NvChad",
|
||||
update_branch = "main",
|
||||
},
|
||||
}
|
||||
|
||||
M.ui = {
|
||||
-- hl = highlights
|
||||
hl_add = {},
|
||||
hl_override = {},
|
||||
changed_themes = {},
|
||||
theme_toggle = { "onedark", "one_light" },
|
||||
theme = "onedark", -- default theme
|
||||
transparency = false,
|
||||
}
|
||||
|
||||
M.plugins = {}
|
||||
|
||||
-- check core.mappings for table structure
|
||||
M.mappings = require "core.mappings"
|
||||
|
||||
return M
|
|
@ -1,27 +0,0 @@
|
|||
-- 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"
|
||||
|
||||
-- commands
|
||||
vim.cmd "silent! command! NvChadUpdate lua require('nvchad').update_nvchad()"
|
||||
vim.cmd "silent! command! NvChadSnapshotCreate lua require('nvchad').snap_create()"
|
||||
vim.cmd "silent! command! NvChadSnapshotDelete lua require('nvchad').snap_delete()"
|
||||
vim.cmd "silent! command! NvChadSnapshotCheckout lua require('nvchad').snap_checkout()"
|
||||
|
||||
-- autocmds
|
||||
local autocmd = vim.api.nvim_create_autocmd
|
||||
|
||||
-- dont list quickfix buffers
|
||||
autocmd("FileType", {
|
||||
pattern = "qf",
|
||||
callback = function()
|
||||
vim.opt_local.buflisted = false
|
||||
end,
|
||||
})
|
||||
|
||||
-- wrap the PackerSync command to warn people before using it in NvChadSnapshots
|
||||
autocmd("VimEnter", {
|
||||
callback = function()
|
||||
vim.cmd "command! -nargs=* -complete=customlist,v:lua.require'packer'.plugin_complete PackerSync lua require('plugins') require('core.utils').packer_sync(<f-args>)"
|
||||
end,
|
||||
})
|
|
@ -1,79 +0,0 @@
|
|||
local M = {}
|
||||
local autocmd = vim.api.nvim_create_autocmd
|
||||
|
||||
-- require("packer").loader(tb.plugins)
|
||||
-- This must be used for plugins that need to be loaded just after a file
|
||||
-- ex : treesitter, lspconfig etc
|
||||
M.lazy_load = function(tb)
|
||||
autocmd(tb.events, {
|
||||
group = vim.api.nvim_create_augroup(tb.augroup_name, {}),
|
||||
callback = function()
|
||||
if tb.condition() then
|
||||
vim.api.nvim_del_augroup_by_name(tb.augroup_name)
|
||||
|
||||
-- dont defer for treesitter as it will show slow highlighting
|
||||
-- This deferring only happens only when we do "nvim filename"
|
||||
if tb.plugin ~= "nvim-treesitter" then
|
||||
vim.defer_fn(function()
|
||||
require("packer").loader(tb.plugin)
|
||||
if tb.plugin == "nvim-lspconfig" then
|
||||
vim.cmd "silent! do FileType"
|
||||
end
|
||||
end, 0)
|
||||
else
|
||||
require("packer").loader(tb.plugin)
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
-- load certain plugins only when there's a file opened in the buffer
|
||||
-- if "nvim filename" is executed -> load the plugin after nvim gui loads
|
||||
-- This gives an instant preview of nvim with the file opened
|
||||
|
||||
M.on_file_open = function(plugin_name)
|
||||
M.lazy_load {
|
||||
events = { "BufRead", "BufWinEnter", "BufNewFile" },
|
||||
augroup_name = "BeLazyOnFileOpen" .. plugin_name,
|
||||
plugin = plugin_name,
|
||||
condition = function()
|
||||
local file = vim.fn.expand "%"
|
||||
return file ~= "NvimTree_1" and file ~= "[packer]" and file ~= ""
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
M.packer_cmds = {
|
||||
"PackerSnapshot",
|
||||
"PackerSnapshotRollback",
|
||||
"PackerSnapshotDelete",
|
||||
"PackerInstall",
|
||||
"PackerUpdate",
|
||||
"PackerSync",
|
||||
"PackerClean",
|
||||
"PackerCompile",
|
||||
"PackerStatus",
|
||||
"PackerProfile",
|
||||
"PackerLoad",
|
||||
}
|
||||
|
||||
M.treesitter_cmds = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSEnable", "TSDisable", "TSModuleInfo" }
|
||||
M.mason_cmds = { "Mason", "MasonInstall", "MasonInstallAll", "MasonUninstall", "MasonUninstallAll", "MasonLog" }
|
||||
|
||||
M.gitsigns = function()
|
||||
autocmd({ "BufRead" }, {
|
||||
group = vim.api.nvim_create_augroup("GitSignsLazyLoad", { clear = true }),
|
||||
callback = function()
|
||||
vim.fn.system("git rev-parse " .. vim.fn.expand "%:p:h")
|
||||
if vim.v.shell_error == 0 then
|
||||
vim.api.nvim_del_augroup_by_name "GitSignsLazyLoad"
|
||||
vim.schedule(function()
|
||||
require("packer").loader "gitsigns.nvim"
|
||||
end)
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
|
@ -1,473 +0,0 @@
|
|||
-- 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 = {
|
||||
i = {
|
||||
-- go to beginning and end
|
||||
["<C-b>"] = { "<ESC>^i", "beginning of line" },
|
||||
["<C-e>"] = { "<End>", "end of line" },
|
||||
|
||||
-- navigate within insert mode
|
||||
["<C-h>"] = { "<Left>", "move left" },
|
||||
["<C-l>"] = { "<Right>", "move right" },
|
||||
["<C-j>"] = { "<Down>", "move down" },
|
||||
["<C-k>"] = { "<Up>", "move up" },
|
||||
},
|
||||
|
||||
n = {
|
||||
["<ESC>"] = { "<cmd> noh <CR>", "no highlight" },
|
||||
|
||||
-- switch between windows
|
||||
["<C-h>"] = { "<C-w>h", "window left" },
|
||||
["<C-l>"] = { "<C-w>l", "window right" },
|
||||
["<C-j>"] = { "<C-w>j", "window down" },
|
||||
["<C-k>"] = { "<C-w>k", "window up" },
|
||||
|
||||
--compile code
|
||||
["<C-leader>l"] = {"<cmd> :!cabal run <CR>", "Run haskell code"},
|
||||
-- save
|
||||
["<C-s>"] = { "<cmd> w <CR>", "save file" },
|
||||
|
||||
-- Copy all
|
||||
["<C-c>"] = { "<cmd> %y+ <CR>", "copy whole file" },
|
||||
|
||||
-- line numbers
|
||||
["<leader>n"] = { "<cmd> set nu! <CR>", "toggle line number" },
|
||||
["<leader>rn"] = { "<cmd> set rnu! <CR>", "toggle relative number" },
|
||||
|
||||
-- update nvchad
|
||||
["<leader>uu"] = { "<cmd> :NvChadUpdate <CR>", "update nvchad" },
|
||||
|
||||
["<leader>tt"] = {
|
||||
function()
|
||||
require("base46").toggle_theme()
|
||||
end,
|
||||
"toggle theme",
|
||||
},
|
||||
|
||||
-- Allow moving the cursor through wrapped lines with j, k, <Up> and <Down>
|
||||
-- http://www.reddit.com/r/vim/comments/2k4cbr/problem_with_gj_and_gk/
|
||||
-- empty mode is same as using <cmd> :map
|
||||
-- also don't use g[j|k] when in operator pending mode, so it doesn't alter d, y or c behaviour
|
||||
["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', opts = { expr = true } },
|
||||
["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', opts = { expr = true } },
|
||||
["<Up>"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', opts = { expr = true } },
|
||||
["<Down>"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', opts = { expr = true } },
|
||||
|
||||
-- new buffer
|
||||
["<leader>b"] = { "<cmd> enew <CR>", "new buffer" },
|
||||
},
|
||||
|
||||
t = { ["<C-x>"] = { termcodes "<C-\\><C-N>", "escape terminal mode" } },
|
||||
|
||||
v = {
|
||||
["<Up>"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', opts = { expr = true } },
|
||||
["<Down>"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', opts = { expr = true } },
|
||||
},
|
||||
|
||||
x = {
|
||||
["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', opts = { expr = true } },
|
||||
["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', opts = { expr = true } },
|
||||
-- Don't copy the replaced text after pasting in visual mode
|
||||
-- https://vim.fandom.com/wiki/Replace_a_word_with_yanked_text#Alternative_mapping_for_paste
|
||||
["p"] = { 'p:let @+=@0<CR>:let @"=@0<CR>', opts = { silent = true } },
|
||||
},
|
||||
}
|
||||
|
||||
M.tabufline = {
|
||||
plugin = true,
|
||||
|
||||
n = {
|
||||
-- cycle through buffers
|
||||
["<TAB>"] = {
|
||||
function()
|
||||
require("nvchad_ui.tabufline").tabuflineNext()
|
||||
end,
|
||||
"goto next buffer",
|
||||
},
|
||||
|
||||
["<S-Tab>"] = {
|
||||
function()
|
||||
require("nvchad_ui.tabufline").tabuflinePrev()
|
||||
end,
|
||||
"goto prev buffer",
|
||||
},
|
||||
|
||||
-- pick buffers via numbers
|
||||
["<Bslash>"] = { "<cmd> TbufPick <CR>", "Pick buffer" },
|
||||
|
||||
-- close buffer + hide terminal buffer
|
||||
["<leader>x"] = {
|
||||
function()
|
||||
require("nvchad_ui.tabufline").close_buffer()
|
||||
end,
|
||||
"close buffer",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
M.comment = {
|
||||
plugin = true,
|
||||
|
||||
-- toggle comment in both modes
|
||||
n = {
|
||||
["<leader>/"] = {
|
||||
function()
|
||||
require("Comment.api").toggle.linewise.current()
|
||||
end,
|
||||
"toggle comment",
|
||||
},
|
||||
},
|
||||
|
||||
v = {
|
||||
["<leader>/"] = {
|
||||
"<ESC><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<CR>",
|
||||
"toggle comment",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
M.lspconfig = {
|
||||
plugin = true,
|
||||
|
||||
-- See `<cmd> :help vim.lsp.*` for documentation on any of the below functions
|
||||
|
||||
n = {
|
||||
["gD"] = {
|
||||
function()
|
||||
vim.lsp.buf.declaration()
|
||||
end,
|
||||
"lsp declaration",
|
||||
},
|
||||
|
||||
["gd"] = {
|
||||
function()
|
||||
vim.lsp.buf.definition()
|
||||
end,
|
||||
"lsp definition",
|
||||
},
|
||||
|
||||
["K"] = {
|
||||
function()
|
||||
vim.lsp.buf.hover()
|
||||
end,
|
||||
"lsp hover",
|
||||
},
|
||||
|
||||
["gi"] = {
|
||||
function()
|
||||
vim.lsp.buf.implementation()
|
||||
end,
|
||||
"lsp implementation",
|
||||
},
|
||||
|
||||
["<leader>ls"] = {
|
||||
function()
|
||||
vim.lsp.buf.signature_help()
|
||||
end,
|
||||
"lsp signature_help",
|
||||
},
|
||||
|
||||
["<leader>D"] = {
|
||||
function()
|
||||
vim.lsp.buf.type_definition()
|
||||
end,
|
||||
"lsp definition type",
|
||||
},
|
||||
|
||||
["<leader>ra"] = {
|
||||
function()
|
||||
require("nvchad_ui.renamer").open()
|
||||
end,
|
||||
"lsp rename",
|
||||
},
|
||||
|
||||
["<leader>ca"] = {
|
||||
function()
|
||||
vim.lsp.buf.code_action()
|
||||
end,
|
||||
"lsp code_action",
|
||||
},
|
||||
|
||||
["gr"] = {
|
||||
function()
|
||||
vim.lsp.buf.references()
|
||||
end,
|
||||
"lsp references",
|
||||
},
|
||||
|
||||
["<leader>f"] = {
|
||||
function()
|
||||
vim.diagnostic.open_float()
|
||||
end,
|
||||
"floating diagnostic",
|
||||
},
|
||||
|
||||
["[d"] = {
|
||||
function()
|
||||
vim.diagnostic.goto_prev()
|
||||
end,
|
||||
"goto prev",
|
||||
},
|
||||
|
||||
["d]"] = {
|
||||
function()
|
||||
vim.diagnostic.goto_next()
|
||||
end,
|
||||
"goto_next",
|
||||
},
|
||||
|
||||
["<leader>q"] = {
|
||||
function()
|
||||
vim.diagnostic.setloclist()
|
||||
end,
|
||||
"diagnostic setloclist",
|
||||
},
|
||||
|
||||
["<leader>fm"] = {
|
||||
function()
|
||||
vim.lsp.buf.format { async = true }
|
||||
end,
|
||||
"lsp formatting",
|
||||
},
|
||||
|
||||
["<leader>wa"] = {
|
||||
function()
|
||||
vim.lsp.buf.add_workspace_folder()
|
||||
end,
|
||||
"add workspace folder",
|
||||
},
|
||||
|
||||
["<leader>wr"] = {
|
||||
function()
|
||||
vim.lsp.buf.remove_workspace_folder()
|
||||
end,
|
||||
"remove workspace folder",
|
||||
},
|
||||
|
||||
["<leader>wl"] = {
|
||||
function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end,
|
||||
"list workspace folders",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
M.nvimtree = {
|
||||
plugin = true,
|
||||
|
||||
n = {
|
||||
-- toggle
|
||||
["<C-n>"] = { "<cmd> NvimTreeToggle <CR>", "toggle nvimtree" },
|
||||
|
||||
-- focus
|
||||
["<leader>e"] = { "<cmd> NvimTreeFocus <CR>", "focus nvimtree" },
|
||||
},
|
||||
}
|
||||
|
||||
M.telescope = {
|
||||
plugin = true,
|
||||
|
||||
n = {
|
||||
-- find
|
||||
["<leader>ff"] = { "<cmd> Telescope find_files <CR>", "find files" },
|
||||
["<leader>fa"] = { "<cmd> Telescope find_files follow=true no_ignore=true hidden=true <CR>", "find all" },
|
||||
["<leader>fw"] = { "<cmd> Telescope live_grep <CR>", "live grep" },
|
||||
["<leader>fb"] = { "<cmd> Telescope buffers <CR>", "find buffers" },
|
||||
["<leader>fh"] = { "<cmd> Telescope help_tags <CR>", "help page" },
|
||||
["<leader>fo"] = { "<cmd> Telescope oldfiles <CR>", "find oldfiles" },
|
||||
["<leader>tk"] = { "<cmd> Telescope keymaps <CR>", "show keys" },
|
||||
|
||||
-- git
|
||||
["<leader>cm"] = { "<cmd> Telescope git_commits <CR>", "git commits" },
|
||||
["<leader>gt"] = { "<cmd> Telescope git_status <CR>", "git status" },
|
||||
|
||||
-- pick a hidden term
|
||||
["<leader>pt"] = { "<cmd> Telescope terms <CR>", "pick hidden term" },
|
||||
|
||||
-- theme switcher
|
||||
["<leader>th"] = { "<cmd> Telescope themes <CR>", "nvchad themes" },
|
||||
},
|
||||
}
|
||||
|
||||
M.nvterm = {
|
||||
plugin = true,
|
||||
|
||||
t = {
|
||||
-- toggle in terminal mode
|
||||
["<A-i>"] = {
|
||||
function()
|
||||
require("nvterm.terminal").toggle "float"
|
||||
end,
|
||||
"toggle floating term",
|
||||
},
|
||||
|
||||
["<A-h>"] = {
|
||||
function()
|
||||
require("nvterm.terminal").toggle "horizontal"
|
||||
end,
|
||||
"toggle horizontal term",
|
||||
},
|
||||
|
||||
["<A-v>"] = {
|
||||
function()
|
||||
require("nvterm.terminal").toggle "vertical"
|
||||
end,
|
||||
"toggle vertical term",
|
||||
},
|
||||
},
|
||||
|
||||
n = {
|
||||
-- toggle in normal mode
|
||||
["<A-i>"] = {
|
||||
function()
|
||||
require("nvterm.terminal").toggle "float"
|
||||
end,
|
||||
"toggle floating term",
|
||||
},
|
||||
|
||||
["<A-h>"] = {
|
||||
function()
|
||||
require("nvterm.terminal").toggle "horizontal"
|
||||
end,
|
||||
"toggle horizontal term",
|
||||
},
|
||||
|
||||
["<A-v>"] = {
|
||||
function()
|
||||
require("nvterm.terminal").toggle "vertical"
|
||||
end,
|
||||
"toggle vertical term",
|
||||
},
|
||||
|
||||
-- new
|
||||
|
||||
["<leader>h"] = {
|
||||
function()
|
||||
require("nvterm.terminal").new "horizontal"
|
||||
end,
|
||||
"new horizontal term",
|
||||
},
|
||||
|
||||
["<leader>v"] = {
|
||||
function()
|
||||
require("nvterm.terminal").new "vertical"
|
||||
end,
|
||||
"new vertical term",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
M.whichkey = {
|
||||
plugin = true,
|
||||
|
||||
n = {
|
||||
["<leader>wK"] = {
|
||||
function()
|
||||
vim.cmd "WhichKey"
|
||||
end,
|
||||
"which-key all keymaps",
|
||||
},
|
||||
["<leader>wk"] = {
|
||||
function()
|
||||
local input = vim.fn.input "WhichKey: "
|
||||
vim.cmd("WhichKey " .. input)
|
||||
end,
|
||||
"which-key query lookup",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
M.blankline = {
|
||||
plugin = true,
|
||||
|
||||
n = {
|
||||
["<leader>cc"] = {
|
||||
function()
|
||||
local ok, start = require("indent_blankline.utils").get_current_context(
|
||||
vim.g.indent_blankline_context_patterns,
|
||||
vim.g.indent_blankline_use_treesitter_scope
|
||||
)
|
||||
|
||||
if ok then
|
||||
vim.api.nvim_win_set_cursor(vim.api.nvim_get_current_win(), { start, 0 })
|
||||
vim.cmd [[normal! _]]
|
||||
end
|
||||
end,
|
||||
|
||||
"Jump to current_context",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
M.gitsigns = {
|
||||
plugin = true,
|
||||
|
||||
n = {
|
||||
-- Navigation through hunks
|
||||
["]c"] = {
|
||||
function()
|
||||
if vim.wo.diff then
|
||||
return "]c"
|
||||
end
|
||||
vim.schedule(function()
|
||||
require("gitsigns").next_hunk()
|
||||
end)
|
||||
return "<Ignore>"
|
||||
end,
|
||||
"Jump to next hunk",
|
||||
opts = { expr = true },
|
||||
},
|
||||
|
||||
["[c"] = {
|
||||
function()
|
||||
if vim.wo.diff then
|
||||
return "[c"
|
||||
end
|
||||
vim.schedule(function()
|
||||
require("gitsigns").prev_hunk()
|
||||
end)
|
||||
return "<Ignore>"
|
||||
end,
|
||||
"Jump to prev hunk",
|
||||
opts = { expr = true },
|
||||
},
|
||||
|
||||
-- Actions
|
||||
["<leader>rh"] = {
|
||||
function()
|
||||
require("gitsigns").reset_hunk()
|
||||
end,
|
||||
"Reset hunk",
|
||||
},
|
||||
|
||||
["<leader>ph"] = {
|
||||
function()
|
||||
require("gitsigns").preview_hunk()
|
||||
end,
|
||||
"Preview hunk",
|
||||
},
|
||||
|
||||
["<leader>gb"] = {
|
||||
function()
|
||||
package.loaded.gitsigns.blame_line()
|
||||
end,
|
||||
"Blame line",
|
||||
},
|
||||
|
||||
["<leader>td"] = {
|
||||
function()
|
||||
require("gitsigns").toggle_deleted()
|
||||
end,
|
||||
"Toggle deleted",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return M
|
|
@ -1,96 +0,0 @@
|
|||
local opt = vim.opt
|
||||
local g = vim.g
|
||||
local config = require("core.utils").load_config()
|
||||
|
||||
g.nvchad_theme = config.ui.theme
|
||||
g.toggle_theme_icon = " "
|
||||
g.transparency = config.ui.transparency
|
||||
g.theme_switcher_loaded = false
|
||||
|
||||
opt.laststatus = 3 -- global statusline
|
||||
opt.showmode = false
|
||||
|
||||
opt.title = true
|
||||
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 builtin vim plugins
|
||||
local default_plugins = {
|
||||
"2html_plugin",
|
||||
"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",
|
||||
}
|
||||
|
||||
for _, plugin in pairs(default_plugins) do
|
||||
g["loaded_" .. plugin] = 1
|
||||
end
|
||||
|
||||
local default_providers = {
|
||||
"node",
|
||||
"perl",
|
||||
"python3",
|
||||
"ruby",
|
||||
}
|
||||
|
||||
for _, provider in ipairs(default_providers) do
|
||||
vim.g["loaded_" .. provider .. "_provider"] = 0
|
||||
end
|
|
@ -1,192 +0,0 @@
|
|||
local M = {}
|
||||
local merge_tb = vim.tbl_deep_extend
|
||||
|
||||
M.load_config = function()
|
||||
local config = require "core.default_config"
|
||||
local chadrc_exists, chadrc = pcall(require, "custom.chadrc")
|
||||
|
||||
if chadrc_exists then
|
||||
-- merge user config if it exists and is a table; otherwise display an error
|
||||
if type(chadrc) == "table" then
|
||||
config.mappings = M.remove_disabled_keys(chadrc.mappings, config.mappings)
|
||||
config = merge_tb("force", config, chadrc) or {}
|
||||
else
|
||||
error "chadrc must return a table!"
|
||||
end
|
||||
end
|
||||
|
||||
config.mappings.disabled = nil
|
||||
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)
|
||||
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
|
||||
|
||||
-- merge default/user plugin tables
|
||||
M.merge_plugins = function(plugins)
|
||||
local plugin_configs = M.load_config().plugins
|
||||
local user_plugins = plugin_configs
|
||||
|
||||
-- old plugin syntax for adding plugins
|
||||
if plugin_configs.user and type(plugin_configs.user) == "table" then
|
||||
user_plugins = plugin_configs.user
|
||||
end
|
||||
|
||||
-- support old plugin removal syntax
|
||||
local remove_plugins = plugin_configs.remove
|
||||
if type(remove_plugins) == "table" then
|
||||
for _, v in ipairs(remove_plugins) do
|
||||
plugins[v] = nil
|
||||
end
|
||||
end
|
||||
|
||||
plugins = merge_tb("force", plugins, user_plugins)
|
||||
|
||||
local final_table = {}
|
||||
|
||||
for key, val in pairs(plugins) do
|
||||
if val and type(val) == "table" then
|
||||
plugins[key] = val.rm_default_opts and user_plugins[key] or plugins[key]
|
||||
plugins[key][1] = key
|
||||
final_table[#final_table + 1] = plugins[key]
|
||||
end
|
||||
end
|
||||
|
||||
return final_table
|
||||
end
|
||||
|
||||
-- override plugin options table with custom ones
|
||||
M.load_override = function(options_table, name)
|
||||
local plugin_configs, plugin_options = M.load_config().plugins, nil
|
||||
|
||||
-- support old plugin syntax for override
|
||||
local user_override = plugin_configs.override and plugin_configs.override[name]
|
||||
if user_override and type(user_override) == "table" then
|
||||
plugin_options = user_override
|
||||
end
|
||||
|
||||
-- if no old style plugin override is found, then use the new syntax
|
||||
if not plugin_options and plugin_configs[name] then
|
||||
local override_options = plugin_configs[name].override_options or {}
|
||||
if type(override_options) == "table" then
|
||||
plugin_options = override_options
|
||||
elseif type(override_options) == "function" then
|
||||
plugin_options = override_options()
|
||||
end
|
||||
end
|
||||
|
||||
-- make sure the plugin options are a table
|
||||
plugin_options = type(plugin_options) == "table" and plugin_options or {}
|
||||
|
||||
return merge_tb("force", options_table, plugin_options)
|
||||
end
|
||||
|
||||
M.packer_sync = function(...)
|
||||
local git_exists, git = pcall(require, "nvchad.utils.git")
|
||||
local defaults_exists, defaults = pcall(require, "nvchad.utils.config")
|
||||
local packer_exists, packer = pcall(require, "packer")
|
||||
|
||||
if git_exists and defaults_exists then
|
||||
local current_branch_name = git.get_current_branch_name()
|
||||
|
||||
-- warn the user if we are on a snapshot branch
|
||||
if current_branch_name:match(defaults.snaps.base_snap_branch_name .. "(.+)" .. "$") then
|
||||
vim.api.nvim_echo({
|
||||
{ "WARNING: You are trying to use ", "WarningMsg" },
|
||||
{ "PackerSync" },
|
||||
{
|
||||
" on a NvChadSnapshot. This will cause issues if NvChad dependencies contain "
|
||||
.. "any breaking changes! Plugin updates will not be included in this "
|
||||
.. "snapshot, so they will be lost after switching between snapshots! Would "
|
||||
.. "you still like to continue? [y/N]\n",
|
||||
"WarningMsg",
|
||||
},
|
||||
}, false, {})
|
||||
|
||||
local ans = vim.trim(string.lower(vim.fn.input "-> "))
|
||||
|
||||
if ans ~= "y" then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if packer_exists then
|
||||
packer.sync(...)
|
||||
|
||||
local plugins = M.load_config().plugins
|
||||
local old_style_options = plugins.user or plugins.override or plugins.remove
|
||||
if old_style_options then
|
||||
vim.notify_once("NvChad: This plugin syntax is deprecated, use new style config.", "Error")
|
||||
end
|
||||
else
|
||||
error "Packer could not be loaded!"
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
Loading…
Add table
Add a link
Reference in a new issue