-- AstroCore provides a central place to modify mappings, vim options, autocommands, and more! -- Configuration documentation can be found with `:h astrocore` -- NOTE: We highly recommend setting up the Lua Language Server (`:LspInstall lua_ls`) -- as this provides autocomplete and documentation while editing local utils = require "utils" local astro_utils = require "astrocore" ---@type LazySpec return { "AstroNvim/astrocore", ---@type AstroCoreOpts opts = { sessions = { autosave = { last = true, cwd = true, }, ignore = { dirs = { "wiki" }, }, }, -- Configure core features of AstroNvim features = { large_buf = { size = 1024 * 500, lines = 10000 }, -- set global limits for large files for disabling features like treesitter autopairs = true, -- enable autopairs at start cmp = true, -- enable completion at start diagnostics_mode = 3, -- diagnostic mode on start (0 = off, 1 = no signs/virtual text, 2 = no virtual text, 3 = on) highlighturl = true, -- highlight URLs at start notifications = true, -- enable notifications at start }, -- Diagnostics configuration (for vim.diagnostics.config({...})) when diagnostics are on diagnostics = { virtual_text = true, underline = true, }, -- vim options can be configured here options = { opt = { -- vim.opt. relativenumber = true, -- sets vim.opt.relativenumber number = true, -- sets vim.opt.number spell = false, -- sets vim.opt.spell signcolumn = "auto", -- sets vim.opt.signcolumn to auto wrap = false, -- sets vim.opt.wrap expandtab = false, tabstop = 8, shiftwidth = 8, showtabline = 8, vim.opt.rtp:append("/usr/share/vim/vimfiles"), vim.opt.cinoptions:append("(0"); }, g = { -- vim.g. -- configure global vim variables (vim.g) -- NOTE: `mapleader` and `maplocalleader` must be set in the AstroNvim opts or before `lazy.setup` -- This can be found in the `lua/lazy_setup.lua` file mapleader = " ", -- sets vim.g.mapleader autoformat_enabled = false, -- enable or disable auto formatting at start (lsp.formatting.format_on_save must be enabled) cmp_enabled = true, -- enable completion at start autopairs_enabled = true, -- enable autopairs at start diagnostics_mode = 3, -- set the visibility of diagnostics in the UI (0=off, 1=only show in status line, 2=virtual text off, 3=all on) icons_enabled = true, -- disable icons in the UI (disable if no nerd font is available, requires :PackerSync after changing) ui_notifications_enabled = true, -- disable notifications when toggling UI elements c_syntax_for_h = 1, wiki_root = '~/Documentos/Wiki', wiki_journal = { name = "journal", frequency = "daily", date_format = { daily = "%Y/%m/%d", }, }, wiki_viewer = { png = "feh", jpg = "feh", jpeg = "feh", }, infoprg = '/usr/bin/info' }, }, -- Mappings can be configured through AstroCore as well. -- NOTE: keycodes follow the casing in the vimdocs. For example, `` must be capitalized mappings = { -- first key is the mode n = { -- second key is the lefthand side of the map -- navigate buffer tabs with `H` and `L` L = { function() require("astrocore.buffer").nav(vim.v.count1) end, desc = "Next buffer" }, H = { function() require("astrocore.buffer").nav(-vim.v.count1) end, desc = "Previous buffer" }, -- mappings seen under group name "Buffer" ["bD"] = { function() require("astroui.status.heirline").buffer_picker( function(bufnr) require("astrocore.buffer").close(bufnr) end ) end, desc = "Pick to close", }, -- tables with just a `desc` key will be registered with which-key if it's installed -- this is useful for naming menus ["b"] = { desc = "Buffers" }, -- quick save -- disable default bindings [""] = false, [""] = false, [""] = false, [""] = false, [""] = false, [""] = false, [""] = false, [""] = false, [""] = false, [""] = false, [""] = false, -- Competitest [""] = { "CompetiTest receive problem", desc = "Open problem" }, [""] = { "CompetiTest run", desc = "Run problem" }, ["q:"] = ":", -- second key is the lefthand side of the map -- mappings seen under group name "Buffer" ["bn"] = { "tabnew", desc = "New tab" }, ["bD"] = { function() require("astroui.status").heirline.buffer_picker(function(bufnr) require("astrocore.buffer").close(bufnr) end) end, desc = "Pick to close", }, ["bb"] = { "tabnew", desc = "New tab" }, ["bc"] = { "BufferLinePickClose", desc = "Pick to close" }, ["bj"] = { "BufferLinePick", desc = "Pick to jump" }, ["bt"] = { "BufferLineSortByTabs", desc = "Sort by tabs" }, ["lp"] = { "ClangdToggleInlayHints", desc = "Toggle inlay hints" }, ["lH"] = { "ClangdSwitchSourceHeader", desc = "Switch between source and header" }, ["L"] = { function() require("astrocore.buffer").nav(vim.v.count > 0 and vim.v.count or 1) end, desc = "Next buffer" }, ["H"] = { function() require("astrocore.buffer").nav(-(vim.v.count > 0 and vim.v.count or 1)) end, desc = "Previous buffer", }, [""] = { function() vim.lsp.buf.rename() end, desc = "Rename current symbol" }, [""] = {"2TermExec cmd=\"%:p:r\"", desc = "Execute file"}, ["et"] = {"term %:p:r"}, [""] = {"ToggleTerm", desc = "Toggle terminal"}, [""] = { "Neotree toggle", desc = "Toggle Explorer" }, -- tables with the `name` key will be registered with which-key if it's installed -- this is useful for naming menus ["b"] = { desc = "Buffers" }, -- quick save -- [""] = { ":w!", desc = "Save File" }, -- change description but the same command n = { utils.better_search "n", desc = "Next search" }, N = { utils.better_search "N", desc = "Previous search" }, [""] = { function() require("smart-splits").resize_up(2) end, desc = "Resize split up" }, [""] = { function() require("smart-splits").resize_down(2) end, desc = "Resize split down" }, [""] = { function() require("smart-splits").resize_left(2) end, desc = "Resize split left" }, [""] = { function() require("smart-splits").resize_right(2) end, desc = "Resize split right" }, [""] = { function() if #vim.t.bufs > 1 then require("telescope.builtin").buffers { sort_mru = true, ignore_current_buffer = true } else astro_utils.notify "No other buffers open" end end, desc = "Switch Buffers", }, ["N"] = { "tabnew", desc = "New Tab" }, [""] = { '/<++>"_c4l', desc = "Next Template" }, ["."] = { "cd %:p:h", desc = "Set CWD" }, -- neogen ["a"] = { desc = "󰏫 Annotate" }, ["a"] = { function() require("neogen").generate() end, desc = "Current" }, ["ac"] = { function() require("neogen").generate { type = "class" } end, desc = "Class" }, ["af"] = { function() require("neogen").generate { type = "func" } end, desc = "Function" }, ["at"] = { function() require("neogen").generate { type = "type" } end, desc = "Type" }, ["aF"] = { function() require("neogen").generate { type = "file" } end, desc = "File" }, -- telescope plugin mappings ["fx"] = { function() require("telescope").extensions.live_grep_args.live_grep_args() end, desc = "Find words (args)", }, ["fB"] = { "Telescope bibtex", desc = "Find BibTeX" }, ["fe"] = { "Telescope file_browser", desc = "File explorer" }, ["fp"] = { function() require("telescope").extensions.projects.projects {} end, desc = "Find projects" }, ["fT"] = { "TodoTelescope", desc = "Find TODOs" }, -- compiler ["m"] = { desc = "󱁤 Compiler" }, ["mk"] = { function() vim.cmd "silent! write" local filename = vim.fn.expand "%:t" utils.async_run({ "compiler", vim.fn.expand "%:p" }, function() astro_utils.notify("Compiled " .. filename) end) end, desc = "Compile", }, ["ma"] = { function() vim.notify "Autocompile Started" utils.async_run({ "autocomp", vim.fn.expand "%:p" }, function() astro_utils.notify "Autocompile stopped" end) end, desc = "Auto Compile", }, ["mv"] = { function() vim.fn.jobstart { "opout", vim.fn.expand "%:p" } end, desc = "View Output", }, ["mb"] = { function() local filename = vim.fn.expand "%:t" utils.async_run({ "pandoc", vim.fn.expand "%", "--pdf-engine=xelatex", "--variable", "urlcolor=blue", "-t", "beamer", "-o", vim.fn.expand "%:r" .. ".pdf", }, function() astro_utils.notify("Compiled " .. filename) end) end, desc = "Compile Beamer", }, ["mp"] = { function() local pdf_path = vim.fn.expand "%:r" .. ".pdf" if vim.fn.filereadable(pdf_path) == 1 then vim.fn.jobstart { "pdfpc", pdf_path } end end, desc = "Present Output", }, ["ml"] = { function() utils.toggle_qf() end, desc = "Logs" }, ["mt"] = { "TexlabBuild", desc = "LaTeX" }, ["mf"] = { "TexlabForward", desc = "Forward Search" }, ["r"] = { desc = " REPL" }, ["rr"] = { "Send", desc = "Send to REPL" }, ["rl"] = { "SendLine", desc = "Send line to REPL" }, ["r"] = { "SendHere", desc = "Set REPL" }, ["z"] = { "ZenMode", desc = "Zen Mode" }, ["s"] = { desc = "󰛔 Search/Replace" }, ["ss"] = { function() require("spectre").toggle() end, desc = "Toggle Spectre" }, ["sf"] = { function() require("spectre").open_file_search() end, desc = "Spectre (current file)" }, ["sw"] = { function() require("spectre").open_visual { select_word = true } end, desc = "Spectre (current word)", }, ["x"] = { desc = "󰒡 Trouble" }, ["xx"] = { "TroubleToggle document_diagnostics", desc = "Document Diagnostics (Trouble)" }, ["xX"] = { "TroubleToggle workspace_diagnostics", desc = "Workspace Diagnostics (Trouble)" }, ["xl"] = { "TroubleToggle loclist", desc = "Location List (Trouble)" }, ["xq"] = { "TroubleToggle quickfix", desc = "Quickfix List (Trouble)" }, ["xT"] = { "TodoTrouble", desc = "TODOs (Trouble)" }, -- Wiki mappings ["w"] = { desc = "󰖬 Wiki" }, ["wn"] = { "(wiki-open)", desc = "Open/create wiki page" }, ["ww"] = { "(wiki-index)", desc = "Open wiki index" }, ["wx"] = { "(wiki-reload)", desc = "Reload wiki" }, ["wp"] = { "(wiki-pages)", desc = "Open wiki page" }, ["wt"] = { "(wiki-tags)", desc = "Open wiki from tags" }, ["wd"] = { "(wiki-page-delete)", desc = "Delete wiki page" }, ["wf"] = { "(wiki-link-transform)", desc = "Transform link" }, ["wr"] = { "(wiki-page-rename)", desc = "Rename wiki page" }, ["wT"] = { "(wiki-toc-generate-local)", desc = "Create local table" }, ["wg"] = { desc = "Graphs" }, ["wgb"] = { "(wiki-graph-find-backlinks)", desc = "Find backlinks" }, ["wbC"] = { "(wiki-graph-check-links-g)", desc = "Check wiki for broken links" }, ["wbc"] = { "(wiki-graph-check-links)", desc = "Check page for broken links" }, ["wbi"] = { "(wiki-graph-in)", desc = "Show link graph in to page" }, ["wbo"] = { "(wiki-graph-out)", desc = "Show link graph out of page" }, ["wbO"] = { "(wiki-graph-check-orphans)", desc = "Check wiki for orphan pages" }, ["wbr"] = { "(wiki-graph-related)", desc = "Open page link relations" }, ["wl"] = { desc = "Links" }, ["wlh"] = { "(wiki-link-extract-header)", desc = "Set link titles from first header" }, ["wli"] = { "(wiki-link-incoming-toggle)", desc = "Toggle incoming links" }, ["wlI"] = { "(wiki-link-incoming-hover)", desc = "Show incoming links" }, ["wll"] = { "(wiki-link-show)", desc = "Show link info" }, ["ws"] = { desc = "Tags" }, ["wsl"] = { "(wiki-tag-list)", desc = "List all tags" }, ["wsn"] = { "(wiki-tag-rename)", desc = "Rename tag" }, ["wsr"] = { "(wiki-tag-reload)", desc = "Reload tags" }, ["wss"] = { "(wiki-tag-search)", desc = "List pages with tag" }, ["w"] = { desc = "Journal" }, -- ["ww"] = { "(wiki-journal)Go!!date +\\%RI# o", desc = "Open wiki journal" }, ["ww"] = { "TermExec cmd='fish -c journal;exit'", desc = "Open journal" }, [""] = { ":w!", desc = "Save File" }, -- change description but the same command [""] = { function() require("luasnip").jump(1) end, desc = "Jump to next snippet" }, }, v = { ["s"] = { function() require("spectre").open_visual() end, desc = "Spectre" }, }, t = { -- setting a mapping to false will disable it -- [""] = false, }, x = { -- better increment/decrement ["+"] = { "g", desc = "Increment number" }, ["-"] = { "g", desc = "Descrement number" }, -- Easy-Align ga = { "(EasyAlign)", desc = "Easy Align" }, }, o = { -- line text-objects ["il"] = { ":normal vil", desc = "Inside line text object" }, ["al"] = { ":normal val", desc = "Around line text object" }, }, }, }, }