From 6f0aa376a8f8e52d33cede45e903767644c7e401 Mon Sep 17 00:00:00 2001 From: siduck Date: Fri, 22 Jul 2022 16:00:00 +0000 Subject: [PATCH] set shiftwidth to 2 | format all files big thanks to @ghifarit53 --- .stylua.toml | 2 +- examples/chadrc.lua | 2 +- init.lua | 2 +- lua/core/default_config.lua | 42 +- lua/core/init.lua | 82 +-- lua/core/lazy_load.lua | 150 +++--- lua/core/mappings.lua | 696 +++++++++++++------------- lua/core/options.lua | 73 +-- lua/core/packer.lua | 74 +-- lua/core/utils.lua | 338 ++++++------- lua/plugins/configs/alpha.lua | 118 ++--- lua/plugins/configs/cmp.lua | 156 +++--- lua/plugins/configs/lsp_installer.lua | 44 +- lua/plugins/configs/lspconfig.lua | 96 ++-- lua/plugins/configs/nvchad_ui.lua | 48 +- lua/plugins/configs/nvimtree.lua | 140 +++--- lua/plugins/configs/nvterm.lua | 40 +- lua/plugins/configs/others.lua | 260 +++++----- lua/plugins/configs/telescope.lua | 102 ++-- lua/plugins/configs/treesitter.lua | 16 +- lua/plugins/configs/whichkey.lua | 44 +- lua/plugins/init.lua | 372 +++++++------- 22 files changed, 1449 insertions(+), 1448 deletions(-) diff --git a/.stylua.toml b/.stylua.toml index f4c1cee..ecb6dca 100644 --- a/.stylua.toml +++ b/.stylua.toml @@ -1,6 +1,6 @@ column_width = 120 line_endings = "Unix" indent_type = "Spaces" -indent_width = 3 +indent_width = 2 quote_style = "AutoPreferDouble" call_parentheses = "None" diff --git a/examples/chadrc.lua b/examples/chadrc.lua index 6aa2521..62bfd71 100644 --- a/examples/chadrc.lua +++ b/examples/chadrc.lua @@ -6,7 +6,7 @@ local M = {} -- example of changing theme: M.ui = { - theme = "gruvchad", + theme = "gruvchad", } return M diff --git a/init.lua b/init.lua index 2237c5c..05ee549 100644 --- a/init.lua +++ b/init.lua @@ -2,7 +2,7 @@ require "core" require "core.options" vim.defer_fn(function() - require("core.utils").load_mappings() + require("core.utils").load_mappings() end, 0) -- setup packer + plugins diff --git a/lua/core/default_config.lua b/lua/core/default_config.lua index db0935a..755a134 100644 --- a/lua/core/default_config.lua +++ b/lua/core/default_config.lua @@ -3,34 +3,34 @@ local M = {} M.options = { - -- load your options here or load module with options - user = function() end, + -- load your options here or load module with options + user = function() end, - nvChad = { - update_url = "https://github.com/NvChad/NvChad", - update_branch = "main", - }, + 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, + -- hl = highlights + hl_add = {}, + hl_override = {}, + changed_themes = {}, + theme_toggle = { "onedark", "one_light" }, + theme = "onedark", -- default theme + transparency = false, } M.plugins = { - override = {}, - remove = {}, - user = {}, - options = { - lspconfig = { - setup_lspconf = "", -- path of lspconfig file - }, - }, + override = {}, + remove = {}, + user = {}, + options = { + lspconfig = { + setup_lspconf = "", -- path of lspconfig file + }, + }, } -- check core.mappings for table structure diff --git a/lua/core/init.lua b/lua/core/init.lua index c9c5a1e..4ec415e 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -10,38 +10,38 @@ local api = vim.api -- dont list quickfix buffers autocmd("FileType", { - pattern = "qf", - callback = function() - vim.opt_local.buflisted = false - end, + 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('core.utils').packer_sync()" - end, + callback = function() + vim.cmd "command! -nargs=* -complete=customlist,v:lua.require'packer'.plugin_complete PackerSync lua require('core.utils').packer_sync()" + end, }) -- Disable statusline in dashboard autocmd("FileType", { - pattern = "alpha", - callback = function() - vim.opt.laststatus = 0 - end, + pattern = "alpha", + callback = function() + vim.opt.laststatus = 0 + end, }) autocmd("BufUnload", { - buffer = 0, - callback = function() - vim.opt.laststatus = 3 - end, + buffer = 0, + callback = function() + vim.opt.laststatus = 3 + end, }) -- Don't auto commenting new lines autocmd("BufEnter", { - pattern = "*", - command = "set fo-=c fo-=r fo-=o", + pattern = "*", + command = "set fo-=c fo-=r fo-=o", }) -- store listed buffers in tab local var @@ -50,34 +50,34 @@ vim.t.bufs = vim.api.nvim_list_bufs() -- autocmds for tabufline -> store bufnrs on bufadd, bufenter events -- thx to https://github.com/ii14 & stores buffer per tab -> table autocmd({ "BufAdd", "BufEnter" }, { - callback = function(args) - if vim.t.bufs == nil then - vim.t.bufs = { args.buf } - else - local bufs = vim.t.bufs + callback = function(args) + if vim.t.bufs == nil then + vim.t.bufs = { args.buf } + else + local bufs = vim.t.bufs - -- check for duplicates - if not vim.tbl_contains(bufs, args.buf) and (args.event == "BufAdd" or vim.bo[args.buf].buflisted) then - table.insert(bufs, args.buf) - vim.t.bufs = bufs - end + -- check for duplicates + if not vim.tbl_contains(bufs, args.buf) and (args.event == "BufAdd" or vim.bo[args.buf].buflisted) then + table.insert(bufs, args.buf) + vim.t.bufs = bufs end - end, + end + end, }) autocmd("BufDelete", { - callback = function(args) - for _, tab in ipairs(api.nvim_list_tabpages()) do - local bufs = vim.t[tab].bufs - if bufs then - for i, bufnr in ipairs(bufs) do - if bufnr == args.buf then - table.remove(bufs, i) - vim.t[tab].bufs = bufs - break - end - end - end + callback = function(args) + for _, tab in ipairs(api.nvim_list_tabpages()) do + local bufs = vim.t[tab].bufs + if bufs then + for i, bufnr in ipairs(bufs) do + if bufnr == args.buf then + table.remove(bufs, i) + vim.t[tab].bufs = bufs + break + end + end end - end, + end + end, }) diff --git a/lua/core/lazy_load.lua b/lua/core/lazy_load.lua index 63da723..0237897 100644 --- a/lua/core/lazy_load.lua +++ b/lua/core/lazy_load.lua @@ -4,37 +4,37 @@ local autocmd = vim.api.nvim_create_autocmd -- 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, { - pattern = "*", - 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) + autocmd(tb.events, { + pattern = "*", + 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.plugins ~= "nvim-treesitter" then - vim.defer_fn(function() - vim.cmd("PackerLoad " .. tb.plugins) - end, 0) - else - vim.cmd("PackerLoad " .. tb.plugins) - end - end - end, - }) + -- dont defer for treesitter as it will show slow highlighting + -- This deferring only happens only when we do "nvim filename" + if tb.plugins ~= "nvim-treesitter" then + vim.defer_fn(function() + vim.cmd("PackerLoad " .. tb.plugins) + end, 0) + else + vim.cmd("PackerLoad " .. tb.plugins) + end + end + end, + }) end M.colorizer = function() - M.lazy_load { - events = { "BufRead", "BufNewFile" }, - augroup_name = "ColorizerLazy", - plugins = "nvim-colorizer.lua", + M.lazy_load { + events = { "BufRead", "BufNewFile" }, + augroup_name = "ColorizerLazy", + plugins = "nvim-colorizer.lua", - condition = function() - return true - end, - } + condition = function() + return true + end, + } end -- load certain plugins only when there's a file opened in the buffer @@ -42,65 +42,65 @@ end -- 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, - plugins = plugin_name, - condition = function() - local file = vim.fn.expand "%" - return file ~= "NvimTree_1" and file ~= "[packer]" and file ~= "" - end, - } + M.lazy_load { + events = { "BufRead", "BufWinEnter", "BufNewFile" }, + augroup_name = "BeLazyOnFileOpen" .. plugin_name, + plugins = plugin_name, + condition = function() + local file = vim.fn.expand "%" + return file ~= "NvimTree_1" and file ~= "[packer]" and file ~= "" + end, + } end -- lspinstaller & lspconfig cmds for lazyloading M.lsp_cmds = { - "LspInfo", - "LspStart", - "LspRestart", - "LspStop", - "LspInstall", - "LspUnInstall", - "LspUnInstallAll", - "LspInstall", - "LspInstallInfo", - "LspInstallLog", - "LspLog", - "LspPrintInstalled", + "LspInfo", + "LspStart", + "LspRestart", + "LspStop", + "LspInstall", + "LspUnInstall", + "LspUnInstallAll", + "LspInstall", + "LspInstallInfo", + "LspInstallLog", + "LspLog", + "LspPrintInstalled", } M.treesitter_cmds = { - "TSInstall", - "TSBufEnable", - "TSBufDisable", - "TSEnable", - "TSDisable", - "TSModuleInfo", + "TSInstall", + "TSBufEnable", + "TSBufDisable", + "TSEnable", + "TSDisable", + "TSModuleInfo", } M.gitsigns = function() - -- taken from https://github.com/max397574 - autocmd({ "BufRead" }, { - callback = function() - local function onexit(code, _) - if code == 0 then - vim.schedule(function() - require("packer").loader "gitsigns.nvim" - end) - end - end - local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false) - if lines ~= { "" } then - vim.loop.spawn("git", { - args = { - "ls-files", - "--error-unmatch", - vim.fn.expand "%:p:h", - }, - }, onexit) - end - end, - }) + -- taken from https://github.com/max397574 + autocmd({ "BufRead" }, { + callback = function() + local function onexit(code, _) + if code == 0 then + vim.schedule(function() + require("packer").loader "gitsigns.nvim" + end) + end + end + local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false) + if lines ~= { "" } then + vim.loop.spawn("git", { + args = { + "ls-files", + "--error-unmatch", + vim.fn.expand "%:p:h", + }, + }, onexit) + end + end, + }) end return M diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index 5ad223f..d44c73f 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -1,387 +1,387 @@ -- n, v, i, t = mode names local function termcodes(str) - return vim.api.nvim_replace_termcodes(str, true, true, true) + return vim.api.nvim_replace_termcodes(str, true, true, true) end local M = {} M.general = { - i = { - - -- go to beginning and end - [""] = { "^i", "論 beginning of line" }, - [""] = { "", "壟 end of line" }, - - -- navigate within insert mode - [""] = { "", " move left" }, - [""] = { "", " move right" }, - [""] = { "", " move down" }, - [""] = { "", " move up" }, - }, - - n = { - - [""] = { " noh ", " no highlight" }, - - -- switch between windows - [""] = { "h", " window left" }, - [""] = { "l", " window right" }, - [""] = { "j", " window down" }, - [""] = { "k", " window up" }, - - -- save - [""] = { " w ", "﬚ save file" }, - - -- Copy all - [""] = { " %y+ ", " copy whole file" }, - - -- line numbers - ["n"] = { " set nu! ", " toggle line number" }, - ["rn"] = { " set rnu! ", " toggle relative number" }, - - -- update nvchad - ["uu"] = { " :NvChadUpdate ", " update nvchad" }, - - ["tt"] = { - function() - require("base46").toggle_theme() - end, - - " toggle theme", - }, - - -- Allow moving the cursor through wrapped lines with j, k, and - -- 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 - ["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 } }, - [""] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', opts = { expr = true } }, - [""] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', opts = { expr = true } }, - }, - - t = { - [""] = { termcodes "", " escape terminal mode" }, - }, - - v = { - ["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 } }, - [""] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', opts = { expr = true } }, - [""] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', 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:let @"=@0', opts = { silent = true } }, - }, + i = { + + -- go to beginning and end + [""] = { "^i", "論 beginning of line" }, + [""] = { "", "壟 end of line" }, + + -- navigate within insert mode + [""] = { "", " move left" }, + [""] = { "", " move right" }, + [""] = { "", " move down" }, + [""] = { "", " move up" }, + }, + + n = { + + [""] = { " noh ", " no highlight" }, + + -- switch between windows + [""] = { "h", " window left" }, + [""] = { "l", " window right" }, + [""] = { "j", " window down" }, + [""] = { "k", " window up" }, + + -- save + [""] = { " w ", "﬚ save file" }, + + -- Copy all + [""] = { " %y+ ", " copy whole file" }, + + -- line numbers + ["n"] = { " set nu! ", " toggle line number" }, + ["rn"] = { " set rnu! ", " toggle relative number" }, + + -- update nvchad + ["uu"] = { " :NvChadUpdate ", " update nvchad" }, + + ["tt"] = { + function() + require("base46").toggle_theme() + end, + + " toggle theme", + }, + + -- Allow moving the cursor through wrapped lines with j, k, and + -- 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 + ["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 } }, + [""] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', opts = { expr = true } }, + [""] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', opts = { expr = true } }, + }, + + t = { + [""] = { termcodes "", " escape terminal mode" }, + }, + + v = { + ["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 } }, + [""] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', opts = { expr = true } }, + [""] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', 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:let @"=@0', opts = { silent = true } }, + }, } M.tabufline = { - n = { - -- new buffer - [""] = { " enew ", "烙 new buffer" }, - - -- cycle through buffers - [""] = { " Tbufnext ", " goto next buffer" }, - [""] = { " Tbufprev ", " goto prev buffer" }, - - -- cycle through tabs - ["tp"] = { " tabprevious ", " goto next tab" }, - ["tn"] = { " tabnext ", " goto prev tab" }, - - -- close buffer + hide terminal buffer - ["x"] = { - function() - require("core.utils").close_buffer() - end, - " close buffer", - }, - }, + n = { + -- new buffer + [""] = { " enew ", "烙 new buffer" }, + + -- cycle through buffers + [""] = { " Tbufnext ", " goto next buffer" }, + [""] = { " Tbufprev ", " goto prev buffer" }, + + -- cycle through tabs + ["tp"] = { " tabprevious ", " goto next tab" }, + ["tn"] = { " tabnext ", " goto prev tab" }, + + -- close buffer + hide terminal buffer + ["x"] = { + function() + require("core.utils").close_buffer() + end, + " close buffer", + }, + }, } M.comment = { - -- toggle comment in both modes - n = { - ["/"] = { - function() - require("Comment.api").toggle_current_linewise() - end, - - "蘒 toggle comment", - }, - }, - - v = { - ["/"] = { - "lua require('Comment.api').toggle_linewise_op(vim.fn.visualmode())", - "蘒 toggle comment", - }, - }, + -- toggle comment in both modes + n = { + ["/"] = { + function() + require("Comment.api").toggle_current_linewise() + end, + + "蘒 toggle comment", + }, + }, + + v = { + ["/"] = { + "lua require('Comment.api').toggle_linewise_op(vim.fn.visualmode())", + "蘒 toggle comment", + }, + }, } M.lspconfig = { - -- See ` :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", - }, - - ["ls"] = { - function() - vim.lsp.buf.signature_help() - end, - " lsp signature_help", - }, - - ["D"] = { - function() - vim.lsp.buf.type_definition() - end, - " lsp definition type", - }, - - ["ra"] = { - function() - require("nvchad_ui.renamer").open() - end, - " lsp rename", - }, - - ["ca"] = { - function() - vim.lsp.buf.code_action() - end, - " lsp code_action", - }, - - ["gr"] = { - function() - vim.lsp.buf.references() - end, - " lsp references", - }, - - ["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", - }, - - ["q"] = { - function() - vim.diagnostic.setloclist() - end, - " diagnostic setloclist", - }, - - ["fm"] = { - function() - vim.lsp.buf.formatting() - end, - " lsp formatting", - }, - - ["wa"] = { - function() - vim.lsp.buf.add_workspace_folder() - end, - " add workspace folder", - }, - - ["wr"] = { - function() - vim.lsp.buf.remove_workspace_folder() - end, - " remove workspace folder", - }, - - ["wl"] = { - function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, - " list workspace folders", - }, - }, + -- See ` :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", + }, + + ["ls"] = { + function() + vim.lsp.buf.signature_help() + end, + " lsp signature_help", + }, + + ["D"] = { + function() + vim.lsp.buf.type_definition() + end, + " lsp definition type", + }, + + ["ra"] = { + function() + require("nvchad_ui.renamer").open() + end, + " lsp rename", + }, + + ["ca"] = { + function() + vim.lsp.buf.code_action() + end, + " lsp code_action", + }, + + ["gr"] = { + function() + vim.lsp.buf.references() + end, + " lsp references", + }, + + ["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", + }, + + ["q"] = { + function() + vim.diagnostic.setloclist() + end, + " diagnostic setloclist", + }, + + ["fm"] = { + function() + vim.lsp.buf.formatting() + end, + " lsp formatting", + }, + + ["wa"] = { + function() + vim.lsp.buf.add_workspace_folder() + end, + " add workspace folder", + }, + + ["wr"] = { + function() + vim.lsp.buf.remove_workspace_folder() + end, + " remove workspace folder", + }, + + ["wl"] = { + function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, + " list workspace folders", + }, + }, } M.nvimtree = { - n = { - -- toggle - [""] = { " NvimTreeToggle ", " toggle nvimtree" }, + n = { + -- toggle + [""] = { " NvimTreeToggle ", " toggle nvimtree" }, - -- focus - ["e"] = { " NvimTreeFocus ", " focus nvimtree" }, - }, + -- focus + ["e"] = { " NvimTreeFocus ", " focus nvimtree" }, + }, } M.telescope = { - n = { - -- find - ["ff"] = { " Telescope find_files ", " find files" }, - ["fa"] = { " Telescope find_files follow=true no_ignore=true hidden=true ", " find all" }, - ["fw"] = { " Telescope live_grep ", " live grep" }, - ["fb"] = { " Telescope buffers ", " find buffers" }, - ["fh"] = { " Telescope help_tags ", " help page" }, - ["fo"] = { " Telescope oldfiles ", " find oldfiles" }, - ["tk"] = { " Telescope keymaps ", " show keys" }, - - -- git - ["cm"] = { " Telescope git_commits ", " git commits" }, - ["gt"] = { " Telescope git_status ", " git status" }, - - -- pick a hidden term - ["pt"] = { " Telescope terms ", " pick hidden term" }, - - -- theme switcher - ["th"] = { " Telescope themes ", " nvchad themes" }, - }, + n = { + -- find + ["ff"] = { " Telescope find_files ", " find files" }, + ["fa"] = { " Telescope find_files follow=true no_ignore=true hidden=true ", " find all" }, + ["fw"] = { " Telescope live_grep ", " live grep" }, + ["fb"] = { " Telescope buffers ", " find buffers" }, + ["fh"] = { " Telescope help_tags ", " help page" }, + ["fo"] = { " Telescope oldfiles ", " find oldfiles" }, + ["tk"] = { " Telescope keymaps ", " show keys" }, + + -- git + ["cm"] = { " Telescope git_commits ", " git commits" }, + ["gt"] = { " Telescope git_status ", " git status" }, + + -- pick a hidden term + ["pt"] = { " Telescope terms ", " pick hidden term" }, + + -- theme switcher + ["th"] = { " Telescope themes ", " nvchad themes" }, + }, } M.nvterm = { - t = { - -- toggle in terminal mode - [""] = { - function() - require("nvterm.terminal").toggle "float" - end, - " toggle floating term", - }, - - [""] = { - function() - require("nvterm.terminal").toggle "horizontal" - end, - " toggle horizontal term", - }, - - [""] = { - function() - require("nvterm.terminal").toggle "vertical" - end, - " toggle vertical term", - }, - }, - - n = { - -- toggle in normal mode - [""] = { - function() - require("nvterm.terminal").toggle "float" - end, - " toggle floating term", - }, - - [""] = { - function() - require("nvterm.terminal").toggle "horizontal" - end, - " toggle horizontal term", - }, - - [""] = { - function() - require("nvterm.terminal").toggle "vertical" - end, - " toggle vertical term", - }, - - -- new - - ["h"] = { - function() - require("nvterm.terminal").new "horizontal" - end, - " new horizontal term", - }, - - ["v"] = { - function() - require("nvterm.terminal").new "vertical" - end, - " new vertical term", - }, - }, + t = { + -- toggle in terminal mode + [""] = { + function() + require("nvterm.terminal").toggle "float" + end, + " toggle floating term", + }, + + [""] = { + function() + require("nvterm.terminal").toggle "horizontal" + end, + " toggle horizontal term", + }, + + [""] = { + function() + require("nvterm.terminal").toggle "vertical" + end, + " toggle vertical term", + }, + }, + + n = { + -- toggle in normal mode + [""] = { + function() + require("nvterm.terminal").toggle "float" + end, + " toggle floating term", + }, + + [""] = { + function() + require("nvterm.terminal").toggle "horizontal" + end, + " toggle horizontal term", + }, + + [""] = { + function() + require("nvterm.terminal").toggle "vertical" + end, + " toggle vertical term", + }, + + -- new + + ["h"] = { + function() + require("nvterm.terminal").new "horizontal" + end, + " new horizontal term", + }, + + ["v"] = { + function() + require("nvterm.terminal").new "vertical" + end, + " new vertical term", + }, + }, } M.whichkey = { - n = { - ["wK"] = { - function() - vim.cmd "WhichKey" - end, - " which-key all keymaps", - }, - ["wk"] = { - function() - local input = vim.fn.input "WhichKey: " - vim.cmd("WhichKey " .. input) - end, - " which-key query lookup", - }, - }, + n = { + ["wK"] = { + function() + vim.cmd "WhichKey" + end, + " which-key all keymaps", + }, + ["wk"] = { + function() + local input = vim.fn.input "WhichKey: " + vim.cmd("WhichKey " .. input) + end, + " which-key query lookup", + }, + }, } M.blankline = { - n = { - ["bc"] = { - 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", - }, - }, + n = { + ["bc"] = { + 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", + }, + }, } return M diff --git a/lua/core/options.lua b/lua/core/options.lua index 73e56ef..793d483 100644 --- a/lua/core/options.lua +++ b/lua/core/options.lua @@ -20,8 +20,10 @@ opt.cul = true -- cursor line -- Indenting opt.expandtab = true -opt.shiftwidth = 3 +opt.shiftwidth = 2 opt.smartindent = true +opt.tabstop = 2 +opt.softtabstop = 2 opt.fillchars = { eob = " " } opt.ignorecase = true @@ -39,7 +41,6 @@ opt.shortmess:append "sI" opt.signcolumn = "yes" opt.splitbelow = true opt.splitright = true -opt.tabstop = 8 opt.termguicolors = true opt.timeoutlen = 400 opt.undofile = true @@ -55,53 +56,53 @@ 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", + "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 + g["loaded_" .. plugin] = 1 end local default_providers = { - "node", - "perl", - "python3", - "ruby", + "node", + "perl", + "python3", + "ruby", } for _, provider in ipairs(default_providers) do - vim.g["loaded_" .. provider .. "_provider"] = 0 + vim.g["loaded_" .. provider .. "_provider"] = 0 end -- set shada path vim.schedule(function() - vim.opt.shadafile = vim.fn.expand "$HOME" .. "/.local/share/nvim/shada/main.shada" - vim.cmd [[ silent! rsh ]] + vim.opt.shadafile = vim.fn.expand "$HOME" .. "/.local/share/nvim/shada/main.shada" + vim.cmd [[ silent! rsh ]] end) -- load user options diff --git a/lua/core/packer.lua b/lua/core/packer.lua index 575cefc..b193b75 100644 --- a/lua/core/packer.lua +++ b/lua/core/packer.lua @@ -1,59 +1,59 @@ local M = {} M.bootstrap = function() - local fn = vim.fn - local install_path = fn.stdpath "data" .. "/site/pack/packer/start/packer.nvim" + local fn = vim.fn + local install_path = fn.stdpath "data" .. "/site/pack/packer/start/packer.nvim" - vim.api.nvim_set_hl(0, "NormalFloat", { bg = "#1e222a" }) + vim.api.nvim_set_hl(0, "NormalFloat", { bg = "#1e222a" }) - if fn.empty(fn.glob(install_path)) > 0 then - print "Cloning packer .." - fn.system { "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path } + if fn.empty(fn.glob(install_path)) > 0 then + print "Cloning packer .." + fn.system { "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path } - -- install plugins + compile their configs - vim.cmd "packadd packer.nvim" - require "plugins" - vim.cmd "PackerSync" - end + -- install plugins + compile their configs + vim.cmd "packadd packer.nvim" + require "plugins" + vim.cmd "PackerSync" + end end M.options = { - auto_clean = true, - compile_on_sync = true, - git = { clone_timeout = 6000 }, - display = { - working_sym = "ﲊ", - error_sym = "✗ ", - done_sym = " ", - removed_sym = " ", - moved_sym = "", - open_fn = function() - return require("packer.util").float { border = "single" } - end, - }, + auto_clean = true, + compile_on_sync = true, + git = { clone_timeout = 6000 }, + display = { + working_sym = "ﲊ", + error_sym = "✗ ", + done_sym = " ", + removed_sym = " ", + moved_sym = "", + open_fn = function() + return require("packer.util").float { border = "single" } + end, + }, } -- merge overrides if there are any M.options = require("core.utils").load_override(M.options, "wbthomason/packer.nvim") M.run = function(plugins) - local present, packer = pcall(require, "packer") + local present, packer = pcall(require, "packer") - if not present then - return - end + if not present then + return + end - -- Override with chadrc values - plugins = require("core.utils").remove_default_plugins(plugins) - plugins = require("core.utils").merge_plugins(plugins) + -- Override with chadrc values + plugins = require("core.utils").remove_default_plugins(plugins) + plugins = require("core.utils").merge_plugins(plugins) - packer.init(M.options) + packer.init(M.options) - packer.startup(function(use) - for _, v in pairs(plugins) do - use(v) - end - end) + packer.startup(function(use) + for _, v in pairs(plugins) do + use(v) + end + end) end return M diff --git a/lua/core/utils.lua b/lua/core/utils.lua index 131369c..c54d4c2 100644 --- a/lua/core/utils.lua +++ b/lua/core/utils.lua @@ -4,225 +4,225 @@ local api = vim.api local merge_tb = vim.tbl_deep_extend M.close_buffer = function(bufnr) - if vim.bo.buftype == "terminal" then - vim.cmd(vim.bo.buflisted and "set nobl | enew" or "hide") - elseif vim.bo.modified then - print "save the file bruh" - else - bufnr = bufnr or api.nvim_get_current_buf() - require("core.utils").tabuflinePrev() - vim.cmd("bd" .. bufnr) - end + if vim.bo.buftype == "terminal" then + vim.cmd(vim.bo.buflisted and "set nobl | enew" or "hide") + elseif vim.bo.modified then + print "save the file bruh" + else + bufnr = bufnr or api.nvim_get_current_buf() + require("core.utils").tabuflinePrev() + vim.cmd("bd" .. bufnr) + end end 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 - M.remove_default_keys() - config = merge_tb("force", config, chadrc) - else - error "chadrc must return a table!" - end - end - - config.mappings.disabled = nil - return config + 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 + M.remove_default_keys() + config = merge_tb("force", config, chadrc) + else + error "chadrc must return a table!" + end + end + + config.mappings.disabled = nil + return config end M.remove_default_keys = function() - local chadrc = require "custom.chadrc" - local user_mappings = chadrc.mappings or {} - local user_keys = {} - local user_sections = vim.tbl_keys(user_mappings) - - -- push user_map keys in user_keys table - for _, section in ipairs(user_sections) do - user_keys = vim.tbl_deep_extend("force", user_keys, user_mappings[section]) - end - - local function disable_key(mode, keybind, mode_mapping) - local keys_in_mode = vim.tbl_keys(user_keys[mode] or {}) - - if vim.tbl_contains(keys_in_mode, keybind) then - mode_mapping[keybind] = nil + local chadrc = require "custom.chadrc" + local user_mappings = chadrc.mappings or {} + local user_keys = {} + local user_sections = vim.tbl_keys(user_mappings) + + -- push user_map keys in user_keys table + for _, section in ipairs(user_sections) do + user_keys = vim.tbl_deep_extend("force", user_keys, user_mappings[section]) + end + + local function disable_key(mode, keybind, mode_mapping) + local keys_in_mode = vim.tbl_keys(user_keys[mode] or {}) + + if vim.tbl_contains(keys_in_mode, keybind) then + mode_mapping[keybind] = nil + end + end + + local default_mappings = require("core.default_config").mappings + + -- remove user_maps from default mapping table + for _, section_mappings in pairs(default_mappings) do + for mode, mode_mapping in pairs(section_mappings) do + for keybind, _ in pairs(mode_mapping) do + disable_key(mode, keybind, mode_mapping) end - end - - local default_mappings = require("core.default_config").mappings - - -- remove user_maps from default mapping table - for _, section_mappings in pairs(default_mappings) do - for mode, mode_mapping in pairs(section_mappings) do - for keybind, _ in pairs(mode_mapping) do - disable_key(mode, keybind, mode_mapping) - end - end - end + end + end end M.load_mappings = function(mappings, mapping_opt) - -- set mapping function with/without whichkey - local set_maps - local whichkey_exists, wk = pcall(require, "which-key") - - if whichkey_exists then - set_maps = function(keybind, mapping_info, opts) - wk.register({ [keybind] = mapping_info }, opts) - end - else - set_maps = function(keybind, mapping_info, opts) - local mode = opts.mode - opts.mode = nil - vim.keymap.set(mode, keybind, mapping_info[1], opts) - end - end - - mappings = mappings or vim.deepcopy(M.load_config().mappings) - mappings.lspconfig = nil - - for _, section in pairs(mappings) do - for mode, mode_values in pairs(section) do - for keybind, mapping_info in pairs(mode_values) do - -- merge default + user opts - local default_opts = merge_tb("force", { mode = mode }, mapping_opt or {}) - local opts = merge_tb("force", default_opts, mapping_info.opts or {}) - - if mapping_info.opts then - mapping_info.opts = nil - end - - set_maps(keybind, mapping_info, opts) - end + -- set mapping function with/without whichkey + local set_maps + local whichkey_exists, wk = pcall(require, "which-key") + + if whichkey_exists then + set_maps = function(keybind, mapping_info, opts) + wk.register({ [keybind] = mapping_info }, opts) + end + else + set_maps = function(keybind, mapping_info, opts) + local mode = opts.mode + opts.mode = nil + vim.keymap.set(mode, keybind, mapping_info[1], opts) + end + end + + mappings = mappings or vim.deepcopy(M.load_config().mappings) + mappings.lspconfig = nil + + for _, section in pairs(mappings) do + for mode, mode_values in pairs(section) do + for keybind, mapping_info in pairs(mode_values) do + -- merge default + user opts + local default_opts = merge_tb("force", { mode = mode }, mapping_opt or {}) + local opts = merge_tb("force", default_opts, mapping_info.opts or {}) + + if mapping_info.opts then + mapping_info.opts = nil + end + + set_maps(keybind, mapping_info, opts) end - end + end + end end -- remove plugins defined in chadrc M.remove_default_plugins = function(plugins) - local removals = M.load_config().plugins.remove or {} + local removals = M.load_config().plugins.remove or {} - if not vim.tbl_isempty(removals) then - for _, plugin in pairs(removals) do - plugins[plugin] = nil - end - end + if not vim.tbl_isempty(removals) then + for _, plugin in pairs(removals) do + plugins[plugin] = nil + end + end - return plugins + return plugins end -- merge default/user plugin tables M.merge_plugins = function(default_plugins) - local user_plugins = M.load_config().plugins.user + local user_plugins = M.load_config().plugins.user - -- merge default + user plugin table - default_plugins = merge_tb("force", default_plugins, user_plugins) + -- merge default + user plugin table + default_plugins = merge_tb("force", default_plugins, user_plugins) - local final_table = {} + local final_table = {} - for key, _ in pairs(default_plugins) do - default_plugins[key][1] = key - final_table[#final_table + 1] = default_plugins[key] - end + for key, _ in pairs(default_plugins) do + default_plugins[key][1] = key + final_table[#final_table + 1] = default_plugins[key] + end - return final_table + return final_table end M.load_override = function(default_table, plugin_name) - local user_table = M.load_config().plugins.override[plugin_name] or {} - user_table = type(user_table) == "table" and user_table or user_table() - return merge_tb("force", default_table, user_table) + local user_table = M.load_config().plugins.override[plugin_name] or {} + user_table = type(user_table) == "table" and user_table or user_table() + return merge_tb("force", default_table, user_table) 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 + 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 - - if packer_exists then - packer.sync(...) - else - error "Packer could not be loaded!" - end + end + end + + if packer_exists then + packer.sync(...) + else + error "Packer could not be loaded!" + end end M.bufilter = function() - local bufs = vim.t.bufs + local bufs = vim.t.bufs - for i = #bufs, 1, -1 do - if not vim.api.nvim_buf_is_valid(bufs[i]) then - table.remove(bufs, i) - end - end + for i = #bufs, 1, -1 do + if not vim.api.nvim_buf_is_valid(bufs[i]) then + table.remove(bufs, i) + end + end - return bufs + return bufs end M.tabuflineNext = function() - local bufs = M.bufilter() or {} - - for i, v in ipairs(bufs) do - if api.nvim_get_current_buf() == v then - vim.cmd(i == #bufs and "b" .. bufs[1] or "b" .. bufs[i + 1]) - break - end - end + local bufs = M.bufilter() or {} + + for i, v in ipairs(bufs) do + if api.nvim_get_current_buf() == v then + vim.cmd(i == #bufs and "b" .. bufs[1] or "b" .. bufs[i + 1]) + break + end + end end M.tabuflinePrev = function() - local bufs = M.bufilter() or {} - - for i, v in ipairs(bufs) do - if api.nvim_get_current_buf() == v then - vim.cmd(i == 1 and "b" .. bufs[#bufs] or "b" .. bufs[i - 1]) - break - end - end + local bufs = M.bufilter() or {} + + for i, v in ipairs(bufs) do + if api.nvim_get_current_buf() == v then + vim.cmd(i == 1 and "b" .. bufs[#bufs] or "b" .. bufs[i - 1]) + break + end + end end -- closes tab + all of its buffers M.closeAllBufs = function(action) - local bufs = vim.t.bufs + local bufs = vim.t.bufs - if action == "closeTab" then - vim.cmd "tabclose" - end + if action == "closeTab" then + vim.cmd "tabclose" + end - for _, buf in ipairs(bufs) do - M.close_buffer(buf) - end + for _, buf in ipairs(bufs) do + M.close_buffer(buf) + end - if action ~= "closeTab" then - vim.cmd "enew" - end + if action ~= "closeTab" then + vim.cmd "enew" + end end return M diff --git a/lua/plugins/configs/alpha.lua b/lua/plugins/configs/alpha.lua index 319ea50..92191b8 100644 --- a/lua/plugins/configs/alpha.lua +++ b/lua/plugins/configs/alpha.lua @@ -1,77 +1,77 @@ local present, alpha = pcall(require, "alpha") if not present then - return + return end require("base46").load_highlight "alpha" local function button(sc, txt, keybind) - local sc_ = sc:gsub("%s", ""):gsub("SPC", "") + local sc_ = sc:gsub("%s", ""):gsub("SPC", "") - local opts = { - position = "center", - text = txt, - shortcut = sc, - cursor = 5, - width = 36, - align_shortcut = "right", - hl = "AlphaButtons", - } + local opts = { + position = "center", + text = txt, + shortcut = sc, + cursor = 5, + width = 36, + align_shortcut = "right", + hl = "AlphaButtons", + } - if keybind then - opts.keymap = { "n", sc_, keybind, { noremap = true, silent = true } } - end + if keybind then + opts.keymap = { "n", sc_, keybind, { noremap = true, silent = true } } + end - return { - type = "button", - val = txt, - on_press = function() - local key = vim.api.nvim_replace_termcodes(sc_, true, false, true) - vim.api.nvim_feedkeys(key, "normal", false) - end, - opts = opts, - } + return { + type = "button", + val = txt, + on_press = function() + local key = vim.api.nvim_replace_termcodes(sc_, true, false, true) + vim.api.nvim_feedkeys(key, "normal", false) + end, + opts = opts, + } end local options = {} local ascii = { - " ⣴⣶⣤⡤⠦⣤⣀⣤⠆ ⣈⣭⣿⣶⣿⣦⣼⣆ ", - " ⠉⠻⢿⣿⠿⣿⣿⣶⣦⠤⠄⡠⢾⣿⣿⡿⠋⠉⠉⠻⣿⣿⡛⣦ ", - " ⠈⢿⣿⣟⠦ ⣾⣿⣿⣷ ⠻⠿⢿⣿⣧⣄ ", - " ⣸⣿⣿⢧ ⢻⠻⣿⣿⣷⣄⣀⠄⠢⣀⡀⠈⠙⠿⠄ ", - " ⢠⣿⣿⣿⠈ ⣻⣿⣿⣿⣿⣿⣿⣿⣛⣳⣤⣀⣀ ", - " ⢠⣧⣶⣥⡤⢄ ⣸⣿⣿⠘ ⢀⣴⣿⣿⡿⠛⣿⣿⣧⠈⢿⠿⠟⠛⠻⠿⠄ ", - " ⣰⣿⣿⠛⠻⣿⣿⡦⢹⣿⣷ ⢊⣿⣿⡏ ⢸⣿⣿⡇ ⢀⣠⣄⣾⠄ ", - " ⣠⣿⠿⠛ ⢀⣿⣿⣷⠘⢿⣿⣦⡀ ⢸⢿⣿⣿⣄ ⣸⣿⣿⡇⣪⣿⡿⠿⣿⣷⡄ ", - " ⠙⠃ ⣼⣿⡟ ⠈⠻⣿⣿⣦⣌⡇⠻⣿⣿⣷⣿⣿⣿ ⣿⣿⡇ ⠛⠻⢷⣄ ", - " ⢻⣿⣿⣄ ⠈⠻⣿⣿⣿⣷⣿⣿⣿⣿⣿⡟ ⠫⢿⣿⡆ ", - " ⠻⣿⣿⣿⣿⣶⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⡟⢀⣀⣤⣾⡿⠃ ", + " ⣴⣶⣤⡤⠦⣤⣀⣤⠆ ⣈⣭⣿⣶⣿⣦⣼⣆ ", + " ⠉⠻⢿⣿⠿⣿⣿⣶⣦⠤⠄⡠⢾⣿⣿⡿⠋⠉⠉⠻⣿⣿⡛⣦ ", + " ⠈⢿⣿⣟⠦ ⣾⣿⣿⣷ ⠻⠿⢿⣿⣧⣄ ", + " ⣸⣿⣿⢧ ⢻⠻⣿⣿⣷⣄⣀⠄⠢⣀⡀⠈⠙⠿⠄ ", + " ⢠⣿⣿⣿⠈ ⣻⣿⣿⣿⣿⣿⣿⣿⣛⣳⣤⣀⣀ ", + " ⢠⣧⣶⣥⡤⢄ ⣸⣿⣿⠘ ⢀⣴⣿⣿⡿⠛⣿⣿⣧⠈⢿⠿⠟⠛⠻⠿⠄ ", + " ⣰⣿⣿⠛⠻⣿⣿⡦⢹⣿⣷ ⢊⣿⣿⡏ ⢸⣿⣿⡇ ⢀⣠⣄⣾⠄ ", + " ⣠⣿⠿⠛ ⢀⣿⣿⣷⠘⢿⣿⣦⡀ ⢸⢿⣿⣿⣄ ⣸⣿⣿⡇⣪⣿⡿⠿⣿⣷⡄ ", + " ⠙⠃ ⣼⣿⡟ ⠈⠻⣿⣿⣦⣌⡇⠻⣿⣿⣷⣿⣿⣿ ⣿⣿⡇ ⠛⠻⢷⣄ ", + " ⢻⣿⣿⣄ ⠈⠻⣿⣿⣿⣷⣿⣿⣿⣿⣿⡟ ⠫⢿⣿⡆ ", + " ⠻⣿⣿⣿⣿⣶⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⡟⢀⣀⣤⣾⡿⠃ ", } options.header = { - type = "text", - val = ascii, - opts = { - position = "center", - hl = "AlphaHeader", - }, + type = "text", + val = ascii, + opts = { + position = "center", + hl = "AlphaHeader", + }, } options.buttons = { - type = "group", - val = { - button("SPC f f", " Find File ", ":Telescope find_files"), - button("SPC f o", " Recent File ", ":Telescope oldfiles"), - button("SPC f w", " Find Word ", ":Telescope live_grep"), - button("SPC b m", " Bookmarks ", ":Telescope marks"), - button("SPC t h", " Themes ", ":Telescope themes"), - button("SPC e s", " Settings", ":e $MYVIMRC | :cd %:p:h "), - }, - opts = { - spacing = 1, - }, + type = "group", + val = { + button("SPC f f", " Find File ", ":Telescope find_files"), + button("SPC f o", " Recent File ", ":Telescope oldfiles"), + button("SPC f w", " Find Word ", ":Telescope live_grep"), + button("SPC b m", " Bookmarks ", ":Telescope marks"), + button("SPC t h", " Themes ", ":Telescope themes"), + button("SPC e s", " Settings", ":e $MYVIMRC | :cd %:p:h "), + }, + opts = { + spacing = 1, + }, } options = require("core.utils").load_override(options, "goolord/alpha-nvim") @@ -82,11 +82,11 @@ local marginTopPercent = 0.3 local headerPadding = fn.max { 2, fn.floor(fn.winheight(0) * marginTopPercent) } alpha.setup { - layout = { - { type = "padding", val = headerPadding }, - options.header, - { type = "padding", val = 2 }, - options.buttons, - }, - opts = {}, + layout = { + { type = "padding", val = headerPadding }, + options.header, + { type = "padding", val = 2 }, + options.buttons, + }, + opts = {}, } diff --git a/lua/plugins/configs/cmp.lua b/lua/plugins/configs/cmp.lua index 2453182..2b69b6b 100644 --- a/lua/plugins/configs/cmp.lua +++ b/lua/plugins/configs/cmp.lua @@ -1,7 +1,7 @@ local present, cmp = pcall(require, "cmp") if not present then - return + return end require("base46").load_highlight "cmp" @@ -9,92 +9,92 @@ require("base46").load_highlight "cmp" vim.opt.completeopt = "menuone,noselect" local function border(hl_name) - return { - { "╭", hl_name }, - { "─", hl_name }, - { "╮", hl_name }, - { "│", hl_name }, - { "╯", hl_name }, - { "─", hl_name }, - { "╰", hl_name }, - { "│", hl_name }, - } + return { + { "╭", hl_name }, + { "─", hl_name }, + { "╮", hl_name }, + { "│", hl_name }, + { "╯", hl_name }, + { "─", hl_name }, + { "╰", hl_name }, + { "│", hl_name }, + } end local cmp_window = require "cmp.utils.window" cmp_window.info_ = cmp_window.info cmp_window.info = function(self) - local info = self:info_() - info.scrollable = false - return info + local info = self:info_() + info.scrollable = false + return info end local options = { - window = { - completion = { - border = border "CmpBorder", - winhighlight = "Normal:CmpPmenu,CursorLine:PmenuSel,Search:None", - }, - documentation = { - border = border "CmpDocBorder", - }, - }, - snippet = { - expand = function(args) - require("luasnip").lsp_expand(args.body) - end, - }, - formatting = { - format = function(_, vim_item) - local icons = require("nvchad_ui.icons").lspkind - vim_item.kind = string.format("%s %s", icons[vim_item.kind], vim_item.kind) - return vim_item - end, - }, - mapping = { - [""] = cmp.mapping.select_prev_item(), - [""] = cmp.mapping.select_next_item(), - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete(), - [""] = cmp.mapping.close(), - [""] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Replace, - select = false, - }, - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif require("luasnip").expand_or_jumpable() then - vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-expand-or-jump", true, true, true), "") - else - fallback() - end - end, { - "i", - "s", - }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif require("luasnip").jumpable(-1) then - vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-jump-prev", true, true, true), "") - else - fallback() - end - end, { - "i", - "s", - }), - }, - sources = { - { name = "luasnip" }, - { name = "nvim_lsp" }, - { name = "buffer" }, - { name = "nvim_lua" }, - { name = "path" }, - }, + window = { + completion = { + border = border "CmpBorder", + winhighlight = "Normal:CmpPmenu,CursorLine:PmenuSel,Search:None", + }, + documentation = { + border = border "CmpDocBorder", + }, + }, + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + formatting = { + format = function(_, vim_item) + local icons = require("nvchad_ui.icons").lspkind + vim_item.kind = string.format("%s %s", icons[vim_item.kind], vim_item.kind) + return vim_item + end, + }, + mapping = { + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.close(), + [""] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = false, + }, + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif require("luasnip").expand_or_jumpable() then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-expand-or-jump", true, true, true), "") + else + fallback() + end + end, { + "i", + "s", + }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif require("luasnip").jumpable(-1) then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-jump-prev", true, true, true), "") + else + fallback() + end + end, { + "i", + "s", + }), + }, + sources = { + { name = "luasnip" }, + { name = "nvim_lsp" }, + { name = "buffer" }, + { name = "nvim_lua" }, + { name = "path" }, + }, } -- check for any override diff --git a/lua/plugins/configs/lsp_installer.lua b/lua/plugins/configs/lsp_installer.lua index 4a78c3d..3afe108 100644 --- a/lua/plugins/configs/lsp_installer.lua +++ b/lua/plugins/configs/lsp_installer.lua @@ -1,34 +1,34 @@ local present, lsp_installer = pcall(require, "nvim-lsp-installer") if not present then - return + return end local options = { - -- ensure_installed is not needed as automatic_installation is enabled - -- then any lsp server you setup by lspconfig is going to get installed automatically! + -- ensure_installed is not needed as automatic_installation is enabled + -- then any lsp server you setup by lspconfig is going to get installed automatically! - -- ensure_installed = { "lua" }, - automatic_installation = true, + -- ensure_installed = { "lua" }, + automatic_installation = true, - ui = { - icons = { - server_installed = " ", - server_pending = " ", - server_uninstalled = " ﮊ", - }, - keymaps = { - toggle_server_expand = "", - install_server = "i", - update_server = "u", - check_server_version = "c", - update_all_servers = "U", - check_outdated_servers = "C", - uninstall_server = "X", - }, - }, + ui = { + icons = { + server_installed = " ", + server_pending = " ", + server_uninstalled = " ﮊ", + }, + keymaps = { + toggle_server_expand = "", + install_server = "i", + update_server = "u", + check_server_version = "c", + update_all_servers = "U", + check_outdated_servers = "C", + uninstall_server = "X", + }, + }, - max_concurrent_installers = 10, + max_concurrent_installers = 10, } options = require("core.utils").load_override(options, "williamboman/nvim-lsp-installer") diff --git a/lua/plugins/configs/lspconfig.lua b/lua/plugins/configs/lspconfig.lua index cf5c7d6..6f7547b 100644 --- a/lua/plugins/configs/lspconfig.lua +++ b/lua/plugins/configs/lspconfig.lua @@ -1,7 +1,7 @@ local present, lspconfig = pcall(require, "lspconfig") if not present then - return + return end require("base46").load_highlight "lsp" @@ -11,72 +11,72 @@ local M = {} local utils = require "core.utils" M.on_attach = function(client, bufnr) - local vim_version = vim.version() + local vim_version = vim.version() - if vim_version.minor > 7 then - -- nightly - client.server_capabilities.documentFormattingProvider = false - client.server_capabilities.documentRangeFormattingProvider = false - else - -- stable - client.resolved_capabilities.document_formatting = false - client.resolved_capabilities.document_range_formatting = false - end + if vim_version.minor > 7 then + -- nightly + client.server_capabilities.documentFormattingProvider = false + client.server_capabilities.documentRangeFormattingProvider = false + else + -- stable + client.resolved_capabilities.document_formatting = false + client.resolved_capabilities.document_range_formatting = false + end - local lsp_mappings = utils.load_config().mappings.lspconfig - utils.load_mappings({ lsp_mappings }, { buffer = bufnr }) + local lsp_mappings = utils.load_config().mappings.lspconfig + utils.load_mappings({ lsp_mappings }, { buffer = bufnr }) - if client.server_capabilities.signatureHelpProvider then - require("nvchad_ui.signature").setup(client) - end + if client.server_capabilities.signatureHelpProvider then + require("nvchad_ui.signature").setup(client) + end end local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities.textDocument.completion.completionItem = { - documentationFormat = { "markdown", "plaintext" }, - snippetSupport = true, - preselectSupport = true, - insertReplaceSupport = true, - labelDetailsSupport = true, - deprecatedSupport = true, - commitCharactersSupport = true, - tagSupport = { valueSet = { 1 } }, - resolveSupport = { - properties = { - "documentation", - "detail", - "additionalTextEdits", - }, - }, + documentationFormat = { "markdown", "plaintext" }, + snippetSupport = true, + preselectSupport = true, + insertReplaceSupport = true, + labelDetailsSupport = true, + deprecatedSupport = true, + commitCharactersSupport = true, + tagSupport = { valueSet = { 1 } }, + resolveSupport = { + properties = { + "documentation", + "detail", + "additionalTextEdits", + }, + }, } lspconfig.sumneko_lua.setup { - on_attach = M.on_attach, - capabilities = capabilities, + on_attach = M.on_attach, + capabilities = capabilities, - settings = { - Lua = { - diagnostics = { - globals = { "vim" }, - }, - workspace = { - library = { - [vim.fn.expand "$VIMRUNTIME/lua"] = true, - [vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true, - }, - maxPreload = 100000, - preloadFileSize = 10000, - }, + settings = { + Lua = { + diagnostics = { + globals = { "vim" }, + }, + workspace = { + library = { + [vim.fn.expand "$VIMRUNTIME/lua"] = true, + [vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true, + }, + maxPreload = 100000, + preloadFileSize = 10000, }, - }, + }, + }, } -- requires a file containing user's lspconfigs local addlsp_confs = utils.load_config().plugins.options.lspconfig.setup_lspconf if #addlsp_confs ~= 0 then - require(addlsp_confs).setup_lsp(M.on_attach, capabilities) + require(addlsp_confs).setup_lsp(M.on_attach, capabilities) end return M diff --git a/lua/plugins/configs/nvchad_ui.lua b/lua/plugins/configs/nvchad_ui.lua index d59ff3a..e19d87e 100644 --- a/lua/plugins/configs/nvchad_ui.lua +++ b/lua/plugins/configs/nvchad_ui.lua @@ -1,22 +1,22 @@ local present, _ = pcall(require, "nvchad_ui") if not present then - return + return end local options = { - statusline = { - separator_style = "default", -- default/round/block/arrow - overriden_modules = nil, - }, - - -- lazyload it when there are 1+ buffers - tabufline = { - enabled = true, - lazyload = true, - overriden_modules = nil, - }, + statusline = { + separator_style = "default", -- default/round/block/arrow + overriden_modules = nil, + }, + + -- lazyload it when there are 1+ buffers + tabufline = { + enabled = true, + lazyload = true, + overriden_modules = nil, + }, } options = require("core.utils").load_override(options, "NvChad/ui") @@ -25,16 +25,16 @@ require "nvchad_ui.tabufline.lazyload"(options.tabufline) -- ignore this as it might scare you XD return { - statusline = function() - return require("nvchad_ui.statusline").setup(options) - end, - - tabufline = function() - return require("nvchad_ui.tabufline").setup(options) - end, - - load_ui_plugins = function() - vim.opt.statusline = "%!v:lua.require('plugins.configs.nvchad_ui').statusline()" - vim.opt.tabline = "%!v:lua.require('plugins.configs.nvchad_ui').tabufline()" - end, + statusline = function() + return require("nvchad_ui.statusline").setup(options) + end, + + tabufline = function() + return require("nvchad_ui.tabufline").setup(options) + end, + + load_ui_plugins = function() + vim.opt.statusline = "%!v:lua.require('plugins.configs.nvchad_ui').statusline()" + vim.opt.tabline = "%!v:lua.require('plugins.configs.nvchad_ui').tabufline()" + end, } diff --git a/lua/plugins/configs/nvimtree.lua b/lua/plugins/configs/nvimtree.lua index d573755..0f1733e 100644 --- a/lua/plugins/configs/nvimtree.lua +++ b/lua/plugins/configs/nvimtree.lua @@ -1,86 +1,86 @@ local present, nvimtree = pcall(require, "nvim-tree") if not present then - return + return end require("base46").load_highlight "nvimtree" local options = { - filters = { - dotfiles = false, - exclude = { vim.fn.stdpath "config" .. "/lua/custom" }, - }, - disable_netrw = true, - hijack_netrw = true, - open_on_setup = false, - ignore_ft_on_setup = { "alpha" }, - hijack_cursor = true, - hijack_unnamed_buffer_when_opening = false, - update_cwd = true, - update_focused_file = { - enable = true, - update_cwd = false, - }, - view = { - adaptive_size = true, - side = "left", - width = 25, - hide_root_folder = true, - }, - git = { + filters = { + dotfiles = false, + exclude = { vim.fn.stdpath "config" .. "/lua/custom" }, + }, + disable_netrw = true, + hijack_netrw = true, + open_on_setup = false, + ignore_ft_on_setup = { "alpha" }, + hijack_cursor = true, + hijack_unnamed_buffer_when_opening = false, + update_cwd = true, + update_focused_file = { + enable = true, + update_cwd = false, + }, + view = { + adaptive_size = true, + side = "left", + width = 25, + hide_root_folder = true, + }, + git = { + enable = false, + ignore = true, + }, + filesystem_watchers = { + enable = true, + }, + actions = { + open_file = { + resize_window = true, + }, + }, + renderer = { + highlight_git = false, + highlight_opened_files = "none", + + indent_markers = { enable = false, - ignore = true, - }, - filesystem_watchers = { - enable = true, - }, - actions = { - open_file = { - resize_window = true, - }, - }, - renderer = { - highlight_git = false, - highlight_opened_files = "none", + }, - indent_markers = { - enable = false, + icons = { + show = { + file = true, + folder = true, + folder_arrow = true, + git = false, }, - icons = { - show = { - file = true, - folder = true, - folder_arrow = true, - git = false, - }, - - glyphs = { - default = "", - symlink = "", - folder = { - default = "", - empty = "", - empty_open = "", - open = "", - symlink = "", - symlink_open = "", - arrow_open = "", - arrow_closed = "", - }, - git = { - unstaged = "✗", - staged = "✓", - unmerged = "", - renamed = "➜", - untracked = "★", - deleted = "", - ignored = "◌", - }, - }, + glyphs = { + default = "", + symlink = "", + folder = { + default = "", + empty = "", + empty_open = "", + open = "", + symlink = "", + symlink_open = "", + arrow_open = "", + arrow_closed = "", + }, + git = { + unstaged = "✗", + staged = "✓", + unmerged = "", + renamed = "➜", + untracked = "★", + deleted = "", + ignored = "◌", + }, }, - }, + }, + }, } -- check for any override diff --git a/lua/plugins/configs/nvterm.lua b/lua/plugins/configs/nvterm.lua index d0580eb..2c82e14 100644 --- a/lua/plugins/configs/nvterm.lua +++ b/lua/plugins/configs/nvterm.lua @@ -1,32 +1,32 @@ local present, nvterm = pcall(require, "nvterm") if not present then - return + return end require "base46.term" 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 }, + terminals = { + list = {}, + type_opts = { + float = { + relative = "editor", + row = 0.3, + col = 0.25, + width = 0.5, + height = 0.4, + border = "single", }, - }, - behavior = { - close_on_exit = true, - auto_insert = true, - }, - enable_new_mappings = true, + horizontal = { location = "rightbelow", split_ratio = 0.3 }, + vertical = { location = "rightbelow", split_ratio = 0.5 }, + }, + }, + behavior = { + close_on_exit = true, + auto_insert = true, + }, + enable_new_mappings = true, } options = require("core.utils").load_override(options, "NvChad/nvterm") diff --git a/lua/plugins/configs/others.lua b/lua/plugins/configs/others.lua index 6f83394..0b2e255 100644 --- a/lua/plugins/configs/others.lua +++ b/lua/plugins/configs/others.lua @@ -3,163 +3,163 @@ local M = {} local load_override = require("core.utils").load_override M.autopairs = function() - local present1, autopairs = pcall(require, "nvim-autopairs") - local present2, cmp = pcall(require, "cmp") + local present1, autopairs = pcall(require, "nvim-autopairs") + local present2, cmp = pcall(require, "cmp") - if not (present1 and present2) then - return - end + if not (present1 and present2) then + return + end - local options = { - fast_wrap = {}, - disable_filetype = { "TelescopePrompt", "vim" }, - } + local options = { + fast_wrap = {}, + disable_filetype = { "TelescopePrompt", "vim" }, + } - options = load_override(options, "windwp/nvim-autopairs") - autopairs.setup(options) + options = load_override(options, "windwp/nvim-autopairs") + autopairs.setup(options) - local cmp_autopairs = require "nvim-autopairs.completion.cmp" - cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) + local cmp_autopairs = require "nvim-autopairs.completion.cmp" + cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) end M.blankline = function() - local present, blankline = pcall(require, "indent_blankline") - - if not present then - return - end - - require("base46").load_highlight "blankline" - - local options = { - indentLine_enabled = 1, - filetype_exclude = { - "help", - "terminal", - "alpha", - "packer", - "lspinfo", - "TelescopePrompt", - "TelescopeResults", - "lsp-installer", - "", - }, - buftype_exclude = { "terminal" }, - show_trailing_blankline_indent = false, - show_first_indent_level = false, - show_current_context = true, - show_current_context_start = true, - } - - options = load_override(options, "lukas-reineke/indent-blankline.nvim") - blankline.setup(options) + local present, blankline = pcall(require, "indent_blankline") + + if not present then + return + end + + require("base46").load_highlight "blankline" + + local options = { + indentLine_enabled = 1, + filetype_exclude = { + "help", + "terminal", + "alpha", + "packer", + "lspinfo", + "TelescopePrompt", + "TelescopeResults", + "lsp-installer", + "", + }, + buftype_exclude = { "terminal" }, + show_trailing_blankline_indent = false, + show_first_indent_level = false, + show_current_context = true, + show_current_context_start = true, + } + + options = load_override(options, "lukas-reineke/indent-blankline.nvim") + blankline.setup(options) end M.colorizer = function() - local present, colorizer = pcall(require, "colorizer") - - if not present then - return - end - - local options = { - filetypes = { - "*", - }, - user_default_options = { - RGB = true, -- #RGB hex codes - RRGGBB = true, -- #RRGGBB hex codes - names = false, -- "Name" codes like Blue - RRGGBBAA = false, -- #RRGGBBAA hex codes - rgb_fn = false, -- CSS rgb() and rgba() functions - hsl_fn = false, -- CSS hsl() and hsla() functions - css = false, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB - css_fn = false, -- Enable all CSS *functions*: rgb_fn, hsl_fn - mode = "background", -- Set the display mode. - }, - } - - options = load_override(options, "NvChad/nvim-colorizer.lua") - colorizer.setup(options["filetypes"], options["user_default_options"]) - - vim.cmd "ColorizerAttachToBuffer" + local present, colorizer = pcall(require, "colorizer") + + if not present then + return + end + + local options = { + filetypes = { + "*", + }, + user_default_options = { + RGB = true, -- #RGB hex codes + RRGGBB = true, -- #RRGGBB hex codes + names = false, -- "Name" codes like Blue + RRGGBBAA = false, -- #RRGGBBAA hex codes + rgb_fn = false, -- CSS rgb() and rgba() functions + hsl_fn = false, -- CSS hsl() and hsla() functions + css = false, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB + css_fn = false, -- Enable all CSS *functions*: rgb_fn, hsl_fn + mode = "background", -- Set the display mode. + }, + } + + options = load_override(options, "NvChad/nvim-colorizer.lua") + colorizer.setup(options["filetypes"], options["user_default_options"]) + + vim.cmd "ColorizerAttachToBuffer" end M.comment = function() - local present, nvim_comment = pcall(require, "Comment") + local present, nvim_comment = pcall(require, "Comment") - if not present then - return - end + if not present then + return + end - local options = {} - options = load_override(options, "numToStr/Comment.nvim") - nvim_comment.setup(options) + local options = {} + options = load_override(options, "numToStr/Comment.nvim") + nvim_comment.setup(options) end M.luasnip = function() - local present, luasnip = pcall(require, "luasnip") - - if not present then - return - end - - local options = { - history = true, - updateevents = "TextChanged,TextChangedI", - } - - options = load_override(options, "L3MON4D3/LuaSnip") - luasnip.config.set_config(options) - require("luasnip.loaders.from_vscode").lazy_load() - require("luasnip.loaders.from_vscode").lazy_load { paths = vim.g.luasnippets_path or "" } - - vim.api.nvim_create_autocmd("InsertLeave", { - callback = function() - if - require("luasnip").session.current_nodes[vim.api.nvim_get_current_buf()] - and not require("luasnip").session.jump_active - then - require("luasnip").unlink_current() - end - end, - }) + local present, luasnip = pcall(require, "luasnip") + + if not present then + return + end + + local options = { + history = true, + updateevents = "TextChanged,TextChangedI", + } + + options = load_override(options, "L3MON4D3/LuaSnip") + luasnip.config.set_config(options) + require("luasnip.loaders.from_vscode").lazy_load() + require("luasnip.loaders.from_vscode").lazy_load { paths = vim.g.luasnippets_path or "" } + + vim.api.nvim_create_autocmd("InsertLeave", { + callback = function() + if + require("luasnip").session.current_nodes[vim.api.nvim_get_current_buf()] + and not require("luasnip").session.jump_active + then + require("luasnip").unlink_current() + end + end, + }) end M.gitsigns = function() - local present, gitsigns = pcall(require, "gitsigns") - - if not present then - return - end - - require("base46").load_highlight "git" - - local options = { - signs = { - add = { hl = "DiffAdd", text = "│", numhl = "GitSignsAddNr" }, - change = { hl = "DiffChange", text = "│", numhl = "GitSignsChangeNr" }, - delete = { hl = "DiffDelete", text = "", numhl = "GitSignsDeleteNr" }, - topdelete = { hl = "DiffDelete", text = "‾", numhl = "GitSignsDeleteNr" }, - changedelete = { hl = "DiffChangeDelete", text = "~", numhl = "GitSignsChangeNr" }, - }, - } - - options = load_override(options, "lewis6991/gitsigns.nvim") - gitsigns.setup(options) + local present, gitsigns = pcall(require, "gitsigns") + + if not present then + return + end + + require("base46").load_highlight "git" + + local options = { + signs = { + add = { hl = "DiffAdd", text = "│", numhl = "GitSignsAddNr" }, + change = { hl = "DiffChange", text = "│", numhl = "GitSignsChangeNr" }, + delete = { hl = "DiffDelete", text = "", numhl = "GitSignsDeleteNr" }, + topdelete = { hl = "DiffDelete", text = "‾", numhl = "GitSignsDeleteNr" }, + changedelete = { hl = "DiffChangeDelete", text = "~", numhl = "GitSignsChangeNr" }, + }, + } + + options = load_override(options, "lewis6991/gitsigns.nvim") + gitsigns.setup(options) end M.devicons = function() - local present, devicons = pcall(require, "nvim-web-devicons") + local present, devicons = pcall(require, "nvim-web-devicons") - if present then - require("base46").load_highlight "devicons" + if present then + require("base46").load_highlight "devicons" - local options = { override = require("nvchad_ui.icons").devicons } - options = require("core.utils").load_override(options, "kyazdani42/nvim-web-devicons") + local options = { override = require("nvchad_ui.icons").devicons } + options = require("core.utils").load_override(options, "kyazdani42/nvim-web-devicons") - devicons.setup(options) - end + devicons.setup(options) + end end return M diff --git a/lua/plugins/configs/telescope.lua b/lua/plugins/configs/telescope.lua index f0e27cc..03e1467 100644 --- a/lua/plugins/configs/telescope.lua +++ b/lua/plugins/configs/telescope.lua @@ -1,7 +1,7 @@ local present, telescope = pcall(require, "telescope") if not present then - return + return end vim.g.theme_switcher_loaded = true @@ -9,56 +9,56 @@ vim.g.theme_switcher_loaded = true require("base46").load_highlight "telescope" local options = { - defaults = { - vimgrep_arguments = { - "rg", - "--color=never", - "--no-heading", - "--with-filename", - "--line-number", - "--column", - "--smart-case", + defaults = { + vimgrep_arguments = { + "rg", + "--color=never", + "--no-heading", + "--with-filename", + "--line-number", + "--column", + "--smart-case", + }, + prompt_prefix = "  ", + selection_caret = " ", + entry_prefix = " ", + initial_mode = "insert", + selection_strategy = "reset", + sorting_strategy = "ascending", + layout_strategy = "horizontal", + layout_config = { + horizontal = { + prompt_position = "top", + preview_width = 0.55, + results_width = 0.8, }, - prompt_prefix = "  ", - selection_caret = " ", - entry_prefix = " ", - initial_mode = "insert", - selection_strategy = "reset", - sorting_strategy = "ascending", - layout_strategy = "horizontal", - layout_config = { - horizontal = { - prompt_position = "top", - preview_width = 0.55, - results_width = 0.8, - }, - vertical = { - mirror = false, - }, - width = 0.87, - height = 0.80, - preview_cutoff = 120, + vertical = { + mirror = false, }, - file_sorter = require("telescope.sorters").get_fuzzy_file, - file_ignore_patterns = { "node_modules" }, - generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter, - path_display = { "truncate" }, - winblend = 0, - border = {}, - borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }, - color_devicons = true, - set_env = { ["COLORTERM"] = "truecolor" }, -- default = nil, - file_previewer = require("telescope.previewers").vim_buffer_cat.new, - grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new, - qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new, - -- Developer configurations: Not meant for general override - buffer_previewer_maker = require("telescope.previewers").buffer_previewer_maker, - mappings = { - n = { ["q"] = require("telescope.actions").close }, - }, - }, + width = 0.87, + height = 0.80, + preview_cutoff = 120, + }, + file_sorter = require("telescope.sorters").get_fuzzy_file, + file_ignore_patterns = { "node_modules" }, + generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter, + path_display = { "truncate" }, + winblend = 0, + border = {}, + borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }, + color_devicons = true, + set_env = { ["COLORTERM"] = "truecolor" }, -- default = nil, + file_previewer = require("telescope.previewers").vim_buffer_cat.new, + grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new, + qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new, + -- Developer configurations: Not meant for general override + buffer_previewer_maker = require("telescope.previewers").buffer_previewer_maker, + mappings = { + n = { ["q"] = require("telescope.actions").close }, + }, + }, - extensions_list = { "themes", "terms" }, + extensions_list = { "themes", "terms" }, } -- check for any override @@ -67,7 +67,7 @@ telescope.setup(options) -- load extensions pcall(function() - for _, ext in ipairs(options.extensions_list) do - telescope.load_extension(ext) - end + for _, ext in ipairs(options.extensions_list) do + telescope.load_extension(ext) + end end) diff --git a/lua/plugins/configs/treesitter.lua b/lua/plugins/configs/treesitter.lua index 563c8c6..73476f0 100644 --- a/lua/plugins/configs/treesitter.lua +++ b/lua/plugins/configs/treesitter.lua @@ -1,20 +1,20 @@ local present, treesitter = pcall(require, "nvim-treesitter.configs") if not present then - return + return end require("base46").load_highlight "syntax" require("base46").load_highlight "treesitter" local options = { - ensure_installed = { - "lua", - }, - highlight = { - enable = true, - use_languagetree = true, - }, + ensure_installed = { + "lua", + }, + highlight = { + enable = true, + use_languagetree = true, + }, } -- check for any override diff --git a/lua/plugins/configs/whichkey.lua b/lua/plugins/configs/whichkey.lua index e29e385..7bc8ef4 100644 --- a/lua/plugins/configs/whichkey.lua +++ b/lua/plugins/configs/whichkey.lua @@ -1,39 +1,39 @@ local present, wk = pcall(require, "which-key") if not present then - return + return end require("base46").load_highlight "whichkey" local options = { - icons = { - breadcrumb = "»", -- symbol used in the command line area that shows your active key combo - separator = "  ", -- symbol used between a key and it's label - group = "+", -- symbol prepended to a group - }, + icons = { + breadcrumb = "»", -- symbol used in the command line area that shows your active key combo + separator = "  ", -- symbol used between a key and it's label + group = "+", -- symbol prepended to a group + }, - popup_mappings = { - scroll_down = "", -- binding to scroll down inside the popup - scroll_up = "", -- binding to scroll up inside the popup - }, + popup_mappings = { + scroll_down = "", -- binding to scroll down inside the popup + scroll_up = "", -- binding to scroll up inside the popup + }, - window = { - border = "none", -- none/single/double/shadow - }, + window = { + border = "none", -- none/single/double/shadow + }, - layout = { - spacing = 6, -- spacing between columns - }, + layout = { + spacing = 6, -- spacing between columns + }, - hidden = { "", "", "", "", "call", "lua", "^:", "^ " }, + hidden = { "", "", "", "", "call", "lua", "^:", "^ " }, - triggers_blacklist = { - -- list of mode / prefixes that should never be hooked by WhichKey - i = { "j", "k" }, - v = { "j", "k" }, - }, + triggers_blacklist = { + -- list of mode / prefixes that should never be hooked by WhichKey + i = { "j", "k" }, + v = { "j", "k" }, + }, } options = require("core.utils").load_override(options, "folke/which-key.nvim") diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index f8dc1bf..0c12e93 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -2,192 +2,192 @@ vim.cmd "packadd packer.nvim" local plugins = { - ["nvim-lua/plenary.nvim"] = { module = "plenary" }, - ["wbthomason/packer.nvim"] = {}, - ["NvChad/extensions"] = { module = { "telescope", "nvchad" } }, - - ["NvChad/base46"] = { - config = function() - local ok, base46 = pcall(require, "base46") - - if ok then - base46.load_theme() - end - end, - }, - - ["NvChad/ui"] = { - after = "base46", - config = function() - require("plugins.configs.nvchad_ui").load_ui_plugins() - end, - }, - - ["NvChad/nvterm"] = { - module = "nvterm", - config = function() - require "plugins.configs.nvterm" - end, - }, - - ["kyazdani42/nvim-web-devicons"] = { - module = "nvim-web-devicons", - config = function() - require("plugins.configs.others").devicons() - end, - }, - - ["lukas-reineke/indent-blankline.nvim"] = { - opt = true, - setup = function() - require("core.lazy_load").on_file_open "indent-blankline.nvim" - end, - config = function() - require("plugins.configs.others").blankline() - end, - }, - - ["NvChad/nvim-colorizer.lua"] = { - opt = true, - setup = function() - require("core.lazy_load").colorizer() - end, - config = function() - require("plugins.configs.others").colorizer() - end, - }, - - ["nvim-treesitter/nvim-treesitter"] = { - module = "nvim-treesitter", - setup = function() - require("core.lazy_load").on_file_open "nvim-treesitter" - end, - cmd = require("core.lazy_load").treesitter_cmds, - run = ":TSUpdate", - config = function() - require "plugins.configs.treesitter" - end, - }, - - -- git stuff - ["lewis6991/gitsigns.nvim"] = { - ft = "gitcommit", - setup = function() - require("core.lazy_load").gitsigns() - end, - config = function() - require("plugins.configs.others").gitsigns() - end, - }, - - -- lsp stuff - - ["williamboman/nvim-lsp-installer"] = { - opt = true, - cmd = require("core.lazy_load").lsp_cmds, - setup = function() - require("core.lazy_load").on_file_open "nvim-lsp-installer" - end, - }, - - ["neovim/nvim-lspconfig"] = { - after = "nvim-lsp-installer", - module = "lspconfig", - config = function() - require "plugins.configs.lsp_installer" - require "plugins.configs.lspconfig" - end, - }, - - -- load luasnips + cmp related in insert mode only - - ["rafamadriz/friendly-snippets"] = { - module = "cmp_nvim_lsp", - event = "InsertEnter", - }, - - ["hrsh7th/nvim-cmp"] = { - after = "friendly-snippets", - config = function() - require "plugins.configs.cmp" - end, - }, - - ["L3MON4D3/LuaSnip"] = { - wants = "friendly-snippets", - after = "nvim-cmp", - config = function() - require("plugins.configs.others").luasnip() - end, - }, - - ["saadparwaiz1/cmp_luasnip"] = { - after = "LuaSnip", - }, - - ["hrsh7th/cmp-nvim-lua"] = { - after = "cmp_luasnip", - }, - - ["hrsh7th/cmp-nvim-lsp"] = { - after = "cmp-nvim-lua", - }, - - ["hrsh7th/cmp-buffer"] = { - after = "cmp-nvim-lsp", - }, - - ["hrsh7th/cmp-path"] = { - after = "cmp-buffer", - }, - - -- misc plugins - ["windwp/nvim-autopairs"] = { - after = "nvim-cmp", - config = function() - require("plugins.configs.others").autopairs() - end, - }, - - ["goolord/alpha-nvim"] = { - after = "base46", - disable = true, - config = function() - require "plugins.configs.alpha" - end, - }, - - ["numToStr/Comment.nvim"] = { - module = "Comment", - keys = { "gc", "gb" }, - config = function() - require("plugins.configs.others").comment() - end, - }, - - -- file managing , picker etc - ["kyazdani42/nvim-tree.lua"] = { - ft = "alpha", - cmd = { "NvimTreeToggle", "NvimTreeFocus" }, - config = function() - require "plugins.configs.nvimtree" - end, - }, - - ["nvim-telescope/telescope.nvim"] = { - cmd = "Telescope", - config = function() - require "plugins.configs.telescope" - end, - }, - - -- Only load whichkey after all the gui - ["folke/which-key.nvim"] = { - module = "which-key", - config = function() - require "plugins.configs.whichkey" - end, - }, + ["nvim-lua/plenary.nvim"] = { module = "plenary" }, + ["wbthomason/packer.nvim"] = {}, + ["NvChad/extensions"] = { module = { "telescope", "nvchad" } }, + + ["NvChad/base46"] = { + config = function() + local ok, base46 = pcall(require, "base46") + + if ok then + base46.load_theme() + end + end, + }, + + ["NvChad/ui"] = { + after = "base46", + config = function() + require("plugins.configs.nvchad_ui").load_ui_plugins() + end, + }, + + ["NvChad/nvterm"] = { + module = "nvterm", + config = function() + require "plugins.configs.nvterm" + end, + }, + + ["kyazdani42/nvim-web-devicons"] = { + module = "nvim-web-devicons", + config = function() + require("plugins.configs.others").devicons() + end, + }, + + ["lukas-reineke/indent-blankline.nvim"] = { + opt = true, + setup = function() + require("core.lazy_load").on_file_open "indent-blankline.nvim" + end, + config = function() + require("plugins.configs.others").blankline() + end, + }, + + ["NvChad/nvim-colorizer.lua"] = { + opt = true, + setup = function() + require("core.lazy_load").colorizer() + end, + config = function() + require("plugins.configs.others").colorizer() + end, + }, + + ["nvim-treesitter/nvim-treesitter"] = { + module = "nvim-treesitter", + setup = function() + require("core.lazy_load").on_file_open "nvim-treesitter" + end, + cmd = require("core.lazy_load").treesitter_cmds, + run = ":TSUpdate", + config = function() + require "plugins.configs.treesitter" + end, + }, + + -- git stuff + ["lewis6991/gitsigns.nvim"] = { + ft = "gitcommit", + setup = function() + require("core.lazy_load").gitsigns() + end, + config = function() + require("plugins.configs.others").gitsigns() + end, + }, + + -- lsp stuff + + ["williamboman/nvim-lsp-installer"] = { + opt = true, + cmd = require("core.lazy_load").lsp_cmds, + setup = function() + require("core.lazy_load").on_file_open "nvim-lsp-installer" + end, + }, + + ["neovim/nvim-lspconfig"] = { + after = "nvim-lsp-installer", + module = "lspconfig", + config = function() + require "plugins.configs.lsp_installer" + require "plugins.configs.lspconfig" + end, + }, + + -- load luasnips + cmp related in insert mode only + + ["rafamadriz/friendly-snippets"] = { + module = "cmp_nvim_lsp", + event = "InsertEnter", + }, + + ["hrsh7th/nvim-cmp"] = { + after = "friendly-snippets", + config = function() + require "plugins.configs.cmp" + end, + }, + + ["L3MON4D3/LuaSnip"] = { + wants = "friendly-snippets", + after = "nvim-cmp", + config = function() + require("plugins.configs.others").luasnip() + end, + }, + + ["saadparwaiz1/cmp_luasnip"] = { + after = "LuaSnip", + }, + + ["hrsh7th/cmp-nvim-lua"] = { + after = "cmp_luasnip", + }, + + ["hrsh7th/cmp-nvim-lsp"] = { + after = "cmp-nvim-lua", + }, + + ["hrsh7th/cmp-buffer"] = { + after = "cmp-nvim-lsp", + }, + + ["hrsh7th/cmp-path"] = { + after = "cmp-buffer", + }, + + -- misc plugins + ["windwp/nvim-autopairs"] = { + after = "nvim-cmp", + config = function() + require("plugins.configs.others").autopairs() + end, + }, + + ["goolord/alpha-nvim"] = { + after = "base46", + disable = true, + config = function() + require "plugins.configs.alpha" + end, + }, + + ["numToStr/Comment.nvim"] = { + module = "Comment", + keys = { "gc", "gb" }, + config = function() + require("plugins.configs.others").comment() + end, + }, + + -- file managing , picker etc + ["kyazdani42/nvim-tree.lua"] = { + ft = "alpha", + cmd = { "NvimTreeToggle", "NvimTreeFocus" }, + config = function() + require "plugins.configs.nvimtree" + end, + }, + + ["nvim-telescope/telescope.nvim"] = { + cmd = "Telescope", + config = function() + require "plugins.configs.telescope" + end, + }, + + -- Only load whichkey after all the gui + ["folke/which-key.nvim"] = { + module = "which-key", + config = function() + require "plugins.configs.whichkey" + end, + }, } require("core.packer").run(plugins)