refactor!: rename core module to astronvim
This commit is contained in:
@@ -35,7 +35,7 @@ body:
|
||||
id: health
|
||||
attributes:
|
||||
label: AstroNvim Health
|
||||
description: Output of `:checkhealth core`
|
||||
description: Output of `:checkhealth astronvim`
|
||||
placeholder: |
|
||||
## AstroNvim
|
||||
- INFO: AstroNvim Version: nightly (v2.11.8-181-g11d5990)
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
for _, source in ipairs {
|
||||
"core.bootstrap",
|
||||
"core.options",
|
||||
"core.lazy",
|
||||
"core.autocmds",
|
||||
"core.mappings",
|
||||
"astronvim.bootstrap",
|
||||
"astronvim.options",
|
||||
"astronvim.lazy",
|
||||
"astronvim.autocmds",
|
||||
"astronvim.mappings",
|
||||
} do
|
||||
local status_ok, fault = pcall(require, source)
|
||||
if not status_ok then vim.api.nvim_err_writeln("Failed to load " .. source .. "\n\n" .. fault) end
|
||||
end
|
||||
|
||||
local utils = require "core.utils"
|
||||
local utils = require "astronvim.utils"
|
||||
|
||||
if astronvim.default_colorscheme then
|
||||
if not pcall(vim.cmd.colorscheme, astronvim.default_colorscheme) then
|
||||
|
||||
@@ -2,7 +2,7 @@ local namespace = vim.api.nvim_create_namespace
|
||||
local autocmd = vim.api.nvim_create_autocmd
|
||||
local augroup = vim.api.nvim_create_augroup
|
||||
|
||||
local utils = require "core.utils"
|
||||
local utils = require "astronvim.utils"
|
||||
local is_available = utils.is_available
|
||||
local astroevent = utils.event
|
||||
|
||||
@@ -24,7 +24,7 @@ autocmd({ "BufAdd", "BufEnter" }, {
|
||||
table.insert(bufs, args.buf)
|
||||
vim.t.bufs = bufs
|
||||
end
|
||||
vim.t.bufs = vim.tbl_filter(require("core.utils.buffer").is_valid, vim.t.bufs)
|
||||
vim.t.bufs = vim.tbl_filter(require("astronvim.utils.buffer").is_valid, vim.t.bufs)
|
||||
astroevent "BufsUpdated"
|
||||
end,
|
||||
})
|
||||
@@ -44,7 +44,7 @@ autocmd("BufDelete", {
|
||||
end
|
||||
end
|
||||
end
|
||||
vim.t.bufs = vim.tbl_filter(require("core.utils.buffer").is_valid, vim.t.bufs)
|
||||
vim.t.bufs = vim.tbl_filter(require("astronvim.utils.buffer").is_valid, vim.t.bufs)
|
||||
astroevent "BufsUpdated"
|
||||
vim.cmd.redrawtabline()
|
||||
end,
|
||||
@@ -215,15 +215,19 @@ autocmd({ "BufRead", "BufWinEnter", "BufNewFile" }, {
|
||||
local cmd = vim.api.nvim_create_user_command
|
||||
cmd(
|
||||
"AstroUpdatePackages",
|
||||
function() require("core.utils.updater").update_packages() end,
|
||||
function() require("astronvim.utils.updater").update_packages() end,
|
||||
{ desc = "Update Plugins and Mason" }
|
||||
)
|
||||
cmd("AstroUpdate", function() require("core.utils.updater").update() end, { desc = "Update AstroNvim" })
|
||||
cmd("AstroRollback", function() require("core.utils.updater").rollback() end, { desc = "Rollback AstroNvim" })
|
||||
cmd("AstroVersion", function() require("core.utils.updater").version() end, { desc = "Check AstroNvim Version" })
|
||||
cmd("AstroChangelog", function() require("core.utils.updater").changelog() end, { desc = "Check AstroNvim Changelog" })
|
||||
cmd("AstroUpdate", function() require("astronvim.utils.updater").update() end, { desc = "Update AstroNvim" })
|
||||
cmd("AstroRollback", function() require("astronvim.utils.updater").rollback() end, { desc = "Rollback AstroNvim" })
|
||||
cmd("AstroVersion", function() require("astronvim.utils.updater").version() end, { desc = "Check AstroNvim Version" })
|
||||
cmd(
|
||||
"AstroChangelog",
|
||||
function() require("astronvim.utils.updater").changelog() end,
|
||||
{ desc = "Check AstroNvim Changelog" }
|
||||
)
|
||||
cmd(
|
||||
"ToggleHighlightURL",
|
||||
function() require("core.utils.ui").toggle_url_match() end,
|
||||
function() require("astronvim.utils.ui").toggle_url_match() end,
|
||||
{ desc = "Toggle URL Highlights" }
|
||||
)
|
||||
@@ -3,7 +3,7 @@
|
||||
-- This module simply sets up the global `astronvim` module.
|
||||
-- This is automatically loaded and should not be resourced, everything is accessible through the global `astronvim` variable.
|
||||
--
|
||||
-- @module core.bootstrap
|
||||
-- @module astronvim.bootstrap
|
||||
-- @copyright 2022
|
||||
-- @license GNU General Public License v3.0
|
||||
|
||||
@@ -37,7 +37,7 @@ local function load_module_file(module)
|
||||
-- if successful at loading, set the return variable
|
||||
if status_ok then
|
||||
found_module = loaded_module
|
||||
-- if unsuccessful, throw an error
|
||||
-- if unsuccessful, throw an error
|
||||
else
|
||||
vim.api.nvim_err_writeln("Error loading file: " .. found_module .. "\n\n" .. loaded_module)
|
||||
end
|
||||
@@ -58,11 +58,11 @@ local function func_or_extend(overrides, default, extend)
|
||||
if type(overrides) == "table" then
|
||||
local opts = overrides or {}
|
||||
default = default and vim.tbl_deep_extend("force", default, opts) or opts
|
||||
-- if the override is a function, call it with the default and overwrite default with the return value
|
||||
-- if the override is a function, call it with the default and overwrite default with the return value
|
||||
elseif type(overrides) == "function" then
|
||||
default = overrides(default)
|
||||
end
|
||||
-- if extend is set to false and we have a provided override, simply override the default
|
||||
-- if extend is set to false and we have a provided override, simply override the default
|
||||
elseif overrides ~= nil then
|
||||
default = overrides
|
||||
end
|
||||
@@ -3,7 +3,7 @@ local M = {}
|
||||
function M.check()
|
||||
vim.health.report_start "AstroNvim"
|
||||
|
||||
vim.health.report_info("AstroNvim Version: " .. require("core.utils.updater").version(true))
|
||||
vim.health.report_info("AstroNvim Version: " .. require("astronvim.utils.updater").version(true))
|
||||
vim.health.report_info("Neovim Version: v" .. vim.fn.matchstr(vim.fn.execute "version", "NVIM v\\zs[^\n]*"))
|
||||
|
||||
if vim.version().prerelease then
|
||||
@@ -12,7 +12,7 @@ if not vim.loop.fs_stat(lazypath) then
|
||||
vim.cmd.bw()
|
||||
vim.opt.cmdheight = oldcmdheight
|
||||
vim.tbl_map(function(module) pcall(require, module) end, { "nvim-treesitter", "mason" })
|
||||
require("core.utils").notify "Mason is installing packages if configured, check status with :Mason"
|
||||
require("astronvim.utils").notify "Mason is installing packages if configured, check status with :Mason"
|
||||
end,
|
||||
})
|
||||
end
|
||||
@@ -0,0 +1,673 @@
|
||||
local utils = require "astronvim.utils"
|
||||
local is_available = utils.is_available
|
||||
|
||||
local maps = { i = {}, n = {}, v = {}, t = {} }
|
||||
|
||||
local sections = {
|
||||
f = { name = "Find" },
|
||||
p = { name = "Packages" },
|
||||
l = { name = "LSP" },
|
||||
u = { name = "UI" },
|
||||
b = { name = "Buffers" },
|
||||
d = { name = "Debugger" },
|
||||
g = { name = "Git" },
|
||||
S = { name = "Session" },
|
||||
t = { name = "Terminal" },
|
||||
}
|
||||
|
||||
-- Normal --
|
||||
-- Standard Operations
|
||||
maps.n["j"] = { "v:count ? 'j' : 'gj'", expr = true, desc = "Move cursor down" }
|
||||
maps.n["k"] = { "v:count ? 'k' : 'gk'", expr = true, desc = "Move cursor up" }
|
||||
maps.v["j"] = maps.n.j
|
||||
maps.v["k"] = maps.n.k
|
||||
maps.n["<leader>w"] = { "<cmd>w<cr>", desc = "Save" }
|
||||
maps.n["<leader>q"] = { "<cmd>confirm q<cr>", desc = "Quit" }
|
||||
maps.n["<leader>n"] = { "<cmd>enew<cr>", desc = "New File" }
|
||||
maps.n["gx"] = {
|
||||
function() require("astronvim.utils").system_open() end,
|
||||
desc = "Open the file under cursor with system app",
|
||||
}
|
||||
maps.n["<C-s>"] = { "<cmd>w!<cr>", desc = "Force write" }
|
||||
maps.n["<C-q>"] = { "<cmd>q!<cr>", desc = "Force quit" }
|
||||
maps.n["|"] = { "<cmd>vsplit<cr>", desc = "Vertical Split" }
|
||||
maps.n["\\"] = { "<cmd>split<cr>", desc = "Horizontal Split" }
|
||||
|
||||
-- Plugin Manager
|
||||
maps.n["<leader>p"] = sections.p
|
||||
maps.n["<leader>pi"] = {
|
||||
function() require("lazy").install() end,
|
||||
desc = "Plugins Install",
|
||||
}
|
||||
maps.n["<leader>ps"] = {
|
||||
function() require("lazy").home() end,
|
||||
desc = "Plugins Status",
|
||||
}
|
||||
maps.n["<leader>pS"] = {
|
||||
function() require("lazy").sync() end,
|
||||
desc = "Plugins Sync",
|
||||
}
|
||||
maps.n["<leader>pu"] = {
|
||||
function() require("lazy").check() end,
|
||||
desc = "Plugins Check Updates",
|
||||
}
|
||||
maps.n["<leader>pU"] = {
|
||||
function() require("lazy").update() end,
|
||||
desc = "Plugins Update",
|
||||
}
|
||||
|
||||
-- AstroNvim
|
||||
maps.n["<leader>pa"] = { "<cmd>AstroUpdatePackages<cr>", desc = "Update Plugins and Mason" }
|
||||
maps.n["<leader>pA"] = { "<cmd>AstroUpdate<cr>", desc = "AstroNvim Update" }
|
||||
maps.n["<leader>pv"] = { "<cmd>AstroVersion<cr>", desc = "AstroNvim Version" }
|
||||
maps.n["<leader>pl"] = { "<cmd>AstroChangelog<cr>", desc = "AstroNvim Changelog" }
|
||||
|
||||
-- Manage Buffers
|
||||
maps.n["<leader>c"] = {
|
||||
function() require("astronvim.utils.buffer").close(0) end,
|
||||
desc = "Close buffer",
|
||||
}
|
||||
maps.n["<leader>C"] = {
|
||||
function() require("astronvim.utils.buffer").close(0, true) end,
|
||||
desc = "Force close buffer",
|
||||
}
|
||||
maps.n["]b"] = {
|
||||
function() require("astronvim.utils.buffer").nav(vim.v.count > 0 and vim.v.count or 1) end,
|
||||
desc = "Next buffer",
|
||||
}
|
||||
maps.n["[b"] = {
|
||||
function() require("astronvim.utils.buffer").nav(-(vim.v.count > 0 and vim.v.count or 1)) end,
|
||||
desc = "Previous buffer",
|
||||
}
|
||||
maps.n[">b"] = {
|
||||
function() require("astronvim.utils.buffer").move(vim.v.count > 0 and vim.v.count or 1) end,
|
||||
desc = "Move buffer tab right",
|
||||
}
|
||||
maps.n["<b"] = {
|
||||
function() require("astronvim.utils.buffer").move(-(vim.v.count > 0 and vim.v.count or 1)) end,
|
||||
desc = "Move buffer tab left",
|
||||
}
|
||||
|
||||
maps.n["<leader>b"] = sections.b
|
||||
maps.n["<leader>bb"] = {
|
||||
function()
|
||||
require("astronvim.utils.status").heirline.buffer_picker(function(bufnr) vim.api.nvim_win_set_buf(0, bufnr) end)
|
||||
end,
|
||||
desc = "Select buffer from tabline",
|
||||
}
|
||||
maps.n["<leader>bd"] = {
|
||||
function()
|
||||
require("astronvim.utils.status").heirline.buffer_picker(
|
||||
function(bufnr) require("astronvim.utils.buffer").close(bufnr) end
|
||||
)
|
||||
end,
|
||||
desc = "Delete buffer from tabline",
|
||||
}
|
||||
maps.n["<leader>b\\"] = {
|
||||
function()
|
||||
require("astronvim.utils.status").heirline.buffer_picker(function(bufnr)
|
||||
vim.cmd.split()
|
||||
vim.api.nvim_win_set_buf(0, bufnr)
|
||||
end)
|
||||
end,
|
||||
desc = "Horizontal split buffer from tabline",
|
||||
}
|
||||
maps.n["<leader>b|"] = {
|
||||
function()
|
||||
require("astronvim.utils.status").heirline.buffer_picker(function(bufnr)
|
||||
vim.cmd.vsplit()
|
||||
vim.api.nvim_win_set_buf(0, bufnr)
|
||||
end)
|
||||
end,
|
||||
desc = "Vertical split buffer from tabline",
|
||||
}
|
||||
|
||||
-- Navigate tabs
|
||||
maps.n["]t"] = {
|
||||
function() vim.cmd.tabnext() end,
|
||||
desc = "Next tab",
|
||||
}
|
||||
maps.n["[t"] = {
|
||||
function() vim.cmd.tabprevious() end,
|
||||
desc = "Previous tab",
|
||||
}
|
||||
|
||||
-- Alpha
|
||||
if is_available "alpha-nvim" then
|
||||
maps.n["<leader>h"] = {
|
||||
function()
|
||||
local wins = vim.api.nvim_tabpage_list_wins(0)
|
||||
if #wins > 1 and vim.api.nvim_get_option_value("filetype", { win = wins[1] }) == "neo-tree" then
|
||||
vim.fn.win_gotoid(wins[2]) -- go to non-neo-tree window to toggle alpha
|
||||
end
|
||||
require("alpha").start(false, require("alpha").default_config)
|
||||
end,
|
||||
desc = "Home Screen",
|
||||
}
|
||||
end
|
||||
|
||||
-- Comment
|
||||
if is_available "Comment.nvim" then
|
||||
maps.n["<leader>/"] = {
|
||||
function() require("Comment.api").toggle.linewise.current() end,
|
||||
desc = "Comment line",
|
||||
}
|
||||
maps.v["<leader>/"] = {
|
||||
"<esc><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<cr>",
|
||||
desc = "Toggle comment line",
|
||||
}
|
||||
end
|
||||
|
||||
-- GitSigns
|
||||
if is_available "gitsigns.nvim" then
|
||||
maps.n["<leader>g"] = sections.g
|
||||
maps.n["]g"] = {
|
||||
function() require("gitsigns").next_hunk() end,
|
||||
desc = "Next Git hunk",
|
||||
}
|
||||
maps.n["[g"] = {
|
||||
function() require("gitsigns").prev_hunk() end,
|
||||
desc = "Previous Git hunk",
|
||||
}
|
||||
maps.n["<leader>gl"] = {
|
||||
function() require("gitsigns").blame_line() end,
|
||||
desc = "View Git blame",
|
||||
}
|
||||
maps.n["<leader>gp"] = {
|
||||
function() require("gitsigns").preview_hunk() end,
|
||||
desc = "Preview Git hunk",
|
||||
}
|
||||
maps.n["<leader>gh"] = {
|
||||
function() require("gitsigns").reset_hunk() end,
|
||||
desc = "Reset Git hunk",
|
||||
}
|
||||
maps.n["<leader>gr"] = {
|
||||
function() require("gitsigns").reset_buffer() end,
|
||||
desc = "Reset Git buffer",
|
||||
}
|
||||
maps.n["<leader>gs"] = {
|
||||
function() require("gitsigns").stage_hunk() end,
|
||||
desc = "Stage Git hunk",
|
||||
}
|
||||
maps.n["<leader>gS"] = {
|
||||
function() require("gitsigns").stage_buffer() end,
|
||||
desc = "Stage Git buffer",
|
||||
}
|
||||
maps.n["<leader>gu"] = {
|
||||
function() require("gitsigns").undo_stage_hunk() end,
|
||||
desc = "Unstage Git hunk",
|
||||
}
|
||||
maps.n["<leader>gd"] = {
|
||||
function() require("gitsigns").diffthis() end,
|
||||
desc = "View Git diff",
|
||||
}
|
||||
end
|
||||
|
||||
-- NeoTree
|
||||
if is_available "neo-tree.nvim" then
|
||||
maps.n["<leader>e"] = { "<cmd>Neotree toggle<cr>", desc = "Toggle Explorer" }
|
||||
maps.n["<leader>o"] = {
|
||||
function()
|
||||
if vim.bo.filetype == "neo-tree" then
|
||||
vim.cmd.wincmd "p"
|
||||
else
|
||||
vim.cmd.Neotree "focus"
|
||||
end
|
||||
end,
|
||||
desc = "Toggle Explorer Focus",
|
||||
}
|
||||
end
|
||||
|
||||
-- Session Manager
|
||||
if is_available "neovim-session-manager" then
|
||||
maps.n["<leader>S"] = sections.S
|
||||
maps.n["<leader>Sl"] = { "<cmd>SessionManager! load_last_session<cr>", desc = "Load last session" }
|
||||
maps.n["<leader>Ss"] = { "<cmd>SessionManager! save_current_session<cr>", desc = "Save this session" }
|
||||
maps.n["<leader>Sd"] = { "<cmd>SessionManager! delete_session<cr>", desc = "Delete session" }
|
||||
maps.n["<leader>Sf"] = { "<cmd>SessionManager! load_session<cr>", desc = "Search sessions" }
|
||||
maps.n["<leader>S."] =
|
||||
{ "<cmd>SessionManager! load_current_dir_session<cr>", desc = "Load current directory session" }
|
||||
end
|
||||
|
||||
-- Package Manager
|
||||
if is_available "mason.nvim" then
|
||||
maps.n["<leader>pm"] = { "<cmd>Mason<cr>", desc = "Mason Installer" }
|
||||
maps.n["<leader>pM"] = { "<cmd>MasonUpdateAll<cr>", desc = "Mason Update" }
|
||||
end
|
||||
|
||||
-- Smart Splits
|
||||
if is_available "smart-splits.nvim" then
|
||||
-- Better window navigation
|
||||
maps.n["<C-h>"] = {
|
||||
function() require("smart-splits").move_cursor_left() end,
|
||||
desc = "Move to left split",
|
||||
}
|
||||
maps.n["<C-j>"] = {
|
||||
function() require("smart-splits").move_cursor_down() end,
|
||||
desc = "Move to below split",
|
||||
}
|
||||
maps.n["<C-k>"] = {
|
||||
function() require("smart-splits").move_cursor_up() end,
|
||||
desc = "Move to above split",
|
||||
}
|
||||
maps.n["<C-l>"] = {
|
||||
function() require("smart-splits").move_cursor_right() end,
|
||||
desc = "Move to right split",
|
||||
}
|
||||
|
||||
-- Resize with arrows
|
||||
maps.n["<C-Up>"] = {
|
||||
function() require("smart-splits").resize_up() end,
|
||||
desc = "Resize split up",
|
||||
}
|
||||
maps.n["<C-Down>"] = {
|
||||
function() require("smart-splits").resize_down() end,
|
||||
desc = "Resize split down",
|
||||
}
|
||||
maps.n["<C-Left>"] = {
|
||||
function() require("smart-splits").resize_left() end,
|
||||
desc = "Resize split left",
|
||||
}
|
||||
maps.n["<C-Right>"] = {
|
||||
function() require("smart-splits").resize_right() end,
|
||||
desc = "Resize split right",
|
||||
}
|
||||
else
|
||||
maps.n["<C-h>"] = { "<C-w>h", desc = "Move to left split" }
|
||||
maps.n["<C-j>"] = { "<C-w>j", desc = "Move to below split" }
|
||||
maps.n["<C-k>"] = { "<C-w>k", desc = "Move to above split" }
|
||||
maps.n["<C-l>"] = { "<C-w>l", desc = "Move to right split" }
|
||||
maps.n["<C-Up>"] = { "<cmd>resize -2<CR>", desc = "Resize split up" }
|
||||
maps.n["<C-Down>"] = { "<cmd>resize +2<CR>", desc = "Resize split down" }
|
||||
maps.n["<C-Left>"] = { "<cmd>vertical resize -2<CR>", desc = "Resize split left" }
|
||||
maps.n["<C-Right>"] = { "<cmd>vertical resize +2<CR>", desc = "Resize split right" }
|
||||
end
|
||||
|
||||
-- SymbolsOutline
|
||||
if is_available "aerial.nvim" then
|
||||
maps.n["<leader>l"] = sections.l
|
||||
maps.n["<leader>lS"] = {
|
||||
function() require("aerial").toggle() end,
|
||||
desc = "Symbols outline",
|
||||
}
|
||||
end
|
||||
|
||||
-- Telescope
|
||||
if is_available "telescope.nvim" then
|
||||
maps.n["<leader>f"] = sections.f
|
||||
maps.n["<leader>g"] = sections.g
|
||||
maps.n["<leader>gb"] = {
|
||||
function() require("telescope.builtin").git_branches() end,
|
||||
desc = "Git branches",
|
||||
}
|
||||
maps.n["<leader>gc"] = {
|
||||
function() require("telescope.builtin").git_commits() end,
|
||||
desc = "Git commits",
|
||||
}
|
||||
maps.n["<leader>gt"] = {
|
||||
function() require("telescope.builtin").git_status() end,
|
||||
desc = "Git status",
|
||||
}
|
||||
maps.n["<leader>f<CR>"] = {
|
||||
function() require("telescope.builtin").resume() end,
|
||||
desc = "Resume previous search",
|
||||
}
|
||||
maps.n["<leader>f'"] = {
|
||||
function() require("telescope.builtin").marks() end,
|
||||
desc = "Find marks",
|
||||
}
|
||||
maps.n["<leader>fa"] = {
|
||||
function()
|
||||
local cwd = vim.fn.stdpath "config" .. "/.."
|
||||
local search_dirs = {}
|
||||
for _, dir in ipairs(astronvim.supported_configs) do -- search all supported config locations
|
||||
if dir == astronvim.install.home then dir = dir .. "/lua/user" end -- don't search the astronvim core files
|
||||
if vim.fn.isdirectory(dir) == 1 then table.insert(search_dirs, dir) end -- add directory to search if exists
|
||||
end
|
||||
if vim.tbl_isempty(search_dirs) then -- if no config folders found, show warning
|
||||
require("astronvim.utils").notify("No user configuration files found", "warn")
|
||||
else
|
||||
if #search_dirs == 1 then cwd = search_dirs[1] end -- if only one directory, focus cwd
|
||||
require("telescope.builtin").find_files {
|
||||
prompt_title = "Config Files",
|
||||
search_dirs = search_dirs,
|
||||
cwd = cwd,
|
||||
} -- call telescope
|
||||
end
|
||||
end,
|
||||
desc = "Find AstroNvim config files",
|
||||
}
|
||||
maps.n["<leader>fb"] = {
|
||||
function() require("telescope.builtin").buffers() end,
|
||||
desc = "Find buffers",
|
||||
}
|
||||
maps.n["<leader>fc"] = {
|
||||
function() require("telescope.builtin").grep_string() end,
|
||||
desc = "Find for word under cursor",
|
||||
}
|
||||
maps.n["<leader>fC"] = {
|
||||
function() require("telescope.builtin").commands() end,
|
||||
desc = "Find commands",
|
||||
}
|
||||
maps.n["<leader>ff"] = {
|
||||
function() require("telescope.builtin").find_files() end,
|
||||
desc = "Find files",
|
||||
}
|
||||
maps.n["<leader>fF"] = {
|
||||
function() require("telescope.builtin").find_files { hidden = true, no_ignore = true } end,
|
||||
desc = "Find all files",
|
||||
}
|
||||
maps.n["<leader>fh"] = {
|
||||
function() require("telescope.builtin").help_tags() end,
|
||||
desc = "Find help",
|
||||
}
|
||||
maps.n["<leader>fk"] = {
|
||||
function() require("telescope.builtin").keymaps() end,
|
||||
desc = "Find keymaps",
|
||||
}
|
||||
maps.n["<leader>fm"] = {
|
||||
function() require("telescope.builtin").man_pages() end,
|
||||
desc = "Find man",
|
||||
}
|
||||
if is_available "nvim-notify" then
|
||||
maps.n["<leader>fn"] = {
|
||||
function() require("telescope").extensions.notify.notify() end,
|
||||
desc = "Find notifications",
|
||||
}
|
||||
end
|
||||
maps.n["<leader>fo"] = {
|
||||
function() require("telescope.builtin").oldfiles() end,
|
||||
desc = "Find history",
|
||||
}
|
||||
maps.n["<leader>fr"] = {
|
||||
function() require("telescope.builtin").registers() end,
|
||||
desc = "Find registers",
|
||||
}
|
||||
maps.n["<leader>ft"] = {
|
||||
function() require("telescope.builtin").colorscheme { enable_preview = true } end,
|
||||
desc = "Find themes",
|
||||
}
|
||||
maps.n["<leader>fw"] = {
|
||||
function() require("telescope.builtin").live_grep() end,
|
||||
desc = "Find words",
|
||||
}
|
||||
maps.n["<leader>fW"] = {
|
||||
function()
|
||||
require("telescope.builtin").live_grep {
|
||||
additional_args = function(args) return vim.list_extend(args, { "--hidden", "--no-ignore" }) end,
|
||||
}
|
||||
end,
|
||||
desc = "Find words in all files",
|
||||
}
|
||||
maps.n["<leader>l"] = sections.l
|
||||
maps.n["<leader>lD"] = {
|
||||
function() require("telescope.builtin").diagnostics() end,
|
||||
desc = "Search diagnostics",
|
||||
}
|
||||
maps.n["<leader>ls"] = {
|
||||
function()
|
||||
local aerial_avail, _ = pcall(require, "aerial")
|
||||
if aerial_avail then
|
||||
require("telescope").extensions.aerial.aerial()
|
||||
else
|
||||
require("telescope.builtin").lsp_document_symbols()
|
||||
end
|
||||
end,
|
||||
desc = "Search symbols",
|
||||
}
|
||||
end
|
||||
|
||||
-- Terminal
|
||||
if is_available "toggleterm.nvim" then
|
||||
maps.n["<leader>t"] = sections.t
|
||||
local toggle_term_cmd = require("astronvim.utils").toggle_term_cmd
|
||||
if vim.fn.executable "lazygit" == 1 then
|
||||
maps.n["<leader>g"] = sections.g
|
||||
maps.n["<leader>gg"] = {
|
||||
function() toggle_term_cmd "lazygit" end,
|
||||
desc = "ToggleTerm lazygit",
|
||||
}
|
||||
maps.n["<leader>tl"] = {
|
||||
function() toggle_term_cmd "lazygit" end,
|
||||
desc = "ToggleTerm lazygit",
|
||||
}
|
||||
end
|
||||
if vim.fn.executable "node" == 1 then
|
||||
maps.n["<leader>tn"] = {
|
||||
function() toggle_term_cmd "node" end,
|
||||
desc = "ToggleTerm node",
|
||||
}
|
||||
end
|
||||
if vim.fn.executable "gdu" == 1 then
|
||||
maps.n["<leader>tu"] = {
|
||||
function() toggle_term_cmd "gdu" end,
|
||||
desc = "ToggleTerm gdu",
|
||||
}
|
||||
end
|
||||
if vim.fn.executable "btm" == 1 then
|
||||
maps.n["<leader>tt"] = {
|
||||
function() toggle_term_cmd "btm" end,
|
||||
desc = "ToggleTerm btm",
|
||||
}
|
||||
end
|
||||
local python = vim.fn.executable "python" == 1 and "python" or vim.fn.executable "python3" == 1 and "python3"
|
||||
if python then
|
||||
maps.n["<leader>tp"] = {
|
||||
function() toggle_term_cmd(python) end,
|
||||
desc = "ToggleTerm python",
|
||||
}
|
||||
end
|
||||
maps.n["<leader>tf"] = { "<cmd>ToggleTerm direction=float<cr>", desc = "ToggleTerm float" }
|
||||
maps.n["<leader>th"] = { "<cmd>ToggleTerm size=10 direction=horizontal<cr>", desc = "ToggleTerm horizontal split" }
|
||||
maps.n["<leader>tv"] = { "<cmd>ToggleTerm size=80 direction=vertical<cr>", desc = "ToggleTerm vertical split" }
|
||||
maps.n["<F7>"] = { "<cmd>ToggleTerm<cr>", desc = "Toggle terminal" }
|
||||
maps.t["<F7>"] = maps.n["<F7>"]
|
||||
maps.n["<C-'>"] = maps.n["<F7>"]
|
||||
maps.t["<C-'>"] = maps.n["<F7>"]
|
||||
end
|
||||
|
||||
if is_available "nvim-dap" then
|
||||
maps.n["<leader>d"] = sections.d
|
||||
-- modified function keys found with `showkey -a` in the terminal to get key code
|
||||
-- run `nvim -V3log +quit` and search through the "Terminal info" in the `log` file for the correct keyname
|
||||
maps.n["<F5>"] = {
|
||||
function() require("dap").continue() end,
|
||||
desc = "Debugger: Start",
|
||||
}
|
||||
maps.n["<F17>"] = {
|
||||
function() require("dap").terminate() end,
|
||||
desc = "Debugger: Stop",
|
||||
} -- Shift+F5
|
||||
maps.n["<F29>"] = {
|
||||
function() require("dap").restart_frame() end,
|
||||
desc = "Debugger: Restart",
|
||||
} -- Control+F5
|
||||
maps.n["<F6>"] = {
|
||||
function() require("dap").pause() end,
|
||||
desc = "Debugger: Pause",
|
||||
}
|
||||
maps.n["<F9>"] = {
|
||||
function() require("dap").toggle_breakpoint() end,
|
||||
desc = "Debugger: Toggle Breakpoint",
|
||||
}
|
||||
maps.n["<F10>"] = {
|
||||
function() require("dap").step_over() end,
|
||||
desc = "Debugger: Step Over",
|
||||
}
|
||||
maps.n["<F11>"] = {
|
||||
function() require("dap").step_into() end,
|
||||
desc = "Debugger: Step Into",
|
||||
}
|
||||
maps.n["<F23>"] = {
|
||||
function() require("dap").step_out() end,
|
||||
desc = "Debugger: Step Out",
|
||||
} -- Shift+F11
|
||||
maps.n["<leader>db"] = {
|
||||
function() require("dap").toggle_breakpoint() end,
|
||||
desc = "Toggle Breakpoint (F9)",
|
||||
}
|
||||
maps.n["<leader>dB"] = {
|
||||
function() require("dap").clear_breakpoints() end,
|
||||
desc = "Clear Breakpoints",
|
||||
}
|
||||
maps.n["<leader>dc"] = {
|
||||
function() require("dap").continue() end,
|
||||
desc = "Start/Continue (F5)",
|
||||
}
|
||||
maps.n["<leader>di"] = {
|
||||
function() require("dap").step_into() end,
|
||||
desc = "Step Into (F11)",
|
||||
}
|
||||
maps.n["<leader>do"] = {
|
||||
function() require("dap").step_over() end,
|
||||
desc = "Step Over (F10)",
|
||||
}
|
||||
maps.n["<leader>dO"] = {
|
||||
function() require("dap").step_out() end,
|
||||
desc = "Step Out (S-F11)",
|
||||
}
|
||||
maps.n["<leader>dq"] = {
|
||||
function() require("dap").close() end,
|
||||
desc = "Close Session",
|
||||
}
|
||||
maps.n["<leader>dQ"] = {
|
||||
function() require("dap").terminate() end,
|
||||
desc = "Terminate Session (S-F5)",
|
||||
}
|
||||
maps.n["<leader>dp"] = {
|
||||
function() require("dap").pause() end,
|
||||
desc = "Pause (F6)",
|
||||
}
|
||||
maps.n["<leader>dr"] = {
|
||||
function() require("dap").restart_frame() end,
|
||||
desc = "Restart (C-F5)",
|
||||
}
|
||||
maps.n["<leader>dR"] = {
|
||||
function() require("dap").repl.toggle() end,
|
||||
desc = "Toggle REPL",
|
||||
}
|
||||
if is_available "nvim-dap-ui" then
|
||||
maps.n["<leader>du"] = {
|
||||
function() require("dapui").toggle() end,
|
||||
desc = "Toggle Debugger UI",
|
||||
}
|
||||
maps.n["<leader>dh"] = {
|
||||
function() require("dap.ui.widgets").hover() end,
|
||||
desc = "Debugger Hover",
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
-- Improved Code Folding
|
||||
if is_available "nvim-ufo" then
|
||||
maps.n["zR"] = {
|
||||
function() require("ufo").openAllFolds() end,
|
||||
desc = "Open all folds",
|
||||
}
|
||||
maps.n["zM"] = {
|
||||
function() require("ufo").closeAllFolds() end,
|
||||
desc = "Close all folds",
|
||||
}
|
||||
maps.n["zr"] = {
|
||||
function() require("ufo").openFoldsExceptKinds() end,
|
||||
desc = "Fold less",
|
||||
}
|
||||
maps.n["zm"] = {
|
||||
function() require("ufo").closeFoldsWith() end,
|
||||
desc = "Fold more",
|
||||
}
|
||||
maps.n["zp"] = {
|
||||
function() require("ufo").peekFoldedLinesUnderCursor() end,
|
||||
desc = "Peek fold",
|
||||
}
|
||||
end
|
||||
|
||||
-- Stay in indent mode
|
||||
maps.v["<S-Tab>"] = { "<gv", desc = "unindent line" }
|
||||
maps.v["<Tab>"] = { ">gv", desc = "indent line" }
|
||||
|
||||
-- Improved Terminal Navigation
|
||||
maps.t["<C-h>"] = { "<c-\\><c-n><c-w>h", desc = "Terminal left window navigation" }
|
||||
maps.t["<C-j>"] = { "<c-\\><c-n><c-w>j", desc = "Terminal down window navigation" }
|
||||
maps.t["<C-k>"] = { "<c-\\><c-n><c-w>k", desc = "Terminal up window navigation" }
|
||||
maps.t["<C-l>"] = { "<c-\\><c-n><c-w>l", desc = "Terminal right window navigation" }
|
||||
|
||||
maps.n["<leader>u"] = sections.u
|
||||
-- Custom menu for modification of the user experience
|
||||
if is_available "nvim-autopairs" then
|
||||
maps.n["<leader>ua"] = {
|
||||
function() require("astronvim.utils.ui").toggle_autopairs() end,
|
||||
desc = "Toggle autopairs",
|
||||
}
|
||||
end
|
||||
maps.n["<leader>ub"] = {
|
||||
function() require("astronvim.utils.ui").toggle_background() end,
|
||||
desc = "Toggle background",
|
||||
}
|
||||
if is_available "nvim-cmp" then
|
||||
maps.n["<leader>uc"] = {
|
||||
function() require("astronvim.utils.ui").toggle_cmp() end,
|
||||
desc = "Toggle autocompletion",
|
||||
}
|
||||
end
|
||||
if is_available "nvim-colorizer.lua" then
|
||||
maps.n["<leader>uC"] = { "<cmd>ColorizerToggle<cr>", desc = "Toggle color highlight" }
|
||||
end
|
||||
maps.n["<leader>ud"] = {
|
||||
function() require("astronvim.utils.ui").toggle_diagnostics() end,
|
||||
desc = "Toggle diagnostics",
|
||||
}
|
||||
maps.n["<leader>ug"] = {
|
||||
function() require("astronvim.utils.ui").toggle_signcolumn() end,
|
||||
desc = "Toggle signcolumn",
|
||||
}
|
||||
maps.n["<leader>ui"] = {
|
||||
function() require("astronvim.utils.ui").set_indent() end,
|
||||
desc = "Change indent setting",
|
||||
}
|
||||
maps.n["<leader>ul"] = {
|
||||
function() require("astronvim.utils.ui").toggle_statusline() end,
|
||||
desc = "Toggle statusline",
|
||||
}
|
||||
maps.n["<leader>uL"] = {
|
||||
function() require("astronvim.utils.ui").toggle_codelens() end,
|
||||
desc = "Toggle CodeLens refresh",
|
||||
}
|
||||
maps.n["<leader>un"] = {
|
||||
function() require("astronvim.utils.ui").change_number() end,
|
||||
desc = "Change line numbering",
|
||||
}
|
||||
maps.n["<leader>uN"] = {
|
||||
function() require("astronvim.utils.ui").toggle_ui_notifications() end,
|
||||
desc = "Toggle UI notifications",
|
||||
}
|
||||
maps.n["<leader>up"] = {
|
||||
function() require("astronvim.utils.ui").toggle_paste() end,
|
||||
desc = "Toggle paste mode",
|
||||
}
|
||||
maps.n["<leader>us"] = {
|
||||
function() require("astronvim.utils.ui").toggle_spell() end,
|
||||
desc = "Toggle spellcheck",
|
||||
}
|
||||
maps.n["<leader>uS"] = {
|
||||
function() require("astronvim.utils.ui").toggle_conceal() end,
|
||||
desc = "Toggle conceal",
|
||||
}
|
||||
maps.n["<leader>ut"] = {
|
||||
function() require("astronvim.utils.ui").toggle_tabline() end,
|
||||
desc = "Toggle tabline",
|
||||
}
|
||||
maps.n["<leader>uu"] = {
|
||||
function() require("astronvim.utils.ui").toggle_url_match() end,
|
||||
desc = "Toggle URL highlight",
|
||||
}
|
||||
maps.n["<leader>uw"] = {
|
||||
function() require("astronvim.utils.ui").toggle_wrap() end,
|
||||
desc = "Toggle wrap",
|
||||
}
|
||||
maps.n["<leader>uy"] = {
|
||||
function() require("astronvim.utils.ui").toggle_syntax() end,
|
||||
desc = "Toggle syntax highlight",
|
||||
}
|
||||
|
||||
utils.set_mappings(astronvim.user_opts("mappings", maps))
|
||||
@@ -2,9 +2,9 @@
|
||||
--
|
||||
-- Buffer management related utility functions
|
||||
--
|
||||
-- This module can be loaded with `local buffer_utils = require "core.utils.buffer"`
|
||||
-- This module can be loaded with `local buffer_utils = require "astronvim.utils.buffer"`
|
||||
--
|
||||
-- @module core.utils.buffer
|
||||
-- @module astronvim.utils.buffer
|
||||
-- @copyright 2022
|
||||
-- @license GNU General Public License v3.0
|
||||
|
||||
@@ -41,7 +41,7 @@ function M.move(n)
|
||||
end
|
||||
end
|
||||
vim.t.bufs = bufs -- set buffers
|
||||
require("core.utils").event "BufsUpdated"
|
||||
require("astronvim.utils").event "BufsUpdated"
|
||||
vim.cmd.redrawtabline() -- redraw tabline
|
||||
end
|
||||
|
||||
@@ -65,7 +65,7 @@ function M.close(bufnr, force)
|
||||
if not bufnr or bufnr == 0 then bufnr = current end
|
||||
if bufnr == current then M.nav(vim.t.bufs[1] == current and 1 or -1) end
|
||||
|
||||
if require("core.utils").is_available "bufdelete.nvim" then
|
||||
if require("astronvim.utils").is_available "bufdelete.nvim" then
|
||||
require("bufdelete").bufdelete(bufnr, force)
|
||||
else
|
||||
vim.cmd((force and "bd!" or "confirm bd") .. bufnr)
|
||||
@@ -76,7 +76,7 @@ end
|
||||
function M.close_tab()
|
||||
if #vim.api.nvim_list_tabpages() > 1 then
|
||||
vim.t.bufs = nil
|
||||
require("core.utils").event "BufsUpdated"
|
||||
require("astronvim.utils").event "BufsUpdated"
|
||||
vim.cmd.tabclose()
|
||||
end
|
||||
end
|
||||
@@ -1,8 +1,8 @@
|
||||
--- ### Git LUA API
|
||||
--
|
||||
-- This module can be loaded with `local git = require "core.utils.git"`
|
||||
-- This module can be loaded with `local git = require "astronvim.utils.git"`
|
||||
--
|
||||
-- @module core.utils.git
|
||||
-- @module astronvim.utils.git
|
||||
-- @copyright 2022
|
||||
-- @license GNU General Public License v3.0
|
||||
|
||||
@@ -13,7 +13,9 @@ local function trim_or_nil(str) return type(str) == "string" and vim.trim(str) o
|
||||
--- Run a git command from the AstroNvim installation directory
|
||||
-- @param args the git arguments
|
||||
-- @return the result of the command or nil if unsuccessful
|
||||
function git.cmd(args, ...) return require("core.utils").cmd("git -C " .. astronvim.install.home .. " " .. args, ...) end
|
||||
function git.cmd(args, ...)
|
||||
return require("astronvim.utils").cmd("git -C " .. astronvim.install.home .. " " .. args, ...)
|
||||
end
|
||||
|
||||
--- Check if the AstroNvim is able to reach the `git` command
|
||||
-- @return the result of running `git --help`
|
||||
@@ -152,10 +154,12 @@ function git.pretty_changelog(commits)
|
||||
for _, commit in ipairs(commits) do
|
||||
local hash, type, msg = commit:match "(%[.*%])(.*:)(.*)"
|
||||
if hash and type and msg then
|
||||
vim.list_extend(
|
||||
changelog,
|
||||
{ { hash, "DiffText" }, { type, git.is_breaking(commit) and "DiffDelete" or "DiffChange" }, { msg }, { "\n" } }
|
||||
)
|
||||
vim.list_extend(changelog, {
|
||||
{ hash, "DiffText" },
|
||||
{ type, git.is_breaking(commit) and "DiffDelete" or "DiffChange" },
|
||||
{ msg },
|
||||
{ "\n" },
|
||||
})
|
||||
end
|
||||
end
|
||||
return changelog
|
||||
@@ -2,9 +2,9 @@
|
||||
--
|
||||
-- Various utility functions to use within AstroNvim and user configurations.
|
||||
--
|
||||
-- This module can be loaded with `local utils = require "core.utils"`
|
||||
-- This module can be loaded with `local utils = require "astronvim.utils"`
|
||||
--
|
||||
-- @module core.utils
|
||||
-- @module astronvim.utils
|
||||
-- @copyright 2022
|
||||
-- @license GNU General Public License v3.0
|
||||
|
||||
@@ -33,8 +33,8 @@ end
|
||||
function M.get_icon(kind)
|
||||
local icon_pack = vim.g.icons_enabled and "icons" or "text_icons"
|
||||
if not M[icon_pack] then
|
||||
M.icons = astronvim.user_opts("icons", require "core.icons.nerd_font")
|
||||
M.text_icons = astronvim.user_opts("text_icons", require "core.icons.text")
|
||||
M.icons = astronvim.user_opts("icons", require "astronvim.icons.nerd_font")
|
||||
M.text_icons = astronvim.user_opts("text_icons", require "astronvim.icons.text")
|
||||
end
|
||||
return M[icon_pack] and M[icon_pack][kind] or ""
|
||||
end
|
||||
@@ -2,10 +2,10 @@
|
||||
--
|
||||
-- LSP related utility functions to use within AstroNvim and user configurations.
|
||||
--
|
||||
-- This module can be loaded with `local lsp_utils = require("core.utils.lsp")`
|
||||
-- This module can be loaded with `local lsp_utils = require("astronvim.utils.lsp")`
|
||||
--
|
||||
-- @module core.utils.lsp
|
||||
-- @see core.utils
|
||||
-- @module astronvim.utils.lsp
|
||||
-- @see astronvim.utils
|
||||
-- @copyright 2022
|
||||
-- @license GNU General Public License v3.0
|
||||
|
||||
@@ -14,13 +14,14 @@ local tbl_contains = vim.tbl_contains
|
||||
local tbl_isempty = vim.tbl_isempty
|
||||
local user_opts = astronvim.user_opts
|
||||
|
||||
local utils = require "core.utils"
|
||||
local utils = require "astronvim.utils"
|
||||
local conditional_func = utils.conditional_func
|
||||
local is_available = utils.is_available
|
||||
|
||||
local server_config = "lsp.config."
|
||||
local setup_handlers =
|
||||
user_opts("lsp.setup_handlers", { function(server, opts) require("lspconfig")[server].setup(opts) end })
|
||||
local setup_handlers = user_opts("lsp.setup_handlers", {
|
||||
function(server, opts) require("lspconfig")[server].setup(opts) end,
|
||||
})
|
||||
|
||||
M.diagnostics = { off = {}, on = {} }
|
||||
|
||||
@@ -103,10 +104,22 @@ M.on_attach = function(client, bufnr)
|
||||
local capabilities = client.server_capabilities
|
||||
local lsp_mappings = {
|
||||
n = {
|
||||
["<leader>ld"] = { function() vim.diagnostic.open_float() end, desc = "Hover diagnostics" },
|
||||
["[d"] = { function() vim.diagnostic.goto_prev() end, desc = "Previous diagnostic" },
|
||||
["]d"] = { function() vim.diagnostic.goto_next() end, desc = "Next diagnostic" },
|
||||
["gl"] = { function() vim.diagnostic.open_float() end, desc = "Hover diagnostics" },
|
||||
["<leader>ld"] = {
|
||||
function() vim.diagnostic.open_float() end,
|
||||
desc = "Hover diagnostics",
|
||||
},
|
||||
["[d"] = {
|
||||
function() vim.diagnostic.goto_prev() end,
|
||||
desc = "Previous diagnostic",
|
||||
},
|
||||
["]d"] = {
|
||||
function() vim.diagnostic.goto_next() end,
|
||||
desc = "Next diagnostic",
|
||||
},
|
||||
["gl"] = {
|
||||
function() vim.diagnostic.open_float() end,
|
||||
desc = "Hover diagnostics",
|
||||
},
|
||||
},
|
||||
v = {},
|
||||
}
|
||||
@@ -120,7 +133,10 @@ M.on_attach = function(client, bufnr)
|
||||
end
|
||||
|
||||
if capabilities.codeActionProvider then
|
||||
lsp_mappings.n["<leader>la"] = { function() vim.lsp.buf.code_action() end, desc = "LSP code action" }
|
||||
lsp_mappings.n["<leader>la"] = {
|
||||
function() vim.lsp.buf.code_action() end,
|
||||
desc = "LSP code action",
|
||||
}
|
||||
lsp_mappings.v["<leader>la"] = lsp_mappings.n["<leader>la"]
|
||||
end
|
||||
|
||||
@@ -132,16 +148,28 @@ M.on_attach = function(client, bufnr)
|
||||
end,
|
||||
})
|
||||
vim.lsp.codelens.refresh()
|
||||
lsp_mappings.n["<leader>ll"] = { function() vim.lsp.codelens.refresh() end, desc = "LSP CodeLens refresh" }
|
||||
lsp_mappings.n["<leader>lL"] = { function() vim.lsp.codelens.run() end, desc = "LSP CodeLens run" }
|
||||
lsp_mappings.n["<leader>ll"] = {
|
||||
function() vim.lsp.codelens.refresh() end,
|
||||
desc = "LSP CodeLens refresh",
|
||||
}
|
||||
lsp_mappings.n["<leader>lL"] = {
|
||||
function() vim.lsp.codelens.run() end,
|
||||
desc = "LSP CodeLens run",
|
||||
}
|
||||
end
|
||||
|
||||
if capabilities.declarationProvider then
|
||||
lsp_mappings.n["gD"] = { function() vim.lsp.buf.declaration() end, desc = "Declaration of current symbol" }
|
||||
lsp_mappings.n["gD"] = {
|
||||
function() vim.lsp.buf.declaration() end,
|
||||
desc = "Declaration of current symbol",
|
||||
}
|
||||
end
|
||||
|
||||
if capabilities.definitionProvider then
|
||||
lsp_mappings.n["gd"] = { function() vim.lsp.buf.definition() end, desc = "Show the definition of current symbol" }
|
||||
lsp_mappings.n["gd"] = {
|
||||
function() vim.lsp.buf.definition() end,
|
||||
desc = "Show the definition of current symbol",
|
||||
}
|
||||
end
|
||||
|
||||
if capabilities.documentFormattingProvider and not tbl_contains(M.formatting.disabled, client.name) then
|
||||
@@ -170,16 +198,16 @@ M.on_attach = function(client, bufnr)
|
||||
local autoformat_enabled = vim.b.autoformat_enabled
|
||||
if autoformat_enabled == nil then autoformat_enabled = vim.g.autoformat_enabled end
|
||||
if autoformat_enabled then
|
||||
vim.lsp.buf.format(require("core.utils").extend_tbl(M.format_opts, { bufnr = bufnr }))
|
||||
vim.lsp.buf.format(require("astronvim.utils").extend_tbl(M.format_opts, { bufnr = bufnr }))
|
||||
end
|
||||
end,
|
||||
})
|
||||
lsp_mappings.n["<leader>uf"] = {
|
||||
function() require("core.utils.ui").toggle_buffer_autoformat() end,
|
||||
function() require("astronvim.utils.ui").toggle_buffer_autoformat() end,
|
||||
desc = "Toggle autoformatting (buffer)",
|
||||
}
|
||||
lsp_mappings.n["<leader>uF"] = {
|
||||
function() require("core.utils.ui").toggle_autoformat() end,
|
||||
function() require("astronvim.utils.ui").toggle_autoformat() end,
|
||||
desc = "Toggle autoformatting (global)",
|
||||
}
|
||||
end
|
||||
@@ -187,38 +215,68 @@ M.on_attach = function(client, bufnr)
|
||||
|
||||
if capabilities.documentHighlightProvider then
|
||||
add_buffer_autocmd("lsp_document_highlight", bufnr, {
|
||||
{ events = { "CursorHold", "CursorHoldI" }, callback = function() vim.lsp.buf.document_highlight() end },
|
||||
{ events = "CursorMoved", callback = function() vim.lsp.buf.clear_references() end },
|
||||
{
|
||||
events = { "CursorHold", "CursorHoldI" },
|
||||
callback = function() vim.lsp.buf.document_highlight() end,
|
||||
},
|
||||
{
|
||||
events = "CursorMoved",
|
||||
callback = function() vim.lsp.buf.clear_references() end,
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
if capabilities.hoverProvider then
|
||||
lsp_mappings.n["K"] = { function() vim.lsp.buf.hover() end, desc = "Hover symbol details" }
|
||||
lsp_mappings.n["K"] = {
|
||||
function() vim.lsp.buf.hover() end,
|
||||
desc = "Hover symbol details",
|
||||
}
|
||||
end
|
||||
|
||||
if capabilities.implementationProvider then
|
||||
lsp_mappings.n["gI"] = { function() vim.lsp.buf.implementation() end, desc = "Implementation of current symbol" }
|
||||
lsp_mappings.n["gI"] = {
|
||||
function() vim.lsp.buf.implementation() end,
|
||||
desc = "Implementation of current symbol",
|
||||
}
|
||||
end
|
||||
|
||||
if capabilities.referencesProvider then
|
||||
lsp_mappings.n["gr"] = { function() vim.lsp.buf.references() end, desc = "References of current symbol" }
|
||||
lsp_mappings.n["<leader>lR"] = { function() vim.lsp.buf.references() end, desc = "Search references" }
|
||||
lsp_mappings.n["gr"] = {
|
||||
function() vim.lsp.buf.references() end,
|
||||
desc = "References of current symbol",
|
||||
}
|
||||
lsp_mappings.n["<leader>lR"] = {
|
||||
function() vim.lsp.buf.references() end,
|
||||
desc = "Search references",
|
||||
}
|
||||
end
|
||||
|
||||
if capabilities.renameProvider then
|
||||
lsp_mappings.n["<leader>lr"] = { function() vim.lsp.buf.rename() end, desc = "Rename current symbol" }
|
||||
lsp_mappings.n["<leader>lr"] = {
|
||||
function() vim.lsp.buf.rename() end,
|
||||
desc = "Rename current symbol",
|
||||
}
|
||||
end
|
||||
|
||||
if capabilities.signatureHelpProvider then
|
||||
lsp_mappings.n["<leader>lh"] = { function() vim.lsp.buf.signature_help() end, desc = "Signature help" }
|
||||
lsp_mappings.n["<leader>lh"] = {
|
||||
function() vim.lsp.buf.signature_help() end,
|
||||
desc = "Signature help",
|
||||
}
|
||||
end
|
||||
|
||||
if capabilities.typeDefinitionProvider then
|
||||
lsp_mappings.n["gT"] = { function() vim.lsp.buf.type_definition() end, desc = "Definition of current type" }
|
||||
lsp_mappings.n["gT"] = {
|
||||
function() vim.lsp.buf.type_definition() end,
|
||||
desc = "Definition of current type",
|
||||
}
|
||||
end
|
||||
|
||||
if capabilities.workspaceSymbolProvider then
|
||||
lsp_mappings.n["<leader>lG"] = { function() vim.lsp.buf.workspace_symbol() end, desc = "Search workspace symbols" }
|
||||
lsp_mappings.n["<leader>lG"] = {
|
||||
function() vim.lsp.buf.workspace_symbol() end,
|
||||
desc = "Search workspace symbols",
|
||||
}
|
||||
end
|
||||
|
||||
if is_available "telescope.nvim" then -- setup telescope mappings if available
|
||||
@@ -266,7 +324,7 @@ M.flags = user_opts "lsp.flags"
|
||||
-- @return the table of LSP options used when setting up the given language server
|
||||
function M.config(server_name)
|
||||
local server = require("lspconfig")[server_name]
|
||||
local lsp_opts = require("core.utils").extend_tbl(
|
||||
local lsp_opts = require("astronvim.utils").extend_tbl(
|
||||
{ capabilities = server.capabilities, flags = server.flags },
|
||||
{ capabilities = M.capabilities, flags = M.flags }
|
||||
)
|
||||
@@ -2,16 +2,16 @@
|
||||
--
|
||||
-- Mason related utility functions to use within AstroNvim and user configurations.
|
||||
--
|
||||
-- This module can be loaded with `local mason_utils = require("core.utils.mason")`
|
||||
-- This module can be loaded with `local mason_utils = require("astronvim.utils.mason")`
|
||||
--
|
||||
-- @module core.utils.mason
|
||||
-- @see core.utils
|
||||
-- @module astronvim.utils.mason
|
||||
-- @see astronvim.utils
|
||||
-- @copyright 2022
|
||||
-- @license GNU General Public License v3.0
|
||||
|
||||
local M = {}
|
||||
|
||||
local utils = require "core.utils"
|
||||
local utils = require "astronvim.utils"
|
||||
local notify = utils.notify
|
||||
local astroevent = utils.event
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
--
|
||||
-- Statusline related utility functions to use within AstroNvim and user configurations.
|
||||
--
|
||||
-- This module can be loaded with `local status = require "core.utils.status"`
|
||||
-- This module can be loaded with `local status = require "astronvim.utils.status"`
|
||||
--
|
||||
-- @module core.utils.status
|
||||
-- @module astronvim.utils.status
|
||||
-- @copyright 2022
|
||||
-- @license GNU General Public License v3.0
|
||||
|
||||
local M = { hl = {}, init = {}, provider = {}, condition = {}, component = {}, utils = {}, env = {}, heirline = {} }
|
||||
|
||||
local utils = require "core.utils"
|
||||
local utils = require "astronvim.utils"
|
||||
local extend_tbl = utils.extend_tbl
|
||||
local get_icon = utils.get_icon
|
||||
local is_available = utils.is_available
|
||||
@@ -157,18 +157,18 @@ end
|
||||
|
||||
--- Get the highlight for the current mode
|
||||
-- @return the highlight group for the current mode
|
||||
-- @usage local heirline_component = { provider = "Example Provider", hl = require("core.utils.status").hl.mode },
|
||||
-- @usage local heirline_component = { provider = "Example Provider", hl = require("astronvim.utils.status").hl.mode },
|
||||
function M.hl.mode() return { bg = M.hl.mode_bg() } end
|
||||
|
||||
--- Get the foreground color group for the current mode, good for usage with Heirline surround utility
|
||||
-- @return the highlight group for the current mode foreground
|
||||
-- @usage local heirline_component = require("heirline.utils").surround({ "|", "|" }, require("core.utils.status").hl.mode_bg, heirline_component),
|
||||
-- @usage local heirline_component = require("heirline.utils").surround({ "|", "|" }, require("astronvim.utils.status").hl.mode_bg, heirline_component),
|
||||
|
||||
function M.hl.mode_bg() return M.env.modes[vim.fn.mode()][2] end
|
||||
|
||||
--- Get the foreground color group for the current filetype
|
||||
-- @return the highlight group for the current filetype foreground
|
||||
-- @usage local heirline_component = { provider = require("core.utils.status").provider.fileicon(), hl = require("core.utils.status").hl.filetype_color },
|
||||
-- @usage local heirline_component = { provider = require("astronvim.utils.status").provider.fileicon(), hl = require("astronvim.utils.status").hl.filetype_color },
|
||||
function M.hl.filetype_color(self)
|
||||
local devicons_avail, devicons = pcall(require, "nvim-web-devicons")
|
||||
if not devicons_avail then return {} end
|
||||
@@ -184,7 +184,7 @@ end
|
||||
-- @param name string, the name of the element to get the attributes and colors for
|
||||
-- @param include_bg boolean whether or not to include background color (Default: false)
|
||||
-- @return a table of highlight information
|
||||
-- @usage local heirline_component = { provider = "Example Provider", hl = require("core.utils.status").hl.get_attributes("treesitter") },
|
||||
-- @usage local heirline_component = { provider = "Example Provider", hl = require("astronvim.utils.status").hl.get_attributes("treesitter") },
|
||||
function M.hl.get_attributes(name, include_bg)
|
||||
local hl = M.env.attributes[name] or {}
|
||||
hl.fg = name .. "_fg"
|
||||
@@ -195,7 +195,7 @@ end
|
||||
--- Enable filetype color highlight if enabled in icon_highlights.file_icon options
|
||||
-- @param name string of the icon_highlights.file_icon table element
|
||||
-- @return function for setting hl property in a component
|
||||
-- @usage local heirline_component = { provider = "Example Provider", hl = require("core.utils.status").hl.file_icon("winbar") },
|
||||
-- @usage local heirline_component = { provider = "Example Provider", hl = require("astronvim.utils.status").hl.file_icon("winbar") },
|
||||
function M.hl.file_icon(name)
|
||||
local hl_enabled = M.env.icon_highlights.file_icon[name]
|
||||
return function(self)
|
||||
@@ -208,7 +208,7 @@ end
|
||||
--- An `init` function to build a set of children components for LSP breadcrumbs
|
||||
-- @param opts options for configuring the breadcrumbs (default: `{ max_depth = 5, separator = " ", icon = { enabled = true, hl = false }, padding = { left = 0, right = 0 } }`)
|
||||
-- @return The Heirline init function
|
||||
-- @usage local heirline_component = { init = require("core.utils.status").init.breadcrumbs { padding = { left = 1 } } }
|
||||
-- @usage local heirline_component = { init = require("astronvim.utils.status").init.breadcrumbs { padding = { left = 1 } } }
|
||||
function M.init.breadcrumbs(opts)
|
||||
opts = extend_tbl({
|
||||
max_depth = 5,
|
||||
@@ -227,7 +227,7 @@ function M.init.breadcrumbs(opts)
|
||||
if opts.max_depth and opts.max_depth > 0 then
|
||||
start_idx = #data - opts.max_depth
|
||||
if start_idx > 0 then
|
||||
table.insert(children, { provider = require("core.utils").get_icon "Ellipsis" .. opts.separator })
|
||||
table.insert(children, { provider = require("astronvim.utils").get_icon "Ellipsis" .. opts.separator })
|
||||
end
|
||||
end
|
||||
-- create a child for each level
|
||||
@@ -271,7 +271,7 @@ end
|
||||
--- An `init` function to build a set of children components for a separated path to file
|
||||
-- @param opts options for configuring the breadcrumbs (default: `{ max_depth = 3, path_func = M.provider.unique_path(), separator = " ", suffix = true, padding = { left = 0, right = 0 } }`)
|
||||
-- @return The Heirline init function
|
||||
-- @usage local heirline_component = { init = require("core.utils.status").init.separated_path { padding = { left = 1 } } }
|
||||
-- @usage local heirline_component = { init = require("astronvim.utils.status").init.separated_path { padding = { left = 1 } } }
|
||||
function M.init.separated_path(opts)
|
||||
opts = extend_tbl({
|
||||
max_depth = 3,
|
||||
@@ -294,7 +294,7 @@ function M.init.separated_path(opts)
|
||||
if opts.max_depth and opts.max_depth > 0 then
|
||||
start_idx = #data - opts.max_depth
|
||||
if start_idx > 0 then
|
||||
table.insert(children, { provider = require("core.utils").get_icon "Ellipsis" .. opts.separator })
|
||||
table.insert(children, { provider = require("astronvim.utils").get_icon "Ellipsis" .. opts.separator })
|
||||
end
|
||||
end
|
||||
-- create a child for each level
|
||||
@@ -320,7 +320,7 @@ end
|
||||
--- An `init` function to build multiple update events which is not supported yet by Heirline's update field
|
||||
-- @param opts an array like table of autocmd events as either just a string or a table with custom patterns and callbacks.
|
||||
-- @return The Heirline init function
|
||||
-- @usage local heirline_component = { init = require("core.utils.status").init.update_events { "BufEnter", { "User", pattern = "LspProgressUpdate" } } }
|
||||
-- @usage local heirline_component = { init = require("astronvim.utils.status").init.update_events { "BufEnter", { "User", pattern = "LspProgressUpdate" } } }
|
||||
function M.init.update_events(opts)
|
||||
return function(self)
|
||||
if not rawget(self, "once") then
|
||||
@@ -342,14 +342,14 @@ end
|
||||
|
||||
--- A provider function for the fill string
|
||||
-- @return the statusline string for filling the empty space
|
||||
-- @usage local heirline_component = { provider = require("core.utils.status").provider.fill }
|
||||
-- @usage local heirline_component = { provider = require("astronvim.utils.status").provider.fill }
|
||||
function M.provider.fill() return "%=" end
|
||||
|
||||
--- A provider function for the signcolumn string
|
||||
-- @param opts options passed to the stylize function
|
||||
-- @return the statuscolumn string for adding the signcolumn
|
||||
-- @usage local heirline_component = { provider = require("core.utils.status").provider.signcolumn }
|
||||
-- @see core.utils.status.utils.stylize
|
||||
-- @usage local heirline_component = { provider = require("astronvim.utils.status").provider.signcolumn }
|
||||
-- @see astronvim.utils.status.utils.stylize
|
||||
function M.provider.signcolumn(opts)
|
||||
opts = extend_tbl({ escape = false }, opts)
|
||||
return M.utils.stylize("%s", opts)
|
||||
@@ -358,8 +358,8 @@ end
|
||||
--- A provider function for the numbercolumn string
|
||||
-- @param opts options passed to the stylize function
|
||||
-- @return the statuscolumn string for adding the numbercolumn
|
||||
-- @usage local heirline_component = { provider = require("core.utils.status").provider.numbercolumn }
|
||||
-- @see core.utils.status.utils.stylize
|
||||
-- @usage local heirline_component = { provider = require("astronvim.utils.status").provider.numbercolumn }
|
||||
-- @see astronvim.utils.status.utils.stylize
|
||||
function M.provider.numbercolumn(opts)
|
||||
opts = extend_tbl({ escape = false }, opts)
|
||||
return function()
|
||||
@@ -372,11 +372,11 @@ end
|
||||
--- A provider function for building a foldcolumn
|
||||
-- @param opts options passed to the stylize function
|
||||
-- @return a custom foldcolumn function for the statuscolumn that doesn't show the nest levels
|
||||
-- @usage local heirline_component = { provider = require("core.utils.status").provider.foldcolumn }
|
||||
-- @see core.utils.status.utils.stylize
|
||||
-- @usage local heirline_component = { provider = require("astronvim.utils.status").provider.foldcolumn }
|
||||
-- @see astronvim.utils.status.utils.stylize
|
||||
function M.provider.foldcolumn(opts)
|
||||
opts = extend_tbl({ escape = false }, opts)
|
||||
local ffi = require "core.utils.ffi" -- get AstroNvim C extensions
|
||||
local ffi = require "astronvim.utils.ffi" -- get AstroNvim C extensions
|
||||
local fillchars = vim.opt.fillchars:get()
|
||||
local foldopen = fillchars.foldopen or get_icon "FoldOpened"
|
||||
local foldclosed = fillchars.foldclose or get_icon "FoldClosed"
|
||||
@@ -417,7 +417,7 @@ end
|
||||
|
||||
--- A provider function for the current tab numbre
|
||||
-- @return the statusline function to return a string for a tab number
|
||||
-- @usage local heirline_component = { provider = require("core.utils.status").provider.tabnr() }
|
||||
-- @usage local heirline_component = { provider = require("astronvim.utils.status").provider.tabnr() }
|
||||
function M.provider.tabnr()
|
||||
return function(self) return (self and self.tabnr) and "%" .. self.tabnr .. "T " .. self.tabnr .. " %T" or "" end
|
||||
end
|
||||
@@ -425,8 +425,8 @@ end
|
||||
--- A provider function for showing if spellcheck is on
|
||||
-- @param opts options passed to the stylize function
|
||||
-- @return the function for outputting if spell is enabled
|
||||
-- @usage local heirline_component = { provider = require("core.utils.status").provider.spell() }
|
||||
-- @see core.utils.status.utils.stylize
|
||||
-- @usage local heirline_component = { provider = require("astronvim.utils.status").provider.spell() }
|
||||
-- @see astronvim.utils.status.utils.stylize
|
||||
function M.provider.spell(opts)
|
||||
opts = extend_tbl({ str = "", icon = { kind = "Spellcheck" }, show_empty = true }, opts)
|
||||
return function() return M.utils.stylize(vim.wo.spell and opts.str, opts) end
|
||||
@@ -436,8 +436,8 @@ end
|
||||
-- @param opts options passed to the stylize function
|
||||
-- @return the function for outputting if paste is enabled
|
||||
|
||||
-- @usage local heirline_component = { provider = require("core.utils.status").provider.paste() }
|
||||
-- @see core.utils.status.utils.stylize
|
||||
-- @usage local heirline_component = { provider = require("astronvim.utils.status").provider.paste() }
|
||||
-- @see astronvim.utils.status.utils.stylize
|
||||
function M.provider.paste(opts)
|
||||
opts = extend_tbl({ str = "", icon = { kind = "Paste" }, show_empty = true }, opts)
|
||||
return function() return M.utils.stylize(vim.opt.paste:get() and opts.str, opts) end
|
||||
@@ -446,8 +446,8 @@ end
|
||||
--- A provider function for displaying if a macro is currently being recorded
|
||||
-- @param opts a prefix before the recording register and options passed to the stylize function
|
||||
-- @return a function that returns a string of the current recording status
|
||||
-- @usage local heirline_component = { provider = require("core.utils.status").provider.macro_recording() }
|
||||
-- @see core.utils.status.utils.stylize
|
||||
-- @usage local heirline_component = { provider = require("astronvim.utils.status").provider.macro_recording() }
|
||||
-- @see astronvim.utils.status.utils.stylize
|
||||
function M.provider.macro_recording(opts)
|
||||
opts = extend_tbl({ prefix = "@" }, opts)
|
||||
return function()
|
||||
@@ -460,8 +460,8 @@ end
|
||||
--- A provider function for displaying the current search count
|
||||
-- @param opts options for `vim.fn.searchcount` and options passed to the stylize function
|
||||
-- @return a function that returns a string of the current search location
|
||||
-- @usage local heirline_component = { provider = require("core.utils.status").provider.search_count() }
|
||||
-- @see core.utils.status.utils.stylize
|
||||
-- @usage local heirline_component = { provider = require("astronvim.utils.status").provider.search_count() }
|
||||
-- @see astronvim.utils.status.utils.stylize
|
||||
function M.provider.search_count(opts)
|
||||
local search_func = vim.tbl_isempty(opts or {}) and function() return vim.fn.searchcount() end
|
||||
or function() return vim.fn.searchcount(opts) end
|
||||
@@ -485,8 +485,8 @@ end
|
||||
--- A provider function for showing the text of the current vim mode
|
||||
-- @param opts options for padding the text and options passed to the stylize function
|
||||
-- @return the function for displaying the text of the current vim mode
|
||||
-- @usage local heirline_component = { provider = require("core.utils.status").provider.mode_text() }
|
||||
-- @see core.utils.status.utils.stylize
|
||||
-- @usage local heirline_component = { provider = require("astronvim.utils.status").provider.mode_text() }
|
||||
-- @see astronvim.utils.status.utils.stylize
|
||||
function M.provider.mode_text(opts)
|
||||
local max_length = math.max(unpack(vim.tbl_map(function(str) return #str[1] end, vim.tbl_values(M.env.modes))))
|
||||
return function()
|
||||
@@ -508,8 +508,8 @@ end
|
||||
--- A provider function for showing the percentage of the current location in a document
|
||||
-- @param opts options for Top/Bot text, fixed width, and options passed to the stylize function
|
||||
-- @return the statusline string for displaying the percentage of current document location
|
||||
-- @usage local heirline_component = { provider = require("core.utils.status").provider.percentage() }
|
||||
-- @see core.utils.status.utils.stylize
|
||||
-- @usage local heirline_component = { provider = require("astronvim.utils.status").provider.percentage() }
|
||||
-- @see astronvim.utils.status.utils.stylize
|
||||
function M.provider.percentage(opts)
|
||||
opts = extend_tbl({ escape = false, fixed_width = false, edge_text = true }, opts)
|
||||
return function()
|
||||
@@ -529,8 +529,8 @@ end
|
||||
--- A provider function for showing the current line and character in a document
|
||||
-- @param opts options for padding the line and character locations and options passed to the stylize function
|
||||
-- @return the statusline string for showing location in document line_num:char_num
|
||||
-- @usage local heirline_component = { provider = require("core.utils.status").provider.ruler({ pad_ruler = { line = 3, char = 2 } }) }
|
||||
-- @see core.utils.status.utils.stylize
|
||||
-- @usage local heirline_component = { provider = require("astronvim.utils.status").provider.ruler({ pad_ruler = { line = 3, char = 2 } }) }
|
||||
-- @see astronvim.utils.status.utils.stylize
|
||||
function M.provider.ruler(opts)
|
||||
opts = extend_tbl({ pad_ruler = { line = 0, char = 0 } }, opts)
|
||||
local padding_str = string.format("%%%dd:%%%dd", opts.pad_ruler.line, opts.pad_ruler.char)
|
||||
@@ -544,8 +544,8 @@ end
|
||||
--- A provider function for showing the current location as a scrollbar
|
||||
-- @param opts options passed to the stylize function
|
||||
-- @return the function for outputting the scrollbar
|
||||
-- @usage local heirline_component = { provider = require("core.utils.status").provider.scrollbar() }
|
||||
-- @see core.utils.status.utils.stylize
|
||||
-- @usage local heirline_component = { provider = require("astronvim.utils.status").provider.scrollbar() }
|
||||
-- @see astronvim.utils.status.utils.stylize
|
||||
function M.provider.scrollbar(opts)
|
||||
local sbar = { "▁", "▂", "▃", "▄", "▅", "▆", "▇", "█" }
|
||||
return function()
|
||||
@@ -559,8 +559,8 @@ end
|
||||
--- A provider to simply show a cloes button icon
|
||||
-- @param opts options passed to the stylize function and the kind of icon to use
|
||||
-- @return return the stylized icon
|
||||
-- @usage local heirline_component = { provider = require("core.utils.status").provider.close_button() }
|
||||
-- @see core.utils.status.utils.stylize
|
||||
-- @usage local heirline_component = { provider = require("astronvim.utils.status").provider.close_button() }
|
||||
-- @see astronvim.utils.status.utils.stylize
|
||||
function M.provider.close_button(opts)
|
||||
opts = extend_tbl({ kind = "BufferClose" }, opts)
|
||||
return M.utils.stylize(get_icon(opts.kind), opts)
|
||||
@@ -569,8 +569,8 @@ end
|
||||
--- A provider function for showing the current filetype
|
||||
-- @param opts options passed to the stylize function
|
||||
-- @return the function for outputting the filetype
|
||||
-- @usage local heirline_component = { provider = require("core.utils.status").provider.filetype() }
|
||||
-- @see core.utils.status.utils.stylize
|
||||
-- @usage local heirline_component = { provider = require("astronvim.utils.status").provider.filetype() }
|
||||
-- @see astronvim.utils.status.utils.stylize
|
||||
function M.provider.filetype(opts)
|
||||
return function(self)
|
||||
local buffer = vim.bo[self and self.bufnr or 0]
|
||||
@@ -581,13 +581,14 @@ end
|
||||
--- A provider function for showing the current filename
|
||||
-- @param opts options for argument to fnamemodify to format filename and options passed to the stylize function
|
||||
-- @return the function for outputting the filename
|
||||
-- @usage local heirline_component = { provider = require("core.utils.status").provider.filename() }
|
||||
-- @see core.utils.status.utils.stylize
|
||||
-- @usage local heirline_component = { provider = require("astronvim.utils.status").provider.filename() }
|
||||
-- @see astronvim.utils.status.utils.stylize
|
||||
function M.provider.filename(opts)
|
||||
opts = extend_tbl(
|
||||
{ fallback = "Empty", fname = function(nr) return vim.api.nvim_buf_get_name(nr) end, modify = ":t" },
|
||||
opts
|
||||
)
|
||||
opts = extend_tbl({
|
||||
fallback = "Empty",
|
||||
fname = function(nr) return vim.api.nvim_buf_get_name(nr) end,
|
||||
modify = ":t",
|
||||
}, opts)
|
||||
return function(self)
|
||||
local filename = vim.fn.fnamemodify(opts.fname(self and self.bufnr or 0), opts.modify)
|
||||
return M.utils.stylize((filename == "" and opts.fallback or filename), opts)
|
||||
@@ -597,8 +598,8 @@ end
|
||||
--- Get a unique filepath between all buffers
|
||||
-- @param opts options for function to get the buffer name, a buffer number, max length, and options passed to the stylize function
|
||||
-- @return path to file that uniquely identifies each buffer
|
||||
-- @usage local heirline_component = { provider = require("core.utils.status").provider.unique_path() }
|
||||
-- @see core.utils.status.utils.stylize
|
||||
-- @usage local heirline_component = { provider = require("astronvim.utils.status").provider.unique_path() }
|
||||
-- @see astronvim.utils.status.utils.stylize
|
||||
function M.provider.unique_path(opts)
|
||||
opts = extend_tbl({
|
||||
buf_name = function(bufnr) return vim.fn.fnamemodify(vim.api.nvim_buf_get_name(bufnr), ":t") end,
|
||||
@@ -650,8 +651,8 @@ end
|
||||
--- A provider function for showing if the current file is modifiable
|
||||
-- @param opts options passed to the stylize function
|
||||
-- @return the function for outputting the indicator if the file is modified
|
||||
-- @usage local heirline_component = { provider = require("core.utils.status").provider.file_modified() }
|
||||
-- @see core.utils.status.utils.stylize
|
||||
-- @usage local heirline_component = { provider = require("astronvim.utils.status").provider.file_modified() }
|
||||
-- @see astronvim.utils.status.utils.stylize
|
||||
function M.provider.file_modified(opts)
|
||||
opts = extend_tbl({ str = "", icon = { kind = "FileModified" }, show_empty = true }, opts)
|
||||
return function(self) return M.utils.stylize(M.condition.file_modified((self or {}).bufnr) and opts.str, opts) end
|
||||
@@ -660,8 +661,8 @@ end
|
||||
--- A provider function for showing if the current file is read-only
|
||||
-- @param opts options passed to the stylize function
|
||||
-- @return the function for outputting the indicator if the file is read-only
|
||||
-- @usage local heirline_component = { provider = require("core.utils.status").provider.file_read_only() }
|
||||
-- @see core.utils.status.utils.stylize
|
||||
-- @usage local heirline_component = { provider = require("astronvim.utils.status").provider.file_read_only() }
|
||||
-- @see astronvim.utils.status.utils.stylize
|
||||
function M.provider.file_read_only(opts)
|
||||
opts = extend_tbl({ str = "", icon = { kind = "FileReadOnly" }, show_empty = true }, opts)
|
||||
return function(self) return M.utils.stylize(M.condition.file_read_only((self or {}).bufnr) and opts.str, opts) end
|
||||
@@ -670,8 +671,8 @@ end
|
||||
--- A provider function for showing the current filetype icon
|
||||
-- @param opts options passed to the stylize function
|
||||
-- @return the function for outputting the filetype icon
|
||||
-- @usage local heirline_component = { provider = require("core.utils.status").provider.file_icon() }
|
||||
-- @see core.utils.status.utils.stylize
|
||||
-- @usage local heirline_component = { provider = require("astronvim.utils.status").provider.file_icon() }
|
||||
-- @see astronvim.utils.status.utils.stylize
|
||||
function M.provider.file_icon(opts)
|
||||
return function(self)
|
||||
local devicons_avail, devicons = pcall(require, "nvim-web-devicons")
|
||||
@@ -688,8 +689,8 @@ end
|
||||
--- A provider function for showing the current git branch
|
||||
-- @param opts options passed to the stylize function
|
||||
-- @return the function for outputting the git branch
|
||||
-- @usage local heirline_component = { provider = require("core.utils.status").provider.git_branch() }
|
||||
-- @see core.utils.status.utils.stylize
|
||||
-- @usage local heirline_component = { provider = require("astronvim.utils.status").provider.git_branch() }
|
||||
-- @see astronvim.utils.status.utils.stylize
|
||||
function M.provider.git_branch(opts)
|
||||
return function(self) return M.utils.stylize(vim.b[self and self.bufnr or 0].gitsigns_head or "", opts) end
|
||||
end
|
||||
@@ -697,8 +698,8 @@ end
|
||||
--- A provider function for showing the current git diff count of a specific type
|
||||
-- @param opts options for type of git diff and options passed to the stylize function
|
||||
-- @return the function for outputting the git diff
|
||||
-- @usage local heirline_component = { provider = require("core.utils.status").provider.git_diff({ type = "added" }) }
|
||||
-- @see core.utils.status.utils.stylize
|
||||
-- @usage local heirline_component = { provider = require("astronvim.utils.status").provider.git_diff({ type = "added" }) }
|
||||
-- @see astronvim.utils.status.utils.stylize
|
||||
function M.provider.git_diff(opts)
|
||||
if not opts or not opts.type then return end
|
||||
return function(self)
|
||||
@@ -713,8 +714,8 @@ end
|
||||
--- A provider function for showing the current diagnostic count of a specific severity
|
||||
-- @param opts options for severity of diagnostic and options passed to the stylize function
|
||||
-- @return the function for outputting the diagnostic count
|
||||
-- @usage local heirline_component = { provider = require("core.utils.status").provider.diagnostics({ severity = "ERROR" }) }
|
||||
-- @see core.utils.status.utils.stylize
|
||||
-- @usage local heirline_component = { provider = require("astronvim.utils.status").provider.diagnostics({ severity = "ERROR" }) }
|
||||
-- @see astronvim.utils.status.utils.stylize
|
||||
function M.provider.diagnostics(opts)
|
||||
if not opts or not opts.severity then return end
|
||||
return function(self)
|
||||
@@ -727,8 +728,8 @@ end
|
||||
--- A provider function for showing the current progress of loading language servers
|
||||
-- @param opts options passed to the stylize function
|
||||
-- @return the function for outputting the LSP progress
|
||||
-- @usage local heirline_component = { provider = require("core.utils.status").provider.lsp_progress() }
|
||||
-- @see core.utils.status.utils.stylize
|
||||
-- @usage local heirline_component = { provider = require("astronvim.utils.status").provider.lsp_progress() }
|
||||
-- @see astronvim.utils.status.utils.stylize
|
||||
function M.provider.lsp_progress(opts)
|
||||
return function()
|
||||
local Lsp = vim.lsp.util.get_progress_messages()[1]
|
||||
@@ -752,8 +753,8 @@ end
|
||||
--- A provider function for showing the connected LSP client names
|
||||
-- @param opts options for explanding null_ls clients, max width percentage, and options passed to the stylize function
|
||||
-- @return the function for outputting the LSP client names
|
||||
-- @usage local heirline_component = { provider = require("core.utils.status").provider.lsp_client_names({ expand_null_ls = true, truncate = 0.25 }) }
|
||||
-- @see core.utils.status.utils.stylize
|
||||
-- @usage local heirline_component = { provider = require("astronvim.utils.status").provider.lsp_client_names({ expand_null_ls = true, truncate = 0.25 }) }
|
||||
-- @see astronvim.utils.status.utils.stylize
|
||||
function M.provider.lsp_client_names(opts)
|
||||
opts = extend_tbl({ expand_null_ls = true, truncate = 0.25 }, opts)
|
||||
return function(self)
|
||||
@@ -783,8 +784,8 @@ end
|
||||
--- A provider function for showing if treesitter is connected
|
||||
-- @param opts options passed to the stylize function
|
||||
-- @return the function for outputting TS if treesitter is connected
|
||||
-- @usage local heirline_component = { provider = require("core.utils.status").provider.treesitter_status() }
|
||||
-- @see core.utils.status.utils.stylize
|
||||
-- @usage local heirline_component = { provider = require("astronvim.utils.status").provider.treesitter_status() }
|
||||
-- @see astronvim.utils.status.utils.stylize
|
||||
function M.provider.treesitter_status(opts)
|
||||
return function() return M.utils.stylize(require("nvim-treesitter.parser").has_parser() and "TS" or "", opts) end
|
||||
end
|
||||
@@ -792,8 +793,8 @@ end
|
||||
--- A provider function for displaying a single string
|
||||
-- @param opts options passed to the stylize function
|
||||
-- @return the stylized statusline string
|
||||
-- @usage local heirline_component = { provider = require("core.utils.status").provider.str({ str = "Hello" }) }
|
||||
-- @see core.utils.status.utils.stylize
|
||||
-- @usage local heirline_component = { provider = require("astronvim.utils.status").provider.str({ str = "Hello" }) }
|
||||
-- @see astronvim.utils.status.utils.stylize
|
||||
function M.provider.str(opts)
|
||||
opts = extend_tbl({ str = " " }, opts)
|
||||
return M.utils.stylize(opts.str, opts)
|
||||
@@ -801,14 +802,14 @@ end
|
||||
|
||||
--- A condition function if the window is currently active
|
||||
-- @return boolean of wether or not the window is currently actie
|
||||
-- @usage local heirline_component = { provider = "Example Provider", condition = require("core.utils.status").condition.is_active }
|
||||
-- @usage local heirline_component = { provider = "Example Provider", condition = require("astronvim.utils.status").condition.is_active }
|
||||
function M.condition.is_active() return vim.api.nvim_get_current_win() == tonumber(vim.g.actual_curwin) end
|
||||
|
||||
--- A condition function if the buffer filetype,buftype,bufname match a pattern
|
||||
-- @param patterns the table of patterns to match
|
||||
-- @param bufnr number of the buffer to match (Default: 0 [current])
|
||||
-- @return boolean of wether or not LSP is attached
|
||||
-- @usage local heirline_component = { provider = "Example Provider", condition = function() return require("core.utils.status").condition.buffer_matches { buftype = { "terminal" } } end }
|
||||
-- @usage local heirline_component = { provider = "Example Provider", condition = function() return require("astronvim.utils.status").condition.buffer_matches { buftype = { "terminal" } } end }
|
||||
function M.condition.buffer_matches(patterns, bufnr)
|
||||
for kind, pattern_list in pairs(patterns) do
|
||||
if M.env.buf_matchers[kind](pattern_list, bufnr) then return true end
|
||||
@@ -818,18 +819,18 @@ end
|
||||
|
||||
--- A condition function if a macro is being recorded
|
||||
-- @return boolean of wether or not a macro is currently being recorded
|
||||
-- @usage local heirline_component = { provider = "Example Provider", condition = require("core.utils.status").condition.is_macro_recording }
|
||||
-- @usage local heirline_component = { provider = "Example Provider", condition = require("astronvim.utils.status").condition.is_macro_recording }
|
||||
function M.condition.is_macro_recording() return vim.fn.reg_recording() ~= "" end
|
||||
|
||||
--- A condition function if search is visible
|
||||
-- @return boolean of wether or not searching is currently visible
|
||||
-- @usage local heirline_component = { provider = "Example Provider", condition = require("core.utils.status").condition.is_hlsearch }
|
||||
-- @usage local heirline_component = { provider = "Example Provider", condition = require("astronvim.utils.status").condition.is_hlsearch }
|
||||
function M.condition.is_hlsearch() return vim.v.hlsearch ~= 0 end
|
||||
|
||||
--- A condition function if the current file is in a git repo
|
||||
-- @param bufnr a buffer number to check the condition for, a table with bufnr property, or nil to get the current buffer
|
||||
-- @return boolean of wether or not the current file is in a git repo
|
||||
-- @usage local heirline_component = { provider = "Example Provider", condition = require("core.utils.status").condition.is_git_repo }
|
||||
-- @usage local heirline_component = { provider = "Example Provider", condition = require("astronvim.utils.status").condition.is_git_repo }
|
||||
function M.condition.is_git_repo(bufnr)
|
||||
if type(bufnr) == "table" then bufnr = bufnr.bufnr end
|
||||
return vim.b[bufnr or 0].gitsigns_head or vim.b[bufnr or 0].gitsigns_status_dict
|
||||
@@ -838,7 +839,7 @@ end
|
||||
--- A condition function if there are any git changes
|
||||
-- @param bufnr a buffer number to check the condition for, a table with bufnr property, or nil to get the current buffer
|
||||
-- @return boolean of wether or not there are any git changes
|
||||
-- @usage local heirline_component = { provider = "Example Provider", condition = require("core.utils.status").condition.git_changed }
|
||||
-- @usage local heirline_component = { provider = "Example Provider", condition = require("astronvim.utils.status").condition.git_changed }
|
||||
function M.condition.git_changed(bufnr)
|
||||
if type(bufnr) == "table" then bufnr = bufnr.bufnr end
|
||||
local git_status = vim.b[bufnr or 0].gitsigns_status_dict
|
||||
@@ -848,7 +849,7 @@ end
|
||||
--- A condition function if the current buffer is modified
|
||||
-- @param bufnr a buffer number to check the condition for, a table with bufnr property, or nil to get the current buffer
|
||||
-- @return boolean of wether or not the current buffer is modified
|
||||
-- @usage local heirline_component = { provider = "Example Provider", condition = require("core.utils.status").condition.file_modified }
|
||||
-- @usage local heirline_component = { provider = "Example Provider", condition = require("astronvim.utils.status").condition.file_modified }
|
||||
function M.condition.file_modified(bufnr)
|
||||
if type(bufnr) == "table" then bufnr = bufnr.bufnr end
|
||||
return vim.bo[bufnr or 0].modified
|
||||
@@ -857,7 +858,7 @@ end
|
||||
--- A condition function if the current buffer is read only
|
||||
-- @param bufnr a buffer number to check the condition for, a table with bufnr property, or nil to get the current buffer
|
||||
-- @return boolean of wether or not the current buffer is read only or not modifiable
|
||||
-- @usage local heirline_component = { provider = "Example Provider", condition = require("core.utils.status").condition.file_read_only }
|
||||
-- @usage local heirline_component = { provider = "Example Provider", condition = require("astronvim.utils.status").condition.file_read_only }
|
||||
function M.condition.file_read_only(bufnr)
|
||||
if type(bufnr) == "table" then bufnr = bufnr.bufnr end
|
||||
local buffer = vim.bo[bufnr or 0]
|
||||
@@ -867,7 +868,7 @@ end
|
||||
--- A condition function if the current file has any diagnostics
|
||||
-- @param bufnr a buffer number to check the condition for, a table with bufnr property, or nil to get the current buffer
|
||||
-- @return boolean of wether or not the current file has any diagnostics
|
||||
-- @usage local heirline_component = { provider = "Example Provider", condition = require("core.utils.status").condition.has_diagnostics }
|
||||
-- @usage local heirline_component = { provider = "Example Provider", condition = require("astronvim.utils.status").condition.has_diagnostics }
|
||||
function M.condition.has_diagnostics(bufnr)
|
||||
if type(bufnr) == "table" then bufnr = bufnr.bufnr end
|
||||
return vim.g.status_diagnostics_enabled and #vim.diagnostic.get(bufnr or 0) > 0
|
||||
@@ -876,7 +877,7 @@ end
|
||||
--- A condition function if there is a defined filetype
|
||||
-- @param bufnr a buffer number to check the condition for, a table with bufnr property, or nil to get the current buffer
|
||||
-- @return boolean of wether or not there is a filetype
|
||||
-- @usage local heirline_component = { provider = "Example Provider", condition = require("core.utils.status").condition.has_filetype }
|
||||
-- @usage local heirline_component = { provider = "Example Provider", condition = require("astronvim.utils.status").condition.has_filetype }
|
||||
function M.condition.has_filetype(bufnr)
|
||||
if type(bufnr) == "table" then bufnr = bufnr.bufnr end
|
||||
return vim.fn.empty(vim.fn.expand "%:t") ~= 1 and vim.bo[bufnr or 0].filetype and vim.bo[bufnr or 0].filetype ~= ""
|
||||
@@ -884,14 +885,14 @@ end
|
||||
|
||||
--- A condition function if Aerial is available
|
||||
-- @return boolean of wether or not aerial plugin is installed
|
||||
-- @usage local heirline_component = { provider = "Example Provider", condition = require("core.utils.status").condition.aerial_available }
|
||||
-- @usage local heirline_component = { provider = "Example Provider", condition = require("astronvim.utils.status").condition.aerial_available }
|
||||
-- function M.condition.aerial_available() return is_available "aerial.nvim" end
|
||||
function M.condition.aerial_available() return package.loaded["aerial"] end
|
||||
|
||||
--- A condition function if LSP is attached
|
||||
-- @param bufnr a buffer number to check the condition for, a table with bufnr property, or nil to get the current buffer
|
||||
-- @return boolean of wether or not LSP is attached
|
||||
-- @usage local heirline_component = { provider = "Example Provider", condition = require("core.utils.status").condition.lsp_attached }
|
||||
-- @usage local heirline_component = { provider = "Example Provider", condition = require("astronvim.utils.status").condition.lsp_attached }
|
||||
function M.condition.lsp_attached(bufnr)
|
||||
if type(bufnr) == "table" then bufnr = bufnr.bufnr end
|
||||
return next(vim.lsp.get_active_clients { bufnr = bufnr or 0 }) ~= nil
|
||||
@@ -900,7 +901,7 @@ end
|
||||
--- A condition function if treesitter is in use
|
||||
-- @param bufnr a buffer number to check the condition for, a table with bufnr property, or nil to get the current buffer
|
||||
-- @return boolean of wether or not treesitter is active
|
||||
-- @usage local heirline_component = { provider = "Example Provider", condition = require("core.utils.status").condition.treesitter_available }
|
||||
-- @usage local heirline_component = { provider = "Example Provider", condition = require("astronvim.utils.status").condition.treesitter_available }
|
||||
function M.condition.treesitter_available(bufnr)
|
||||
if not package.loaded["nvim-treesitter"] then return false end
|
||||
if type(bufnr) == "table" then bufnr = bufnr.bufnr end
|
||||
@@ -922,7 +923,7 @@ local function escape(str) return str:gsub("%%", "%%%%") end
|
||||
-- @param str the string to stylize
|
||||
-- @param opts options of `{ padding = { left = 0, right = 0 }, separator = { left = "|", right = "|" }, escape = true, show_empty = false, icon = { kind = "NONE", padding = { left = 0, right = 0 } } }`
|
||||
-- @return the stylized string
|
||||
-- @usage local string = require("core.utils.status").utils.stylize("Hello", { padding = { left = 1, right = 1 }, icon = { kind = "String" } })
|
||||
-- @usage local string = require("astronvim.utils.status").utils.stylize("Hello", { padding = { left = 1, right = 1 }, icon = { kind = "String" } })
|
||||
function M.utils.stylize(str, opts)
|
||||
opts = extend_tbl({
|
||||
padding = { left = 0, right = 0 },
|
||||
@@ -941,13 +942,13 @@ end
|
||||
--- A Heirline component for filling in the empty space of the bar
|
||||
-- @param opts options for configuring the other fields of the heirline component
|
||||
-- @return The heirline component table
|
||||
-- @usage local heirline_component = require("core.utils.status").component.fill()
|
||||
-- @usage local heirline_component = require("astronvim.utils.status").component.fill()
|
||||
function M.component.fill(opts) return extend_tbl({ provider = M.provider.fill() }, opts) end
|
||||
|
||||
--- A function to build a set of children components for an entire file information section
|
||||
-- @param opts options for configuring file_icon, filename, filetype, file_modified, file_read_only, and the overall padding
|
||||
-- @return The Heirline component table
|
||||
-- @usage local heirline_component = require("core.utils.status").component.file_info()
|
||||
-- @usage local heirline_component = require("astronvim.utils.status").component.file_info()
|
||||
function M.component.file_info(opts)
|
||||
opts = extend_tbl({
|
||||
file_icon = { hl = M.hl.file_icon "statusline", padding = { left = 1, right = 1 } },
|
||||
@@ -971,7 +972,7 @@ end
|
||||
--- A function with different file_info defaults specifically for use in the tabline
|
||||
-- @param opts options for configuring file_icon, filename, filetype, file_modified, file_read_only, and the overall padding
|
||||
-- @return The Heirline component table
|
||||
-- @usage local heirline_component = require("core.utils.status").component.tabline_file_info()
|
||||
-- @usage local heirline_component = require("astronvim.utils.status").component.tabline_file_info()
|
||||
function M.component.tabline_file_info(opts)
|
||||
return M.component.file_info(extend_tbl({
|
||||
file_icon = {
|
||||
@@ -985,7 +986,7 @@ function M.component.tabline_file_info(opts)
|
||||
hl = function(self) return M.hl.get_attributes(self.tab_type .. "_close") end,
|
||||
padding = { left = 1, right = 1 },
|
||||
on_click = {
|
||||
callback = function(_, minwid) require("core.utils.buffer").close(minwid) end,
|
||||
callback = function(_, minwid) require("astronvim.utils.buffer").close(minwid) end,
|
||||
minwid = function(self) return self.bufnr end,
|
||||
name = "heirline_tabline_close_buffer_callback",
|
||||
},
|
||||
@@ -1003,7 +1004,7 @@ end
|
||||
--- A function to build a set of children components for an entire navigation section
|
||||
-- @param opts options for configuring ruler, percentage, scrollbar, and the overall padding
|
||||
-- @return The Heirline component table
|
||||
-- @usage local heirline_component = require("core.utils.status").component.nav()
|
||||
-- @usage local heirline_component = require("astronvim.utils.status").component.nav()
|
||||
function M.component.nav(opts)
|
||||
opts = extend_tbl({
|
||||
ruler = {},
|
||||
@@ -1019,7 +1020,7 @@ end
|
||||
--- A function to build a set of children components for information shown in the cmdline
|
||||
-- @param opts options for configuring macro recording, search count, and the overall padding
|
||||
-- @return The Heirline component table
|
||||
-- @usage local heirline_component = require("core.utils.status").component.cmd_info()
|
||||
-- @usage local heirline_component = require("astronvim.utils.status").component.cmd_info()
|
||||
function M.component.cmd_info(opts)
|
||||
opts = extend_tbl({
|
||||
macro_recording = {
|
||||
@@ -1046,7 +1047,7 @@ end
|
||||
--- A function to build a set of children components for a mode section
|
||||
-- @param opts options for configuring mode_text, paste, spell, and the overall padding
|
||||
-- @return The Heirline component table
|
||||
-- @usage local heirline_component = require("core.utils.status").component.mode { mode_text = true }
|
||||
-- @usage local heirline_component = require("astronvim.utils.status").component.mode { mode_text = true }
|
||||
function M.component.mode(opts)
|
||||
opts = extend_tbl({
|
||||
mode_text = false,
|
||||
@@ -1063,7 +1064,7 @@ end
|
||||
--- A function to build a set of children components for an LSP breadcrumbs section
|
||||
-- @param opts options for configuring breadcrumbs and the overall padding
|
||||
-- @return The Heirline component table
|
||||
-- @usage local heirline_component = require("core.utils.status").component.breadcumbs()
|
||||
-- @usage local heirline_component = require("astronvim.utils.status").component.breadcumbs()
|
||||
function M.component.breadcrumbs(opts)
|
||||
opts = extend_tbl({ padding = { left = 1 }, condition = M.condition.aerial_available, update = "CursorMoved" }, opts)
|
||||
opts.init = M.init.breadcrumbs(opts)
|
||||
@@ -1073,7 +1074,7 @@ end
|
||||
--- A function to build a set of children components for the current file path
|
||||
-- @param opts options for configuring path and the overall padding
|
||||
-- @return The Heirline component table
|
||||
-- @usage local heirline_component = require("core.utils.status").component.separated_path()
|
||||
-- @usage local heirline_component = require("astronvim.utils.status").component.separated_path()
|
||||
function M.component.separated_path(opts)
|
||||
opts = extend_tbl({ padding = { left = 1 }, update = { "BufEnter", "DirChanged" } }, opts)
|
||||
opts.init = M.init.separated_path(opts)
|
||||
@@ -1083,7 +1084,7 @@ end
|
||||
--- A function to build a set of children components for a git branch section
|
||||
-- @param opts options for configuring git branch and the overall padding
|
||||
-- @return The Heirline component table
|
||||
-- @usage local heirline_component = require("core.utils.status").component.git_branch()
|
||||
-- @usage local heirline_component = require("astronvim.utils.status").component.git_branch()
|
||||
function M.component.git_branch(opts)
|
||||
opts = extend_tbl({
|
||||
git_branch = { icon = { kind = "GitBranch", padding = { right = 1 } } },
|
||||
@@ -1106,7 +1107,7 @@ end
|
||||
--- A function to build a set of children components for a git difference section
|
||||
-- @param opts options for configuring git changes and the overall padding
|
||||
-- @return The Heirline component table
|
||||
-- @usage local heirline_component = require("core.utils.status").component.git_diff()
|
||||
-- @usage local heirline_component = require("astronvim.utils.status").component.git_diff()
|
||||
function M.component.git_diff(opts)
|
||||
opts = extend_tbl({
|
||||
added = { icon = { kind = "GitAdd", padding = { left = 1, right = 1 } } },
|
||||
@@ -1139,7 +1140,7 @@ end
|
||||
--- A function to build a set of children components for a diagnostics section
|
||||
-- @param opts options for configuring diagnostic providers and the overall padding
|
||||
-- @return The Heirline component table
|
||||
-- @usage local heirline_component = require("core.utils.status").component.diagnostics()
|
||||
-- @usage local heirline_component = require("astronvim.utils.status").component.diagnostics()
|
||||
function M.component.diagnostics(opts)
|
||||
opts = extend_tbl({
|
||||
ERROR = { icon = { kind = "DiagnosticError", padding = { left = 1, right = 1 } } },
|
||||
@@ -1174,7 +1175,7 @@ end
|
||||
--- A function to build a set of children components for a Treesitter section
|
||||
-- @param opts options for configuring diagnostic providers and the overall padding
|
||||
-- @return The Heirline component table
|
||||
-- @usage local heirline_component = require("core.utils.status").component.treesitter()
|
||||
-- @usage local heirline_component = require("astronvim.utils.status").component.treesitter()
|
||||
function M.component.treesitter(opts)
|
||||
opts = extend_tbl({
|
||||
str = { str = "TS", icon = { kind = "ActiveTS" } },
|
||||
@@ -1193,7 +1194,7 @@ end
|
||||
--- A function to build a set of children components for an LSP section
|
||||
-- @param opts options for configuring lsp progress and client_name providers and the overall padding
|
||||
-- @return The Heirline component table
|
||||
-- @usage local heirline_component = require("core.utils.status").component.lsp()
|
||||
-- @usage local heirline_component = require("astronvim.utils.status").component.lsp()
|
||||
function M.component.lsp(opts)
|
||||
opts = extend_tbl({
|
||||
lsp_progress = {
|
||||
@@ -1235,7 +1236,7 @@ end
|
||||
--- A function to build a set of components for a foldcolumn section in a statuscolumn
|
||||
-- @param opts options for configuring foldcolumn and the overall padding
|
||||
-- @return The Heirline component table
|
||||
-- @usage local heirline_component = require("core.utils.status").component.foldcolumn()
|
||||
-- @usage local heirline_component = require("astronvim.utils.status").component.foldcolumn()
|
||||
function M.component.foldcolumn(opts)
|
||||
opts = extend_tbl({
|
||||
foldcolumn = { padding = { right = 1 } },
|
||||
@@ -1255,7 +1256,7 @@ end
|
||||
--- A function to build a set of components for a numbercolumn section in statuscolumn
|
||||
-- @param opts options for configuring numbercolumn and the overall padding
|
||||
-- @return The Heirline component table
|
||||
-- @usage local heirline_component = require("core.utils.status").component.numbercolumn()
|
||||
-- @usage local heirline_component = require("astronvim.utils.status").component.numbercolumn()
|
||||
function M.component.numbercolumn(opts)
|
||||
opts = extend_tbl({
|
||||
numbercolumn = { padding = { right = 1 } },
|
||||
@@ -1277,7 +1278,7 @@ end
|
||||
--- A function to build a set of components for a signcolumn section in statuscolumn
|
||||
-- @param opts options for configuring signcolumn and the overall padding
|
||||
-- @return The Heirline component table
|
||||
-- @usage local heirline_component = require("core.utils.status").component.signcolumn()
|
||||
-- @usage local heirline_component = require("astronvim.utils.status").component.signcolumn()
|
||||
function M.component.signcolumn(opts)
|
||||
opts = extend_tbl({
|
||||
signcolumn = {},
|
||||
@@ -1298,7 +1299,7 @@ end
|
||||
--- A general function to build a section of astronvim status providers with highlights, conditions, and section surrounding
|
||||
-- @param opts a list of components to build into a section
|
||||
-- @return The Heirline component table
|
||||
-- @usage local heirline_component = require("core.utils.status").components.builder({ { provider = "file_icon", opts = { padding = { right = 1 } } }, { provider = "filename" } })
|
||||
-- @usage local heirline_component = require("astronvim.utils.status").components.builder({ { provider = "file_icon", opts = { padding = { right = 1 } } }, { provider = "filename" } })
|
||||
function M.component.builder(opts)
|
||||
opts = extend_tbl({ padding = { left = 0, right = 0 } }, opts)
|
||||
local children = {}
|
||||
@@ -1461,7 +1462,7 @@ end
|
||||
-- @param button the button parameter from Heirline component on_click.callback function call
|
||||
-- @param mods the button parameter from Heirline component on_click.callback function call
|
||||
-- @return the argument table with the decoded mouse information and signcolumn signs information
|
||||
-- @usage local heirline_component = { on_click = { callback = function(...) local args = require("core.utils.status").utils.statuscolumn_clickargs(...) end } }
|
||||
-- @usage local heirline_component = { on_click = { callback = function(...) local args = require("astronvim.utils.status").utils.statuscolumn_clickargs(...) end } }
|
||||
function M.utils.statuscolumn_clickargs(self, minwid, clicks, button, mods)
|
||||
local args = {
|
||||
minwid = minwid,
|
||||
@@ -2,10 +2,10 @@
|
||||
--
|
||||
-- Utility functions for easy UI toggles.
|
||||
--
|
||||
-- This module can be loaded with `local ui = require("core.utils.ui")`
|
||||
-- This module can be loaded with `local ui = require("astronvim.utils.ui")`
|
||||
--
|
||||
-- @module core.utils.ui
|
||||
-- @see core.utils
|
||||
-- @module astronvim.utils.ui
|
||||
-- @see astronvim.utils
|
||||
-- @copyright 2022
|
||||
-- @license GNU General Public License v3.0
|
||||
|
||||
@@ -14,7 +14,7 @@ local M = {}
|
||||
local function bool2str(bool) return bool and "on" or "off" end
|
||||
|
||||
local function ui_notify(str)
|
||||
if vim.g.ui_notifications_enabled then require("core.utils").notify(str) end
|
||||
if vim.g.ui_notifications_enabled then require("astronvim.utils").notify(str) end
|
||||
end
|
||||
|
||||
--- Toggle notifications for UI toggles
|
||||
@@ -55,7 +55,7 @@ function M.toggle_diagnostics()
|
||||
vim.g.status_diagnostics_enabled = true
|
||||
end
|
||||
|
||||
vim.diagnostic.config(require("core.utils.lsp").diagnostics[bool2str(vim.g.diagnostics_enabled)])
|
||||
vim.diagnostic.config(require("astronvim.utils.lsp").diagnostics[bool2str(vim.g.diagnostics_enabled)])
|
||||
ui_notify(string.format("diagnostics %s", status))
|
||||
end
|
||||
|
||||
@@ -198,7 +198,7 @@ end
|
||||
--- Toggle URL/URI syntax highlighting rules
|
||||
function M.toggle_url_match()
|
||||
vim.g.highlighturl_enabled = not vim.g.highlighturl_enabled
|
||||
require("core.utils").set_url_match()
|
||||
require("astronvim.utils").set_url_match()
|
||||
end
|
||||
|
||||
return M
|
||||
@@ -2,18 +2,18 @@
|
||||
--
|
||||
-- AstroNvim Updater utilities to use within AstroNvim and user configurations.
|
||||
--
|
||||
-- This module can also loaded with `local updater = require("core.utils.updater")`
|
||||
-- This module can also loaded with `local updater = require("astronvim.utils.updater")`
|
||||
--
|
||||
-- @module core.utils.updater
|
||||
-- @see core.utils
|
||||
-- @module astronvim.utils.updater
|
||||
-- @see astronvim.utils
|
||||
-- @copyright 2022
|
||||
-- @license GNU General Public License v3.0
|
||||
|
||||
local git = require "core.utils.git"
|
||||
local git = require "astronvim.utils.git"
|
||||
|
||||
local M = {}
|
||||
|
||||
local utils = require "core.utils"
|
||||
local utils = require "astronvim.utils"
|
||||
local notify = utils.notify
|
||||
|
||||
local function echo(messages)
|
||||
@@ -98,7 +98,7 @@ local function attempt_update(target, opts)
|
||||
-- if updating to a new stable version or a specific commit checkout the provided target
|
||||
if opts.channel == "stable" or opts.commit then
|
||||
return git.checkout(target, false)
|
||||
-- if no target, pull the latest
|
||||
-- if no target, pull the latest
|
||||
else
|
||||
return git.pull(false)
|
||||
end
|
||||
@@ -110,7 +110,7 @@ local cancelled_message = { { "Update cancelled", "WarningMsg" } }
|
||||
--- Sync Packer and then update Mason
|
||||
function M.update_packages()
|
||||
require("lazy").sync { wait = true }
|
||||
require("core.utils.mason").update_all()
|
||||
require("astronvim.utils.mason").update_all()
|
||||
end
|
||||
|
||||
--- Create a table of options for the currently installed AstroNvim version
|
||||
@@ -142,7 +142,7 @@ end
|
||||
--- AstroNvim's updater function
|
||||
function M.update(opts)
|
||||
if not opts then opts = astronvim.updater.options end
|
||||
opts = require("core.utils").extend_tbl({ remote = "origin", show_changelog = true, auto_quit = false }, opts)
|
||||
opts = require("astronvim.utils").extend_tbl({ remote = "origin", show_changelog = true, auto_quit = false }, opts)
|
||||
-- if the git command is not available, then throw an error
|
||||
if not git.available() then
|
||||
notify(
|
||||
@@ -270,7 +270,7 @@ function M.update(opts)
|
||||
then
|
||||
echo(cancelled_message)
|
||||
return
|
||||
-- if continued and there were errors reset the base config and attempt another update
|
||||
-- if continued and there were errors reset the base config and attempt another update
|
||||
elseif not updated then
|
||||
git.hard_reset(source)
|
||||
updated = attempt_update(target, opts)
|
||||
@@ -1,377 +0,0 @@
|
||||
local utils = require "core.utils"
|
||||
local is_available = utils.is_available
|
||||
|
||||
local maps = { i = {}, n = {}, v = {}, t = {} }
|
||||
|
||||
local sections = {
|
||||
f = { name = "Find" },
|
||||
p = { name = "Packages" },
|
||||
l = { name = "LSP" },
|
||||
u = { name = "UI" },
|
||||
b = { name = "Buffers" },
|
||||
d = { name = "Debugger" },
|
||||
g = { name = "Git" },
|
||||
S = { name = "Session" },
|
||||
t = { name = "Terminal" },
|
||||
}
|
||||
|
||||
-- Normal --
|
||||
-- Standard Operations
|
||||
maps.n["j"] = { "v:count ? 'j' : 'gj'", expr = true, desc = "Move cursor down" }
|
||||
maps.n["k"] = { "v:count ? 'k' : 'gk'", expr = true, desc = "Move cursor up" }
|
||||
maps.v["j"] = maps.n.j
|
||||
maps.v["k"] = maps.n.k
|
||||
maps.n["<leader>w"] = { "<cmd>w<cr>", desc = "Save" }
|
||||
maps.n["<leader>q"] = { "<cmd>confirm q<cr>", desc = "Quit" }
|
||||
maps.n["<leader>n"] = { "<cmd>enew<cr>", desc = "New File" }
|
||||
maps.n["gx"] =
|
||||
{ function() require("core.utils").system_open() end, desc = "Open the file under cursor with system app" }
|
||||
maps.n["<C-s>"] = { "<cmd>w!<cr>", desc = "Force write" }
|
||||
maps.n["<C-q>"] = { "<cmd>q!<cr>", desc = "Force quit" }
|
||||
maps.n["|"] = { "<cmd>vsplit<cr>", desc = "Vertical Split" }
|
||||
maps.n["\\"] = { "<cmd>split<cr>", desc = "Horizontal Split" }
|
||||
|
||||
-- Plugin Manager
|
||||
maps.n["<leader>p"] = sections.p
|
||||
maps.n["<leader>pi"] = { function() require("lazy").install() end, desc = "Plugins Install" }
|
||||
maps.n["<leader>ps"] = { function() require("lazy").home() end, desc = "Plugins Status" }
|
||||
maps.n["<leader>pS"] = { function() require("lazy").sync() end, desc = "Plugins Sync" }
|
||||
maps.n["<leader>pu"] = { function() require("lazy").check() end, desc = "Plugins Check Updates" }
|
||||
maps.n["<leader>pU"] = { function() require("lazy").update() end, desc = "Plugins Update" }
|
||||
|
||||
-- AstroNvim
|
||||
maps.n["<leader>pa"] = { "<cmd>AstroUpdatePackages<cr>", desc = "Update Plugins and Mason" }
|
||||
maps.n["<leader>pA"] = { "<cmd>AstroUpdate<cr>", desc = "AstroNvim Update" }
|
||||
maps.n["<leader>pv"] = { "<cmd>AstroVersion<cr>", desc = "AstroNvim Version" }
|
||||
maps.n["<leader>pl"] = { "<cmd>AstroChangelog<cr>", desc = "AstroNvim Changelog" }
|
||||
|
||||
-- Manage Buffers
|
||||
maps.n["<leader>c"] = { function() require("core.utils.buffer").close(0) end, desc = "Close buffer" }
|
||||
maps.n["<leader>C"] = { function() require("core.utils.buffer").close(0, true) end, desc = "Force close buffer" }
|
||||
maps.n["]b"] =
|
||||
{ function() require("core.utils.buffer").nav(vim.v.count > 0 and vim.v.count or 1) end, desc = "Next buffer" }
|
||||
maps.n["[b"] = {
|
||||
function() require("core.utils.buffer").nav(-(vim.v.count > 0 and vim.v.count or 1)) end,
|
||||
desc = "Previous buffer",
|
||||
}
|
||||
maps.n[">b"] = {
|
||||
function() require("core.utils.buffer").move(vim.v.count > 0 and vim.v.count or 1) end,
|
||||
desc = "Move buffer tab right",
|
||||
}
|
||||
maps.n["<b"] = {
|
||||
function() require("core.utils.buffer").move(-(vim.v.count > 0 and vim.v.count or 1)) end,
|
||||
desc = "Move buffer tab left",
|
||||
}
|
||||
|
||||
maps.n["<leader>b"] = sections.b
|
||||
maps.n["<leader>bb"] = {
|
||||
function()
|
||||
require("core.utils.status").heirline.buffer_picker(function(bufnr) vim.api.nvim_win_set_buf(0, bufnr) end)
|
||||
end,
|
||||
desc = "Select buffer from tabline",
|
||||
}
|
||||
maps.n["<leader>bd"] = {
|
||||
function()
|
||||
require("core.utils.status").heirline.buffer_picker(function(bufnr) require("core.utils.buffer").close(bufnr) end)
|
||||
end,
|
||||
desc = "Delete buffer from tabline",
|
||||
}
|
||||
maps.n["<leader>b\\"] = {
|
||||
function()
|
||||
require("core.utils.status").heirline.buffer_picker(function(bufnr)
|
||||
vim.cmd.split()
|
||||
vim.api.nvim_win_set_buf(0, bufnr)
|
||||
end)
|
||||
end,
|
||||
desc = "Horizontal split buffer from tabline",
|
||||
}
|
||||
maps.n["<leader>b|"] = {
|
||||
function()
|
||||
require("core.utils.status").heirline.buffer_picker(function(bufnr)
|
||||
vim.cmd.vsplit()
|
||||
vim.api.nvim_win_set_buf(0, bufnr)
|
||||
end)
|
||||
end,
|
||||
desc = "Vertical split buffer from tabline",
|
||||
}
|
||||
|
||||
-- Navigate tabs
|
||||
maps.n["]t"] = { function() vim.cmd.tabnext() end, desc = "Next tab" }
|
||||
maps.n["[t"] = { function() vim.cmd.tabprevious() end, desc = "Previous tab" }
|
||||
|
||||
-- Alpha
|
||||
if is_available "alpha-nvim" then
|
||||
maps.n["<leader>h"] = {
|
||||
function()
|
||||
local wins = vim.api.nvim_tabpage_list_wins(0)
|
||||
if #wins > 1 and vim.api.nvim_get_option_value("filetype", { win = wins[1] }) == "neo-tree" then
|
||||
vim.fn.win_gotoid(wins[2]) -- go to non-neo-tree window to toggle alpha
|
||||
end
|
||||
require("alpha").start(false, require("alpha").default_config)
|
||||
end,
|
||||
desc = "Home Screen",
|
||||
}
|
||||
end
|
||||
|
||||
-- Comment
|
||||
if is_available "Comment.nvim" then
|
||||
maps.n["<leader>/"] = { function() require("Comment.api").toggle.linewise.current() end, desc = "Comment line" }
|
||||
maps.v["<leader>/"] = {
|
||||
"<esc><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<cr>",
|
||||
desc = "Toggle comment line",
|
||||
}
|
||||
end
|
||||
|
||||
-- GitSigns
|
||||
if is_available "gitsigns.nvim" then
|
||||
maps.n["<leader>g"] = sections.g
|
||||
maps.n["]g"] = { function() require("gitsigns").next_hunk() end, desc = "Next Git hunk" }
|
||||
maps.n["[g"] = { function() require("gitsigns").prev_hunk() end, desc = "Previous Git hunk" }
|
||||
maps.n["<leader>gl"] = { function() require("gitsigns").blame_line() end, desc = "View Git blame" }
|
||||
maps.n["<leader>gp"] = { function() require("gitsigns").preview_hunk() end, desc = "Preview Git hunk" }
|
||||
maps.n["<leader>gh"] = { function() require("gitsigns").reset_hunk() end, desc = "Reset Git hunk" }
|
||||
maps.n["<leader>gr"] = { function() require("gitsigns").reset_buffer() end, desc = "Reset Git buffer" }
|
||||
maps.n["<leader>gs"] = { function() require("gitsigns").stage_hunk() end, desc = "Stage Git hunk" }
|
||||
maps.n["<leader>gS"] = { function() require("gitsigns").stage_buffer() end, desc = "Stage Git buffer" }
|
||||
maps.n["<leader>gu"] = { function() require("gitsigns").undo_stage_hunk() end, desc = "Unstage Git hunk" }
|
||||
maps.n["<leader>gd"] = { function() require("gitsigns").diffthis() end, desc = "View Git diff" }
|
||||
end
|
||||
|
||||
-- NeoTree
|
||||
if is_available "neo-tree.nvim" then
|
||||
maps.n["<leader>e"] = { "<cmd>Neotree toggle<cr>", desc = "Toggle Explorer" }
|
||||
maps.n["<leader>o"] = {
|
||||
function()
|
||||
if vim.bo.filetype == "neo-tree" then
|
||||
vim.cmd.wincmd "p"
|
||||
else
|
||||
vim.cmd.Neotree "focus"
|
||||
end
|
||||
end,
|
||||
desc = "Toggle Explorer Focus",
|
||||
}
|
||||
end
|
||||
|
||||
-- Session Manager
|
||||
if is_available "neovim-session-manager" then
|
||||
maps.n["<leader>S"] = sections.S
|
||||
maps.n["<leader>Sl"] = { "<cmd>SessionManager! load_last_session<cr>", desc = "Load last session" }
|
||||
maps.n["<leader>Ss"] = { "<cmd>SessionManager! save_current_session<cr>", desc = "Save this session" }
|
||||
maps.n["<leader>Sd"] = { "<cmd>SessionManager! delete_session<cr>", desc = "Delete session" }
|
||||
maps.n["<leader>Sf"] = { "<cmd>SessionManager! load_session<cr>", desc = "Search sessions" }
|
||||
maps.n["<leader>S."] =
|
||||
{ "<cmd>SessionManager! load_current_dir_session<cr>", desc = "Load current directory session" }
|
||||
end
|
||||
|
||||
-- Package Manager
|
||||
if is_available "mason.nvim" then
|
||||
maps.n["<leader>pm"] = { "<cmd>Mason<cr>", desc = "Mason Installer" }
|
||||
maps.n["<leader>pM"] = { "<cmd>MasonUpdateAll<cr>", desc = "Mason Update" }
|
||||
end
|
||||
|
||||
-- Smart Splits
|
||||
if is_available "smart-splits.nvim" then
|
||||
-- Better window navigation
|
||||
maps.n["<C-h>"] = { function() require("smart-splits").move_cursor_left() end, desc = "Move to left split" }
|
||||
maps.n["<C-j>"] = { function() require("smart-splits").move_cursor_down() end, desc = "Move to below split" }
|
||||
maps.n["<C-k>"] = { function() require("smart-splits").move_cursor_up() end, desc = "Move to above split" }
|
||||
maps.n["<C-l>"] = { function() require("smart-splits").move_cursor_right() end, desc = "Move to right split" }
|
||||
|
||||
-- Resize with arrows
|
||||
maps.n["<C-Up>"] = { function() require("smart-splits").resize_up() end, desc = "Resize split up" }
|
||||
maps.n["<C-Down>"] = { function() require("smart-splits").resize_down() end, desc = "Resize split down" }
|
||||
maps.n["<C-Left>"] = { function() require("smart-splits").resize_left() end, desc = "Resize split left" }
|
||||
maps.n["<C-Right>"] = { function() require("smart-splits").resize_right() end, desc = "Resize split right" }
|
||||
else
|
||||
maps.n["<C-h>"] = { "<C-w>h", desc = "Move to left split" }
|
||||
maps.n["<C-j>"] = { "<C-w>j", desc = "Move to below split" }
|
||||
maps.n["<C-k>"] = { "<C-w>k", desc = "Move to above split" }
|
||||
maps.n["<C-l>"] = { "<C-w>l", desc = "Move to right split" }
|
||||
maps.n["<C-Up>"] = { "<cmd>resize -2<CR>", desc = "Resize split up" }
|
||||
maps.n["<C-Down>"] = { "<cmd>resize +2<CR>", desc = "Resize split down" }
|
||||
maps.n["<C-Left>"] = { "<cmd>vertical resize -2<CR>", desc = "Resize split left" }
|
||||
maps.n["<C-Right>"] = { "<cmd>vertical resize +2<CR>", desc = "Resize split right" }
|
||||
end
|
||||
|
||||
-- SymbolsOutline
|
||||
if is_available "aerial.nvim" then
|
||||
maps.n["<leader>l"] = sections.l
|
||||
maps.n["<leader>lS"] = { function() require("aerial").toggle() end, desc = "Symbols outline" }
|
||||
end
|
||||
|
||||
-- Telescope
|
||||
if is_available "telescope.nvim" then
|
||||
maps.n["<leader>f"] = sections.f
|
||||
maps.n["<leader>g"] = sections.g
|
||||
maps.n["<leader>gb"] = { function() require("telescope.builtin").git_branches() end, desc = "Git branches" }
|
||||
maps.n["<leader>gc"] = { function() require("telescope.builtin").git_commits() end, desc = "Git commits" }
|
||||
maps.n["<leader>gt"] = { function() require("telescope.builtin").git_status() end, desc = "Git status" }
|
||||
maps.n["<leader>f<CR>"] = { function() require("telescope.builtin").resume() end, desc = "Resume previous search" }
|
||||
maps.n["<leader>f'"] = { function() require("telescope.builtin").marks() end, desc = "Find marks" }
|
||||
maps.n["<leader>fa"] = {
|
||||
function()
|
||||
local cwd = vim.fn.stdpath "config" .. "/.."
|
||||
local search_dirs = {}
|
||||
for _, dir in ipairs(astronvim.supported_configs) do -- search all supported config locations
|
||||
if dir == astronvim.install.home then dir = dir .. "/lua/user" end -- don't search the astronvim core files
|
||||
if vim.fn.isdirectory(dir) == 1 then table.insert(search_dirs, dir) end -- add directory to search if exists
|
||||
end
|
||||
if vim.tbl_isempty(search_dirs) then -- if no config folders found, show warning
|
||||
require("core.utils").notify("No user configuration files found", "warn")
|
||||
else
|
||||
if #search_dirs == 1 then cwd = search_dirs[1] end -- if only one directory, focus cwd
|
||||
require("telescope.builtin").find_files { prompt_title = "Config Files", search_dirs = search_dirs, cwd = cwd } -- call telescope
|
||||
end
|
||||
end,
|
||||
desc = "Find AstroNvim config files",
|
||||
}
|
||||
maps.n["<leader>fb"] = { function() require("telescope.builtin").buffers() end, desc = "Find buffers" }
|
||||
maps.n["<leader>fc"] =
|
||||
{ function() require("telescope.builtin").grep_string() end, desc = "Find for word under cursor" }
|
||||
maps.n["<leader>fC"] = { function() require("telescope.builtin").commands() end, desc = "Find commands" }
|
||||
maps.n["<leader>ff"] = { function() require("telescope.builtin").find_files() end, desc = "Find files" }
|
||||
maps.n["<leader>fF"] = {
|
||||
function() require("telescope.builtin").find_files { hidden = true, no_ignore = true } end,
|
||||
desc = "Find all files",
|
||||
}
|
||||
maps.n["<leader>fh"] = { function() require("telescope.builtin").help_tags() end, desc = "Find help" }
|
||||
maps.n["<leader>fk"] = { function() require("telescope.builtin").keymaps() end, desc = "Find keymaps" }
|
||||
maps.n["<leader>fm"] = { function() require("telescope.builtin").man_pages() end, desc = "Find man" }
|
||||
if is_available "nvim-notify" then
|
||||
maps.n["<leader>fn"] =
|
||||
{ function() require("telescope").extensions.notify.notify() end, desc = "Find notifications" }
|
||||
end
|
||||
maps.n["<leader>fo"] = { function() require("telescope.builtin").oldfiles() end, desc = "Find history" }
|
||||
maps.n["<leader>fr"] = { function() require("telescope.builtin").registers() end, desc = "Find registers" }
|
||||
maps.n["<leader>ft"] =
|
||||
{ function() require("telescope.builtin").colorscheme { enable_preview = true } end, desc = "Find themes" }
|
||||
maps.n["<leader>fw"] = { function() require("telescope.builtin").live_grep() end, desc = "Find words" }
|
||||
maps.n["<leader>fW"] = {
|
||||
function()
|
||||
require("telescope.builtin").live_grep {
|
||||
additional_args = function(args) return vim.list_extend(args, { "--hidden", "--no-ignore" }) end,
|
||||
}
|
||||
end,
|
||||
desc = "Find words in all files",
|
||||
}
|
||||
maps.n["<leader>l"] = sections.l
|
||||
maps.n["<leader>lD"] = { function() require("telescope.builtin").diagnostics() end, desc = "Search diagnostics" }
|
||||
maps.n["<leader>ls"] = {
|
||||
function()
|
||||
local aerial_avail, _ = pcall(require, "aerial")
|
||||
if aerial_avail then
|
||||
require("telescope").extensions.aerial.aerial()
|
||||
else
|
||||
require("telescope.builtin").lsp_document_symbols()
|
||||
end
|
||||
end,
|
||||
desc = "Search symbols",
|
||||
}
|
||||
end
|
||||
|
||||
-- Terminal
|
||||
if is_available "toggleterm.nvim" then
|
||||
maps.n["<leader>t"] = sections.t
|
||||
local toggle_term_cmd = require("core.utils").toggle_term_cmd
|
||||
if vim.fn.executable "lazygit" == 1 then
|
||||
maps.n["<leader>g"] = sections.g
|
||||
maps.n["<leader>gg"] = { function() toggle_term_cmd "lazygit" end, desc = "ToggleTerm lazygit" }
|
||||
maps.n["<leader>tl"] = { function() toggle_term_cmd "lazygit" end, desc = "ToggleTerm lazygit" }
|
||||
end
|
||||
if vim.fn.executable "node" == 1 then
|
||||
maps.n["<leader>tn"] = { function() toggle_term_cmd "node" end, desc = "ToggleTerm node" }
|
||||
end
|
||||
if vim.fn.executable "gdu" == 1 then
|
||||
maps.n["<leader>tu"] = { function() toggle_term_cmd "gdu" end, desc = "ToggleTerm gdu" }
|
||||
end
|
||||
if vim.fn.executable "btm" == 1 then
|
||||
maps.n["<leader>tt"] = { function() toggle_term_cmd "btm" end, desc = "ToggleTerm btm" }
|
||||
end
|
||||
local python = vim.fn.executable "python" == 1 and "python" or vim.fn.executable "python3" == 1 and "python3"
|
||||
if python then maps.n["<leader>tp"] = { function() toggle_term_cmd(python) end, desc = "ToggleTerm python" } end
|
||||
maps.n["<leader>tf"] = { "<cmd>ToggleTerm direction=float<cr>", desc = "ToggleTerm float" }
|
||||
maps.n["<leader>th"] = { "<cmd>ToggleTerm size=10 direction=horizontal<cr>", desc = "ToggleTerm horizontal split" }
|
||||
maps.n["<leader>tv"] = { "<cmd>ToggleTerm size=80 direction=vertical<cr>", desc = "ToggleTerm vertical split" }
|
||||
maps.n["<F7>"] = { "<cmd>ToggleTerm<cr>", desc = "Toggle terminal" }
|
||||
maps.t["<F7>"] = maps.n["<F7>"]
|
||||
maps.n["<C-'>"] = maps.n["<F7>"]
|
||||
maps.t["<C-'>"] = maps.n["<F7>"]
|
||||
end
|
||||
|
||||
if is_available "nvim-dap" then
|
||||
maps.n["<leader>d"] = sections.d
|
||||
-- modified function keys found with `showkey -a` in the terminal to get key code
|
||||
-- run `nvim -V3log +quit` and search through the "Terminal info" in the `log` file for the correct keyname
|
||||
maps.n["<F5>"] = { function() require("dap").continue() end, desc = "Debugger: Start" }
|
||||
maps.n["<F17>"] = { function() require("dap").terminate() end, desc = "Debugger: Stop" } -- Shift+F5
|
||||
maps.n["<F29>"] = { function() require("dap").restart_frame() end, desc = "Debugger: Restart" } -- Control+F5
|
||||
maps.n["<F6>"] = { function() require("dap").pause() end, desc = "Debugger: Pause" }
|
||||
maps.n["<F9>"] = { function() require("dap").toggle_breakpoint() end, desc = "Debugger: Toggle Breakpoint" }
|
||||
maps.n["<F10>"] = { function() require("dap").step_over() end, desc = "Debugger: Step Over" }
|
||||
maps.n["<F11>"] = { function() require("dap").step_into() end, desc = "Debugger: Step Into" }
|
||||
maps.n["<F23>"] = { function() require("dap").step_out() end, desc = "Debugger: Step Out" } -- Shift+F11
|
||||
maps.n["<leader>db"] = { function() require("dap").toggle_breakpoint() end, desc = "Toggle Breakpoint (F9)" }
|
||||
maps.n["<leader>dB"] = { function() require("dap").clear_breakpoints() end, desc = "Clear Breakpoints" }
|
||||
maps.n["<leader>dc"] = { function() require("dap").continue() end, desc = "Start/Continue (F5)" }
|
||||
maps.n["<leader>di"] = { function() require("dap").step_into() end, desc = "Step Into (F11)" }
|
||||
maps.n["<leader>do"] = { function() require("dap").step_over() end, desc = "Step Over (F10)" }
|
||||
maps.n["<leader>dO"] = { function() require("dap").step_out() end, desc = "Step Out (S-F11)" }
|
||||
maps.n["<leader>dq"] = { function() require("dap").close() end, desc = "Close Session" }
|
||||
maps.n["<leader>dQ"] = { function() require("dap").terminate() end, desc = "Terminate Session (S-F5)" }
|
||||
maps.n["<leader>dp"] = { function() require("dap").pause() end, desc = "Pause (F6)" }
|
||||
maps.n["<leader>dr"] = { function() require("dap").restart_frame() end, desc = "Restart (C-F5)" }
|
||||
maps.n["<leader>dR"] = { function() require("dap").repl.toggle() end, desc = "Toggle REPL" }
|
||||
if is_available "nvim-dap-ui" then
|
||||
maps.n["<leader>du"] = { function() require("dapui").toggle() end, desc = "Toggle Debugger UI" }
|
||||
maps.n["<leader>dh"] = { function() require("dap.ui.widgets").hover() end, desc = "Debugger Hover" }
|
||||
end
|
||||
end
|
||||
|
||||
-- Improved Code Folding
|
||||
if is_available "nvim-ufo" then
|
||||
maps.n["zR"] = { function() require("ufo").openAllFolds() end, desc = "Open all folds" }
|
||||
maps.n["zM"] = { function() require("ufo").closeAllFolds() end, desc = "Close all folds" }
|
||||
maps.n["zr"] = { function() require("ufo").openFoldsExceptKinds() end, desc = "Fold less" }
|
||||
maps.n["zm"] = { function() require("ufo").closeFoldsWith() end, desc = "Fold more" }
|
||||
maps.n["zp"] = { function() require("ufo").peekFoldedLinesUnderCursor() end, desc = "Peek fold" }
|
||||
end
|
||||
|
||||
-- Stay in indent mode
|
||||
maps.v["<S-Tab>"] = { "<gv", desc = "unindent line" }
|
||||
maps.v["<Tab>"] = { ">gv", desc = "indent line" }
|
||||
|
||||
-- Improved Terminal Navigation
|
||||
maps.t["<C-h>"] = { "<c-\\><c-n><c-w>h", desc = "Terminal left window navigation" }
|
||||
maps.t["<C-j>"] = { "<c-\\><c-n><c-w>j", desc = "Terminal down window navigation" }
|
||||
maps.t["<C-k>"] = { "<c-\\><c-n><c-w>k", desc = "Terminal up window navigation" }
|
||||
maps.t["<C-l>"] = { "<c-\\><c-n><c-w>l", desc = "Terminal right window navigation" }
|
||||
|
||||
maps.n["<leader>u"] = sections.u
|
||||
-- Custom menu for modification of the user experience
|
||||
if is_available "nvim-autopairs" then
|
||||
maps.n["<leader>ua"] = { function() require("core.utils.ui").toggle_autopairs() end, desc = "Toggle autopairs" }
|
||||
end
|
||||
maps.n["<leader>ub"] = { function() require("core.utils.ui").toggle_background() end, desc = "Toggle background" }
|
||||
if is_available "nvim-cmp" then
|
||||
maps.n["<leader>uc"] = { function() require("core.utils.ui").toggle_cmp() end, desc = "Toggle autocompletion" }
|
||||
end
|
||||
if is_available "nvim-colorizer.lua" then
|
||||
maps.n["<leader>uC"] = { "<cmd>ColorizerToggle<cr>", desc = "Toggle color highlight" }
|
||||
end
|
||||
maps.n["<leader>ud"] = { function() require("core.utils.ui").toggle_diagnostics() end, desc = "Toggle diagnostics" }
|
||||
maps.n["<leader>ug"] = { function() require("core.utils.ui").toggle_signcolumn() end, desc = "Toggle signcolumn" }
|
||||
maps.n["<leader>ui"] = { function() require("core.utils.ui").set_indent() end, desc = "Change indent setting" }
|
||||
maps.n["<leader>ul"] = { function() require("core.utils.ui").toggle_statusline() end, desc = "Toggle statusline" }
|
||||
maps.n["<leader>uL"] = { function() require("core.utils.ui").toggle_codelens() end, desc = "Toggle CodeLens refresh" }
|
||||
maps.n["<leader>un"] = { function() require("core.utils.ui").change_number() end, desc = "Change line numbering" }
|
||||
maps.n["<leader>uN"] =
|
||||
{ function() require("core.utils.ui").toggle_ui_notifications() end, desc = "Toggle UI notifications" }
|
||||
maps.n["<leader>up"] = { function() require("core.utils.ui").toggle_paste() end, desc = "Toggle paste mode" }
|
||||
maps.n["<leader>us"] = { function() require("core.utils.ui").toggle_spell() end, desc = "Toggle spellcheck" }
|
||||
maps.n["<leader>uS"] = { function() require("core.utils.ui").toggle_conceal() end, desc = "Toggle conceal" }
|
||||
maps.n["<leader>ut"] = { function() require("core.utils.ui").toggle_tabline() end, desc = "Toggle tabline" }
|
||||
maps.n["<leader>uu"] = { function() require("core.utils.ui").toggle_url_match() end, desc = "Toggle URL highlight" }
|
||||
maps.n["<leader>uw"] = { function() require("core.utils.ui").toggle_wrap() end, desc = "Toggle wrap" }
|
||||
maps.n["<leader>uy"] = { function() require("core.utils.ui").toggle_syntax() end, desc = "Toggle syntax highlight" }
|
||||
|
||||
utils.set_mappings(astronvim.user_opts("mappings", maps))
|
||||
@@ -18,7 +18,7 @@ return {
|
||||
}
|
||||
dashboard.section.header.opts.hl = "DashboardHeader"
|
||||
|
||||
local button = require("core.utils").alpha_button
|
||||
local button = require("astronvim.utils").alpha_button
|
||||
dashboard.section.buttons.val = {
|
||||
button("LDR n", " New File "),
|
||||
button("LDR f f", " Find File "),
|
||||
|
||||
+4
-2
@@ -19,8 +19,10 @@ return {
|
||||
local snip_status_ok, luasnip = pcall(require, "luasnip")
|
||||
local lspkind_status_ok, lspkind = pcall(require, "lspkind")
|
||||
if not snip_status_ok then return end
|
||||
local border_opts =
|
||||
{ border = "single", winhighlight = "Normal:Normal,FloatBorder:FloatBorder,CursorLine:Visual,Search:None" }
|
||||
local border_opts = {
|
||||
border = "single",
|
||||
winhighlight = "Normal:Normal,FloatBorder:FloatBorder,CursorLine:Visual,Search:None",
|
||||
}
|
||||
|
||||
local function has_words_before()
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
return function(_, opts)
|
||||
local heirline = require "heirline"
|
||||
local status = require "core.utils.status"
|
||||
local status = require "astronvim.utils.status"
|
||||
local C = status.env.fallback_colors
|
||||
local get_hlgroup = require("core.utils").get_hlgroup
|
||||
local get_hlgroup = require("astronvim.utils").get_hlgroup
|
||||
|
||||
local function setup_colors()
|
||||
local Normal = get_hlgroup("Normal", { fg = C.fg, bg = C.bg })
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
return function(_, _)
|
||||
local lsp = require "core.utils.lsp"
|
||||
local get_icon = require("core.utils").get_icon
|
||||
local lsp = require "astronvim.utils.lsp"
|
||||
local get_icon = require("astronvim.utils").get_icon
|
||||
local signs = {
|
||||
{ name = "DiagnosticSignError", text = get_icon "DiagnosticError", texthl = "DiagnosticSignError" },
|
||||
{ name = "DiagnosticSignWarn", text = get_icon "DiagnosticWarn", texthl = "DiagnosticSignWarn" },
|
||||
@@ -24,10 +24,10 @@ return function(_, _)
|
||||
vim.lsp.with(vim.lsp.handlers.signature_help, { border = "rounded" })
|
||||
end
|
||||
local setup_servers = function()
|
||||
vim.tbl_map(require("core.utils.lsp").setup, astronvim.user_opts "lsp.servers")
|
||||
vim.tbl_map(require("astronvim.utils.lsp").setup, astronvim.user_opts "lsp.servers")
|
||||
vim.api.nvim_exec_autocmds("FileType", {})
|
||||
end
|
||||
if require("core.utils").is_available "mason-lspconfig.nvim" then
|
||||
if require("astronvim.utils").is_available "mason-lspconfig.nvim" then
|
||||
vim.api.nvim_create_autocmd("User", { pattern = "AstroLspSetup", once = true, callback = setup_servers })
|
||||
else
|
||||
setup_servers()
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
return function(_, opts)
|
||||
local mason_lspconfig = require "mason-lspconfig"
|
||||
mason_lspconfig.setup(opts)
|
||||
mason_lspconfig.setup_handlers { function(server) require("core.utils.lsp").setup(server) end }
|
||||
require("core.utils").event "LspSetup"
|
||||
mason_lspconfig.setup_handlers {
|
||||
function(server) require("astronvim.utils.lsp").setup(server) end,
|
||||
}
|
||||
require("astronvim.utils").event "LspSetup"
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
return function(_, opts)
|
||||
require("nvim-web-devicons").set_default_icon(require("core.utils").get_icon "DefaultFile", "#6d8086", "66")
|
||||
require("nvim-web-devicons").set_default_icon(require("astronvim.utils").get_icon "DefaultFile", "#6d8086", "66")
|
||||
require("nvim-web-devicons").set_icon(opts)
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
return function(_, opts)
|
||||
local telescope = require "telescope"
|
||||
telescope.setup(opts)
|
||||
local utils = require "core.utils"
|
||||
local utils = require "astronvim.utils"
|
||||
local conditional_func = utils.conditional_func
|
||||
conditional_func(telescope.load_extension, pcall(require, "notify"), "notify")
|
||||
conditional_func(telescope.load_extension, pcall(require, "aerial"), "aerial")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
return function(_, opts)
|
||||
require("which-key").setup(opts)
|
||||
require("core.utils").which_key_register()
|
||||
require("astronvim.utils").which_key_register()
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@ return {
|
||||
"rebelot/heirline.nvim",
|
||||
event = "BufEnter",
|
||||
opts = function()
|
||||
local status = require "core.utils.status"
|
||||
local status = require "astronvim.utils.status"
|
||||
return {
|
||||
statusline = { -- statusline
|
||||
hl = { fg = "fg", bg = "bg" },
|
||||
@@ -70,7 +70,7 @@ return {
|
||||
provider = status.provider.close_button { kind = "TabClose", padding = { left = 1, right = 1 } },
|
||||
hl = status.hl.get_attributes("tab_close", true),
|
||||
on_click = {
|
||||
callback = function() require("core.utils.buffer").close_tab() end,
|
||||
callback = function() require("astronvim.utils.buffer").close_tab() end,
|
||||
name = "heirline_tabline_close_tab_callback",
|
||||
},
|
||||
},
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ return {
|
||||
},
|
||||
},
|
||||
init = function() table.insert(astronvim.file_plugins, "null-ls.nvim") end,
|
||||
opts = function() return { on_attach = require("core.utils.lsp").on_attach } end,
|
||||
opts = function() return { on_attach = require("astronvim.utils.lsp").on_attach } end,
|
||||
},
|
||||
{
|
||||
"stevearc/aerial.nvim",
|
||||
|
||||
@@ -10,10 +10,14 @@ return {
|
||||
},
|
||||
init = function()
|
||||
local cmd = vim.api.nvim_create_user_command
|
||||
cmd("MasonUpdateAll", function() require("core.utils.mason").update_all() end, { desc = "Update Mason Packages" })
|
||||
cmd(
|
||||
"MasonUpdateAll",
|
||||
function() require("astronvim.utils.mason").update_all() end,
|
||||
{ desc = "Update Mason Packages" }
|
||||
)
|
||||
cmd(
|
||||
"MasonUpdate",
|
||||
function(options) require("core.utils.mason").update(options.args) end,
|
||||
function(options) require("astronvim.utils.mason").update(options.args) end,
|
||||
{ nargs = 1, desc = "Update Mason Package" }
|
||||
)
|
||||
end,
|
||||
|
||||
@@ -6,7 +6,7 @@ return {
|
||||
opts = function()
|
||||
-- TODO move after neo-tree improves (https://github.com/nvim-neo-tree/neo-tree.nvim/issues/707)
|
||||
local global_commands = {
|
||||
system_open = function(state) require("core.utils").system_open(state.tree:get_node():get_id()) end,
|
||||
system_open = function(state) require("astronvim.utils").system_open(state.tree:get_node():get_id()) end,
|
||||
parent_or_close = function(state)
|
||||
local node = state.tree:get_node()
|
||||
if (node.type == "directory" or node:has_children()) and node:is_expanded() then
|
||||
@@ -28,7 +28,7 @@ return {
|
||||
end
|
||||
end,
|
||||
}
|
||||
local get_icon = require("core.utils").get_icon
|
||||
local get_icon = require("astronvim.utils").get_icon
|
||||
return {
|
||||
close_if_last_window = true,
|
||||
source_selector = {
|
||||
@@ -86,7 +86,10 @@ return {
|
||||
git_status = { commands = global_commands },
|
||||
diagnostics = { commands = global_commands },
|
||||
event_handlers = {
|
||||
{ event = "neo_tree_buffer_enter", handler = function(_) vim.opt_local.signcolumn = "auto" end },
|
||||
{
|
||||
event = "neo_tree_buffer_enter",
|
||||
handler = function(_) vim.opt_local.signcolumn = "auto" end,
|
||||
},
|
||||
},
|
||||
}
|
||||
end,
|
||||
|
||||
@@ -6,7 +6,7 @@ return {
|
||||
cmd = "Telescope",
|
||||
opts = function()
|
||||
local actions = require "telescope.actions"
|
||||
local get_icon = require("core.utils").get_icon
|
||||
local get_icon = require("astronvim.utils").get_icon
|
||||
return {
|
||||
defaults = {
|
||||
prompt_prefix = string.format("%s ", get_icon "Search"),
|
||||
|
||||
+2
-2
@@ -46,13 +46,13 @@ return {
|
||||
},
|
||||
{
|
||||
"rcarriga/nvim-notify",
|
||||
init = function() require("core.utils").load_plugin_with_func("nvim-notify", vim, "notify") end,
|
||||
init = function() require("astronvim.utils").load_plugin_with_func("nvim-notify", vim, "notify") end,
|
||||
opts = { stages = "fade" },
|
||||
config = require "plugins.configs.notify",
|
||||
},
|
||||
{
|
||||
"stevearc/dressing.nvim",
|
||||
init = function() require("core.utils").load_plugin_with_func("dressing.nvim", vim.ui, { "input", "select" }) end,
|
||||
init = function() require("astronvim.utils").load_plugin_with_func("dressing.nvim", vim.ui, { "input", "select" }) end,
|
||||
opts = {
|
||||
input = {
|
||||
default_prompt = "➤ ",
|
||||
|
||||
@@ -171,7 +171,15 @@ local config = {
|
||||
performance = {
|
||||
rtp = {
|
||||
-- customize default disabled vim plugins
|
||||
disabled_plugins = { "tohtml", "gzip", "matchit", "zipPlugin", "netrwPlugin", "tarPlugin", "matchparen" },
|
||||
disabled_plugins = {
|
||||
"tohtml",
|
||||
"gzip",
|
||||
"matchit",
|
||||
"zipPlugin",
|
||||
"netrwPlugin",
|
||||
"tarPlugin",
|
||||
"matchparen",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -322,7 +330,7 @@ local config = {
|
||||
-- },
|
||||
-- -- Customize colors for each element each element has a `_fg` and a `_bg`
|
||||
-- colors = function(colors)
|
||||
-- colors.git_branch_fg = require("core.utils").get_hlgroup "Conditional"
|
||||
-- colors.git_branch_fg = require("astronvim.utils").get_hlgroup "Conditional"
|
||||
-- return colors
|
||||
-- end,
|
||||
-- -- Customize attributes of highlighting in Heirline components
|
||||
|
||||
Reference in New Issue
Block a user