refactor: make utils globally accessible

This commit is contained in:
Micah Halter
2022-05-14 08:00:17 -04:00
committed by Micah Halter
parent 0aff4abb4b
commit bc1ef0641f
39 changed files with 461 additions and 473 deletions
+1
View File
@@ -1,6 +1,7 @@
-- Global objects
globals = {
"PACKER_BOOTSTRAP",
"astronvim",
"vim",
"C",
"packer_plugins",
+6 -21
View File
@@ -1,41 +1,26 @@
vim.opt.rtp:append(vim.fn.stdpath "config" .. "/../astronvim")
local impatient_ok, impatient = pcall(require, "impatient")
if impatient_ok then
impatient.enable_profile()
end
local utils = require "core.utils"
vim.opt.rtp:append(vim.fn.stdpath "config" .. "/../astronvim")
utils.bootstrap()
local sources = {
for _, source in ipairs {
"core.utils",
"core.options",
"core.plugins",
"core.autocmds",
"core.mappings",
"core.ui",
"configs.which-key-register",
}
for _, source in ipairs(sources) do
} do
local status_ok, fault = pcall(require, source)
if not status_ok then
error("Failed to load " .. source .. "\n\n" .. fault)
elseif source == "core.plugins" then
utils.compiled()
end
end
local status_ok, ui = pcall(require, "core.ui")
if status_ok then
for ui_addition, enabled in pairs(utils.user_plugin_opts("ui", { nui_input = true, telescope_select = true })) do
if enabled and type(ui[ui_addition]) == "function" then
ui[ui_addition]()
end
end
end
local polish = utils.user_plugin_opts("polish", nil, false)
local polish = astronvim.user_plugin_opts("polish", nil, false)
if type(polish) == "function" then
polish()
end
+1 -1
View File
@@ -3,7 +3,7 @@ local M = {}
function M.config()
local status_ok, Comment = pcall(require, "Comment")
if status_ok then
Comment.setup(require("core.utils").user_plugin_opts("plugins.Comment", {
Comment.setup(astronvim.user_plugin_opts("plugins.Comment", {
pre_hook = function(ctx)
local U = require "Comment.utils"
+1 -1
View File
@@ -3,7 +3,7 @@ local M = {}
function M.config()
local present, aerial = pcall(require, "aerial")
if present then
aerial.setup(require("core.utils").user_plugin_opts("plugins.aerial", {
aerial.setup(astronvim.user_plugin_opts("plugins.aerial", {
close_behavior = "global",
backends = { "lsp", "treesitter", "markdown" },
min_width = 28,
+9 -9
View File
@@ -3,13 +3,13 @@ local M = {}
function M.config()
local present, alpha = pcall(require, "alpha")
if present then
local utils = require "core.utils"
alpha.setup(utils.user_plugin_opts("plugins.alpha", {
local alpha_button = astronvim.alpha_button
alpha.setup(astronvim.user_plugin_opts("plugins.alpha", {
layout = {
{ type = "padding", val = vim.fn.max { 2, vim.fn.floor(vim.fn.winheight(0) * 0.2) } },
{
type = "text",
val = utils.user_plugin_opts("header", {
val = astronvim.user_plugin_opts("header", {
" █████ ███████ ████████ ██████ ██████",
"██ ██ ██ ██ ██ ██ ██ ██",
"███████ ███████ ██ ██████ ██ ██",
@@ -28,12 +28,12 @@ function M.config()
{
type = "group",
val = {
utils.alpha_button("LDR f f", " Find File "),
utils.alpha_button("LDR f o", " Recents "),
utils.alpha_button("LDR f w", " Find Word "),
utils.alpha_button("LDR f n", " New File "),
utils.alpha_button("LDR f m", " Bookmarks "),
utils.alpha_button("LDR S l", " Last Session "),
alpha_button("LDR f f", " Find File "),
alpha_button("LDR f o", " Recents "),
alpha_button("LDR f w", " Find Word "),
alpha_button("LDR f n", " New File "),
alpha_button("LDR f m", " Bookmarks "),
alpha_button("LDR S l", " Last Session "),
},
opts = { spacing = 1 },
},
+3 -2
View File
@@ -1,9 +1,10 @@
local M = {}
local user_plugin_opts = astronvim.user_plugin_opts
function M.config()
local status_ok, npairs = pcall(require, "nvim-autopairs")
if status_ok then
npairs.setup(require("core.utils").user_plugin_opts("plugins.nvim-autopairs", {
npairs.setup(user_plugin_opts("plugins.nvim-autopairs", {
check_ts = true,
ts_config = {
lua = { "string", "source" },
@@ -24,7 +25,7 @@ function M.config()
},
}))
local rules = require("core.utils").user_plugin_opts("nvim-autopairs").add_rules
local rules = user_plugin_opts("nvim-autopairs").add_rules
if vim.tbl_contains({ "function", "table" }, type(rules)) then
npairs.add_rules(type(rules) == "function" and rules(npairs) or rules)
end
+1 -1
View File
@@ -3,7 +3,7 @@ local M = {}
function M.config()
local present, better_escape = pcall(require, "better_escape")
if present then
better_escape.setup(require("core.utils").user_plugin_opts "plugins.better_escape")
better_escape.setup(astronvim.user_plugin_opts "plugins.better_escape")
end
end
+1 -1
View File
@@ -3,7 +3,7 @@ local M = {}
function M.config()
local status_ok, bufferline = pcall(require, "bufferline")
if status_ok then
bufferline.setup(require("core.utils").user_plugin_opts("plugins.bufferline", {
bufferline.setup(astronvim.user_plugin_opts("plugins.bufferline", {
options = {
offsets = {
{ filetype = "NvimTree", text = "", padding = 1 },
+1 -1
View File
@@ -3,7 +3,7 @@ local M = {}
function M.config()
local status_ok, cinnamon = pcall(require, "cinnamon")
if status_ok then
cinnamon.setup(require("core.utils").user_plugin_opts("plugins.cinnamon", {
cinnamon.setup(astronvim.user_plugin_opts("plugins.cinnamon", {
extra_keymaps = true,
extended_keymaps = true,
}))
+1 -1
View File
@@ -37,7 +37,7 @@ function M.config()
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match "%s" == nil
end
cmp.setup(require("core.utils").user_plugin_opts("plugins.cmp", {
cmp.setup(astronvim.user_plugin_opts("plugins.cmp", {
preselect = cmp.PreselectMode.None,
formatting = {
fields = { "kind", "abbr", "menu" },
+1 -1
View File
@@ -1,6 +1,6 @@
local M = {}
local user_plugin_opts = require("core.utils").user_plugin_opts
local user_plugin_opts = astronvim.user_plugin_opts
function M.config()
local present, colorizer = pcall(require, "colorizer")
+1 -1
View File
@@ -8,7 +8,7 @@ function M.config()
local provider = require("core.status").provider
local conditional = require("core.status").conditional
-- stylua: ignore
feline.setup(require("core.utils").user_plugin_opts("plugins.feline", {
feline.setup(astronvim.user_plugin_opts("plugins.feline", {
disable = { filetypes = { "^NvimTree$", "^neo%-tree$", "^dashboard$", "^Outline$", "^aerial$" } },
theme = hl.group("StatusLine", { fg = C.fg, bg = C.bg_1 }),
components = {
+1 -1
View File
@@ -3,7 +3,7 @@ local M = {}
function M.config()
local status_ok, gitsigns = pcall(require, "gitsigns")
if status_ok then
gitsigns.setup(require("core.utils").user_plugin_opts("plugins.gitsigns", {
gitsigns.setup(astronvim.user_plugin_opts("plugins.gitsigns", {
signs = {
add = { text = "" },
change = { text = "" },
+1 -1
View File
@@ -3,7 +3,7 @@ local M = {}
function M.config()
local status_ok, icons = pcall(require, "nvim-web-devicons")
if status_ok then
icons.set_icon(require("core.utils").user_plugin_opts("plugins.nvim-web-devicons", {
icons.set_icon(astronvim.user_plugin_opts("plugins.nvim-web-devicons", {
deb = { icon = "", name = "Deb" },
lock = { icon = "", name = "Lock" },
mp3 = { icon = "", name = "Mp3" },
+1 -1
View File
@@ -3,7 +3,7 @@ local M = {}
function M.config()
local status_ok, indent_blankline = pcall(require, "indent_blankline")
if status_ok then
indent_blankline.setup(require("core.utils").user_plugin_opts("plugins.indent_blankline", {
indent_blankline.setup(astronvim.user_plugin_opts("plugins.indent_blankline", {
buftype_exclude = {
"nofile",
"terminal",
+1 -1
View File
@@ -3,7 +3,7 @@ local M = {}
function M.config()
local present, indent_o_matic = pcall(require, "indent-o-matic")
if present then
indent_o_matic.setup(require("core.utils").user_plugin_opts "plugins.indent-o-matic")
indent_o_matic.setup(astronvim.user_plugin_opts "plugins.indent-o-matic")
end
end
+3 -2
View File
@@ -1,4 +1,5 @@
local M = {}
local user_plugin_opts = astronvim.user_plugin_opts
local sign_define = vim.fn.sign_define
local map = vim.keymap.set
@@ -15,7 +16,7 @@ function M.setup()
sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" })
end
vim.diagnostic.config(require("core.utils").user_plugin_opts("diagnostics", {
vim.diagnostic.config(user_plugin_opts("diagnostics", {
virtual_text = true,
signs = { active = signs },
update_in_insert = true,
@@ -112,7 +113,7 @@ M.on_attach = function(client, bufnr)
client.resolved_capabilities.document_formatting = false
end
local on_attach_override = require("core.utils").user_plugin_opts("lsp.on_attach", nil, false)
local on_attach_override = user_plugin_opts("lsp.on_attach", nil, false)
if type(on_attach_override) == "function" then
on_attach_override(client, bufnr)
end
+1 -1
View File
@@ -2,7 +2,7 @@ local status_ok, lspconfig = pcall(require, "lspconfig")
if status_ok then
local insert = table.insert
local tbl_deep_extend = vim.tbl_deep_extend
local user_plugin_opts = require("core.utils").user_plugin_opts
local user_plugin_opts = astronvim.user_plugin_opts
local user_registration = user_plugin_opts("lsp.server_registration", nil, false)
local handlers = require "configs.lsp.handlers"
local on_attach = handlers.on_attach
+1 -1
View File
@@ -1,7 +1,7 @@
local M = {}
function M.config()
local user_settings = require("core.utils").user_plugin_opts "luasnip"
local user_settings = astronvim.user_plugin_opts "luasnip"
local loader_avail, loader = pcall(require, "luasnip/loaders/from_vscode")
if loader_avail then
if user_settings.vscode_snippet_paths ~= nil then
+1 -2
View File
@@ -3,8 +3,7 @@ local M = {}
function M.config()
local status_ok, neotree = pcall(require, "neo-tree")
if status_ok then
vim.g.neo_tree_remove_legacy_commands = true
neotree.setup(require("core.utils").user_plugin_opts("plugins.neo-tree", {
neotree.setup(astronvim.user_plugin_opts("plugins.neo-tree", {
popup_border_style = "rounded",
enable_diagnostics = false,
default_component_configs = {
+1 -1
View File
@@ -3,7 +3,7 @@ local M = {}
function M.config()
local present, notify = pcall(require, "notify")
if present then
notify.setup(require("core.utils").user_plugin_opts("plugins.notify", { stages = "fade" }))
notify.setup(astronvim.user_plugin_opts("plugins.notify", { stages = "fade" }))
vim.notify = notify
end
+1 -1
View File
@@ -3,7 +3,7 @@ local M = {}
function M.config()
local present, null_ls = pcall(require, "null-ls")
if present then
null_ls.setup(require("core.utils").user_plugin_opts "plugins.null-ls")
null_ls.setup(astronvim.user_plugin_opts "plugins.null-ls")
end
end
+1 -1
View File
@@ -3,7 +3,7 @@ local M = {}
function M.config()
local status_ok, lsp_installer = pcall(require, "nvim-lsp-installer")
if status_ok then
lsp_installer.setup(require("core.utils").user_plugin_opts("plugins.nvim-lsp-installer", {
lsp_installer.setup(astronvim.user_plugin_opts("plugins.nvim-lsp-installer", {
ui = {
icons = {
server_installed = "",
+1 -3
View File
@@ -3,9 +3,7 @@ local M = {}
function M.config()
local status_ok, session_manager = pcall(require, "session_manager")
if status_ok then
session_manager.setup(require("core.utils").user_plugin_opts("plugins.session_manager", {
autosave_last_session = false,
}))
session_manager.setup(astronvim.user_plugin_opts("plugins.session_manager", { autosave_last_session = false }))
end
end
+1 -1
View File
@@ -3,7 +3,7 @@ local M = {}
function M.config()
local present, smart_splits = pcall(require, "smart-splits")
if present then
smart_splits.setup(require("core.utils").user_plugin_opts("plugins.smart-splits", {
smart_splits.setup(astronvim.user_plugin_opts("plugins.smart-splits", {
ignored_filetypes = {
"nofile",
"quickfix",
+1 -1
View File
@@ -14,7 +14,7 @@ function M.config()
telescope.load_extension "aerial"
end
telescope.setup(require("core.utils").user_plugin_opts("plugins.telescope", {
telescope.setup(astronvim.user_plugin_opts("plugins.telescope", {
defaults = {
prompt_prefix = "",
+1 -1
View File
@@ -3,7 +3,7 @@ local M = {}
function M.config()
local status_ok, toggleterm = pcall(require, "toggleterm")
if status_ok then
toggleterm.setup(require("core.utils").user_plugin_opts("plugins.toggleterm", {
toggleterm.setup(astronvim.user_plugin_opts("plugins.toggleterm", {
size = 10,
open_mapping = [[<c-\>]],
shading_factor = 2,
+1 -1
View File
@@ -3,7 +3,7 @@ local M = {}
function M.config()
local status_ok, treesitter = pcall(require, "nvim-treesitter.configs")
if status_ok then
treesitter.setup(require("core.utils").user_plugin_opts("plugins.treesitter", {
treesitter.setup(astronvim.user_plugin_opts("plugins.treesitter", {
ensure_installed = {},
sync_install = false,
ignore_install = {},
+8 -12
View File
@@ -1,9 +1,7 @@
local M = {}
local utils = require "core.utils"
local status_ok, which_key = pcall(require, "which-key")
if status_ok then
local is_available = astronvim.is_available
local user_plugin_opts = astronvim.user_plugin_opts
local mappings = {
n = {
["<leader>"] = {
@@ -27,27 +25,27 @@ if status_ok then
end
end
if utils.is_available "neovim-session-manager" then
if is_available "neovim-session-manager" then
init_table("n", "<leader>", "S")
end
if utils.is_available "gitsigns.nvim" then
if is_available "gitsigns.nvim" then
init_table("n", "<leader>", "g")
end
if utils.is_available "nvim-toggleterm.lua" then
if is_available "nvim-toggleterm.lua" then
init_table("n", "<leader>", "g")
init_table("n", "<leader>", "t")
end
if utils.is_available "telescope.nvim" then
if is_available "telescope.nvim" then
init_table("n", "<leader>", "s")
init_table("n", "<leader>", "g")
end
mappings = require("core.utils").user_plugin_opts("which-key.register_mappings", mappings)
mappings = user_plugin_opts("which-key.register_mappings", mappings)
-- support previous legacy notation, deprecate at some point
mappings.n["<leader>"] = require("core.utils").user_plugin_opts("which-key.register_n_leader", mappings.n["<leader>"])
mappings.n["<leader>"] = user_plugin_opts("which-key.register_n_leader", mappings.n["<leader>"])
for mode, prefixes in pairs(mappings) do
for prefix, mapping_table in pairs(prefixes) do
which_key.register(mapping_table, {
@@ -61,5 +59,3 @@ if status_ok then
end
end
end
return M
+3 -2
View File
@@ -1,10 +1,11 @@
local M = {}
local user_plugin_opts = astronvim.user_plugin_opts
function M.config()
local status_ok, which_key = pcall(require, "which-key")
if status_ok then
local show = which_key.show
local show_override = require("core.utils").user_plugin_opts("which-key.show", nil, false)
local show_override = user_plugin_opts("which-key.show", nil, false)
if type(show_override) == "function" then
which_key.show = show_override(show)
else
@@ -14,7 +15,7 @@ function M.config()
end
end
end
which_key.setup(require("core.utils").user_plugin_opts("plugins.which-key", {
which_key.setup(user_plugin_opts("plugins.which-key", {
plugins = {
spelling = { enabled = true },
presets = { operators = false },
+4 -5
View File
@@ -1,5 +1,4 @@
local utils = require "core.utils"
local is_available = utils.is_available
local is_available = astronvim.is_available
local cmd = vim.api.nvim_create_autocmd
local augroup = vim.api.nvim_create_augroup
local create_command = vim.api.nvim_create_user_command
@@ -10,7 +9,7 @@ cmd({ "VimEnter", "FileType", "BufEnter", "WinEnter" }, {
group = "highlighturl",
pattern = "*",
callback = function()
utils.set_url_match()
astronvim.set_url_match()
end,
})
@@ -85,5 +84,5 @@ if is_available "feline.nvim" then
})
end
create_command("AstroUpdate", utils.update, { desc = "Update AstroNvim" })
create_command("ToggleHighlightURL", utils.toggle_url_match, { desc = "Toggle URL Highlights" })
create_command("AstroUpdate", astronvim.update, { desc = "Update AstroNvim" })
create_command("ToggleHighlightURL", astronvim.toggle_url_match, { desc = "Toggle URL Highlights" })
+4 -5
View File
@@ -1,5 +1,4 @@
local utils = require "core.utils"
local is_available = utils.is_available
local is_available = astronvim.is_available
local map = vim.keymap.set
map("", "<Space>", "<Nop>") -- disable space because leader
@@ -10,11 +9,11 @@ map("n", "<leader>w", "<cmd>w<cr>", { desc = "Save" })
map("n", "<leader>q", "<cmd>q<cr>", { desc = "Quit" })
map("n", "<leader>h", "<cmd>nohlsearch<cr>", { desc = "No Highlight" })
map("n", "<leader>u", function()
utils.toggle_url_match()
astronvim.toggle_url_match()
end, { desc = "Toggle URL Highlights" })
map("n", "<leader>fn", "<cmd>enew<cr>", { desc = "New File" })
map("n", "gx", function()
utils.url_opener()
astronvim.url_opener()
end, { desc = "Open the file under cursor with system app" })
map("n", "<C-s>", "<cmd>w!<cr>", { desc = "Force write" })
map("n", "<C-q>", "<cmd>q!<cr>", { desc = "Force quit" })
@@ -233,7 +232,7 @@ end
-- Terminal
if is_available "nvim-toggleterm.lua" then
local toggle_term_cmd = utils.toggle_term_cmd
local toggle_term_cmd = astronvim.toggle_term_cmd
map("n", "<C-\\>", "<cmd>ToggleTerm<cr>", { desc = "Toggle terminal" })
map("n", "<leader>gg", function()
toggle_term_cmd "lazygit"
+2 -4
View File
@@ -1,13 +1,11 @@
local utils = require "core.utils"
local default = "default_theme"
local colorscheme = utils.user_plugin_opts("colorscheme", default, false)
local colorscheme = astronvim.user_plugin_opts("colorscheme", default, false)
if not vim.tbl_contains(vim.fn.getcompletion("", "color"), colorscheme) then
colorscheme = default
end
vim.api.nvim_command(("colorscheme %s"):format(colorscheme))
utils.vim_opts(utils.user_plugin_opts("options", {
astronvim.vim_opts(astronvim.user_plugin_opts("options", {
opt = {
clipboard = "unnamedplus", -- Connection to the system clipboard
completeopt = { "menuone", "noselect" }, -- Options for insert mode completion
+340 -338
View File
@@ -1,344 +1,346 @@
local packer_status_ok, packer = pcall(require, "packer")
if packer_status_ok then
local astro_plugins = {
-- Plugin manager
["wbthomason/packer.nvim"] = {},
local astro_plugins = {
-- Plugin manager
["wbthomason/packer.nvim"] = {},
-- Optimiser
["lewis6991/impatient.nvim"] = {},
-- Optimiser
["lewis6991/impatient.nvim"] = {},
-- Lua functions
["nvim-lua/plenary.nvim"] = { module = "plenary" },
-- Lua functions
["nvim-lua/plenary.nvim"] = { module = "plenary" },
-- Popup API
["nvim-lua/popup.nvim"] = {},
-- Popup API
["nvim-lua/popup.nvim"] = {},
-- Indent detection
["Darazaki/indent-o-matic"] = {
event = "BufReadPost",
config = function()
require("configs.indent-o-matic").config()
end,
},
-- Notification Enhancer
["rcarriga/nvim-notify"] = {
event = "VimEnter",
config = function()
require("configs.notify").config()
end,
},
-- Neovim UI Enhancer
["MunifTanjim/nui.nvim"] = { module = "nui" },
-- Cursorhold fix
["antoinemadec/FixCursorHold.nvim"] = {
event = { "BufRead", "BufNewFile" },
config = function()
vim.g.cursorhold_updatetime = 100
end,
},
-- Smarter Splits
["mrjones2014/smart-splits.nvim"] = {
module = "smart-splits",
config = function()
require("configs.smart-splits").config()
end,
},
-- Icons
["kyazdani42/nvim-web-devicons"] = {
event = "VimEnter",
config = function()
require("configs.icons").config()
end,
},
-- Bufferline
["akinsho/bufferline.nvim"] = {
after = "nvim-web-devicons",
config = function()
require("configs.bufferline").config()
end,
},
-- Better buffer closing
["famiu/bufdelete.nvim"] = { cmd = { "Bdelete", "Bwipeout" } },
-- File explorer
["nvim-neo-tree/neo-tree.nvim"] = {
branch = "v2.x",
module = "neo-tree",
cmd = "Neotree",
requires = { "MunifTanjim/nui.nvim", "nvim-lua/plenary.nvim" },
config = function()
require("configs.neo-tree").config()
end,
},
-- Statusline
["feline-nvim/feline.nvim"] = {
after = "nvim-web-devicons",
config = function()
require("configs.feline").config()
end,
},
-- Parenthesis highlighting
["p00f/nvim-ts-rainbow"] = { after = "nvim-treesitter" },
-- Autoclose tags
["windwp/nvim-ts-autotag"] = { after = "nvim-treesitter" },
-- Context based commenting
["JoosepAlviste/nvim-ts-context-commentstring"] = { after = "nvim-treesitter" },
-- Syntax highlighting
["nvim-treesitter/nvim-treesitter"] = {
run = ":TSUpdate",
event = { "BufRead", "BufNewFile" },
cmd = {
"TSInstall",
"TSInstallInfo",
"TSInstallSync",
"TSUninstall",
"TSUpdate",
"TSUpdateSync",
"TSDisableAll",
"TSEnableAll",
},
config = function()
require("configs.treesitter").config()
end,
},
-- Snippet collection
["rafamadriz/friendly-snippets"] = { event = "InsertEnter" },
-- Snippet engine
["L3MON4D3/LuaSnip"] = {
after = "friendly-snippets",
config = function()
require("configs.luasnip").config()
end,
},
-- Completion engine
["hrsh7th/nvim-cmp"] = {
after = "LuaSnip",
config = function()
require("configs.cmp").config()
end,
},
-- Snippet completion source
["saadparwaiz1/cmp_luasnip"] = {
after = "nvim-cmp",
config = function()
require("core.utils").add_user_cmp_source "luasnip"
end,
},
-- Buffer completion source
["hrsh7th/cmp-buffer"] = {
after = "nvim-cmp",
config = function()
require("core.utils").add_user_cmp_source "buffer"
end,
},
-- Path completion source
["hrsh7th/cmp-path"] = {
after = "nvim-cmp",
config = function()
require("core.utils").add_user_cmp_source "path"
end,
},
-- LSP completion source
["hrsh7th/cmp-nvim-lsp"] = {
after = "nvim-cmp",
config = function()
require("core.utils").add_user_cmp_source "nvim_lsp"
end,
},
-- Built-in LSP
["neovim/nvim-lspconfig"] = { event = "VimEnter" },
-- LSP manager
["williamboman/nvim-lsp-installer"] = {
after = "nvim-lspconfig",
config = function()
require("configs.nvim-lsp-installer").config()
require "configs.lsp"
end,
},
-- LSP symbols
["stevearc/aerial.nvim"] = {
module = "aerial",
cmd = { "AerialToggle", "AerialOpen", "AerialInfo" },
config = function()
require("configs.aerial").config()
end,
},
-- Formatting and linting
["jose-elias-alvarez/null-ls.nvim"] = {
event = { "BufRead", "BufNewFile" },
config = function()
require("configs.null-ls").config()
end,
},
-- Fuzzy finder
["nvim-telescope/telescope.nvim"] = {
cmd = "Telescope",
module = "telescope",
config = function()
require("configs.telescope").config()
end,
},
-- Fuzzy finder syntax support
[("nvim-telescope/telescope-%s-native.nvim"):format(vim.fn.has "win32" == 1 and "fzy" or "fzf")] = {
after = "telescope.nvim",
run = "make",
config = function()
require("telescope").load_extension(vim.fn.has "win32" == 1 and "fzy_native" or "fzf")
end,
},
-- Git integration
["lewis6991/gitsigns.nvim"] = {
event = "BufEnter",
config = function()
require("configs.gitsigns").config()
end,
},
-- Start screen
["goolord/alpha-nvim"] = {
cmd = "Alpha",
module = "alpha",
config = function()
require("configs.alpha").config()
end,
},
-- Color highlighting
["norcalli/nvim-colorizer.lua"] = {
event = { "BufRead", "BufNewFile" },
config = function()
require("configs.colorizer").config()
end,
},
-- Autopairs
["windwp/nvim-autopairs"] = {
event = "InsertEnter",
config = function()
require("configs.autopairs").config()
end,
},
-- Terminal
["akinsho/nvim-toggleterm.lua"] = {
cmd = "ToggleTerm",
module = { "toggleterm", "toggleterm.terminal" },
config = function()
require("configs.toggleterm").config()
end,
},
-- Commenting
["numToStr/Comment.nvim"] = {
module = { "Comment", "Comment.api" },
keys = { "gc", "gb", "g<", "g>" },
config = function()
require("configs.Comment").config()
end,
},
-- Indentation
["lukas-reineke/indent-blankline.nvim"] = {
event = "BufRead",
config = function()
require("configs.indent-line").config()
end,
},
-- Keymaps popup
["folke/which-key.nvim"] = {
module = "which-key",
config = function()
require("configs.which-key").config()
end,
},
-- Smooth scrolling
["declancm/cinnamon.nvim"] = {
event = { "BufRead", "BufNewFile" },
config = function()
require("configs.cinnamon").config()
end,
},
-- Smooth escaping
["max397574/better-escape.nvim"] = {
event = "InsertCharPre",
config = function()
require("configs.better_escape").config()
end,
},
-- Get extra JSON schemas
["b0o/SchemaStore.nvim"] = { module = "schemastore" },
-- Session manager
["Shatur/neovim-session-manager"] = {
module = "session_manager",
cmd = "SessionManager",
event = "BufWritePost",
config = function()
require("configs.session_manager").config()
end,
},
}
local utils = require "core.utils"
local user_plugin_opts = utils.user_plugin_opts
packer.startup {
function(use)
for key, plugin in pairs(user_plugin_opts("plugins.init", astro_plugins)) do
if type(key) == "string" and not plugin[1] then
plugin[1] = key
end
use(plugin)
end
-- Indent detection
["Darazaki/indent-o-matic"] = {
event = "BufReadPost",
config = function()
require("configs.indent-o-matic").config()
end,
config = user_plugin_opts("plugins.packer", {
compile_path = utils.default_compile_path,
display = {
open_fn = function()
return require("packer.util").float { border = "rounded" }
end,
},
-- Notification Enhancer
["rcarriga/nvim-notify"] = {
event = "VimEnter",
config = function()
require("configs.notify").config()
end,
},
-- Neovim UI Enhancer
["MunifTanjim/nui.nvim"] = { module = "nui" },
-- Cursorhold fix
["antoinemadec/FixCursorHold.nvim"] = {
event = { "BufRead", "BufNewFile" },
config = function()
vim.g.cursorhold_updatetime = 100
end,
},
-- Smarter Splits
["mrjones2014/smart-splits.nvim"] = {
module = "smart-splits",
config = function()
require("configs.smart-splits").config()
end,
},
-- Icons
["kyazdani42/nvim-web-devicons"] = {
event = "VimEnter",
config = function()
require("configs.icons").config()
end,
},
-- Bufferline
["akinsho/bufferline.nvim"] = {
after = "nvim-web-devicons",
config = function()
require("configs.bufferline").config()
end,
},
-- Better buffer closing
["famiu/bufdelete.nvim"] = { cmd = { "Bdelete", "Bwipeout" } },
-- File explorer
["nvim-neo-tree/neo-tree.nvim"] = {
branch = "v2.x",
module = "neo-tree",
cmd = "Neotree",
requires = { "MunifTanjim/nui.nvim", "nvim-lua/plenary.nvim" },
setup = function()
vim.g.neo_tree_remove_legacy_commands = true
end,
config = function()
require("configs.neo-tree").config()
end,
},
-- Statusline
["feline-nvim/feline.nvim"] = {
after = "nvim-web-devicons",
config = function()
require("configs.feline").config()
end,
},
-- Parenthesis highlighting
["p00f/nvim-ts-rainbow"] = { after = "nvim-treesitter" },
-- Autoclose tags
["windwp/nvim-ts-autotag"] = { after = "nvim-treesitter" },
-- Context based commenting
["JoosepAlviste/nvim-ts-context-commentstring"] = { after = "nvim-treesitter" },
-- Syntax highlighting
["nvim-treesitter/nvim-treesitter"] = {
run = ":TSUpdate",
event = { "BufRead", "BufNewFile" },
cmd = {
"TSInstall",
"TSInstallInfo",
"TSInstallSync",
"TSUninstall",
"TSUpdate",
"TSUpdateSync",
"TSDisableAll",
"TSEnableAll",
},
config = function()
require("configs.treesitter").config()
end,
},
-- Snippet collection
["rafamadriz/friendly-snippets"] = { event = "InsertEnter" },
-- Snippet engine
["L3MON4D3/LuaSnip"] = {
after = "friendly-snippets",
config = function()
require("configs.luasnip").config()
end,
},
-- Completion engine
["hrsh7th/nvim-cmp"] = {
after = "LuaSnip",
config = function()
require("configs.cmp").config()
end,
},
-- Snippet completion source
["saadparwaiz1/cmp_luasnip"] = {
after = "nvim-cmp",
config = function()
astronvim.add_user_cmp_source "luasnip"
end,
},
-- Buffer completion source
["hrsh7th/cmp-buffer"] = {
after = "nvim-cmp",
config = function()
astronvim.add_user_cmp_source "buffer"
end,
},
-- Path completion source
["hrsh7th/cmp-path"] = {
after = "nvim-cmp",
config = function()
astronvim.add_user_cmp_source "path"
end,
},
-- LSP completion source
["hrsh7th/cmp-nvim-lsp"] = {
after = "nvim-cmp",
config = function()
astronvim.add_user_cmp_source "nvim_lsp"
end,
},
-- Built-in LSP
["neovim/nvim-lspconfig"] = { event = "VimEnter" },
-- LSP manager
["williamboman/nvim-lsp-installer"] = {
after = "nvim-lspconfig",
config = function()
require("configs.nvim-lsp-installer").config()
require "configs.lsp"
end,
},
-- LSP symbols
["stevearc/aerial.nvim"] = {
module = "aerial",
cmd = { "AerialToggle", "AerialOpen", "AerialInfo" },
config = function()
require("configs.aerial").config()
end,
},
-- Formatting and linting
["jose-elias-alvarez/null-ls.nvim"] = {
event = { "BufRead", "BufNewFile" },
config = function()
require("configs.null-ls").config()
end,
},
-- Fuzzy finder
["nvim-telescope/telescope.nvim"] = {
cmd = "Telescope",
module = "telescope",
config = function()
require("configs.telescope").config()
end,
},
-- Fuzzy finder syntax support
[("nvim-telescope/telescope-%s-native.nvim"):format(vim.fn.has "win32" == 1 and "fzy" or "fzf")] = {
after = "telescope.nvim",
run = "make",
config = function()
require("telescope").load_extension(vim.fn.has "win32" == 1 and "fzy_native" or "fzf")
end,
},
-- Git integration
["lewis6991/gitsigns.nvim"] = {
event = "BufEnter",
config = function()
require("configs.gitsigns").config()
end,
},
-- Start screen
["goolord/alpha-nvim"] = {
cmd = "Alpha",
module = "alpha",
config = function()
require("configs.alpha").config()
end,
},
-- Color highlighting
["norcalli/nvim-colorizer.lua"] = {
event = { "BufRead", "BufNewFile" },
config = function()
require("configs.colorizer").config()
end,
},
-- Autopairs
["windwp/nvim-autopairs"] = {
event = "InsertEnter",
config = function()
require("configs.autopairs").config()
end,
},
-- Terminal
["akinsho/nvim-toggleterm.lua"] = {
cmd = "ToggleTerm",
module = { "toggleterm", "toggleterm.terminal" },
config = function()
require("configs.toggleterm").config()
end,
},
-- Commenting
["numToStr/Comment.nvim"] = {
module = { "Comment", "Comment.api" },
keys = { "gc", "gb", "g<", "g>" },
config = function()
require("configs.Comment").config()
end,
},
-- Indentation
["lukas-reineke/indent-blankline.nvim"] = {
event = "BufRead",
config = function()
require("configs.indent-line").config()
end,
},
-- Keymaps popup
["folke/which-key.nvim"] = {
module = "which-key",
config = function()
require("configs.which-key").config()
end,
},
-- Smooth scrolling
["declancm/cinnamon.nvim"] = {
event = { "BufRead", "BufNewFile" },
config = function()
require("configs.cinnamon").config()
end,
},
-- Smooth escaping
["max397574/better-escape.nvim"] = {
event = "InsertCharPre",
config = function()
require("configs.better_escape").config()
end,
},
-- Get extra JSON schemas
["b0o/SchemaStore.nvim"] = { module = "schemastore" },
-- Session manager
["Shatur/neovim-session-manager"] = {
module = "session_manager",
cmd = "SessionManager",
event = "BufWritePost",
config = function()
require("configs.session_manager").config()
end,
},
}
local user_plugin_opts = astronvim.user_plugin_opts
local packer = astronvim.initialize_packer()
packer.startup {
function(use)
for key, plugin in pairs(user_plugin_opts("plugins.init", astro_plugins)) do
if type(key) == "string" and not plugin[1] then
plugin[1] = key
end
use(plugin)
end
end,
config = user_plugin_opts("plugins.packer", {
compile_path = astronvim.default_compile_path,
display = {
open_fn = function()
return require("packer.util").float { border = "rounded" }
end,
},
profile = {
enable = true,
threshold = 0.0001,
},
git = {
clone_timeout = 300,
subcommands = {
update = "pull --rebase",
},
profile = {
enable = true,
threshold = 0.0001,
},
git = {
clone_timeout = 300,
subcommands = {
update = "pull --rebase",
},
},
auto_clean = true,
compile_on_sync = true,
}),
}
end
},
auto_clean = true,
compile_on_sync = true,
}),
}
astronvim.compiled()
+9 -4
View File
@@ -1,5 +1,6 @@
local M = {}
function M.nui_input()
local ui = {}
function ui.nui_input()
-- Set up NUI for UI Input
-- From: https://github.com/MunifTanjim/nui.nvim/wiki/vim.ui#vimuiinput
local input_ui
@@ -71,7 +72,7 @@ function M.nui_input()
end
end
function M.telescope_select()
function ui.telescope_select()
-- Telescope UI selection
-- From: https://github.com/stevearc/dressing.nvim/blob/master/lua/dressing/select/telescope.lua
vim.ui.select = vim.schedule_wrap(function(items, opts, on_choice)
@@ -137,4 +138,8 @@ function M.telescope_select()
end)
end
return M
for ui_addition, enabled in pairs(astronvim.user_plugin_opts("ui", { nui_input = true, telescope_select = true })) do
if enabled and type(ui[ui_addition]) == "function" then
ui[ui_addition]()
end
end
+43 -40
View File
@@ -1,4 +1,4 @@
local M = {}
_G.astronvim = {}
local stdpath = vim.fn.stdpath
local supported_configs = {
@@ -6,15 +6,11 @@ local supported_configs = {
stdpath "config" .. "/../astronvim",
}
local function file_not_empty(path)
return vim.fn.empty(vim.fn.glob(path)) == 0
end
local function load_module_file(module)
local found_module = nil
for _, config_path in ipairs(supported_configs) do
local module_path = config_path .. "/lua/" .. module:gsub("%.", "/") .. ".lua"
if file_not_empty(module_path) then
if vim.fn.filereadable(module_path) == 1 then
found_module = module_path
end
end
@@ -23,16 +19,16 @@ local function load_module_file(module)
if status_ok then
found_module = loaded_module
else
vim.notify("Error loading " .. found_module, "error", M.base_notification)
vim.notify("Error loading " .. found_module, "error", astronvim.base_notification)
end
end
return found_module
end
M.user_settings = load_module_file "user.init"
M.default_compile_path = stdpath "config" .. "/lua/packer_compiled.lua"
M.base_notification = { title = "AstroNvim" }
M.user_terminals = {}
astronvim.user_settings = load_module_file "user.init"
astronvim.default_compile_path = stdpath "config" .. "/lua/packer_compiled.lua"
astronvim.base_notification = { title = "AstroNvim" }
astronvim.user_terminals = {}
local function func_or_extend(overrides, default, extend)
if extend then
@@ -48,7 +44,7 @@ local function func_or_extend(overrides, default, extend)
end
local function user_setting_table(module)
local settings = M.user_settings or {}
local settings = astronvim.user_settings or {}
for tbl in string.gmatch(module, "([^%.]+)") do
settings = settings[tbl]
if settings == nil then
@@ -58,23 +54,30 @@ local function user_setting_table(module)
return settings
end
function M.bootstrap()
local packer_avail, _ = pcall(require, "packer")
function astronvim.initialize_packer()
local packer_avail, packer = pcall(require, "packer")
if not packer_avail then
local packer_path = stdpath "data" .. "/site/pack/packer/start/packer.nvim"
vim.fn.delete(packer_path, "rf")
vim.fn.system {
"git",
"clone",
"--depth",
"1",
"https://github.com/wbthomason/packer.nvim",
stdpath "data" .. "/site/pack/packer/start/packer.nvim",
packer_path,
}
print "Cloning packer...\nSetup AstroNvim"
vim.cmd "packadd packer.nvim"
packer_avail, packer = pcall(require, "packer")
if not packer_avail then
error("Failed to load packer at:" .. packer_path .. "\n\n" .. packer)
end
end
return packer
end
function M.vim_opts(options)
function astronvim.vim_opts(options)
for scope, table in pairs(options) do
for setting, value in pairs(table) do
vim[scope][setting] = value
@@ -82,7 +85,7 @@ function M.vim_opts(options)
end
end
function M.user_plugin_opts(module, default, extend)
function astronvim.user_plugin_opts(module, default, extend)
if extend == nil then
extend = true
end
@@ -97,9 +100,9 @@ function M.user_plugin_opts(module, default, extend)
return default
end
function M.compiled()
function astronvim.compiled()
local run_me, _ = loadfile(
M.user_plugin_opts("plugins.packer", { compile_path = M.default_compile_path }).compile_path
astronvim.user_plugin_opts("plugins.packer", { compile_path = astronvim.default_compile_path }).compile_path
)
if run_me then
run_me()
@@ -108,19 +111,19 @@ function M.compiled()
end
end
function M.url_opener()
function astronvim.url_opener()
if vim.fn.has "mac" == 1 then
vim.fn.jobstart({ "open", vim.fn.expand "<cfile>" }, { detach = true })
elseif vim.fn.has "unix" == 1 then
vim.fn.jobstart({ "xdg-open", vim.fn.expand "<cfile>" }, { detach = true })
else
vim.notify("gx is not supported on this OS!", "error", M.base_notification)
vim.notify("gx is not supported on this OS!", "error", astronvim.base_notification)
end
end
-- term_details can be either a string for just a command or
-- a complete table to provide full access to configuration when calling Terminal:new()
function M.toggle_term_cmd(term_details)
function astronvim.toggle_term_cmd(term_details)
if type(term_details) == "string" then
term_details = { cmd = term_details, hidden = true }
end
@@ -129,13 +132,13 @@ function M.toggle_term_cmd(term_details)
term_details.count = vim.v.count
term_key = term_key .. vim.v.count
end
if M.user_terminals[term_key] == nil then
M.user_terminals[term_key] = require("toggleterm.terminal").Terminal:new(term_details)
if astronvim.user_terminals[term_key] == nil then
astronvim.user_terminals[term_key] = require("toggleterm.terminal").Terminal:new(term_details)
end
M.user_terminals[term_key]:toggle()
astronvim.user_terminals[term_key]:toggle()
end
function M.add_cmp_source(source)
function astronvim.add_cmp_source(source)
local cmp_avail, cmp = pcall(require, "cmp")
if cmp_avail then
local config = cmp.get_config()
@@ -144,8 +147,8 @@ function M.add_cmp_source(source)
end
end
function M.add_user_cmp_source(source)
local priority = M.user_plugin_opts("cmp.source_priority", {
function astronvim.add_user_cmp_source(source)
local priority = astronvim.user_plugin_opts("cmp.source_priority", {
nvim_lsp = 1000,
luasnip = 750,
buffer = 500,
@@ -155,10 +158,10 @@ function M.add_user_cmp_source(source)
if priority then
source.priority = priority
end
M.add_cmp_source(source)
astronvim.add_cmp_source(source)
end
function M.alpha_button(sc, txt)
function astronvim.alpha_button(sc, txt)
local sc_ = sc:gsub("%s", ""):gsub("LDR", "<leader>")
if vim.g.mapleader then
sc = sc:gsub("LDR", vim.g.mapleader == " " and "SPC" or vim.g.mapleader)
@@ -183,11 +186,11 @@ function M.alpha_button(sc, txt)
}
end
function M.is_available(plugin)
function astronvim.is_available(plugin)
return packer_plugins ~= nil and packer_plugins[plugin] ~= nil
end
function M.delete_url_match()
function astronvim.delete_url_match()
for _, match in ipairs(vim.fn.getmatches()) do
if match.group == "HighlightURL" then
vim.fn.matchdelete(match.id)
@@ -195,8 +198,8 @@ function M.delete_url_match()
end
end
function M.set_url_match()
M.delete_url_match()
function astronvim.set_url_match()
astronvim.delete_url_match()
if vim.g.highlighturl_enabled then
vim.fn.matchadd(
"HighlightURL",
@@ -206,12 +209,12 @@ function M.set_url_match()
end
end
function M.toggle_url_match()
function astronvim.toggle_url_match()
vim.g.highlighturl_enabled = not vim.g.highlighturl_enabled
M.set_url_match()
astronvim.set_url_match()
end
function M.update()
function astronvim.update()
(require "plenary.job")
:new({
command = "git",
@@ -219,13 +222,13 @@ function M.update()
cwd = stdpath "config",
on_exit = function(_, return_val)
if return_val == 0 then
vim.notify("Updated!", "info", M.base_notification)
vim.notify("Updated!", "info", astronvim.base_notification)
else
vim.notify("Update failed! Please try pulling manually.", "error", M.base_notification)
vim.notify("Update failed! Please try pulling manually.", "error", astronvim.base_notification)
end
end,
})
:sync()
end
return M
return astronvim
+1 -1
View File
@@ -73,4 +73,4 @@ local colors = {
zip = "#f9d71c",
}
return require("core.utils").user_plugin_opts("default_theme.colors", colors)
return astronvim.user_plugin_opts("default_theme.colors", colors)
+1 -1
View File
@@ -6,7 +6,7 @@ vim.o.background = "dark"
vim.o.termguicolors = true
vim.g.colors_name = "default_theme"
local user_plugin_opts = require("core.utils").user_plugin_opts
local user_plugin_opts = astronvim.user_plugin_opts
local utils = require "default_theme.utils"
local modules = {
+1 -1
View File
@@ -1,6 +1,6 @@
local M = {}
local user_settings = require("core.utils").user_plugin_opts "default_theme"
local user_settings = astronvim.user_plugin_opts "default_theme"
function M.parse_diagnostic_style(default)
if type(user_settings.diagnostics_style) == "table" then