feat(plugins/astrocore): fully configure as in astronvim

This commit is contained in:
Nicolas Goudry 2024-06-07 17:07:38 +02:00
parent 455cb6f839
commit 519e85f142
No known key found for this signature in database
GPG key ID: 5FC434D9FFD1DF44
8 changed files with 1215 additions and 12 deletions

View file

@ -0,0 +1,358 @@
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_autocmds.lua
{
autoGroups = {
auto_quit.clear = true;
autoview.clear = true;
bufferline.clear = true;
checktime.clear = true;
create_dir.clear = true;
editorconfig_filetype.clear = true;
file_user_events.clear = true;
highlighturl.clear = true;
highlightyank.clear = true;
large_buf_settings.clear = true;
q_close_windows.clear = true;
terminal_settings.clear = true;
unlist_quickfix.clear = true;
};
autoCmd = [
# auto_quit
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_autocmds.lua#L18-L46
{
event = "BufEnter";
desc = "Quit neovim if more than one window is open and only sidebar windows are list";
group = "auto_quit";
callback.__raw = ''
function()
local wins = vim.api.nvim_tabpage_list_wins(0)
-- Both neo-tree and aerial will auto-quit if there is only a single window left
if #wins <= 1 then return end
local sidebar_fts = { aerial = true, ["neo-tree"] = true }
for _, winid in ipairs(wins) do
if vim.api.nvim_win_is_valid(winid) then
local bufnr = vim.api.nvim_win_get_buf(winid)
local filetype = vim.bo[bufnr].filetype
-- If any visible windows are not sidebars, early return
if not sidebar_fts[filetype] then
return
-- If the visible window is a sidebar
else
-- only count filetypes once, so remove a found sidebar from the detection
sidebar_fts[filetype] = nil
end
end
end
if #vim.api.nvim_list_tabpages() > 1 then
vim.cmd.tabclose()
else
vim.cmd.qall()
end
end
'';
}
# autoview
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_autocmds.lua#L49-L70
{
event = [ "BufWinLeave" "BufWritePost" "WinLeave" ];
desc = "Save view with mkview for real files";
group = "autoview";
callback.__raw = ''
function(event)
if vim.b[event.buf].view_activated then vim.cmd.mkview { mods = { emsg_silent = true } } end
end
'';
}
{
event = "BufWinEnter";
desc = "Try to load file view if available and enable view saving for real files";
group = "autoview";
callback.__raw = ''
function(event)
if not vim.b[event.buf].view_activated then
local filetype = vim.bo[event.buf].filetype
local buftype = vim.bo[event.buf].buftype
local ignore_filetypes = { "gitcommit", "gitrebase", "svg", "hgcommit" }
if buftype == "" and filetype and filetype ~= "" and not vim.tbl_contains(ignore_filetypes, filetype) then
vim.b[event.buf].view_activated = true
vim.cmd.loadview { mods = { emsg_silent = true } }
end
end
end
'';
}
# bufferline
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_autocmds.lua#L73-L115
{
event = [ "BufAdd" "BufEnter" "TabNewEntered" ];
desc = "Update buffers when adding new buffers";
group = "bufferline";
callback.__raw = ''
function(args)
local buf_utils = require "astrocore.buffer"
if not vim.t.bufs then vim.t.bufs = {} end
if not buf_utils.is_valid(args.buf) then return end
if args.buf ~= buf_utils.current_buf then
buf_utils.last_buf = buf_utils.is_valid(buf_utils.current_buf) and buf_utils.current_buf or nil
buf_utils.current_buf = args.buf
end
local bufs = vim.t.bufs
if not vim.tbl_contains(bufs, args.buf) then
table.insert(bufs, args.buf)
vim.t.bufs = bufs
end
vim.t.bufs = vim.tbl_filter(buf_utils.is_valid, vim.t.bufs)
require("astrocore").event "BufsUpdated"
end
'';
}
{
event = [ "BufDelete" "TermClose" ];
desc = "Update buffers when deleting buffers";
group = "bufferline";
callback.__raw = ''
function(args)
local removed
for _, tab in ipairs(vim.api.nvim_list_tabpages()) do
local bufs = vim.t[tab].bufs
if bufs then
for i, bufnr in ipairs(bufs) do
if bufnr == args.buf then
removed = true
table.remove(bufs, i)
vim.t[tab].bufs = bufs
break
end
end
end
end
vim.t.bufs = vim.tbl_filter(require("astrocore.buffer").is_valid, vim.t.bufs)
if removed then require("astrocore").event "BufsUpdated" end
vim.cmd.redrawtabline()
end
'';
}
# checktime
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_autocmds.lua#L118-L122
{
event = [ "FocusGained" "TermClose" "TermLeave" ];
desc = "Check if buffers changed on editor focus";
group = "checktime";
command = "checktime";
}
# create_dir
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_autocmds.lua#L125-L132
{
event = "BufWritePre";
desc = "Automatically create parent directories if they don't exist when saving a file";
group = "create_dir";
callback.__raw = ''
function(args)
if not require("astrocore.buffer").is_valid(args.buf) then return end
vim.fn.mkdir(vim.fn.fnamemodify(vim.loop.fs_realpath(args.match) or args.match, ":p:h"), "p")
end
'';
}
# editorconfig_filetype
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_autocmds.lua#L135-L144
{
event = "FileType";
desc = "configure editorconfig after filetype detection to override `ftplugin`s";
group = "editorconfig_filetype";
callback.__raw = ''
function(args)
if vim.F.if_nil(vim.b.editorconfig, vim.g.editorconfig, true) then
local editorconfig_avail, editorconfig = pcall(require, "editorconfig")
if editorconfig_avail then editorconfig.config(args.buf) end
end
end
'';
}
# file_user_events
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_autocmds.lua#L147-L177
{
event = [ "BufReadPost" "BufNewFile" "BufWritePost" ];
desc = "AstroNvim user events for file detection (AstroFile and AstroGitFile)";
group = "file_user_events";
callback.__raw = ''
function(args)
if vim.b[args.buf].astrofile_checked then return end
vim.b[args.buf].astrofile_checked = true
vim.schedule(function()
if not vim.api.nvim_buf_is_valid(args.buf) then return end
local astro = require "astrocore"
local current_file = vim.api.nvim_buf_get_name(args.buf)
if vim.g.vscode or not (current_file == "" or vim.bo[args.buf].buftype == "nofile") then
astro.event "File"
local folder = vim.fn.fnamemodify(current_file, ":p:h")
if vim.fn.has "win32" == 1 then folder = ('"%s"'):format(folder) end
if vim.fn.executable "git" == 1 then
if astro.cmd({ "git", "-C", folder, "rev-parse" }, false) or astro.file_worktree() then
astro.event "GitFile"
pcall(vim.api.nvim_del_augroup_by_name, "file_user_events")
end
else
pcall(vim.api.nvim_del_augroup_by_name, "file_user_events")
end
vim.schedule(function()
if require("astrocore.buffer").is_valid(args.buf) then
vim.api.nvim_exec_autocmds(args.event, { buffer = args.buf, data = args.data })
end
end)
end
end)
end
'';
}
# highlighturl
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_autocmds.lua#L180-L203
{
event = [ "VimEnter" "FileType" "BufEnter" "WinEnter" ];
desc = "URL Highlighting";
group = "highlighturl";
callback.__raw = ''
function(args)
for _, win in ipairs(vim.api.nvim_list_wins()) do
if
vim.api.nvim_win_get_buf(win) == args.buf
and vim.tbl_get(require "astrocore", "config", "features", "highlighturl")
and not vim.w[win].highlighturl_enabled
then
require("astrocore").set_url_match(win)
end
end
end
'';
}
{
event = [ "VimEnter" "User" ];
desc = "Set up the default HighlightURL highlight group";
group = "highlighturl";
callback.__raw = ''
function(args)
if args.event == "VimEnter" or args.match == "AstroColorScheme" then
vim.api.nvim_set_hl(0, "HighlightURL", { default = true, underline = true })
end
end
'';
}
# highlightyank
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_autocmds.lua#L206-L211
{
event = "TextYankPost";
desc = "Highlight yanked text";
group = "highlightyank";
pattern = "*";
callback.__raw = ''
function()
vim.highlight.on_yank()
end
'';
}
# large_buf_settings
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_autocmds.lua#L214-L239
{
event = "User";
desc = "Disable certain functionality on very large files";
group = "large_buf_settings";
pattern = "AstroLargeBuf";
callback.__raw = ''
function(args)
vim.opt_local.wrap = true -- enable wrap, long lines in vim are slow
vim.opt_local.list = false -- disable list chars
vim.b[args.buf].autoformat = false -- disable autoformat on save
vim.b[args.buf].cmp_enabled = false -- disable completion
vim.b[args.buf].miniindentscope_disable = true -- disable indent scope
vim.b[args.buf].matchup_matchparen_enabled = 0 -- disable vim-matchup
local astrocore = require "astrocore"
if vim.tbl_get(astrocore.config, "features", "highlighturl") then
astrocore.config.features.highlighturl = false
vim.tbl_map(function(win)
if vim.w[win].highlighturl_enabled then astrocore.delete_url_match(win) end
end, vim.api.nvim_list_wins())
end
local ibl_avail, ibl = pcall(require, "ibl") -- disable indent-blankline
if ibl_avail then ibl.setup_buffer(args.buf, { enabled = false }) end
local illuminate_avail, illuminate = pcall(require, "illuminate.engine") -- disable vim-illuminate
if illuminate_avail then illuminate.stop_buf(args.buf) end
local rainbow_avail, rainbow = pcall(require, "rainbow-delimiters") -- disable rainbow-delimiters
if rainbow_avail then rainbow.disable(args.buf) end
end
'';
}
# q_close_windows
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_autocmds.lua#L242-L255
{
event = "BufWinEnter";
desc = "Make q close help, man, quickfix, dap floats";
group = "q_close_windows";
callback.__raw = ''
function(event)
if vim.tbl_contains({ "help", "nofile", "quickfix" }, vim.bo[event.buf].buftype) then
vim.keymap.set("n", "q", "<Cmd>close<CR>", {
desc = "Close window",
buffer = event.buf,
silent = true,
nowait = true,
})
end
end
'';
}
# terminal_settings
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_autocmds.lua#L258-L266
{
event = "TermOpen";
desc = "Disable line number/fold column/sign column for terminals";
group = "terminal_settings";
callback.__raw = ''
function()
vim.opt_local.number = false
vim.opt_local.relativenumber = false
vim.opt_local.foldcolumn = "0"
vim.opt_local.signcolumn = "no"
end
'';
}
# unlist_quickfix
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_autocmds.lua#L270-L275
{
event = "FileType";
desc = "Unlist quickfix buffers";
group = "unlist_quickfix";
pattern = "qf";
callback.__raw = ''
function()
vim.opt_local.buflisted = false
end
'';
}
];
}

View file

@ -1,27 +1,45 @@
# homepage: https://github.com/AstroNvim/astrocore # homepage: https://github.com/AstroNvim/astrocore
{ lib, pkgs, ... }: { helpers, icons, lib, pkgs, ... }:
let
autocmds = import ./autocmds.nix;
diagnostics = import ./diagnostics.nix { inherit icons; };
features = import ./features.nix;
mappings = import ./mappings.nix;
options = import ./options.nix { inherit lib; };
rooter = import ./rooter.nix;
sessions = import ./sessions.nix;
in
{ {
extra = { extra = {
packages = [ packages = [
(import ./package { inherit lib pkgs; }) (import ./package { inherit lib pkgs; })
]; ];
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_options.lua#L49-L53
config = '' config = ''
local g = {}
g.markdown_recommended_style = 0
if not vim.t.bufs then vim.t.bufs = vim.api.nvim_list_bufs() end -- initialize buffer list
require('astrocore').setup({ require('astrocore').setup({
g = { diagnostics = ${helpers.toLuaObject diagnostics},
markdown_recommended_style = 0, features = ${helpers.toLuaObject features},
options = ${helpers.toLuaObject options.astrocore},
rooter = ${helpers.toLuaObject rooter},
sessions = ${helpers.toLuaObject sessions},
on_keys = {
auto_hlsearch = {
function(char)
if vim.fn.mode() == "n" then
local new_hlsearch = vim.tbl_contains({ "<CR>", "n", "N", "*", "#", "?", "/" }, vim.fn.keytrans(char))
if vim.opt.hlsearch:get() ~= new_hlsearch then vim.opt.hlsearch = new_hlsearch end
end
end,
}, },
t = {
bufs = vim.t.bufs,
}, },
}) })
''; '';
}; };
rootOpts = {
inherit (autocmds) autoGroups autoCmd;
inherit (mappings) keymaps;
inherit (options) opts;
};
} }

View file

@ -0,0 +1,33 @@
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore.lua#L40-L61
{ icons, ... }:
{
diagnostics = {
underline = true;
update_in_insert = true;
severity_sort = true;
virtual_text = true;
float = {
focused = false;
style = "minimal";
border = "rounded";
source = "always";
header = "";
prefix = "";
};
signs = {
text = {
# vim.diagnostic.severity.ERROR
"1" = icons.DiagnosticError;
# vim.diagnostic.severity.WARN
"2" = icons.DiagnosticWarn;
# vim.diagnostic.severity.INFO
"3" = icons.DiagnosticInfo;
# vim.diagnostic.severity.HINT
"4" = icons.DiagnosticHint;
};
};
};
}

View file

@ -0,0 +1,25 @@
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore.lua#L32-L39
{
features = {
# Enable autopairs at start
autopairs = true;
# Enable completion at start
cmp = true;
# Enable diagnostics by default
diagnostics_mode = 3;
# Highlight URLs by default
highlighturl = true;
# Disable notifications
notifications = true;
# Set global limits for large files
large_buf = {
lines = 10000;
size = 1024 * 500;
};
};
}

View file

@ -0,0 +1,565 @@
let
forceWrite = {
action = "<cmd>silent! update! | redraw<cr>";
options.desc = "Force write";
};
in
{
keymaps = [
# Standard operations
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_mappings.lua#L27-L44
{
key = "j";
mode = [ "n" "x" ];
action = "v:count == 0 ? 'gj' : 'j'";
options = {
desc = "Move cursor down";
expr = true;
silent = true;
};
}
{
key = "k";
mode = [ "n" "x" ];
action = "v:count == 0 ? 'gk' : 'k'";
options = {
desc = "Move cursor up";
expr = true;
silent = true;
};
}
{
key = "<leader>w";
action = "<cmd>w<cr>";
options.desc = "Save";
}
{
key = "<leader>q";
action = "<cmd>confirm q<cr>";
options.desc = "Quit window";
}
{
key = "<leader>Q";
action = "<cmd>confirm qall<cr>";
options.desc = "Exit neovim";
}
{
key = "<leader>n";
action = "<cmd>enew<cr>";
options.desc = "New file";
}
{
inherit (forceWrite) action options;
key = "<c-s>";
}
{
inherit (forceWrite) options;
key = "<c-s>";
mode = [ "i" "x" ];
action = "<esc>" + forceWrite.action;
}
{
key = "<c-q>";
action = "<cmd>q!<cr>";
options.desc = "Force quit";
}
{
key = "|";
action = "<cmd>vsplit<cr>";
options.desc = "Vertical split";
}
{
key = "\\\\";
action = "<cmd>split<cr>";
options.desc = "Horizontal split";
}
{
key = "gx";
action.__raw = "require('astrocore').system_open";
options.desc = "Open the file under cursor with system app";
}
# Manage buffers
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_mappings.lua#L56-L89
{
key = "<leader>c";
options.desc = "Close buffer";
action.__raw = ''
function()
require("astrocore.buffer").close()
end
'';
}
{
key = "<leader>C";
options.desc = "Force close buffer";
action.__raw = ''
function()
require("astrocore.buffer").close(0, true)
end
'';
}
{
key = "]b";
options.desc = "Next buffer in tabline";
action.__raw = ''
function()
require("astrocore.buffer").nav(vim.v.count1)
end
'';
}
{
key = "[b";
options.desc = "Previous buffer in tabline";
action.__raw = ''
function()
require("astrocore.buffer").nav(-vim.v.count1)
end
'';
}
{
key = ">b";
options.desc = "Move buffer tab right";
action.__raw = ''
function()
require("astrocore.buffer").move(vim.v.count1)
end
'';
}
{
key = "<b";
options.desc = "Move buffer tab left";
action.__raw = ''
function()
require("astrocore.buffer").move(-vim.v.count1)
end
'';
}
{
key = "<leader>bc";
options.desc = "Close all buffers except current";
action.__raw = ''
function()
require("astrocore.buffer").close_all(true)
end
'';
}
{
key = "<leader>bC";
options.desc = "Close all buffers";
action.__raw = ''
function()
require("astrocore.buffer").close_all()
end
'';
}
{
key = "<leader>bl";
options.desc = "Close all buffers to the left";
action.__raw = ''
function()
require("astrocore.buffer").close_left()
end
'';
}
{
key = "<leader>bp";
options.desc = "Previous buffer";
action.__raw = ''
function()
require("astrocore.buffer").prev()
end
'';
}
{
key = "<leader>br";
options.desc = "Close all buffers to the right";
action.__raw = ''
function()
require("astrocore.buffer").close_right()
end
'';
}
{
key = "<Leader>bse";
options.desc = "By extension";
action.__raw = ''
function()
require("astrocore.buffer").sort "extension"
end
'';
}
{
key = "<Leader>bsr";
options.desc = "By relative path";
action.__raw = ''
function()
require("astrocore.buffer").sort "unique_path"
end
'';
}
{
key = "<Leader>bsp";
options.desc = "By full path";
action.__raw = ''
function()
require("astrocore.buffer").sort "full_path"
end
'';
}
{
key = "<Leader>bsi";
options.desc = "By buffer number";
action.__raw = ''
function()
require("astrocore.buffer").sort "bufnr"
end
'';
}
{
key = "<Leader>bsm";
options.desc = "By modification";
action.__raw = ''
function()
require("astrocore.buffer").sort "modified"
end
'';
}
# Diagnostics
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_mappings.lua#L92-L100
{
key = "<Leader>ld";
options.desc = "Hover diagnostics";
action.__raw = ''
function()
vim.diagnostic.open_float()
end
'';
}
{
key = "[d";
options.desc = "Previous diagnostic";
action.__raw = ''
function()
vim.diagnostic.goto_prev()
end
'';
}
{
key = "]d";
options.desc = "Next diagnostic";
action.__raw = ''
function()
vim.diagnostic.goto_next()
end
'';
}
{
key = "gl";
options.desc = "Hover diagnostics";
action.__raw = ''
function()
vim.diagnostic.open_float()
end
'';
}
# Navigate tabs
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_mappings.lua#L103-L104
{
key = "]t";
options.desc = "Next tab";
action.__raw = ''
function()
vim.cmd.tabnext()
end
'';
}
{
key = "[t";
options.desc = "Previous tab";
action.__raw = ''
function()
vim.cmd.tabprevious()
end
'';
}
# Split navigation
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_mappings.lua#L107-L114
{
key = "<C-H>";
action = "<C-w>h";
options.desc = "Move to left split";
}
{
key = "<C-J>";
action = "<C-w>j";
options.desc = "Move to below split";
}
{
key = "<C-K>";
action = "<C-w>k";
options.desc = "Move to above split";
}
{
key = "<C-L>";
action = "<C-w>l";
options.desc = "Move to right split";
}
{
key = "<C-Up>";
action = "<Cmd>resize -2<CR>";
options.desc = "Resize split up";
}
{
key = "<C-Down>";
action = "<Cmd>resize +2<CR>";
options.desc = "Resize split down";
}
{
key = "<C-Left>";
action = "<Cmd>vertical resize -2<CR>";
options.desc = "Resize split left";
}
{
key = "<C-Right>";
action = "<Cmd>vertical resize +2<CR>";
options.desc = "Resize split right";
}
# Stay in indent mode
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_mappings.lua#L117-L118
{
key = "<S-Tab>";
mode = [ "v" ];
action = "<gv";
options.desc = "Unindent line";
}
{
key = "<Tab>";
mode = [ "v" ];
action = ">gv";
options.desc = "Indent line";
}
# Improved terminal navigation
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_mappings.lua#L121-L124
{
key = "<C-H>";
mode = [ "t" ];
action = "<Cmd>wincmd h<CR>";
options.desc = "Terminal left window navigation";
}
{
key = "<C-J>";
mode = [ "t" ];
action = "<Cmd>wincmd j<CR>";
options.desc = "Terminal down window navigation";
}
{
key = "<C-K>";
mode = [ "t" ];
action = "<Cmd>wincmd k<CR>";
options.desc = "Terminal up window navigation";
}
{
key = "<C-L>";
mode = [ "t" ];
action = "<Cmd>wincmd l<CR>";
options.desc = "Terminal right window navigation";
}
# UI/UX toggles
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_mappings.lua#L128-L145
{
key = "<Leader>uA";
options.desc = "Toggle rooter autochdir";
action.__raw = ''
function()
require("astrocore.toggles").autochdir()
end
'';
}
{
key = "<Leader>ub";
options.desc = "Toggle background";
action.__raw = ''
function()
require("astrocore.toggles").background()
end
'';
}
{
key = "<Leader>ud";
options.desc = "Toggle diagnostics";
action.__raw = ''
function()
require("astrocore.toggles").diagnostics()
end
'';
}
{
key = "<Leader>ug";
options.desc = "Toggle signcolumn";
action.__raw = ''
function()
require("astrocore.toggles").signcolumn()
end
'';
}
{
key = "<Leader>u>";
options.desc = "Toggle foldcolumn";
action.__raw = ''
function()
require("astrocore.toggles").foldcolumn()
end
'';
}
{
key = "<Leader>ui";
options.desc = "Change indent setting";
action.__raw = ''
function()
require("astrocore.toggles").indent()
end
'';
}
{
key = "<Leader>ul";
options.desc = "Toggle statusline";
action.__raw = ''
function()
require("astrocore.toggles").statusline()
end
'';
}
{
key = "<Leader>un";
options.desc = "Change line numbering";
action.__raw = ''
function()
require("astrocore.toggles").number()
end
'';
}
{
key = "<Leader>uN";
options.desc = "Toggle Notifications";
action.__raw = ''
function()
require("astrocore.toggles").notifications()
end
'';
}
{
key = "<Leader>up";
options.desc = "Toggle paste mode";
action.__raw = ''
function()
require("astrocore.toggles").paste()
end
'';
}
{
key = "<Leader>us";
options.desc = "Toggle spellcheck";
action.__raw = ''
function()
require("astrocore.toggles").spell()
end
'';
}
{
key = "<Leader>uS";
options.desc = "Toggle conceal";
action.__raw = ''
function()
require("astrocore.toggles").conceal()
end
'';
}
{
key = "<Leader>ut";
options.desc = "Toggle tabline";
action.__raw = ''
function()
require("astrocore.toggles").tabline()
end
'';
}
{
key = "<Leader>uu";
options.desc = "Toggle URL highlight";
action.__raw = ''
function()
require("astrocore.toggles").url_match()
end
'';
}
{
key = "<Leader>uw";
options.desc = "Toggle wrap";
action.__raw = ''
function()
require("astrocore.toggles").wrap()
end
'';
}
{
key = "<Leader>uy";
options.desc = "Toggle syntax highlight";
action.__raw = ''
function()
require("astrocore.toggles").buffer_syntax()
end
'';
}
];
mapSectionsLua = ''
'';
}

View file

@ -0,0 +1,159 @@
{ lib, ... }:
{
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_options.lua#L49-L53
astrocore = {
g.markdown_recommended_style = 0;
t.bufs.__raw = ''
(function()
if not vim.t.bufs then vim.t.bufs = vim.api.nvim_list_bufs() end
return vim.t.bufs
end)()
'';
};
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_options.lua#L6-L47
opts = {
# Don't stop backspace at insert
backspace = lib.mkDefault {
__raw = ''
vim.list_extend(vim.opt.backspace:get(), { "nostop" })
'';
};
# Wrap indent to match line start
breakindent = lib.mkDefault true;
# Connection to the system clipboard
clipboard = lib.mkDefault "unnamedplus";
# Hide command line unless needed
cmdheight = lib.mkDefault 0;
# Options for insert mode completion
completeopt = lib.mkDefault [ "menu" "menuone" "noselect" ];
# Raise a dialog asking if you wish to save the current file(s)
confirm = lib.mkDefault true;
# Copy the previous indentation on autoindenting
copyindent = lib.mkDefault true;
# Highlight the text line of the cursor
cursorline = lib.mkDefault true;
# Enable linematch diff algorithm
diffopt = lib.mkDefault {
__raw = ''
vim.list_extend(vim.opt.diffopt:get(), { "algorithm:histogram", "linematch:60" })
'';
};
# Enable the use of space in tab
expandtab = lib.mkDefault true;
# Disable `~` on nonexistent lines
fillchars = lib.mkDefault { eob = " "; };
# Show foldcolumn
foldcolumn = lib.mkDefault "1";
# Enable fold for nvim-ufo
foldenable = lib.mkDefault true;
# Set high foldlevel for nvim-ufo
foldlevel = lib.mkDefault 99;
# Start with all code unfolded
foldlevelstart = lib.mkDefault 99;
# Case insensitive searching
ignorecase = lib.mkDefault true;
# Infer cases in keyword completion
infercase = lib.mkDefault true;
# Global statusline
laststatus = lib.mkDefault 3;
# Wrap lines at 'breakat'
linebreak = lib.mkDefault true;
# Enable mouse support
mouse = lib.mkDefault "a";
# Show numberline
number = lib.mkDefault true;
# Preserve indent structure as much as possible
preserveindent = lib.mkDefault true;
# Height of the pop up menu
pumheight = lib.mkDefault 10;
# Show relative numberline
relativenumber = lib.mkDefault true;
# Number of space inserted for indentation; when zero the 'tabstop' value will be used
shiftwidth = lib.mkDefault 0;
# Disable search count wrap and startup messages
shortmess = lib.mkDefault {
__raw = ''
vim.tbl_deep_extend("force", vim.opt.shortmess:get(), { s = true, I = true })
'';
};
# Disable showing modes in command line
showmode = lib.mkDefault false;
# Always display tabline
showtabline = lib.mkDefault 2;
# Always show the sign column
signcolumn = lib.mkDefault "yes";
# Case sensitive searching
smartcase = lib.mkDefault true;
# Splitting a new window below the current one
splitbelow = lib.mkDefault true;
# Splitting a new window at the right of the current one
splitright = lib.mkDefault true;
# Number of space in a tab
tabstop = lib.mkDefault 2;
# Enable 24-bit RGB color in the TUI
termguicolors = lib.mkDefault true;
# Shorten key timeout length a little bit for which-key
timeoutlen = lib.mkDefault 500;
# Set terminal title to the filename and path
title = lib.mkDefault true;
# Enable persistent undo
undofile = lib.mkDefault true;
# Length of time to wait before triggering the plugin
updatetime = lib.mkDefault 300;
viewoptions = lib.mkDefault {
__raw = ''
vim.tbl_filter(function(val) return val ~= "curdir" end, vim.opt.viewoptions:get())
'';
};
# Allow going past end of line in visual block mode
virtualedit = lib.mkDefault "block";
# Disable wrapping of lines longer than the width of window
wrap = lib.mkDefault false;
# Disable making a backup before overwriting a file
writebackup = lib.mkDefault false;
};
}

View file

@ -0,0 +1,30 @@
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore.lua#L62-L72
{
rooter = {
enabled = true;
autochdir = false;
notify = false;
scope = "global";
detector = [
"lsp"
[
".git"
"_darcs"
".hg"
".bzr"
".svn"
]
[
"lua"
"MakeFile"
"package.json"
]
];
ignore = {
dirs = {};
servers = {};
};
};
}

View file

@ -0,0 +1,15 @@
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore.lua#L73-L80
{
sessions = {
autosave = {
cwd = true;
last = true;
};
ignore = {
buftypes = {};
dirs = {};
filetypes = [ "gitcommit" "gitrebase" ];
};
};
}