BREAKING CHANGE | re-implementation of custom config

This commit is contained in:
siduck 2022-04-27 21:12:28 +05:30
parent d906bb0d9c
commit adecbe719f
20 changed files with 835 additions and 1309 deletions

View File

@ -1,6 +1,4 @@
-- Please check NvChad docs if you're totally new to nvchad + dont know lua!! -- example file i.e lua/custom/init.lua
-- This is an example init file in /lua/custom/
-- this init.lua can load stuffs etc too so treat it like your ~/.config/nvim/
-- MAPPINGS -- MAPPINGS
local map = require("core.utils").map local map = require("core.utils").map
@ -8,4 +6,4 @@ local map = require("core.utils").map
map("n", "<leader>cc", ":Telescope <CR>") map("n", "<leader>cc", ":Telescope <CR>")
map("n", "<leader>q", ":q <CR>") map("n", "<leader>q", ":q <CR>")
-- NOTE: the 4th argument in the map function is be a table i.e options but its most likely un-needed so dont worry about it -- require("my autocmds file") or just declare them here

View File

@ -1,6 +1,3 @@
-- REMOVE THIS LATER
print("EMERGENCY: GUYS CHECK THE PINNED ISSUE ASAP!")
local present, impatient = pcall(require, "impatient") local present, impatient = pcall(require, "impatient")
if present then if present then
@ -20,15 +17,14 @@ for _, module in ipairs(core_modules) do
end end
end end
-- non plugin mappings
require("core.mappings").misc()
-- check if custom init.lua file exists -- check if custom init.lua file exists
if vim.fn.filereadable(vim.fn.stdpath "config" .. "/lua/custom/init.lua") == 1 then if vim.fn.filereadable(vim.fn.stdpath "config" .. "/lua/custom/init.lua") == 1 then
-- try to call custom init, if not successful, show error -- try to call custom init, if not successful, show error
local ok, err = pcall(require, "custom") local ok, err = pcall(require, "custom")
if not ok then if not ok then
vim.notify("Error loading custom/init.lua\n\n" .. err) vim.notify("Error loading custom/init.lua\n\n" .. err)
end end
return return
end end

View File

@ -30,11 +30,7 @@ local fg_bg = require("core.utils").fg_bg
local bg = require("core.utils").bg local bg = require("core.utils").bg
-- Comments -- Comments
if ui.italic_comments then fg("Comment", grey_fg)
fg("Comment", grey_fg .. " gui=italic")
else
fg("Comment", grey_fg)
end
-- Disable cursor line -- Disable cursor line
cmd "hi clear CursorLine" cmd "hi clear CursorLine"
@ -128,25 +124,6 @@ fg_bg("TelescopeResultsTitle", darker_black, darker_black)
bg("TelescopeSelection", black2) bg("TelescopeSelection", black2)
-- keybinds cheatsheet
fg_bg("CheatsheetBorder", black, black)
bg("CheatsheetSectionContent", black)
fg("CheatsheetHeading", white)
local section_title_colors = {
white,
blue,
red,
green,
yellow,
purple,
orange,
}
for i, color in ipairs(section_title_colors) do
vim.cmd("highlight CheatsheetTitle" .. i .. " guibg = " .. color .. " guifg=" .. black)
end
-- Disable some highlight in nvim tree if transparency enabled -- Disable some highlight in nvim tree if transparency enabled
if ui.transparency then if ui.transparency then
bg("NormalFloat", "NONE") bg("NormalFloat", "NONE")

View File

@ -1,4 +1,3 @@
local settings=require("core.utils").load_config().options.nvChad
-- uncomment this if you want to open nvim with a dir -- uncomment this if you want to open nvim with a dir
-- vim.cmd [[ autocmd BufEnter * if &buftype != "terminal" | lcd %:p:h | endif ]] -- vim.cmd [[ autocmd BufEnter * if &buftype != "terminal" | lcd %:p:h | endif ]]
@ -6,16 +5,6 @@ local settings=require("core.utils").load_config().options.nvChad
-- vim.cmd[[ au InsertEnter * set norelativenumber ]] -- vim.cmd[[ au InsertEnter * set norelativenumber ]]
-- vim.cmd[[ au InsertLeave * set relativenumber ]] -- vim.cmd[[ au InsertLeave * set relativenumber ]]
-- Don't show any numbers inside terminals
if not settings.terminal_numbers then
vim.cmd [[ au TermOpen term://* setlocal nonumber norelativenumber | setfiletype terminal ]]
end
-- Don't show status line on certain windows
if not require("core.utils").load_config().plugins.options.statusline.hide_disable then
vim.cmd [[ autocmd BufEnter,BufRead,BufWinEnter,FileType,WinEnter * lua require("core.utils").hide_statusline() ]]
end
-- Open a file from its last left off position -- Open a file from its last left off position
-- vim.cmd [[ au BufReadPost * if expand('%:p') !~# '\m/\.git/' && line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif ]] -- vim.cmd [[ au BufReadPost * if expand('%:p') !~# '\m/\.git/' && line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif ]]
-- File extension specific tabbing -- File extension specific tabbing

View File

@ -1,279 +1,51 @@
-- IMPORTANT NOTE : This is default config, so dont change anything here. -- IMPORTANT NOTE : This is default config, so dont change anything here.
-- use custom/chadrc.lua instead -- chadrc overrides this file
local M = {} local M = {}
M.options = { M.options = {
-- custom = {}
-- general nvim/vim options , check :h optionname to know more about an option
clipboard = "unnamedplus", path = "", -- path to file that overrides core.options
cmdheight = 1,
ruler = false,
hidden = true,
ignorecase = true,
smartcase = true,
mapleader = " ",
mouse = "a",
number = true,
numberwidth = 2,
relativenumber = false,
expandtab = true,
shiftwidth = 2,
smartindent = true,
tabstop = 8,
timeoutlen = 400,
updatetime = 250,
undofile = true,
fillchars = { eob = " " },
shadafile = vim.opt.shadafile,
-- NvChad options -- NvChad options
nvChad = { nvChad = {
copy_cut = true, -- copy cut text ( x key ), visual and normal mode
copy_del = true, -- copy deleted text ( dd key ), visual and normal mode
insert_nav = true, -- navigation in insertmode
window_nav = true,
terminal_numbers = false,
-- updater -- updater
update_url = "https://github.com/NvChad/NvChad", update_url = "https://github.com/NvChad/NvChad",
update_branch = "main", update_branch = "main",
}, },
terminal = {
behavior = {
close_on_exit = true,
},
window = {
vsplit_ratio = 0.5,
split_ratio = 0.4,
},
location = {
horizontal = "rightbelow",
vertical = "rightbelow",
float = {
relative = 'editor',
row = 0.3,
col = 0.25,
width = 0.5,
height = 0.4,
border = "single",
}
},
},
} }
---- UI ----- ---- UI -----
M.ui = { M.ui = {
hl_override = "", -- path of your file that contains highlights hl_override = "",
colors = "", -- path of your file that contains colors colors = "", -- path of your file that contains colors
italic_comments = false,
theme = "onedark", -- default theme theme = "onedark", -- default theme
-- Change terminal bg to nvim theme's bg color so it'll match well
-- For Ex : if you have onedark set in nvchad, set onedark's bg color on your terminal
transparency = false, transparency = false,
} }
---- PLUGIN OPTIONS ----
M.plugins = { M.plugins = {
override = {},
-- builtin nvim plugins are disabled
builtins = {
"2html_plugin",
"getscript",
"getscriptPlugin",
"gzip",
"logipat",
"netrw",
"netrwPlugin",
"netrwSettings",
"netrwFileHandlers",
"matchit",
"tar",
"tarPlugin",
"rrhelper",
"spellfile_plugin",
"vimball",
"vimballPlugin",
"zip",
"zipPlugin",
},
-- enable/disable plugins (false for disable)
status = {
blankline = true, -- indentline stuff
bufferline = true, -- manage and preview opened buffers
colorizer = false, -- color RGB, HEX, CSS, NAME color codes
comment = true, -- easily (un)comment code, language aware
alpha = false, -- dashboard
better_escape = true, -- map to <ESC> with no lag
feline = true, -- statusline
gitsigns = true,
lspsignature = true, -- lsp enhancements
vim_matchup = true, -- improved matchit
cmp = true,
nvimtree = true,
autopairs = true,
},
options = { options = {
packer = { packer = {
init_file = "plugins.packerInit", init_file = "plugins.packerInit",
}, },
autopairs = { loadAfter = "nvim-cmp" },
cmp = {
lazy_load = true,
},
lspconfig = { lspconfig = {
setup_lspconf = "", -- path of file containing setups of different lsps setup_lspconf = "", -- path of lspconfig file
},
nvimtree = {
-- packerCompile required after changing lazy_load
lazy_load = true,
},
luasnip = {
snippet_path = {},
}, },
statusline = { statusline = {
hide_disable = false, style = "default", -- default/round/slant/block/arrow
-- hide, show on specific filetypes },
hidden = {
"help",
"NvimTree",
"terminal",
"alpha",
}, },
shown = {},
-- truncate statusline on small screens -- add, modify, remove plugins
shortline = true, user = {},
style = "default", -- default, round , slant , block , arrow
},
esc_insertmode_timeout = 300,
},
default_plugin_config_replace = {},
default_plugin_remove = {},
install = nil,
} }
-- Don't use a single keymap twice -- non plugin only
--- MAPPINGS ----
-- non plugin
M.mappings = { M.mappings = {
-- custom = {}, -- custom user mappings misc = nil,
misc = {
cheatsheet = "<leader>ch",
close_buffer = "<leader>x",
cp_whole_file = "<C-c>", -- copy all contents of current buffer
lineNR_toggle = "<leader>n", -- toggle line number
lineNR_rel_toggle = "<leader>rn",
update_nvchad = "<leader>uu",
new_buffer = "<S-t>",
new_tab = "<C-t>b",
save_file = "<C-s>", -- save file using :w
},
-- navigation in insert mode, only if enabled in options
insert_nav = {
backward = "<C-h>",
end_of_line = "<C-e>",
forward = "<C-l>",
next_line = "<C-j>",
prev_line = "<C-k>",
beginning_of_line = "<C-a>",
},
-- better window movement
window_nav = {
moveLeft = "<C-h>",
moveRight = "<C-l>",
moveUp = "<C-k>",
moveDown = "<C-j>",
},
-- terminal related mappings
terminal = {
-- multiple mappings can be given for esc_termmode, esc_hide_termmode
-- get out of terminal mode
esc_termmode = { "jk" },
-- get out of terminal mode and hide it
esc_hide_termmode = { "JK" },
-- show & recover hidden terminal buffers in a telescope picker
pick_term = "<leader>W",
-- spawn a single terminal and toggle it
-- this just works like toggleterm kinda
new_horizontal = "<leader>h",
new_vertical = "<leader>v",
new_float = "<A-i>",
-- spawn new terminals
spawn_horizontal = "<A-h>",
spawn_vertical = "<A-v>",
spawn_window = "<leader>w",
},
}
-- plugins related mappings
-- To disable a mapping, equate the variable to "" or false or nil in chadrc
M.mappings.plugins = {
bufferline = {
next_buffer = "<TAB>",
prev_buffer = "<S-Tab>",
},
comment = {
toggle = "<leader>/",
},
-- map to <ESC> with no lag
better_escape = { -- <ESC> will still work
esc_insertmode = { "jk" }, -- multiple mappings allowed
},
lspconfig = {
declaration = "gD",
definition = "gd",
hover = "K",
implementation = "gi",
signature_help = "gk",
add_workspace_folder = "<leader>wa",
remove_workspace_folder = "<leader>wr",
list_workspace_folders = "<leader>wl",
type_definition = "<leader>D",
rename = "<leader>ra",
code_action = "<leader>ca",
references = "gr",
float_diagnostics = "ge",
goto_prev = "[d",
goto_next = "]d",
set_loclist = "<leader>q",
formatting = "<leader>fm",
},
nvimtree = {
toggle = "<C-n>",
focus = "<leader>e",
},
telescope = {
buffers = "<leader>fb",
find_files = "<leader>ff",
find_hiddenfiles = "<leader>fa",
git_commits = "<leader>cm",
git_status = "<leader>gt",
help_tags = "<leader>fh",
live_grep = "<leader>fw",
oldfiles = "<leader>fo",
themes = "<leader>th", -- NvChad theme picker
},
} }
return M return M

View File

@ -1,207 +1,200 @@
local utils = require "core.utils" local utils = require "core.utils"
local config = utils.load_config() local config = utils.load_config()
local map_wrapper = utils.map local map = utils.map
local user_cmd = vim.api.nvim_create_user_command
local maps = config.mappings
local plugin_maps = maps.plugins
local nvChad_options = config.options.nvChad local nvChad_options = config.options.nvChad
local terminal_options = config.options.terminal
local mappings = config.mappings
local cmd = vim.cmd local cmd = vim.cmd
-- This is a wrapper function made to disable a plugin mapping from chadrc -- This is a wrapper function made to disable a plugin mapping from chadrc
-- If keys are nil, false or empty string, then the mapping will be not applied -- If keys are nil, false or empty string, then the mapping will be not applied
-- Useful when one wants to use that keymap for any other purpose -- Useful when one wants to use that keymap for any other purpose
local map = function(...)
local keys = select(2, ...) -- Don't copy the replaced text after pasting in visual mode
if not keys or keys == "" then map("v", "p", "p:let @+=@0<CR>")
return
-- Allow moving the cursor through wrapped lines with j, k, <Up> and <Down>
-- http<cmd> ://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
map({ "n", "x", "o" }, "j", 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', { expr = true })
map({ "n", "x", "o" }, "k", 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', { expr = true })
map("", "<Down>", 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', { expr = true })
map("", "<Up>", 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', { expr = true })
-- use ESC to turn off search highlighting
map("n", "<Esc>", "<cmd> :noh <CR>")
-- move cursor within insert mode
map("i", "<C-h>", "<Left>")
map("i", "<C-e>", "<End>")
map("i", "<C-l>", "<Right>")
map("i", "<C-j>", "<Down>")
map("i", "<C-k>", "<Up>")
map("i", "<C-a>", "<ESC>^i")
-- navigation between windows
map("n", "<C-h>", "<C-w>h")
map("n", "<C-l>", "<C-w>l")
map("n", "<C-k>", "<C-w>k")
map("n", "<C-j>", "<C-w>j")
map("n", "<leader>x", function()
require("core.utils").close_buffer()
end)
map("n", "<C-c>", "<cmd> :%y+ <CR>") -- copy whole file content
map("n", "<S-t>", "<cmd> :enew <CR>") -- new buffer
map("n", "<C-t>b", "<cmd> :tabnew <CR>") -- new tabs
map("n", "<leader>n", "<cmd> :set nu! <CR>")
map("n", "<leader>rn", "<cmd> :set rnu! <CR>") -- relative line numbers
map("n", "<C-s>", "<cmd> :w <CR>") -- ctrl + s to save file
-- terminal mappings
-- get out of terminal mode
map("t", { "jk" }, "<C-\\><C-n>")
-- hide a term from within terminal mode
map("t", { "JK" }, function()
require("nvchad.terminal").hide()
end)
-- Add Packer commands because we are not loading it at startup
local packer_cmd = function(callback)
return function()
require "plugins"
require("packer")[callback]()
end end
map_wrapper(...) end
user_cmd("PackerClean", packer_cmd "clean", {})
user_cmd("PackerCompile", packer_cmd "compile", {})
user_cmd("PackerInstall", packer_cmd "install", {})
user_cmd("PackerStatus", packer_cmd "status", {})
user_cmd("PackerSync", packer_cmd "sync", {})
user_cmd("PackerUpdate", packer_cmd "update", {})
-- add NvChadUpdate command and mapping
cmd "silent! command! NvChadUpdate lua require('nvchad').update_nvchad()"
map("n", "<leader>uu", "<cmd> :NvChadUpdate <CR>")
-- load overriden misc mappings
if mappings.misc ~= nil and type(mappings.misc) == "function" then
mappings.misc()
end end
local M = {} local M = {}
-- these mappings will only be called during initialization
M.misc = function()
local function non_config_mappings()
-- Don't copy the replaced text after pasting in visual mode
map_wrapper("v", "p", "p:let @+=@0<CR>")
-- 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 :map
-- also don't use g[j|k] when in operator pending mode, so it doesn't alter d, y or c behaviour
map_wrapper({ "n", "x", "o" }, "j", 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', { expr = true })
map_wrapper({ "n", "x", "o" }, "k", 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', { expr = true })
map_wrapper("", "<Down>", 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', { expr = true })
map_wrapper("", "<Up>", 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', { expr = true })
-- use ESC to turn off search highlighting
map_wrapper("n", "<Esc>", ":noh <CR>")
-- center cursor when moving (goto_definition)
end
local function optional_mappings()
-- don't yank text on cut ( x )
if not nvChad_options.copy_cut then
map_wrapper({ "n", "v" }, "x", '"_x')
end
-- don't yank text on delete ( dd )
if not nvChad_options.copy_del then
map_wrapper({ "n", "v" }, "d", '"_d')
end
-- navigation within insert mode
if nvChad_options.insert_nav then
local inav = maps.insert_nav
map("i", inav.backward, "<Left>")
map("i", inav.end_of_line, "<End>")
map("i", inav.forward, "<Right>")
map("i", inav.next_line, "<Down>")
map("i", inav.prev_line, "<Up>")
map("i", inav.beginning_of_line, "<ESC>^i")
end
-- easier navigation between windows
if nvChad_options.window_nav then
local wnav = maps.window_nav
map("n", wnav.moveLeft, "<C-w>h")
map("n", wnav.moveRight, "<C-w>l")
map("n", wnav.moveUp, "<C-w>k")
map("n", wnav.moveDown, "<C-w>j")
end
end
local function required_mappings()
map("n", maps.misc.cheatsheet, ":lua require('nvchad.cheatsheet').show() <CR>") -- show keybinds
map("n", maps.misc.close_buffer, ":lua require('core.utils').close_buffer() <CR>") -- close buffer
map("n", maps.misc.cp_whole_file, ":%y+ <CR>") -- copy whole file content
map("n", maps.misc.new_buffer, ":enew <CR>") -- new buffer
map("n", maps.misc.new_tab, ":tabnew <CR>") -- new tabs
map("n", maps.misc.lineNR_toggle, ":set nu! <CR>")
map("n", maps.misc.lineNR_rel_toggle, ":set rnu! <CR>") -- relative line numbers
map("n", maps.misc.save_file, ":w <CR>") -- ctrl + s to save file
-- terminal mappings --
local term_maps = maps.terminal
-- get out of terminal mode
map("t", term_maps.esc_termmode, "<C-\\><C-n>")
-- hide a term from within terminal mode
map("t", term_maps.esc_hide_termmode, "<CMD>lua require('nvchad.terminal').hide() <CR>")
-- pick a hidden term
map("n", term_maps.pick_term, ":Telescope terms <CR>")
-- Open terminals
-- TODO this opens on top of an existing vert/hori term, fixme
map(
{ "n", "t" },
term_maps.new_horizontal,
"<CMD>lua require('nvchad.terminal').new_or_toggle('horizontal', "
.. tostring(terminal_options.window.split_height)
.. ")<CR>"
)
map(
{ "n", "t" },
term_maps.new_vertical,
"<CMD>lua require('nvchad.terminal').new_or_toggle('vertical', "
.. tostring(terminal_options.window.vsplit_width)
.. ")<CR>"
)
map(
{ "n", "t" },
term_maps.new_float,
"<CMD>lua require('nvchad.terminal').new_or_toggle('float')<CR>"
)
-- spawns terminals
map(
"n",
term_maps.spawn_horizontal,
":execute 15 .. 'new +terminal' | let b:term_type = 'hori' | startinsert <CR>"
)
map("n", term_maps.spawn_vertical, ":execute 'vnew +terminal' | let b:term_type = 'vert' | startinsert <CR>")
map("n", term_maps.spawn_window, ":execute 'terminal' | let b:term_type = 'wind' | startinsert <CR>")
-- terminal mappings end --
-- Add Packer commands because we are not loading it at startup
cmd "silent! command PackerClean lua require 'plugins' require('packer').clean()"
cmd "silent! command PackerCompile lua require 'plugins' require('packer').compile()"
cmd "silent! command PackerInstall lua require 'plugins' require('packer').install()"
cmd "silent! command PackerStatus lua require 'plugins' require('packer').status()"
cmd "silent! command PackerSync lua require 'plugins' require('packer').sync()"
cmd "silent! command PackerUpdate lua require 'plugins' require('packer').update()"
-- add NvChadUpdate command and mapping
cmd "silent! command! NvChadUpdate lua require('nvchad').update_nvchad()"
map("n", maps.misc.update_nvchad, ":NvChadUpdate <CR>")
end
non_config_mappings()
optional_mappings()
required_mappings()
end
-- below are all plugin related mappings -- below are all plugin related mappings
M.bufferline = function() M.bufferline = function()
local m = plugin_maps.bufferline map("n", "<TAB>", "<cmd> :BufferLineCycleNext <CR>")
map("n", "<S-Tab>", "<cmd> :BufferLineCyclePrev <CR>")
map("n", m.next_buffer, ":BufferLineCycleNext <CR>")
map("n", m.prev_buffer, ":BufferLineCyclePrev <CR>")
end end
M.comment = function() M.comment = function()
local m = plugin_maps.comment.toggle map("n", "<leader>/", "<cmd> :lua require('Comment.api').toggle_current_linewise()<CR>")
map("n", m, ":lua require('Comment.api').toggle_current_linewise()<CR>") map("v", "<leader>/", "<cmd> :lua require('Comment.api').toggle_linewise_op(vim.fn.visualmode())<CR>")
map("v", m, ":lua require('Comment.api').toggle_linewise_op(vim.fn.visualmode())<CR>")
end end
M.lspconfig = function() M.lspconfig = function()
local m = plugin_maps.lspconfig -- See `<cmd> :help vim.lsp.*` for documentation on any of the below functions
map("n", "gD", function()
vim.lsp.buf.declaration()
end)
-- See `:help vim.lsp.*` for documentation on any of the below functions map("n", "gd", function()
map("n", m.declaration, "<cmd>lua vim.lsp.buf.declaration()<CR>") vim.lsp.buf.definition()
map("n", m.definition, "<cmd>lua vim.lsp.buf.definition()<CR>") end)
map("n", m.hover, "<cmd>lua vim.lsp.buf.hover()<CR>")
map("n", m.implementation, "<cmd>lua vim.lsp.buf.implementation()<CR>") map("n", "K", function()
map("n", m.signature_help, "<cmd>lua vim.lsp.buf.signature_help()<CR>") vim.lsp.buf.hover()
map("n", m.add_workspace_folder, "<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>") end)
map("n", m.remove_workspace_folder, "<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>")
map("n", m.list_workspace_folders, "<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>") map("n", "gi", function()
map("n", m.type_definition, "<cmd>lua vim.lsp.buf.type_definition()<CR>") vim.lsp.buf.implementation()
map("n", m.rename, "<cmd>lua vim.lsp.buf.rename()<CR>") end)
map("n", m.code_action, "<cmd>lua vim.lsp.buf.code_action()<CR>")
map("n", m.references, "<cmd>lua vim.lsp.buf.references()<CR>") map("n", "<C-k>", function()
map("n", m.float_diagnostics, "<cmd>lua vim.diagnostic.open_float()<CR>") vim.lsp.buf.signature_help()
map("n", m.goto_prev, "<cmd>lua vim.diagnostic.goto_prev()<CR>") end)
map("n", m.goto_next, "<cmd>lua vim.diagnostic.goto_next()<CR>")
map("n", m.set_loclist, "<cmd>lua vim.diagnostic.setloclist()<CR>") map("n", "<space>D", function()
map("n", m.formatting, "<cmd>lua vim.lsp.buf.formatting()<CR>") vim.lsp.buf.type_definition()
end)
map("n", "<space>ra", function()
vim.lsp.buf.rename()
end)
map("n", "<space>ca", function()
vim.lsp.buf.code_action()
end)
map("n", "gr", function()
vim.lsp.buf.references()
end)
map("n", "<space>f", function()
vim.diagnostic.open_float()
end)
map("n", "[d", function()
vim.diagnostic.goto_prev()
end)
map("n", "d]", function()
vim.diagnostic.goto_next()
end)
map("n", "<space>q", function()
vim.diagnostic.setloclist()
end)
map("n", "<space>fm", function()
vim.lsp.buf.formatting()
end)
map("n", "<space>wa", function()
vim.lsp.buf.add_workspace_folder()
end)
map("n", "<space>wr", function()
vim.lsp.buf.remove_workspace_folder()
end)
map("n", "<space>wl", function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end)
end end
M.nvimtree = function() M.nvimtree = function()
map("n", plugin_maps.nvimtree.toggle, ":NvimTreeToggle <CR>") map("n", "<C-n>", "<cmd> :NvimTreeToggle <CR>")
map("n", plugin_maps.nvimtree.focus, ":NvimTreeFocus <CR>") map("n", "<leader>e", "<cmd> :NvimTreeFocus <CR>")
end end
M.telescope = function() M.telescope = function()
local m = plugin_maps.telescope map("n", "<leader>fb", "<cmd> :Telescope buffers <CR>")
map("n", "<leader>ff", "<cmd> :Telescope find_files <CR>")
map("n", "<leader>fa", "<cmd> :Telescope find_files follow=true no_ignore=true hidden=true <CR>")
map("n", "<leader>cm", "<cmd> :Telescope git_commits <CR>")
map("n", "<leader>gt", "<cmd> :Telescope git_status <CR>")
map("n", "<leader>fh", "<cmd> :Telescope help_tags <CR>")
map("n", "<leader>fw", "<cmd> :Telescope live_grep <CR>")
map("n", "<leader>fo", "<cmd> :Telescope oldfiles <CR>")
map("n", "<leader>th", "<cmd> :Telescope themes <CR>")
map("n", m.buffers, ":Telescope buffers <CR>") -- pick a hidden term
map("n", m.find_files, ":Telescope find_files <CR>") map("n", "<leader>W", "<cmd> :Telescope terms <CR>")
map("n", m.find_hiddenfiles, ":Telescope find_files follow=true no_ignore=true hidden=true <CR>")
map("n", m.git_commits, ":Telescope git_commits <CR>")
map("n", m.git_status, ":Telescope git_status <CR>")
map("n", m.help_tags, ":Telescope help_tags <CR>")
map("n", m.live_grep, ":Telescope live_grep <CR>")
map("n", m.oldfiles, ":Telescope oldfiles <CR>")
map("n", m.themes, ":Telescope themes <CR>")
end end
return M return M

View File

@ -1,31 +1,34 @@
local opt = vim.opt local opt = vim.opt
local g = vim.g local g = vim.g
local options = require("core.utils").load_config().options -- use filetype.lua instead of filetype.vim
g.did_load_filetypes = 0
g.do_filetype_lua = 1
opt.laststatus = 3 -- global statusline
opt.title = true opt.title = true
opt.clipboard = options.clipboard opt.clipboard = "unnamedplus"
opt.cmdheight = options.cmdheight opt.cmdheight = 1
opt.cul = true -- cursor line opt.cul = true -- cursor line
-- Indentline -- Indentline
opt.expandtab = options.expandtab opt.expandtab = true
opt.shiftwidth = options.shiftwidth opt.shiftwidth = 2
opt.smartindent = options.smartindent opt.smartindent = true
-- disable tilde on end of buffer: https://github.com/neovim/neovim/pull/8546#issuecomment-643643758 -- disable tilde on end of buffer: https://github.com/neovim/neovim/pull/8546#issuecomment-643643758
opt.fillchars = options.fillchars opt.fillchars = { eob = " " }
opt.hidden = options.hidden opt.hidden = true
opt.ignorecase = options.ignorecase opt.ignorecase = true
opt.smartcase = options.smartcase opt.smartcase = true
opt.mouse = options.mouse opt.mouse = "a"
-- Numbers -- Numbers
opt.number = options.number opt.number = true
opt.numberwidth = options.numberwidth opt.numberwidth = 2
opt.relativenumber = options.relativenumber opt.relativenumber = false
opt.ruler = options.ruler opt.ruler = false
-- disable nvim intro -- disable nvim intro
opt.shortmess:append "sI" opt.shortmess:append "sI"
@ -33,31 +36,54 @@ opt.shortmess:append "sI"
opt.signcolumn = "yes" opt.signcolumn = "yes"
opt.splitbelow = true opt.splitbelow = true
opt.splitright = true opt.splitright = true
opt.tabstop = options.tabstop opt.tabstop = 8
opt.termguicolors = true opt.termguicolors = true
opt.timeoutlen = options.timeoutlen opt.timeoutlen = 400
opt.undofile = options.undofile opt.undofile = true
-- interval for writing swap file to disk, also used by gitsigns -- interval for writing swap file to disk, also used by gitsigns
opt.updatetime = options.updatetime opt.updatetime = 250
-- go to previous/next line with h,l,left arrow and right arrow -- go to previous/next line with h,l,left arrow and right arrow
-- when cursor reaches end/beginning of line -- when cursor reaches end/beginning of line
opt.whichwrap:append "<>[]hl" opt.whichwrap:append "<>[]hl"
g.mapleader = " "
g.mapleader = options.mapleader
-- disable some builtin vim plugins -- disable some builtin vim plugins
local disabled_built_ins = require("core.utils").load_config().plugins.builtins
for _, plugin in pairs(disabled_built_ins) do local default_plugins = {
"2html_plugin",
"getscript",
"getscriptPlugin",
"gzip",
"logipat",
"netrw",
"netrwPlugin",
"netrwSettings",
"netrwFileHandlers",
"matchit",
"tar",
"tarPlugin",
"rrhelper",
"spellfile_plugin",
"vimball",
"vimballPlugin",
"zip",
"zipPlugin",
}
for _, plugin in pairs(default_plugins) do
g["loaded_" .. plugin] = 1 g["loaded_" .. plugin] = 1
end end
--Defer loading shada until after startup_
vim.opt.shadafile = "NONE"
vim.schedule(function() vim.schedule(function()
vim.opt.shadafile = require("core.utils").load_config().options.shadafile vim.opt.shadafile = "NONE"
vim.cmd [[ silent! rsh ]] vim.cmd [[ silent! rsh ]]
end) end)
-- load user options if the file exists
local load_ifExists = require("core.utils").load_ifExists
local user_options = require("core.utils").load_config().options.path
load_ifExists(user_options)

View File

@ -1,141 +1,13 @@
local M = {} local M = {}
local cmd = vim.cmd local cmd = vim.cmd
M.close_buffer = function(force) M.close_buffer = function(force)
-- This is a modification of a NeoVim plugin from if force or not vim.bo.buflisted then
-- Author: ojroques - Olivier Roques cmd ":bd!"
-- Src: https://github.com/ojroques/nvim-bufdel
-- (Author has okayed copy-paste)
-- Options
local opts = {
next = "cycle", -- how to retrieve the next buffer
quit = false, -- exit when last buffer is deleted
--TODO make this a chadrc flag/option
}
-- ----------------
-- Helper functions
-- ----------------
-- Switch to buffer 'buf' on each window from list 'windows'
local function switch_buffer(windows, buf)
local cur_win = vim.fn.winnr()
for _, winid in ipairs(windows) do
winid = tonumber(winid) or 0
vim.cmd(string.format("%d wincmd w", vim.fn.win_id2win(winid)))
vim.cmd(string.format("buffer %d", buf))
end
vim.cmd(string.format("%d wincmd w", cur_win)) -- return to original window
end
-- Select the first buffer with a number greater than given buffer
local function get_next_buf(buf)
local next = vim.fn.bufnr "#"
if opts.next == "alternate" and vim.fn.buflisted(next) == 1 then
return next
end
for i = 0, vim.fn.bufnr "$" - 1 do
next = (buf + i) % vim.fn.bufnr "$" + 1 -- will loop back to 1
if vim.fn.buflisted(next) == 1 then
return next
end
end
end
-- ----------------
-- End helper functions
-- ----------------
local buf = vim.fn.bufnr()
if vim.fn.buflisted(buf) == 0 then -- exit if buffer number is invalid
vim.cmd "close"
return
end
if #vim.fn.getbufinfo { buflisted = 1 } < 2 then
if opts.quit then
-- exit when there is only one buffer left
if force then
vim.cmd "qall!"
else else
vim.cmd "confirm qall" cmd "bd"
end end
return
end
local chad_term, _ = pcall(function()
return vim.api.nvim_buf_get_var(buf, "term_type")
end)
if chad_term then
-- Must be a window type
vim.cmd(string.format("setlocal nobl", buf))
vim.cmd "enew"
return
end
-- don't exit and create a new empty buffer
vim.cmd "enew"
vim.cmd "bp"
end
local next_buf = get_next_buf(buf)
local windows = vim.fn.getbufinfo(buf)[1].windows
-- force deletion of terminal buffers to avoid the prompt
if force or vim.fn.getbufvar(buf, "&buftype") == "terminal" then
local chad_term, type = pcall(function()
return vim.api.nvim_buf_get_var(buf, "term_type")
end)
-- TODO this scope is error prone, make resilient
if chad_term then
if type == "wind" then
-- hide from bufferline
vim.cmd(string.format("%d bufdo setlocal nobl", buf))
-- switch to another buff
-- TODO switch to next buffer, this works too
vim.cmd "BufferLineCycleNext"
else
local cur_win = vim.fn.winnr()
-- we can close this window
vim.cmd(string.format("%d wincmd c", cur_win))
return
end
else
switch_buffer(windows, next_buf)
vim.cmd(string.format("bd! %d", buf))
end
else
switch_buffer(windows, next_buf)
vim.cmd(string.format("silent! confirm bd %d", buf))
end
-- revert buffer switches if user has canceled deletion
if vim.fn.buflisted(buf) == 1 then
switch_buffer(windows, buf)
end
end
-- hide statusline
-- tables fetched from load_config function
M.hide_statusline = function()
local hidden = require("core.utils").load_config().plugins.options.statusline.hidden
local shown = require("core.utils").load_config().plugins.options.statusline.shown
local api = vim.api
local buftype = api.nvim_buf_get_option(0, "ft")
-- shown table from config has the highest priority
if vim.tbl_contains(shown, buftype) then
api.nvim_set_option("laststatus", 2)
return
end
if vim.tbl_contains(hidden, buftype) then
api.nvim_set_option("laststatus", 0)
return
end
api.nvim_set_option("laststatus", 2)
end end
M.load_config = function() M.load_config = function()
@ -146,10 +18,10 @@ M.load_config = function()
if chadrc_exists then if chadrc_exists then
-- merge user config if it exists and is a table; otherwise display an error -- merge user config if it exists and is a table; otherwise display an error
local user_config = require "custom.chadrc" local user_config = require "custom.chadrc"
if type(user_config) == 'table' then if type(user_config) == "table" then
conf = vim.tbl_deep_extend("force", conf, user_config) conf = vim.tbl_deep_extend("force", conf, user_config)
else else
error("User config (chadrc.lua) *must* return a table!") error "User config (chadrc.lua) *must* return a table!"
end end
end end
@ -158,52 +30,19 @@ end
M.map = function(mode, keys, command, opt) M.map = function(mode, keys, command, opt)
local options = { noremap = true, silent = true } local options = { noremap = true, silent = true }
if opt then if opt then
options = vim.tbl_extend("force", options, opt) options = vim.tbl_extend("force", options, opt)
end end
-- all valid modes allowed for mappings if type(keys) == "table" then
-- :h map-modes for _, keymap in ipairs(keys) do
local valid_modes = { M.map(mode, keymap, command, opt)
[""] = true,
["n"] = true,
["v"] = true,
["s"] = true,
["x"] = true,
["o"] = true,
["!"] = true,
["i"] = true,
["l"] = true,
["c"] = true,
["t"] = true,
}
-- helper function for M.map
-- can gives multiple modes and keys
local function map_wrapper(sub_mode, lhs, rhs, sub_options)
if type(lhs) == "table" then
for _, key in ipairs(lhs) do
map_wrapper(sub_mode, key, rhs, sub_options)
end
else
if type(sub_mode) == "table" then
for _, m in ipairs(sub_mode) do
map_wrapper(m, lhs, rhs, sub_options)
end
else
if valid_modes[sub_mode] and lhs and rhs then
vim.api.nvim_set_keymap(sub_mode, lhs, rhs, sub_options)
else
sub_mode, lhs, rhs = sub_mode or "", lhs or "", rhs or ""
print(
"Cannot set mapping [ mode = '" .. sub_mode .. "' | key = '" .. lhs .. "' | cmd = '" .. rhs .. "' ]"
)
end
end
end end
return
end end
map_wrapper(mode, keys, command, options) vim.keymap.set(mode, keys, command, opt)
end end
-- load plugin after entering vim ui -- load plugin after entering vim ui
@ -241,81 +80,49 @@ M.fg_bg = function(group, fgcol, bgcol)
cmd("hi " .. group .. " guifg=" .. fgcol .. " guibg=" .. bgcol) cmd("hi " .. group .. " guifg=" .. fgcol .. " guibg=" .. bgcol)
end end
-- Override default config of a plugin based on the path provided in the chadrc M.load_ifExists = function(module)
-- Arguments: if #module ~= 0 then
-- 1st - name of plugin if type(module) == "string" then
-- 2nd - default config path require(module)
-- 3rd - optional function name which will called from default_config path
-- e.g: if given args - "telescope", "plugins.configs.telescope", "setup"
-- then return "require('plugins.configs.telescope').setup()"
-- if 3rd arg not given, then return "require('plugins.configs.telescope')"
-- if override is a table, mark set the override flag for the default config to true
-- override flag being true tells the plugin to call tbl_override_req as part of configuration
M.override_req = function(name, default_config, config_function) -- file[1] = module & file[2] = function
local override, apply_table_override = elseif type(module) == "table" then
require("core.utils").load_config().plugins.default_plugin_config_replace[name], "false" require(module[1])[module[2]]()
local result = default_config
if type(override) == "string" and override ~= "" then
return "require('" .. override .. "')"
elseif type(override) == "table" then
apply_table_override = "true"
elseif type(override) == "function" then
return override
end end
result = "('" .. result .. "')"
if type(config_function) == "string" and config_function ~= "" then
-- add the . to call the functions and concatenate true or false as argument
result = result .. "." .. config_function .. "(" .. apply_table_override .. ")"
end end
return "require" .. result
end end
-- Override parts of default config of a plugin based on the table provided in the chadrc -- merge default/user plugin tables
-- FUNCTION: tbl_override_req, use `chadrc` plugin config override to modify default config if present M.plugin_list = function(default_plugins)
-- name = name inside `default_config` / `chadrc` local user_plugins = require("core.utils").load_config().plugins.user
-- default_table = the default configuration table of the plugin local plug_override = require("core.default_config").plugins.override
-- returns the modified configuration table
M.tbl_override_req = function(name, default_table) -- merge default + user plugin table
local override = require("core.utils").load_config().plugins.default_plugin_config_replace[name] or {} default_plugins = vim.tbl_deep_extend("force", default_plugins, user_plugins)
return vim.tbl_deep_extend("force", default_table, override)
local final_table = {}
for key, _ in pairs(default_plugins) do
default_plugins[key][1] = key
final_table[#final_table + 1] = default_plugins[key]
plug_override[#plug_override + 1] = default_plugins[key]
end
return final_table
end end
--provide labels to plugins instead of integers M.load_override = function(default_table, plugin_name)
M.label_plugins = function(plugins) local user_table = require("core.utils").load_config().plugins.override[plugin_name]
local plugins_labeled = {}
for _, plugin in ipairs(plugins) do
plugins_labeled[plugin[1]] = plugin
end
return plugins_labeled
end
-- remove plugins specified by user from the plugins table if type(user_table) == "table" then
M.remove_default_plugins = function(plugins) default_table = vim.tbl_deep_extend("force", default_table, user_table)
local removals = require("core.utils").load_config().plugins.default_plugin_remove or {} else
if not vim.tbl_isempty(removals) then default_table = default_table
for _, plugin in pairs(removals) do
plugins[plugin] = nil
end end
end
return plugins
end
-- append user plugins to default plugins return default_table
M.add_user_plugins = function(plugins)
local user_Plugins = require("core.utils").load_config().plugins.install or {}
if type(user_Plugins) == "string"
then user_Plugins=require(user_Plugins)
end
if not vim.tbl_isempty(user_Plugins) then
for _, v in pairs(user_Plugins) do
plugins[v[1]] = v
end
end
return plugins
end end
return M return M

View File

@ -32,9 +32,9 @@ local function button(sc, txt, keybind)
} }
end end
local default = {} local options = {}
default.ascii = { local ascii = {
" ⣴⣶⣤⡤⠦⣤⣀⣤⠆ ⣈⣭⣿⣶⣿⣦⣼⣆ ", " ⣴⣶⣤⡤⠦⣤⣀⣤⠆ ⣈⣭⣿⣶⣿⣦⣼⣆ ",
" ⠉⠻⢿⣿⠿⣿⣿⣶⣦⠤⠄⡠⢾⣿⣿⡿⠋⠉⠉⠻⣿⣿⡛⣦ ", " ⠉⠻⢿⣿⠿⣿⣿⣶⣦⠤⠄⡠⢾⣿⣿⡿⠋⠉⠉⠻⣿⣿⡛⣦ ",
" ⠈⢿⣿⣟⠦ ⣾⣿⣿⣷ ⠻⠿⢿⣿⣧⣄ ", " ⠈⢿⣿⣟⠦ ⣾⣿⣿⣷ ⠻⠿⢿⣿⣧⣄ ",
@ -48,16 +48,16 @@ default.ascii = {
" ⠻⣿⣿⣿⣿⣶⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⡟⢀⣀⣤⣾⡿⠃ ", " ⠻⣿⣿⣿⣿⣶⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⡟⢀⣀⣤⣾⡿⠃ ",
} }
default.header = { options.header = {
type = "text", type = "text",
val = default.ascii, val = ascii,
opts = { opts = {
position = "center", position = "center",
hl = "AlphaHeader", hl = "AlphaHeader",
}, },
} }
default.buttons = { options.buttons = {
type = "group", type = "group",
val = { val = {
button("SPC f f", " Find File ", ":Telescope find_files<CR>"), button("SPC f f", " Find File ", ":Telescope find_files<CR>"),
@ -72,21 +72,14 @@ default.buttons = {
}, },
} }
local M = {} options = require("core.utils").load_override(options, "goolord/alpha-nvim")
M.setup = function(override_flag) alpha.setup {
if override_flag then
default = require("core.utils").tbl_override_req("alpha", default)
end
alpha.setup {
layout = { layout = {
{ type = "padding", val = 9 }, { type = "padding", val = 9 },
default.header, options.header,
{ type = "padding", val = 2 }, { type = "padding", val = 2 },
default.buttons, options.buttons,
}, },
opts = {}, opts = {},
} }
end
return M

View File

@ -3,10 +3,9 @@ if not present then
return return
end end
local default = { local colors = require("colors").get()
colors = require("colors").get(),
} local options = {
default = {
options = { options = {
offsets = { { filetype = "NvimTree", text = "", padding = 1 } }, offsets = { { filetype = "NvimTree", text = "", padding = 1 } },
buffer_close_icon = "", buffer_close_icon = "",
@ -46,103 +45,98 @@ default = {
highlights = { highlights = {
background = { background = {
guifg = default.colors.grey_fg, guifg = colors.grey_fg,
guibg = default.colors.black2, guibg = colors.black2,
}, },
-- buffers -- buffers
buffer_selected = { buffer_selected = {
guifg = default.colors.white, guifg = colors.white,
guibg = default.colors.black, guibg = colors.black,
gui = "bold", gui = "bold",
}, },
buffer_visible = { buffer_visible = {
guifg = default.colors.light_grey, guifg = colors.light_grey,
guibg = default.colors.black2, guibg = colors.black2,
}, },
-- for diagnostics = "nvim_lsp" -- for diagnostics = "nvim_lsp"
error = { error = {
guifg = default.colors.light_grey, guifg = colors.light_grey,
guibg = default.colors.black2, guibg = colors.black2,
}, },
error_diagnostic = { error_diagnostic = {
guifg = default.colors.light_grey, guifg = colors.light_grey,
guibg = default.colors.black2, guibg = colors.black2,
}, },
-- close buttons -- close buttons
close_button = { close_button = {
guifg = default.colors.light_grey, guifg = colors.light_grey,
guibg = default.colors.black2, guibg = colors.black2,
}, },
close_button_visible = { close_button_visible = {
guifg = default.colors.light_grey, guifg = colors.light_grey,
guibg = default.colors.black2, guibg = colors.black2,
}, },
close_button_selected = { close_button_selected = {
guifg = default.colors.red, guifg = colors.red,
guibg = default.colors.black, guibg = colors.black,
}, },
fill = { fill = {
guifg = default.colors.grey_fg, guifg = colors.grey_fg,
guibg = default.colors.black2, guibg = colors.black2,
}, },
indicator_selected = { indicator_selected = {
guifg = default.colors.black, guifg = colors.black,
guibg = default.colors.black, guibg = colors.black,
}, },
-- modified -- modified
modified = { modified = {
guifg = default.colors.red, guifg = colors.red,
guibg = default.colors.black2, guibg = colors.black2,
}, },
modified_visible = { modified_visible = {
guifg = default.colors.red, guifg = colors.red,
guibg = default.colors.black2, guibg = colors.black2,
}, },
modified_selected = { modified_selected = {
guifg = default.colors.green, guifg = colors.green,
guibg = default.colors.black, guibg = colors.black,
}, },
-- separators -- separators
separator = { separator = {
guifg = default.colors.black2, guifg = colors.black2,
guibg = default.colors.black2, guibg = colors.black2,
}, },
separator_visible = { separator_visible = {
guifg = default.colors.black2, guifg = colors.black2,
guibg = default.colors.black2, guibg = colors.black2,
}, },
separator_selected = { separator_selected = {
guifg = default.colors.black2, guifg = colors.black2,
guibg = default.colors.black2, guibg = colors.black2,
}, },
-- tabs -- tabs
tab = { tab = {
guifg = default.colors.light_grey, guifg = colors.light_grey,
guibg = default.colors.one_bg3, guibg = colors.one_bg3,
}, },
tab_selected = { tab_selected = {
guifg = default.colors.black2, guifg = colors.black2,
guibg = default.colors.nord_blue, guibg = colors.nord_blue,
}, },
tab_close = { tab_close = {
guifg = default.colors.red, guifg = colors.red,
guibg = default.colors.black, guibg = colors.black,
}, },
}, },
} }
local M = {} -- check for any override
M.setup = function(override_flag) options = require("core.utils").load_override(options, "akinsho/bufferline.nvim")
if override_flag then
default = require("core.utils").tbl_override_req("bufferline", default)
end
bufferline.setup(default)
end
return M bufferline.setup(options)

View File

@ -6,7 +6,7 @@ end
vim.opt.completeopt = "menuone,noselect" vim.opt.completeopt = "menuone,noselect"
local default = { local options = {
snippet = { snippet = {
expand = function(args) expand = function(args)
require("luasnip").lsp_expand(args.body) require("luasnip").lsp_expand(args.body)
@ -45,7 +45,10 @@ local default = {
else else
fallback() fallback()
end end
end, { "i", "s" }), end, {
"i",
"s",
}),
["<S-Tab>"] = cmp.mapping(function(fallback) ["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_prev_item() cmp.select_prev_item()
@ -54,7 +57,10 @@ local default = {
else else
fallback() fallback()
end end
end, { "i", "s" }), end, {
"i",
"s",
}),
}, },
sources = { sources = {
{ name = "nvim_lsp" }, { name = "nvim_lsp" },
@ -65,12 +71,7 @@ local default = {
}, },
} }
local M = {} -- check for any override
M.setup = function(override_flag) -- options = require("core.utils").load_override(options, "cmp")
if override_flag then
default = require("core.utils").tbl_override_req("nvim_cmp", default)
end
cmp.setup(default)
end
return M cmp.setup(options)

View File

@ -1,158 +1,152 @@
local present, icons = pcall(require, "nvim-web-devicons") local present, devicons = pcall(require, "nvim-web-devicons")
if not present then if not present then
return return
end end
local default = { local colors = require("colors").get()
colors = require("colors").get(),
}
default = { local options = {
override = { override = {
c = { c = {
icon = "", icon = "",
color = default.colors.blue, color = colors.blue,
name = "c", name = "c",
}, },
css = { css = {
icon = "", icon = "",
color = default.colors.blue, color = colors.blue,
name = "css", name = "css",
}, },
deb = { deb = {
icon = "", icon = "",
color = default.colors.cyan, color = colors.cyan,
name = "deb", name = "deb",
}, },
Dockerfile = { Dockerfile = {
icon = "", icon = "",
color = default.colors.cyan, color = colors.cyan,
name = "Dockerfile", name = "Dockerfile",
}, },
html = { html = {
icon = "", icon = "",
color = default.colors.baby_pink, color = colors.baby_pink,
name = "html", name = "html",
}, },
jpeg = { jpeg = {
icon = "", icon = "",
color = default.colors.dark_purple, color = colors.dark_purple,
name = "jpeg", name = "jpeg",
}, },
jpg = { jpg = {
icon = "", icon = "",
color = default.colors.dark_purple, color = colors.dark_purple,
name = "jpg", name = "jpg",
}, },
js = { js = {
icon = "", icon = "",
color = default.colors.sun, color = colors.sun,
name = "js", name = "js",
}, },
kt = { kt = {
icon = "󱈙", icon = "󱈙",
color = default.colors.orange, color = colors.orange,
name = "kt", name = "kt",
}, },
lock = { lock = {
icon = "", icon = "",
color = default.colors.red, color = colors.red,
name = "lock", name = "lock",
}, },
lua = { lua = {
icon = "", icon = "",
color = default.colors.blue, color = colors.blue,
name = "lua", name = "lua",
}, },
mp3 = { mp3 = {
icon = "", icon = "",
color = default.colors.white, color = colors.white,
name = "mp3", name = "mp3",
}, },
mp4 = { mp4 = {
icon = "", icon = "",
color = default.colors.white, color = colors.white,
name = "mp4", name = "mp4",
}, },
out = { out = {
icon = "", icon = "",
color = default.colors.white, color = colors.white,
name = "out", name = "out",
}, },
png = { png = {
icon = "", icon = "",
color = default.colors.dark_purple, color = colors.dark_purple,
name = "png", name = "png",
}, },
py = { py = {
icon = "", icon = "",
color = default.colors.cyan, color = colors.cyan,
name = "py", name = "py",
}, },
["robots.txt"] = { ["robots.txt"] = {
icon = "", icon = "",
color = default.colors.red, color = colors.red,
name = "robots", name = "robots",
}, },
toml = { toml = {
icon = "", icon = "",
color = default.colors.blue, color = colors.blue,
name = "toml", name = "toml",
}, },
ts = { ts = {
icon = "", icon = "",
color = default.colors.teal, color = colors.teal,
name = "ts", name = "ts",
}, },
ttf = { ttf = {
icon = "", icon = "",
color = default.colors.white, color = colors.white,
name = "TrueTypeFont", name = "TrueTypeFont",
}, },
rb = { rb = {
icon = "", icon = "",
color = default.colors.pink, color = colors.pink,
name = "rb", name = "rb",
}, },
rpm = { rpm = {
icon = "", icon = "",
color = default.colors.orange, color = colors.orange,
name = "rpm", name = "rpm",
}, },
vue = { vue = {
icon = "", icon = "",
color = default.colors.vibrant_green, color = colors.vibrant_green,
name = "vue", name = "vue",
}, },
woff = { woff = {
icon = "", icon = "",
color = default.colors.white, color = colors.white,
name = "WebOpenFontFormat", name = "WebOpenFontFormat",
}, },
woff2 = { woff2 = {
icon = "", icon = "",
color = default.colors.white, color = colors.white,
name = "WebOpenFontFormat2", name = "WebOpenFontFormat2",
}, },
xz = { xz = {
icon = "", icon = "",
color = default.colors.sun, color = colors.sun,
name = "xz", name = "xz",
}, },
zip = { zip = {
icon = "", icon = "",
color = default.colors.sun, color = colors.sun,
name = "zip", name = "zip",
}, },
}, },
} }
local M = {} -- check for any override
M.setup = function(override_flag) -- options = require("core.utils").load_override(options, "nvim_web_devicons")
if override_flag then
default = require("core.utils").tbl_override_req("nvim_web_devicons", default)
end
icons.setup(default)
end
return M devicons.setup(options)

View File

@ -1,4 +1,5 @@
local M = {} local M = {}
require("plugins.configs.others").lsp_handlers() require("plugins.configs.others").lsp_handlers()
function M.on_attach(client, bufnr) function M.on_attach(client, bufnr)

View File

@ -1,8 +1,14 @@
local present, nvimtree = pcall(require, "nvim-tree")
if not present then
return
end
-- globals must be set prior to requiring nvim-tree to function -- globals must be set prior to requiring nvim-tree to function
local g = vim.g local g = vim.g
g.nvim_tree_add_trailing = 0 -- append a trailing slash to folder names g.nvim_tree_add_trailing = 0 -- append a trailing slash to folder names
g.nvim_tree_git_hl = 0 g.nvim_tree_git_hl = 1
g.nvim_tree_highlight_opened_files = 0 g.nvim_tree_highlight_opened_files = 0
g.nvim_tree_root_folder_modifier = table.concat { ":t:gs?$?/..", string.rep(" ", 1000), "?:gs?^??" } g.nvim_tree_root_folder_modifier = table.concat { ":t:gs?$?/..", string.rep(" ", 1000), "?:gs?^??" }
@ -34,20 +40,13 @@ g.nvim_tree_icons = {
}, },
} }
local present, nvimtree = pcall(require, "nvim-tree") local options = {
if not present then
return
end
local default = {
filters = { filters = {
dotfiles = false, dotfiles = false,
}, },
disable_netrw = true, disable_netrw = true,
hijack_netrw = true, hijack_netrw = true,
ignore_ft_on_setup = { "dashboard" }, ignore_ft_on_setup = { "dashboard" },
auto_close = false,
open_on_tab = false, open_on_tab = false,
hijack_cursor = true, hijack_cursor = true,
hijack_unnamed_buffer_when_opening = false, hijack_unnamed_buffer_when_opening = false,
@ -57,7 +56,6 @@ local default = {
update_cwd = false, update_cwd = false,
}, },
view = { view = {
allow_resize = true,
side = "left", side = "left",
width = 25, width = 25,
hide_root_folder = true, hide_root_folder = true,
@ -74,17 +72,11 @@ local default = {
renderer = { renderer = {
indent_markers = { indent_markers = {
enable = true, enable = true,
} },
} },
} }
local M = {} -- check for any override
options = require("core.utils").load_override(options, "kyazdani42/nvim-tree.lua")
M.setup = function(override_flag) nvimtree.setup(options)
if override_flag then
default = require("core.utils").tbl_override_req("nvim_tree", default)
end
nvimtree.setup(default)
end
return M

View File

@ -0,0 +1,43 @@
local present, nvterm = pcall(require, "nvterm")
if not present then
return
end
local options = {
terminals = {
list = {},
type_opts = {
float = {
relative = "editor",
row = 0.3,
col = 0.25,
width = 0.5,
height = 0.4,
border = "single",
},
horizontal = { location = "rightbelow", split_ratio = 0.3 },
vertical = { location = "rightbelow", split_ratio = 0.5 },
},
},
behavior = {
close_on_exit = true,
auto_insert = true,
},
mappings = {
toggle = {
float = "<A-i>",
horizontal = "<A-h>",
vertical = "<A-v>",
},
new = {
horizontal = "<leader>h",
vertical = "<leader>v",
},
},
enable_new_mappings = true,
}
options = require("core.utils").load_override(options, "NvChad/nvterm")
nvterm.setup(options)

View File

@ -1,36 +1,49 @@
local M = {} local M = {}
local chadrc_config = require("core.utils").load_config() M.autopairs = function()
M.autopairs = function(override_flag)
local present1, autopairs = pcall(require, "nvim-autopairs") local present1, autopairs = pcall(require, "nvim-autopairs")
local present2, cmp_autopairs = pcall(require, "nvim-autopairs.completion.cmp") local present2, cmp = pcall(require, "cmp")
if present1 and present2 then if not present1 and present2 then
local default = { fast_wrap = {} } return
if override_flag then
default = require("core.utils").tbl_override_req("nvim_autopairs", default)
end end
autopairs.setup(default)
local cmp = require "cmp" autopairs.setup {
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) fast_wrap = {},
end disable_filetype = { "TelescopePrompt", "vim" },
end
M.better_escape = function(override_flag)
local default = {
mapping = chadrc_config.mappings.plugins.better_escape.esc_insertmode,
timeout = chadrc_config.plugins.options.esc_insertmode_timeout,
} }
if override_flag then
default = require("core.utils").tbl_override_req("better_escape", default) local cmp_autopairs = require "nvim-autopairs.completion.cmp"
end
require("better_escape").setup(default) cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
end end
M.blankline = function(override_flag) M.better_escape = function()
local default = { local present, escape = pcall(require, "better_escape")
if not present then
return
end
local options = {
mapping = { "jk" }, -- a table with mappings to use
timeout = vim.o.timeoutlen,
clear_empty_lines = false, -- clear line after escaping if there is only whitespace
keys = "<Esc>",
}
options = require("core.utils").load_override(options, "max397574/better-escape.nvim")
escape.setup(options)
end
M.blankline = function()
local present, blankline = pcall(require, "indent_blankline")
if not present then
return
end
local options = {
indentLine_enabled = 1, indentLine_enabled = 1,
char = "", char = "",
filetype_exclude = { filetype_exclude = {
@ -49,16 +62,19 @@ M.blankline = function(override_flag)
show_trailing_blankline_indent = false, show_trailing_blankline_indent = false,
show_first_indent_level = false, show_first_indent_level = false,
} }
if override_flag then
default = require("core.utils").tbl_override_req("indent_blankline", default) options = require("core.utils").load_override(options, "lukas-reineke/indent-blankline.nvim")
end blankline.setup(options)
require("indent_blankline").setup(default)
end end
M.colorizer = function(override_flag) M.colorizer = function()
local present, colorizer = pcall(require, "colorizer") local present, colorizer = pcall(require, "colorizer")
if present then
local default = { if not present then
return
end
local options = {
filetypes = { filetypes = {
"*", "*",
}, },
@ -76,45 +92,48 @@ M.colorizer = function(override_flag)
mode = "background", -- Set the display mode. mode = "background", -- Set the display mode.
}, },
} }
if override_flag then
default = require("core.utils").tbl_override_req("nvim_colorizer", default) options = require("core.utils").load_override(options, "NvChad/nvim-colorizer.lua")
end
colorizer.setup(default["filetypes"], default["user_default_options"]) colorizer.setup(options["filetypes"], options["user_default_options"])
vim.cmd "ColorizerReloadAllBuffers" vim.cmd "ColorizerReloadAllBuffers"
end
end end
M.comment = function(override_flag) M.comment = function()
local present, nvim_comment = pcall(require, "Comment") local present, nvim_comment = pcall(require, "Comment")
if present then
local default = {} if not present then
if override_flag then return
default = require("core.utils").tbl_override_req("nvim_comment", default)
end
nvim_comment.setup(default)
end end
nvim_comment.setup()
end end
M.luasnip = function(override_flag) M.luasnip = function()
local present, luasnip = pcall(require, "luasnip") local present, luasnip = pcall(require, "luasnip")
if present then if present then
local default = { return
end
luasnip.config.set_config {
history = true, history = true,
updateevents = "TextChanged,TextChangedI", updateevents = "TextChanged,TextChangedI",
} }
if override_flag then
default = require("core.utils").tbl_override_req("luasnip", default) -- add snippet path here!
end require("luasnip/loaders/from_vscode").load { paths = {} }
luasnip.config.set_config(default)
require("luasnip/loaders/from_vscode").load { paths = chadrc_config.plugins.options.luasnip.snippet_path }
require("luasnip/loaders/from_vscode").load() require("luasnip/loaders/from_vscode").load()
end
end end
M.signature = function(override_flag) M.signature = function()
local present, lspsignature = pcall(require, "lsp_signature") local present, lsp_signature = pcall(require, "lsp_signature")
if present then
local default = { if not present then
return
end
local options = {
bind = true, bind = true,
doc_lines = 0, doc_lines = 0,
floating_window = true, floating_window = true,
@ -131,11 +150,9 @@ M.signature = function(override_flag)
zindex = 200, -- by default it will be on top of all floating windows, set to 50 send it to bottom zindex = 200, -- by default it will be on top of all floating windows, set to 50 send it to bottom
padding = "", -- character to pad on left and right of signature can be ' ', or '|' etc padding = "", -- character to pad on left and right of signature can be ' ', or '|' etc
} }
if override_flag then
default = require("core.utils").tbl_override_req("signature", default) options = require("core.utils").load_override(options, "ray-x/lsp_signature.nvim")
end lsp_signature.setup(options)
lspsignature.setup(default)
end
end end
M.lsp_handlers = function() M.lsp_handlers = function()
@ -178,10 +195,14 @@ M.lsp_handlers = function()
end end
end end
M.gitsigns = function(override_flag) M.gitsigns = function()
local present, gitsigns = pcall(require, "gitsigns") local present, gitsigns = pcall(require, "gitsigns")
if present then
local default = { if not present then
return
end
gitsigns.setup {
signs = { signs = {
add = { hl = "DiffAdd", text = "", numhl = "GitSignsAddNr" }, add = { hl = "DiffAdd", text = "", numhl = "GitSignsAddNr" },
change = { hl = "DiffChange", text = "", numhl = "GitSignsChangeNr" }, change = { hl = "DiffChange", text = "", numhl = "GitSignsChangeNr" },
@ -190,11 +211,6 @@ M.gitsigns = function(override_flag)
changedelete = { hl = "DiffChangeDelete", text = "~", numhl = "GitSignsChangeNr" }, changedelete = { hl = "DiffChangeDelete", text = "~", numhl = "GitSignsChangeNr" },
}, },
} }
if override_flag then
default = require("core.utils").tbl_override_req("gitsigns", default)
end
gitsigns.setup(default)
end
end end
return M return M

View File

@ -1,16 +1,14 @@
local present, feline = pcall(require, "feline") local present, feline = pcall(require, "feline")
if not present then if not present then
return return
end end
local default = { local colors = require("colors").get()
colors = require("colors").get(), local lsp = require "feline.providers.lsp"
lsp = require "feline.providers.lsp", local lsp_severity = vim.diagnostic.severity
lsp_severity = vim.diagnostic.severity,
config = require("core.utils").load_config().plugins.options.statusline,
}
default.icon_styles = { local icon_styles = {
default = { default = {
left = "", left = "",
right = "", right = "",
@ -51,35 +49,31 @@ default.icon_styles = {
}, },
} }
-- statusline style local separator_style = icon_styles.default
default.statusline_style = default.icon_styles[default.config.style]
-- show short statusline on small screens
default.shortline = default.config.shortline == false and true
-- Initialize the components table -- Initialize the components table
default.components = { local components = {
active = {}, active = {},
} }
default.main_icon = { local main_icon = {
provider = default.statusline_style.main_icon, provider = separator_style.main_icon,
hl = { hl = {
fg = default.colors.statusline_bg, fg = colors.statusline_bg,
bg = default.colors.nord_blue, bg = colors.nord_blue,
}, },
right_sep = { right_sep = {
str = default.statusline_style.right, str = separator_style.right,
hl = { hl = {
fg = default.colors.nord_blue, fg = colors.nord_blue,
bg = default.colors.lightbg, bg = colors.lightbg,
}, },
}, },
} }
default.file_name = { local file_name = {
provider = function() provider = function()
local filename = vim.fn.expand "%:t" local filename = vim.fn.expand "%:t"
local extension = vim.fn.expand "%:e" local extension = vim.fn.expand "%:e"
@ -90,49 +84,42 @@ default.file_name = {
end end
return " " .. icon .. " " .. filename .. " " return " " .. icon .. " " .. filename .. " "
end, end,
enabled = default.shortline or function(winid)
return vim.api.nvim_win_get_width(tonumber(winid) or 0) > 70
end,
hl = { hl = {
fg = default.colors.white, fg = colors.white,
bg = default.colors.lightbg, bg = colors.lightbg,
}, },
right_sep = { right_sep = {
str = default.statusline_style.right, str = separator_style.right,
hl = { fg = default.colors.lightbg, bg = default.colors.lightbg2 }, hl = { fg = colors.lightbg, bg = colors.lightbg2 },
}, },
} }
default.dir_name = { local dir_name = {
provider = function() provider = function()
local dir_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":t") local dir_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":t")
return "" .. dir_name .. " " return "" .. dir_name .. " "
end, end,
enabled = default.shortline or function(winid)
return vim.api.nvim_win_get_width(tonumber(winid) or 0) > 80
end,
hl = { hl = {
fg = default.colors.grey_fg2, fg = colors.grey_fg2,
bg = default.colors.lightbg2, bg = colors.lightbg2,
}, },
right_sep = { right_sep = {
str = default.statusline_style.right, str = separator_style.right,
hi = { hi = {
fg = default.colors.lightbg2, fg = colors.lightbg2,
bg = default.colors.statusline_bg, bg = colors.statusline_bg,
}, },
}, },
} }
default.diff = { local diff = {
add = { add = {
provider = "git_diff_added", provider = "git_diff_added",
hl = { hl = {
fg = default.colors.grey_fg2, fg = colors.grey_fg2,
bg = default.colors.statusline_bg, bg = colors.statusline_bg,
}, },
icon = "", icon = "",
}, },
@ -140,8 +127,8 @@ default.diff = {
change = { change = {
provider = "git_diff_changed", provider = "git_diff_changed",
hl = { hl = {
fg = default.colors.grey_fg2, fg = colors.grey_fg2,
bg = default.colors.statusline_bg, bg = colors.statusline_bg,
}, },
icon = "", icon = "",
}, },
@ -149,65 +136,62 @@ default.diff = {
remove = { remove = {
provider = "git_diff_removed", provider = "git_diff_removed",
hl = { hl = {
fg = default.colors.grey_fg2, fg = colors.grey_fg2,
bg = default.colors.statusline_bg, bg = colors.statusline_bg,
}, },
icon = "", icon = "",
}, },
} }
default.git_branch = { local git_branch = {
provider = "git_branch", provider = "git_branch",
enabled = default.shortline or function(winid)
return vim.api.nvim_win_get_width(tonumber(winid) or 0) > 70
end,
hl = { hl = {
fg = default.colors.grey_fg2, fg = colors.grey_fg2,
bg = default.colors.statusline_bg, bg = colors.statusline_bg,
}, },
icon = "", icon = "",
} }
default.diagnostic = { local diagnostic = {
error = { error = {
provider = "diagnostic_errors", provider = "diagnostic_errors",
enabled = function() enabled = function()
return default.lsp.diagnostics_exist(default.lsp_severity.ERROR) return lsp.diagnostics_exist(lsp_severity.ERROR)
end, end,
hl = { fg = default.colors.red }, hl = { fg = colors.red },
icon = "", icon = "",
}, },
warning = { warning = {
provider = "diagnostic_warnings", provider = "diagnostic_warnings",
enabled = function() enabled = function()
return default.lsp.diagnostics_exist(default.lsp_severity.WARN) return lsp.diagnostics_exist(lsp_severity.WARN)
end, end,
hl = { fg = default.colors.yellow }, hl = { fg = colors.yellow },
icon = "", icon = "",
}, },
hint = { hint = {
provider = "diagnostic_hints", provider = "diagnostic_hints",
enabled = function() enabled = function()
return default.lsp.diagnostics_exist(default.lsp_severity.HINT) return lsp.diagnostics_exist(lsp_severity.HINT)
end, end,
hl = { fg = default.colors.grey_fg2 }, hl = { fg = colors.grey_fg2 },
icon = "", icon = "",
}, },
info = { info = {
provider = "diagnostic_info", provider = "diagnostic_info",
enabled = function() enabled = function()
return default.lsp.diagnostics_exist(default.lsp_severity.INFO) return lsp.diagnostics_exist(lsp_severity.INFO)
end, end,
hl = { fg = default.colors.green }, hl = { fg = colors.green },
icon = "", icon = "",
}, },
} }
default.lsp_progress = { local lsp_progress = {
provider = function() provider = function()
local Lsp = vim.lsp.util.get_progress_messages()[1] local Lsp = vim.lsp.util.get_progress_messages()[1]
@ -239,13 +223,10 @@ default.lsp_progress = {
return "" return ""
end, end,
enabled = default.shortline or function(winid) hl = { fg = colors.green },
return vim.api.nvim_win_get_width(tonumber(winid) or 0) > 80
end,
hl = { fg = default.colors.green },
} }
default.lsp_icon = { local lsp_icon = {
provider = function() provider = function()
if next(vim.lsp.buf_get_clients()) ~= nil then if next(vim.lsp.buf_get_clients()) ~= nil then
return " LSP" return " LSP"
@ -253,112 +234,100 @@ default.lsp_icon = {
return "" return ""
end end
end, end,
enabled = default.shortline or function(winid) hl = { fg = colors.grey_fg2, bg = colors.statusline_bg },
return vim.api.nvim_win_get_width(tonumber(winid) or 0) > 70
end,
hl = { fg = default.colors.grey_fg2, bg = default.colors.statusline_bg },
} }
default.mode_colors = { local mode_colors = {
["n"] = { "NORMAL", default.colors.red }, ["n"] = { "NORMAL", colors.red },
["no"] = { "N-PENDING", default.colors.red }, ["no"] = { "N-PENDING", colors.red },
["i"] = { "INSERT", default.colors.dark_purple }, ["i"] = { "INSERT", colors.dark_purple },
["ic"] = { "INSERT", default.colors.dark_purple }, ["ic"] = { "INSERT", colors.dark_purple },
["t"] = { "TERMINAL", default.colors.green }, ["t"] = { "TERMINAL", colors.green },
["v"] = { "VISUAL", default.colors.cyan }, ["v"] = { "VISUAL", colors.cyan },
["V"] = { "V-LINE", default.colors.cyan }, ["V"] = { "V-LINE", colors.cyan },
[""] = { "V-BLOCK", default.colors.cyan }, [""] = { "V-BLOCK", colors.cyan },
["R"] = { "REPLACE", default.colors.orange }, ["R"] = { "REPLACE", colors.orange },
["Rv"] = { "V-REPLACE", default.colors.orange }, ["Rv"] = { "V-REPLACE", colors.orange },
["s"] = { "SELECT", default.colors.nord_blue }, ["s"] = { "SELECT", colors.nord_blue },
["S"] = { "S-LINE", default.colors.nord_blue }, ["S"] = { "S-LINE", colors.nord_blue },
[""] = { "S-BLOCK", default.colors.nord_blue }, [""] = { "S-BLOCK", colors.nord_blue },
["c"] = { "COMMAND", default.colors.pink }, ["c"] = { "COMMAND", colors.pink },
["cv"] = { "COMMAND", default.colors.pink }, ["cv"] = { "COMMAND", colors.pink },
["ce"] = { "COMMAND", default.colors.pink }, ["ce"] = { "COMMAND", colors.pink },
["r"] = { "PROMPT", default.colors.teal }, ["r"] = { "PROMPT", colors.teal },
["rm"] = { "MORE", default.colors.teal }, ["rm"] = { "MORE", colors.teal },
["r?"] = { "CONFIRM", default.colors.teal }, ["r?"] = { "CONFIRM", colors.teal },
["!"] = { "SHELL", default.colors.green }, ["!"] = { "SHELL", colors.green },
} }
default.chad_mode_hl = function() local chad_mode_hl = function()
return { return {
fg = default.mode_colors[vim.fn.mode()][2], fg = mode_colors[vim.fn.mode()][2],
bg = default.colors.one_bg, bg = colors.one_bg,
} }
end end
default.empty_space = { local empty_space = {
provider = " " .. default.statusline_style.left, provider = " " .. separator_style.left,
hl = { hl = {
fg = default.colors.one_bg2, fg = colors.one_bg2,
bg = default.colors.statusline_bg, bg = colors.statusline_bg,
}, },
} }
-- this matches the vi mode color -- this matches the vi mode color
default.empty_spaceColored = { local empty_spaceColored = {
provider = default.statusline_style.left, provider = separator_style.left,
hl = function() hl = function()
return { return {
fg = default.mode_colors[vim.fn.mode()][2], fg = mode_colors[vim.fn.mode()][2],
bg = default.colors.one_bg2, bg = colors.one_bg2,
} }
end, end,
} }
default.mode_icon = { local mode_icon = {
provider = default.statusline_style.vi_mode_icon, provider = separator_style.vi_mode_icon,
hl = function() hl = function()
return { return {
fg = default.colors.statusline_bg, fg = colors.statusline_bg,
bg = default.mode_colors[vim.fn.mode()][2], bg = mode_colors[vim.fn.mode()][2],
} }
end, end,
} }
default.empty_space2 = { local empty_space2 = {
provider = function() provider = function()
return " " .. default.mode_colors[vim.fn.mode()][1] .. " " return " " .. mode_colors[vim.fn.mode()][1] .. " "
end, end,
hl = default.chad_mode_hl, hl = chad_mode_hl,
} }
default.separator_right = { local separator_right = {
provider = default.statusline_style.left, provider = separator_style.left,
enabled = default.shortline or function(winid)
return vim.api.nvim_win_get_width(tonumber(winid) or 0) > 90
end,
hl = { hl = {
fg = default.colors.grey, fg = colors.grey,
bg = default.colors.one_bg, bg = colors.one_bg,
}, },
} }
default.separator_right2 = { local separator_right2 = {
provider = default.statusline_style.left, provider = separator_style.left,
enabled = default.shortline or function(winid)
return vim.api.nvim_win_get_width(tonumber(winid) or 0) > 90
end,
hl = { hl = {
fg = default.colors.green, fg = colors.green,
bg = default.colors.grey, bg = colors.grey,
}, },
} }
default.position_icon = { local position_icon = {
provider = default.statusline_style.position_icon, provider = separator_style.position_icon,
enabled = default.shortline or function(winid)
return vim.api.nvim_win_get_width(tonumber(winid) or 0) > 90
end,
hl = { hl = {
fg = default.colors.black, fg = colors.black,
bg = default.colors.green, bg = colors.green,
}, },
} }
default.current_line = { local current_line = {
provider = function() provider = function()
local current_line = vim.fn.line "." local current_line = vim.fn.line "."
local total_line = vim.fn.line "$" local total_line = vim.fn.line "$"
@ -372,13 +341,9 @@ default.current_line = {
return " " .. result .. "%% " return " " .. result .. "%% "
end, end,
enabled = default.shortline or function(winid)
return vim.api.nvim_win_get_width(tonumber(winid) or 0) > 90
end,
hl = { hl = {
fg = default.colors.green, fg = colors.green,
bg = default.colors.one_bg, bg = colors.one_bg,
}, },
} }
@ -386,53 +351,45 @@ local function add_table(a, b)
table.insert(a, b) table.insert(a, b)
end end
local M = {} -- components are divided in 3 sections
M.setup = function(override_flag) local left = {}
if override_flag then local middle = {}
default = require("core.utils").tbl_override_req("feline", default) local right = {}
end
-- components are divided in 3 sections
default.left = {}
default.middle = {}
default.right = {}
-- left -- left
add_table(default.left, default.main_icon) add_table(left, main_icon)
add_table(default.left, default.file_name) add_table(left, file_name)
add_table(default.left, default.dir_name) add_table(left, dir_name)
add_table(default.left, default.diff.add) add_table(left, diff.add)
add_table(default.left, default.diff.change) add_table(left, diff.change)
add_table(default.left, default.diff.remove) add_table(left, diff.remove)
add_table(default.left, default.diagnostic.error) add_table(left, diagnostic.error)
add_table(default.left, default.diagnostic.warning) add_table(left, diagnostic.warning)
add_table(default.left, default.diagnostic.hint) add_table(left, diagnostic.hint)
add_table(default.left, default.diagnostic.info) add_table(left, diagnostic.info)
add_table(default.middle, default.lsp_progress) add_table(middle, lsp_progress)
-- right -- right
add_table(default.right, default.lsp_icon) add_table(right, lsp_icon)
add_table(default.right, default.git_branch) add_table(right, git_branch)
add_table(default.right, default.empty_space) add_table(right, empty_space)
add_table(default.right, default.empty_spaceColored) add_table(right, empty_spaceColored)
add_table(default.right, default.mode_icon) add_table(right, mode_icon)
add_table(default.right, default.empty_space2) add_table(right, empty_space2)
add_table(default.right, default.separator_right) add_table(right, separator_right)
add_table(default.right, default.separator_right2) add_table(right, separator_right2)
add_table(default.right, default.position_icon) add_table(right, position_icon)
add_table(default.right, default.current_line) add_table(right, current_line)
default.components.active[1] = default.left components.active[1] = left
default.components.active[2] = default.middle components.active[2] = middle
default.components.active[3] = default.right components.active[3] = right
feline.setup { feline.setup {
theme = { theme = {
bg = default.colors.statusline_bg, bg = colors.statusline_bg,
fg = default.colors.fg, fg = colors.fg,
}, },
components = default.components, components = components,
} }
end
return M

View File

@ -4,7 +4,7 @@ if not present then
return return
end end
local default = { local options = {
defaults = { defaults = {
vimgrep_arguments = { vimgrep_arguments = {
"rg", "rg",
@ -53,21 +53,15 @@ local default = {
}, },
} }
local M = {} -- check for any override
M.setup = function(override_flag) options = require("core.utils").load_override(options, "nvim-telescope/telescope.nvim")
if override_flag then telescope.setup(options)
default = require("core.utils").tbl_override_req("telescope", default)
end
telescope.setup(default) -- load extensions
local extensions = { "themes", "terms" }
local extensions = { "themes", "terms" } pcall(function()
pcall(function()
for _, ext in ipairs(extensions) do for _, ext in ipairs(extensions) do
telescope.load_extension(ext) telescope.load_extension(ext)
end end
end) end)
end
return M

View File

@ -1,10 +1,10 @@
local present, ts_config = pcall(require, "nvim-treesitter.configs") local present, treesitter = pcall(require, "nvim-treesitter.configs")
if not present then if not present then
return return
end end
local default = { local options = {
ensure_installed = { ensure_installed = {
"lua", "lua",
"vim", "vim",
@ -15,12 +15,7 @@ local default = {
}, },
} }
local M = {} -- check for any override
M.setup = function(override_flag) options = require("core.utils").load_override(options, "nvim-treesitter/nvim-treesitter")
if override_flag then
default = require("core.utils").tbl_override_req("nvim_treesitter", default)
end
ts_config.setup(default)
end
return M treesitter.setup(options)

View File

@ -5,84 +5,83 @@ if not present then
return false return false
end end
local override_req = require("core.utils").override_req
local plugins = { local plugins = {
{ "nvim-lua/plenary.nvim" }, ["nvim-lua/plenary.nvim"] = {},
{ "lewis6991/impatient.nvim" }, ["lewis6991/impatient.nvim"] = {},
{ "nathom/filetype.nvim" },
{ ["wbthomason/packer.nvim"] = {
"wbthomason/packer.nvim",
event = "VimEnter", event = "VimEnter",
}, },
{ ["NvChad/extensions"] = {},
"NvChad/extensions",
config = function ()
vim.schedule_wrap(require("nvchad.terminal").init())
end
},
{ ["NvChad/nvim-base16.lua"] = {
"NvChad/nvim-base16.lua",
after = "packer.nvim", after = "packer.nvim",
config = function() config = function()
require("colors").init() require("colors").init()
end, end,
}, },
{ ["NvChad/nvterm"] = {
"kyazdani42/nvim-web-devicons", config = function()
after = "nvim-base16.lua", require "plugins.configs.nvterm"
config = override_req("nvim_web_devicons", "plugins.configs.icons", "setup"),
},
{
"feline-nvim/feline.nvim",
disable = not plugin_settings.status.feline,
after = "nvim-web-devicons",
config = override_req("feline", "plugins.configs.statusline", "setup"),
},
{
"akinsho/bufferline.nvim",
branch = "main",
disable = not plugin_settings.status.bufferline,
after = "nvim-web-devicons",
config = override_req("bufferline", "plugins.configs.bufferline", "setup"),
setup = function()
require("core.mappings").bufferline()
end, end,
}, },
{ ["kyazdani42/nvim-web-devicons"] = {
"lukas-reineke/indent-blankline.nvim", after = "nvim-base16.lua",
disable = not plugin_settings.status.blankline, config = function()
event = "BufRead", require "plugins.configs.icons"
config = override_req("indent_blankline", "plugins.configs.others", "blankline"), end,
}, },
{ ["feline-nvim/feline.nvim"] = {
"NvChad/nvim-colorizer.lua", after = "nvim-web-devicons",
disable = not plugin_settings.status.colorizer, config = function()
event = "BufRead", require "plugins.configs.statusline"
config = override_req("nvim_colorizer", "plugins.configs.others", "colorizer"), end,
}, },
{ ["akinsho/bufferline.nvim"] = {
"nvim-treesitter/nvim-treesitter", after = "nvim-web-devicons",
setup = function()
require("core.mappings").bufferline()
end,
config = function()
require "plugins.configs.bufferline"
end,
},
["lukas-reineke/indent-blankline.nvim"] = {
event = "BufRead",
config = function()
require("plugins.configs.others").blankline()
end,
},
["NvChad/nvim-colorizer.lua"] = {
event = "BufRead",
config = function()
require("plugins.configs.others").colorizer()
end,
},
["nvim-treesitter/nvim-treesitter"] = {
event = { "BufRead", "BufNewFile" }, event = { "BufRead", "BufNewFile" },
config = override_req("nvim_treesitter", "plugins.configs.treesitter", "setup"),
run = ":TSUpdate", run = ":TSUpdate",
config = function()
require "plugins.configs.treesitter"
end,
}, },
-- git stuff -- git stuff
{ ["lewis6991/gitsigns.nvim"] = {
"lewis6991/gitsigns.nvim",
disable = not plugin_settings.status.gitsigns,
opt = true, opt = true,
config = override_req("gitsigns", "plugins.configs.others", "gitsigns"), config = function()
require("plugins.configs.others").gitsigns()
end,
setup = function() setup = function()
require("core.utils").packer_lazy_load "gitsigns.nvim" require("core.utils").packer_lazy_load "gitsigns.nvim"
end, end,
@ -90,8 +89,7 @@ local plugins = {
-- lsp stuff -- lsp stuff
{ ["neovim/nvim-lspconfig"] = {
"neovim/nvim-lspconfig",
module = "lspconfig", module = "lspconfig",
opt = true, opt = true,
setup = function() setup = function()
@ -101,141 +99,131 @@ local plugins = {
vim.cmd 'if &ft == "packer" | echo "" | else | silent! e %' vim.cmd 'if &ft == "packer" | echo "" | else | silent! e %'
end, 0) end, 0)
end, end,
config = override_req("lspconfig", "plugins.configs.lspconfig"), config = function()
require "plugins.configs.lspconfig"
end,
}, },
{ ["ray-x/lsp_signature.nvim"] = {
"ray-x/lsp_signature.nvim",
disable = not plugin_settings.status.lspsignature,
after = "nvim-lspconfig", after = "nvim-lspconfig",
config = override_req("signature", "plugins.configs.others", "signature"), config = function()
require("plugins.configs.others").signature()
end,
}, },
{ ["andymass/vim-matchup"] = {
"andymass/vim-matchup",
disable = not plugin_settings.status.vim_matchup,
opt = true, opt = true,
setup = function() setup = function()
require("core.utils").packer_lazy_load "vim-matchup" require("core.utils").packer_lazy_load "vim-matchup"
end, end,
}, },
{ ["max397574/better-escape.nvim"] = {
"max397574/better-escape.nvim",
disable = not plugin_settings.status.better_escape,
event = "InsertCharPre", event = "InsertCharPre",
config = override_req("better_escape", "plugins.configs.others", "better_escape"), config = function()
require("plugins.configs.others").better_escape()
end,
}, },
-- load luasnips + cmp related in insert mode only -- load luasnips + cmp related in insert mode only
{ ["rafamadriz/friendly-snippets"] = {
"rafamadriz/friendly-snippets",
module = "cmp_nvim_lsp", module = "cmp_nvim_lsp",
disable = not plugin_settings.status.cmp,
event = "InsertEnter", event = "InsertEnter",
}, },
{ ["hrsh7th/nvim-cmp"] = {
"hrsh7th/nvim-cmp",
disable = not plugin_settings.status.cmp,
after = "friendly-snippets", after = "friendly-snippets",
config = override_req("nvim_cmp", "plugins.configs.cmp", "setup"), config = function()
require "plugins.configs.cmp"
end,
}, },
{ ["L3MON4D3/LuaSnip"] = {
"L3MON4D3/LuaSnip",
disable = not plugin_settings.status.cmp,
wants = "friendly-snippets", wants = "friendly-snippets",
after = "nvim-cmp", after = "nvim-cmp",
config = override_req("luasnip", "plugins.configs.others", "luasnip"), config = function()
require("plugins.configs.others").luasnip()
end,
}, },
{ ["saadparwaiz1/cmp_luasnip"] = {
"saadparwaiz1/cmp_luasnip", after = "LuaSnip",
disable = not plugin_settings.status.cmp,
after = plugin_settings.options.cmp.lazy_load and "LuaSnip",
}, },
{ ["hrsh7th/cmp-nvim-lua"] = {
"hrsh7th/cmp-nvim-lua",
disable = not plugin_settings.status.cmp,
after = "cmp_luasnip", after = "cmp_luasnip",
}, },
{ ["hrsh7th/cmp-nvim-lsp"] = {
"hrsh7th/cmp-nvim-lsp",
disable = not plugin_settings.status.cmp,
after = "cmp-nvim-lua", after = "cmp-nvim-lua",
}, },
{ ["hrsh7th/cmp-buffer"] = {
"hrsh7th/cmp-buffer",
disable = not plugin_settings.status.cmp,
after = "cmp-nvim-lsp", after = "cmp-nvim-lsp",
}, },
{ ["hrsh7th/cmp-path"] = {
"hrsh7th/cmp-path",
disable = not plugin_settings.status.cmp,
after = "cmp-buffer", after = "cmp-buffer",
}, },
-- misc plugins -- misc plugins
{ ["windwp/nvim-autopairs"] = {
"windwp/nvim-autopairs", after = "nvim-cmp",
disable = not plugin_settings.status.autopairs, config = function()
after = plugin_settings.options.autopairs.loadAfter, require("plugins.configs.others").autopairs()
config = override_req("nvim_autopairs", "plugins.configs.others", "autopairs"), end,
}, },
{ ["goolord/alpha-nvim"] = {
disable = not plugin_settings.status.alpha, disable = true,
"goolord/alpha-nvim", config = function()
config = override_req("alpha", "plugins.configs.alpha", "setup"), require "plugins.configs.alpha"
end,
}, },
{ ["numToStr/Comment.nvim"] = {
"numToStr/Comment.nvim",
disable = not plugin_settings.status.comment,
module = "Comment", module = "Comment",
keys = { "gcc" }, keys = { "gcc" },
config = override_req("nvim_comment", "plugins.configs.others", "comment"),
setup = function() setup = function()
require("core.mappings").comment() require("core.mappings").comment()
end, end,
config = function()
require("plugins.configs.others").comment()
end,
}, },
-- file managing , picker etc -- file managing , picker etc
{ ["kyazdani42/nvim-tree.lua"] = {
"kyazdani42/nvim-tree.lua", cmd = { "NvimTreeToggle", "NvimTreeFocus" },
disable = not plugin_settings.status.nvimtree,
-- only set "after" if lazy load is disabled and vice versa for "cmd"
after = not plugin_settings.options.nvimtree.lazy_load and "nvim-web-devicons",
cmd = plugin_settings.options.nvimtree.lazy_load and { "NvimTreeToggle", "NvimTreeFocus" },
config = override_req("nvim_tree", "plugins.configs.nvimtree", "setup"),
setup = function() setup = function()
require("core.mappings").nvimtree() require("core.mappings").nvimtree()
end, end,
config = function()
require "plugins.configs.nvimtree"
end,
}, },
{ ["nvim-telescope/telescope.nvim"] = {
"nvim-telescope/telescope.nvim",
module = "telescope", module = "telescope",
cmd = "Telescope", cmd = "Telescope",
config = override_req("telescope", "plugins.configs.telescope", "setup"),
setup = function() setup = function()
require("core.mappings").telescope() require("core.mappings").telescope()
end, end,
config = function()
require "plugins.configs.telescope"
end,
}, },
} }
--label plugins for operational assistance -- merge user plugin table & default plugin table
plugins = require("core.utils").label_plugins(plugins) plugins = require("core.utils").plugin_list(plugins)
--remove plugins specified in chadrc
plugins = require("core.utils").remove_default_plugins(plugins)
--add plugins specified in chadrc
plugins = require("core.utils").add_user_plugins(plugins)
return packer.startup(function(use) return packer.startup(function(use)
for _, v in pairs(plugins) do for _, v in pairs(plugins) do