My neovim config

This commit is contained in:
2024-09-17 15:02:57 -03:00
commit 5e25828335
37 changed files with 1712 additions and 0 deletions

308
lua/plugins/astrocore.lua Normal file
View File

@@ -0,0 +1,308 @@
-- 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.<key>
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.<key>
-- 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, `<Leader>` 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"
["<Leader>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
["<Leader>b"] = { desc = "Buffers" },
-- quick save
-- disable default bindings
["<C-Down>"] = false,
["<C-Left>"] = false,
["<C-Right>"] = false,
["<C-Up>"] = false,
["<C-h>"] = false,
["<C-j>"] = false,
["<C-k>"] = false,
["<C-l>"] = false,
["<C-q>"] = false,
["<C-s>"] = false,
["<C-r>"] = false,
-- Competitest
["<C-o>"] = { "<cmd>CompetiTest receive problem<cr>", desc = "Open problem" },
["<C-r>"] = { "<cmd>CompetiTest run<cr>", desc = "Run problem" },
["q:"] = ":",
-- second key is the lefthand side of the map
-- mappings seen under group name "Buffer"
["<Leader>bn"] = { "<cmd>tabnew<cr>", desc = "New tab" },
["<Leader>bD"] = {
function()
require("astroui.status").heirline.buffer_picker(function(bufnr) require("astrocore.buffer").close(bufnr) end)
end,
desc = "Pick to close",
},
["<Leader>bb"] = { "<cmd>tabnew<cr>", desc = "New tab" },
["<Leader>bc"] = { "<cmd>BufferLinePickClose<cr>", desc = "Pick to close" },
["<Leader>bj"] = { "<cmd>BufferLinePick<cr>", desc = "Pick to jump" },
["<Leader>bt"] = { "<cmd>BufferLineSortByTabs<cr>", desc = "Sort by tabs" },
["<Leader>lp"] = { "<cmd>ClangdToggleInlayHints<cr>", desc = "Toggle inlay hints" },
["<Leader>lH"] = { "<cmd>ClangdSwitchSourceHeader<cr>", 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",
},
["<F2>"] = { function() vim.lsp.buf.rename() end, desc = "Rename current symbol" },
["<F8>"] = {"<cmd>2TermExec cmd=\"%:p:r\"<cr>", desc = "Execute file"},
["et"] = {"<cmd>term %:p:r<cr>"},
["<C-'>"] = {"<cmd>ToggleTerm<cr>", desc = "Toggle terminal"},
["<C-n>"] = { "<cmd>Neotree toggle<cr>", desc = "Toggle Explorer" },
-- tables with the `name` key will be registered with which-key if it's installed
-- this is useful for naming menus
["<Leader>b"] = { desc = "Buffers" },
-- quick save
-- ["<C-s>"] = { ":w!<cr>", 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" },
["<Up>"] = { function() require("smart-splits").resize_up(2) end, desc = "Resize split up" },
["<Down>"] = { function() require("smart-splits").resize_down(2) end, desc = "Resize split down" },
["<Left>"] = { function() require("smart-splits").resize_left(2) end, desc = "Resize split left" },
["<Right>"] = { function() require("smart-splits").resize_right(2) end, desc = "Resize split right" },
["<Tab>"] = {
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",
},
["<Leader>N"] = { "<cmd>tabnew<cr>", desc = "New Tab" },
["<Leader><cr>"] = { '<esc>/<++><cr>"_c4l', desc = "Next Template" },
["<Leader>."] = { "<cmd>cd %:p:h<cr>", desc = "Set CWD" },
-- neogen
["<Leader>a"] = { desc = "󰏫 Annotate" },
["<Leader>a<cr>"] = { function() require("neogen").generate() end, desc = "Current" },
["<Leader>ac"] = { function() require("neogen").generate { type = "class" } end, desc = "Class" },
["<Leader>af"] = { function() require("neogen").generate { type = "func" } end, desc = "Function" },
["<Leader>at"] = { function() require("neogen").generate { type = "type" } end, desc = "Type" },
["<Leader>aF"] = { function() require("neogen").generate { type = "file" } end, desc = "File" },
-- telescope plugin mappings
["<Leader>fx"] = {
function() require("telescope").extensions.live_grep_args.live_grep_args() end,
desc = "Find words (args)",
},
["<Leader>fB"] = { "<cmd>Telescope bibtex<cr>", desc = "Find BibTeX" },
["<Leader>fe"] = { "<cmd>Telescope file_browser<cr>", desc = "File explorer" },
["<Leader>fp"] = { function() require("telescope").extensions.projects.projects {} end, desc = "Find projects" },
["<Leader>fT"] = { "<cmd>TodoTelescope<cr>", desc = "Find TODOs" },
-- compiler
["<Leader>m"] = { desc = "󱁤 Compiler" },
["<Leader>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",
},
["<Leader>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",
},
["<Leader>mv"] = {
function() vim.fn.jobstart { "opout", vim.fn.expand "%:p" } end,
desc = "View Output",
},
["<Leader>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",
},
["<Leader>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",
},
["<Leader>ml"] = { function() utils.toggle_qf() end, desc = "Logs" },
["<Leader>mt"] = { "<cmd>TexlabBuild<cr>", desc = "LaTeX" },
["<Leader>mf"] = { "<cmd>TexlabForward<cr>", desc = "Forward Search" },
["<Leader>r"] = { desc = " REPL" },
["<Leader>rr"] = { "<Plug>Send", desc = "Send to REPL" },
["<Leader>rl"] = { "<Plug>SendLine", desc = "Send line to REPL" },
["<Leader>r<cr>"] = { "<cmd>SendHere<cr>", desc = "Set REPL" },
["<Leader>z"] = { "<cmd>ZenMode<cr>", desc = "Zen Mode" },
["<Leader>s"] = { desc = "󰛔 Search/Replace" },
["<Leader>ss"] = { function() require("spectre").toggle() end, desc = "Toggle Spectre" },
["<Leader>sf"] = { function() require("spectre").open_file_search() end, desc = "Spectre (current file)" },
["<Leader>sw"] = {
function() require("spectre").open_visual { select_word = true } end,
desc = "Spectre (current word)",
},
["<Leader>x"] = { desc = "󰒡 Trouble" },
["<Leader>xx"] = { "<cmd>TroubleToggle document_diagnostics<cr>", desc = "Document Diagnostics (Trouble)" },
["<Leader>xX"] = { "<cmd>TroubleToggle workspace_diagnostics<cr>", desc = "Workspace Diagnostics (Trouble)" },
["<Leader>xl"] = { "<cmd>TroubleToggle loclist<cr>", desc = "Location List (Trouble)" },
["<Leader>xq"] = { "<cmd>TroubleToggle quickfix<cr>", desc = "Quickfix List (Trouble)" },
["<Leader>xT"] = { "<cmd>TodoTrouble<cr>", desc = "TODOs (Trouble)" },
-- Wiki mappings
["<Leader>w"] = { desc = "󰖬 Wiki" },
["<Leader>wn"] = { "<Plug>(wiki-open)", desc = "Open/create wiki page" },
["<Leader>ww"] = { "<Plug>(wiki-index)", desc = "Open wiki index" },
["<Leader>wx"] = { "<Plug>(wiki-reload)", desc = "Reload wiki" },
["<Leader>wp"] = { "<Plug>(wiki-pages)", desc = "Open wiki page" },
["<Leader>wt"] = { "<Plug>(wiki-tags)", desc = "Open wiki from tags" },
["<Leader>wd"] = { "<Plug>(wiki-page-delete)", desc = "Delete wiki page" },
["<Leader>wf"] = { "<Plug>(wiki-link-transform)", desc = "Transform link" },
["<Leader>wr"] = { "<Plug>(wiki-page-rename)", desc = "Rename wiki page" },
["<Leader>wT"] = { "<Plug>(wiki-toc-generate-local)", desc = "Create local table" },
["<Leader>wg"] = { desc = "Graphs" },
["<Leader>wgb"] = { "<Plug>(wiki-graph-find-backlinks)", desc = "Find backlinks" },
["<Leader>wbC"] = { "<Plug>(wiki-graph-check-links-g)", desc = "Check wiki for broken links" },
["<Leader>wbc"] = { "<Plug>(wiki-graph-check-links)", desc = "Check page for broken links" },
["<Leader>wbi"] = { "<Plug>(wiki-graph-in)", desc = "Show link graph in to page" },
["<Leader>wbo"] = { "<Plug>(wiki-graph-out)", desc = "Show link graph out of page" },
["<Leader>wbO"] = { "<Plug>(wiki-graph-check-orphans)", desc = "Check wiki for orphan pages" },
["<Leader>wbr"] = { "<Plug>(wiki-graph-related)", desc = "Open page link relations" },
["<Leader>wl"] = { desc = "Links" },
["<Leader>wlh"] = { "<Plug>(wiki-link-extract-header)", desc = "Set link titles from first header" },
["<Leader>wli"] = { "<Plug>(wiki-link-incoming-toggle)", desc = "Toggle incoming links" },
["<Leader>wlI"] = { "<Plug>(wiki-link-incoming-hover)", desc = "Show incoming links" },
["<Leader>wll"] = { "<Plug>(wiki-link-show)", desc = "Show link info" },
["<Leader>ws"] = { desc = "Tags" },
["<Leader>wsl"] = { "<Plug>(wiki-tag-list)", desc = "List all tags" },
["<Leader>wsn"] = { "<Plug>(wiki-tag-rename)", desc = "Rename tag" },
["<Leader>wsr"] = { "<Plug>(wiki-tag-reload)", desc = "Reload tags" },
["<Leader>wss"] = { "<Plug>(wiki-tag-search)", desc = "List pages with tag" },
["<Leader>w<space>"] = { desc = "Journal" },
-- ["<Leader>w<space>w"] = { "<Plug>(wiki-journal)Go<enter><esc>!!date +\\%R<cr>I# <C-o>o<enter>", desc = "Open wiki journal" },
["<Leader>w<space>w"] = { "<cmd>TermExec cmd='fish -c journal;exit'<cr>", desc = "Open journal" },
["<C-s>"] = { ":w!<cr>", desc = "Save File" }, -- change description but the same command
["<C-l>"] = { function() require("luasnip").jump(1) end, desc = "Jump to next snippet" },
},
v = {
["<Leader>s"] = { function() require("spectre").open_visual() end, desc = "Spectre" },
},
t = {
-- setting a mapping to false will disable it
-- ["<esc>"] = false,
},
x = {
-- better increment/decrement
["+"] = { "g<C-a>", desc = "Increment number" },
["-"] = { "g<C-x>", desc = "Descrement number" },
-- Easy-Align
ga = { "<Plug>(EasyAlign)", desc = "Easy Align" },
},
o = {
-- line text-objects
["il"] = { ":normal vil<cr>", desc = "Inside line text object" },
["al"] = { ":normal val<cr>", desc = "Around line text object" },
},
},
},
}

124
lua/plugins/astrolsp.lua Normal file
View File

@@ -0,0 +1,124 @@
-- AstroLSP allows you to customize the features in AstroNvim's LSP configuration engine
-- Configuration documentation can be found with `:h astrolsp`
-- NOTE: We highly recommend setting up the Lua Language Server (`:LspInstall lua_ls`)
-- as this provides autocomplete and documentation while editing
---@type LazySpec
return {
"AstroNvim/astrolsp",
---@type AstroLSPOpts
opts = {
-- Configuration table of features provided by AstroLSP
features = {
autoformat = true, -- enable or disable auto formatting on start
codelens = true, -- enable/disable codelens refresh on start
-- inlay_hints = true, -- enable/disable inlay hints on start
semantic_tokens = true, -- enable/disable semantic token highlighting
},
-- customize lsp formatting options
formatting = {
-- control auto formatting on save
format_on_save = {
enabled = false, -- enable or disable format on save globally
allow_filetypes = { -- enable format on save for specified filetypes only
-- "go",
},
ignore_filetypes = { -- disable format on save for specified filetypes
-- "python",
},
},
disabled = { -- disable formatting capabilities for the listed language servers
-- disable lua_ls formatting capability if you want to use StyLua to format your lua code
"lua_ls",
},
timeout_ms = 1000, -- default format timeout
-- filter = function(client) -- fully override the default formatting function
-- return true
-- end
},
-- enable servers that you already have installed without mason
servers = {
-- "pyright"
"clangd",
},
-- customize language server configuration options passed to `lspconfig`
---@diagnostic disable: missing-fields
config = {
-- clangd = { capabilities = { offsetEncoding = "utf-8" } },
clangd = {
cmd = {
"clangd",
"--background-index",
"--malloc-trim",
"--clang-tidy",
"--all-scopes-completion",
"--limit-references=100",
"--limit-results=20",
"--query-driver=/usr/bin/*gcc",
"--function-arg-placeholders=0",
},
capabilities = {
offsetEncoding = "utf-8",
}
}
},
-- customize how language servers are attached
handlers = {
-- a function without a key is simply the default handler, functions take two parameters, the server name and the configured options table for that server
-- function(server, opts) require("lspconfig")[server].setup(opts) end
-- the key is the server that is being setup with `lspconfig`
-- rust_analyzer = false, -- setting a handler to false will disable the set up of that language server
-- pyright = function(_, opts) require("lspconfig").pyright.setup(opts) end -- or a custom handler function can be passed
-- clangd = function(_, opts) require("clangd_extensions").setup { server = opts } end,
},
-- Configure buffer local auto commands to add when attaching a language server
autocmds = {
-- first key is the `augroup` to add the auto commands to (:h augroup)
lsp_document_highlight = {
-- Optional condition to create/delete auto command group
-- can either be a string of a client capability or a function of `fun(client, bufnr): boolean`
-- condition will be resolved for each client on each execution and if it ever fails for all clients,
-- the auto commands will be deleted for that buffer
cond = "textDocument/documentHighlight",
-- cond = function(client, bufnr) return client.name == "lua_ls" end,
-- list of auto commands to set
{
-- events to trigger
event = { "CursorHold", "CursorHoldI" },
-- the rest of the autocmd options (:h nvim_create_autocmd)
desc = "Document Highlighting",
callback = function() vim.lsp.buf.document_highlight() end,
},
{
event = { "CursorMoved", "CursorMovedI", "BufLeave" },
desc = "Document Highlighting Clear",
callback = function() vim.lsp.buf.clear_references() end,
},
},
},
-- mappings to be set up on attaching of a language server
mappings = {
n = {
gl = { function() vim.diagnostic.open_float() end, desc = "Hover diagnostics" },
-- a `cond` key can provided as the string of a server capability to be required to attach, or a function with `client` and `bufnr` parameters from the `on_attach` that returns a boolean
-- gD = {
-- function() vim.lsp.buf.declaration() end,
-- desc = "Declaration of current symbol",
-- cond = "textDocument/declaration",
-- },
-- ["<Leader>uY"] = {
-- function() require("astrolsp.toggles").buffer_semantic_tokens() end,
-- desc = "Toggle LSP semantic highlight (buffer)",
-- cond = function(client) return client.server_capabilities.semanticTokensProvider and vim.lsp.semantic_tokens end,
-- },
},
},
-- A custom `on_attach` function to be run after the default `on_attach` function
-- takes two parameters `client` and `bufnr` (`:h lspconfig-setup`)
on_attach = function(client, bufnr)
-- this would disable semanticTokensProvider for all clients
-- client.server_capabilities.semanticTokensProvider = nil
end,
},
}

41
lua/plugins/astroui.lua Normal file
View File

@@ -0,0 +1,41 @@
-- AstroUI provides the basis for configuring the AstroNvim User Interface
-- Configuration documentation can be found with `:h astroui`
-- NOTE: We highly recommend setting up the Lua Language Server (`:LspInstall lua_ls`)
-- as this provides autocomplete and documentation while editing
---@type LazySpec
return {
"AstroNvim/astroui",
---@type AstroUIOpts
opts = {
-- change colorscheme
colorscheme = "catppuccin",
-- AstroUI allows you to easily modify highlight groups easily for any and all colorschemes
highlights = {
init = { -- this table overrides highlights in all themes
-- Normal = { bg = "#000000" },
},
astrotheme = { -- a table of overrides/changes when applying the astrotheme theme
-- Normal = { bg = "#000000" },
},
["catppuccin-mocha"]= {
-- ["@string.escape"] = { fg = "#55ffff" },
LspInlayHint = { bg = "NONE", fg = "#585b70" },
},
},
-- Icons can be configured throughout the interface
icons = {
-- configure the loading of the lsp in the status line
LSPLoading1 = "",
LSPLoading2 = "",
LSPLoading3 = "",
LSPLoading4 = "",
LSPLoading5 = "",
LSPLoading6 = "",
LSPLoading7 = "",
LSPLoading8 = "",
LSPLoading9 = "",
LSPLoading10 = "",
},
},
}

View File

@@ -0,0 +1,17 @@
return {
-- {
-- "p00f/clangd_extensions.nvim",
-- name = "clangd_extensions",
-- lazy = false,
-- -- config = function()
-- -- require("clangd_extensions").setup {
-- -- server = astronvim.lsp.config "clangd",
-- -- cmd = {
-- -- "clangd",
-- -- "--malloc-trim",
-- -- "--query-driver='/usr/bin/*gcc'",
-- -- },
-- -- }
-- -- end
-- }
}

View File

@@ -0,0 +1,15 @@
return {
'xeluxee/competitest.nvim',
requires = "MunifTanjim/nui.nvim",
config = function() require("competitest").setup{
-- template_file = {
-- cpp = "~/.config/nvim/templates/template.cpp",
-- c = "~/.config/nvim/templates/template.c"
-- }
template_file = "~/.config/nvim/templates/template.$(FEXT)",
compile_command = {
c = { exec = "gcc", args = { "-Wall", "-g", "-DDEBUG", "-fsanitize=address", "$(FNAME)", "-o", "$(FNOEXT)" } },
cpp = { exec = "g++", args = { "-Wall", "-g", "-DDEBUG", "-fsanitize=address", "$(FNAME)", "-o", "$(FNOEXT)" } },
},
} end
}

77
lua/plugins/core.lua Normal file
View File

@@ -0,0 +1,77 @@
return {
-- customize alpha options
{
"goolord/alpha-nvim",
opts = function(_, opts)
-- customize the dashboard header
opts.section.header.val = {
" █████ ███████ ████████ ██████ ██████",
"██ ██ ██ ██ ██ ██ ██ ██",
"███████ ███████ ██ ██████ ██ ██",
"██ ██ ██ ██ ██ ██ ██ ██",
"██ ██ ███████ ██ ██ ██ ██████",
" ",
" ███  ██ ██  ██ ██ ███  ███",
" ████  ██ ██  ██ ██ ████  ████",
" ██ ██  ██ ██  ██ ██ ██ ████ ██",
" ██  ██ ██  ██  ██  ██ ██  ██  ██",
" ██   ████   ████   ██ ██  ██",
}
return opts
end,
},
-- You can disable default plugins as follows:
-- { "max397574/better-escape.nvim", enabled = false },
--
-- You can also easily customize additional setup of plugins that is outside of the plugin's setup call
-- {
-- "L3MON4D3/LuaSnip",
-- config = function(plugin, opts)
-- require "plugins.configs.luasnip"(plugin, opts) -- include the default astronvim config that calls the setup call
-- -- add more custom luasnip configuration such as filetype extend or custom snippets
-- local luasnip = require "luasnip"
-- luasnip.filetype_extend("javascript", { "javascriptreact" })
-- end,
-- },
-- {
-- "windwp/nvim-autopairs",
-- config = function(plugin, opts)
-- require "plugins.configs.nvim-autopairs"(plugin, opts) -- include the default astronvim config that calls the setup call
-- -- add more custom autopairs configuration such as custom rules
-- local npairs = require "nvim-autopairs"
-- local Rule = require "nvim-autopairs.rule"
-- local cond = require "nvim-autopairs.conds"
-- npairs.add_rules(
-- {
-- Rule("$", "$", { "tex", "latex" })
-- -- don't add a pair if the next character is %
-- :with_pair(cond.not_after_regex "%%")
-- -- don't add a pair if the previous character is xxx
-- :with_pair(
-- cond.not_before_regex("xxx", 3)
-- )
-- -- don't move right when repeat character
-- :with_move(cond.none())
-- -- don't delete if the next character is xx
-- :with_del(cond.not_after_regex "xx")
-- -- disable adding a newline when you press <cr>
-- :with_cr(cond.none()),
-- },
-- -- disable for .vim files, but it work for another filetypes
-- Rule("a", "a", "-vim")
-- )
-- end,
-- },
-- By adding to the which-key config and using our helper function you can add more which-key registered bindings
-- {
-- "folke/which-key.nvim",
-- config = function(plugin, opts)
-- require "plugins.configs.which-key"(plugin, opts) -- include the default astronvim config that calls the setup call
-- -- Add bindings which show up as group name
-- local wk = require "which-key"
-- wk.register({
-- b = { name = "Buffer" },
-- }, { mode = "n", prefix = "<leader>" })
-- end,
-- },
}

123
lua/plugins/diffview.lua Normal file
View File

@@ -0,0 +1,123 @@
return {
"sindrets/diffview.nvim",
event = "User AstroGitFile",
opts = function()
local actions = require "diffview.actions"
local utils = require "astrocore" -- astronvim utils
local prefix = "<leader>D"
utils.set_mappings {
n = {
[prefix] = { name = " Diff View" },
[prefix .. "<cr>"] = { "<cmd>DiffviewOpen<cr>", desc = "Open DiffView" },
[prefix .. "h"] = { "<cmd>DiffviewFileHistory %<cr>", desc = "Open DiffView File History" },
[prefix .. "H"] = { "<cmd>DiffviewFileHistory<cr>", desc = "Open DiffView Branch History" },
},
}
local build_keymaps = function(maps)
local out = {}
local i = 1
for lhs, def in
pairs(utils.extend_tbl(maps, {
[prefix .. "q"] = { "<cmd>DiffviewClose<cr>", desc = "Quit Diffview" }, -- Toggle the file panel.
["]D"] = { actions.select_next_entry, desc = "Next Difference" }, -- Open the diff for the next file
["[D"] = { actions.select_prev_entry, desc = "Previous Difference" }, -- Open the diff for the previous file
["[C"] = { actions.prev_conflict, desc = "Next Conflict" }, -- In the merge_tool: jump to the previous conflict
["]C"] = { actions.next_conflict, desc = "Previous Conflict" }, -- In the merge_tool: jump to the next conflict
["Cl"] = { actions.cycle_layout, desc = "Cycle Diff Layout" }, -- Cycle through available layouts.
["Ct"] = { actions.listing_style, desc = "Cycle Tree Style" }, -- Cycle through available layouts.
["<leader>e"] = { actions.toggle_files, desc = "Toggle Explorer" }, -- Toggle the file panel.
["<leader>o"] = { actions.focus_files, desc = "Focus Explorer" }, -- Bring focus to the file panel
}))
do
local opts
local rhs = def
local mode = { "n" }
if type(def) == "table" then
if def.mode then mode = def.mode end
rhs = def[1]
def[1] = nil
def.mode = nil
opts = def
end
out[i] = { mode, lhs, rhs, opts }
i = i + 1
end
return out
end
return {
enhanced_diff_hl = true,
view = {
merge_tool = { layout = "diff3_mixed" },
},
hooks = { diff_buf_read = function(bufnr) vim.b[bufnr].view_activated = false end },
keymaps = {
disable_defaults = true,
view = build_keymaps {
[prefix .. "o"] = { actions.conflict_choose "ours", desc = "Take Ours" }, -- Choose the OURS version of a conflict
[prefix .. "t"] = { actions.conflict_choose "theirs", desc = "Take Theirs" }, -- Choose the THEIRS version of a conflict
[prefix .. "b"] = { actions.conflict_choose "base", desc = "Take Base" }, -- Choose the BASE version of a conflict
[prefix .. "a"] = { actions.conflict_choose "all", desc = "Take All" }, -- Choose all the versions of a conflict
[prefix .. "0"] = { actions.conflict_choose "none", desc = "Take None" }, -- Delete the conflict region
},
diff3 = build_keymaps {
[prefix .. "O"] = { actions.diffget "ours", mode = { "n", "x" }, desc = "Get Our Diff" }, -- Obtain the diff hunk from the OURS version of the file
[prefix .. "T"] = { actions.diffget "theirs", mode = { "n", "x" }, desc = "Get Their Diff" }, -- Obtain the diff hunk from the THEIRS version of the file
},
diff4 = build_keymaps {
[prefix .. "B"] = { actions.diffget "base", mode = { "n", "x" }, desc = "Get Base Diff" }, -- Obtain the diff hunk from the OURS version of the file
[prefix .. "O"] = { actions.diffget "ours", mode = { "n", "x" }, desc = "Get Our Diff" }, -- Obtain the diff hunk from the OURS version of the file
[prefix .. "T"] = { actions.diffget "theirs", mode = { "n", "x" }, desc = "Get Their Diff" }, -- Obtain the diff hunk from the THEIRS version of the file
},
file_panel = build_keymaps {
j = actions.next_entry, -- Bring the cursor to the next file entry
k = actions.prev_entry, -- Bring the cursor to the previous file entry.
o = actions.select_entry,
S = actions.stage_all, -- Stage all entries.
U = actions.unstage_all, -- Unstage all entries.
X = actions.restore_entry, -- Restore entry to the state on the left side.
L = actions.open_commit_log, -- Open the commit log panel.
Cf = { actions.toggle_flatten_dirs, desc = "Flatten" }, -- Flatten empty subdirectories in tree listing style.
R = actions.refresh_files, -- Update stats and entries in the file list.
["-"] = actions.toggle_stage_entry, -- Stage / unstage the selected entry.
["<down>"] = actions.next_entry,
["<up>"] = actions.prev_entry,
["<cr>"] = actions.select_entry, -- Open the diff for the selected entry.
["<2-LeftMouse>"] = actions.select_entry,
["<c-b>"] = actions.scroll_view(-0.25), -- Scroll the view up
["<c-f>"] = actions.scroll_view(0.25), -- Scroll the view down
["<tab>"] = actions.select_next_entry,
["<s-tab>"] = actions.select_prev_entry,
},
file_history_panel = build_keymaps {
j = actions.next_entry,
k = actions.prev_entry,
o = actions.select_entry,
y = actions.copy_hash, -- Copy the commit hash of the entry under the cursor
L = actions.open_commit_log,
zR = { actions.open_all_folds, desc = "Open all folds" },
zM = { actions.close_all_folds, desc = "Close all folds" },
["?"] = { actions.options, desc = "Options" }, -- Open the option panel
["<down>"] = actions.next_entry,
["<up>"] = actions.prev_entry,
["<cr>"] = actions.select_entry,
["<2-LeftMouse>"] = actions.select_entry,
["<C-A-d>"] = actions.open_in_diffview, -- Open the entry under the cursor in a diffview
["<c-b>"] = actions.scroll_view(-0.25),
["<c-f>"] = actions.scroll_view(0.25),
["<tab>"] = actions.select_next_entry,
["<s-tab>"] = actions.select_prev_entry,
},
option_panel = {
q = actions.close,
o = actions.select_entry,
["<cr>"] = actions.select_entry,
["<2-LeftMouse"] = actions.select_entry,
},
},
}
end,
}

138
lua/plugins/editor.lua Normal file
View File

@@ -0,0 +1,138 @@
return {
{
"folke/zen-mode.nvim",
cmd = "ZenMode",
opts = {
window = {
backdrop = 1,
width = function() return math.min(120, vim.o.columns * 0.75) end,
height = 0.9,
options = {
number = false,
relativenumber = false,
foldcolumn = "0",
list = false,
showbreak = "NONE",
signcolumn = "no",
},
},
plugins = {
options = {
cmdheight = 1,
laststatus = 0,
},
},
on_open = function() -- disable diagnostics, indent blankline, and winbar
vim.g.diagnostics_mode_old = vim.g.diagnostics_mode
vim.g.indent_blankline_enabled_old = vim.g.indent_blankline_enabled
vim.g.winbar_old = vim.wo.winbar
vim.g.diagnostics_mode = 0
vim.g.indent_blankline_enabled = false
vim.wo.winbar = nil
vim.diagnostic.config(require("astrolsp").diagnostics[vim.g.diagnostics_mode])
end,
on_close = function() -- restore diagnostics, indent blankline, and winbar
vim.g.diagnostics_mode = vim.g.diagnostics_mode_old
vim.g.indent_blankline_enabled = vim.g.indent_blankline_enabled_old
vim.wo.winbar = vim.g.winbar_old
vim.diagnostic.config(require("astrolsp").diagnostics[vim.g.diagnostics_mode])
end,
},
},
{
"echasnovski/mini.move",
keys = {
{ "<C-l>", mode = { "n", "v" } },
{ "<C-k>", mode = { "n", "v" } },
{ "<C-j>", mode = { "n", "v" } },
{ "<C-h>", mode = { "n", "v" } },
},
opts = {
mappings = {
left = '<C-h>',
right = '<C-l>',
down = '<C-j>',
up = '<C-k>',
line_down = '<C-j>',
line_left = '<C-h>',
line_right = '<C-l>',
line_up = '<C-k>',
}
},
},
{
"arsham/indent-tools.nvim",
dependencies = { "arsham/arshlib.nvim" },
event = "User AstroFile",
config = function() require("indent-tools").config {} end,
},
{
"danymat/neogen",
cmd = "Neogen",
opts = {
snippet_engine = "luasnip",
languages = {
lua = { template = { annotation_convention = "emmylua" } },
typescript = { template = { annotation_convention = "tsdoc" } },
typescriptreact = { template = { annotation_convention = "tsdoc" } },
},
},
},
{
"lukas-reineke/headlines.nvim",
dependencies = "nvim-treesitter/nvim-treesitter",
ft = "markdown",
opts = {},
},
{
"folke/todo-comments.nvim",
event = "User AstroFile",
cmd = { "TodoTrouble", "TodoTelescope", "TodoLocList", "TodoQuickFix" },
opts = {},
},
{
"folke/trouble.nvim",
cmd = { "TroubleToggle", "Trouble" },
opts = {
use_diagnostic_signs = true,
action_keys = {
close = { "q", "<esc>" },
cancel = "<c-e>",
},
},
},
{
"nvim-pack/nvim-spectre",
cmd = "Spectre",
opts = function()
local prefix = "<leader>s"
return {
open_cmd = "new",
mapping = {
send_to_qf = { map = prefix .. "q" },
replace_cmd = { map = prefix .. "c" },
show_option_menu = { map = prefix .. "o" },
run_current_replace = { map = prefix .. "C" },
run_replace = { map = prefix .. "R" },
change_view_mode = { map = prefix .. "v" },
resume_last_search = { map = prefix .. "l" },
},
}
end,
},
{ "junegunn/vim-easy-align", event = "User AstroFile" },
{
"echasnovski/mini.surround",
keys = {
{ "sa", desc = "Add surrounding", mode = { "n", "v" } },
{ "sd", desc = "Delete surrounding" },
{ "sf", desc = "Find right surrounding" },
{ "sF", desc = "Find left surrounding" },
{ "sh", desc = "Highlight surrounding" },
{ "sr", desc = "Replace surrounding" },
{ "sn", desc = "Update `MiniSurround.config.n_lines`" },
},
opts = { n_lines = 200 },
},
}

27
lua/plugins/heirline.lua Normal file
View File

@@ -0,0 +1,27 @@
return {
"rebelot/heirline.nvim",
opts = function(_, opts)
local status = require "astroui.status"
opts.statusline[3] = status.component.file_info { filetype = {}, filename = false }
opts.winbar[1][1] = status.component.separated_path { path_func = status.provider.filename { modify = ":.:h" } }
opts.winbar[2] = {
status.component.separated_path { path_func = status.provider.filename { modify = ":.:h" } },
status.component.file_info { -- add file_info to breadcrumbs
file_icon = { hl = status.hl.filetype_color, padding = { left = 0 } },
file_modified = false,
file_read_only = false,
hl = status.hl.get_attributes("winbar", true),
surround = false,
update = "BufEnter",
},
status.component.breadcrumbs {
icon = { hl = true },
hl = status.hl.get_attributes("winbar", true),
prefix = true,
padding = { left = 0 },
},
}
return opts
end,
}

4
lua/plugins/info.lua Normal file
View File

@@ -0,0 +1,4 @@
return {
"HiPhish/info.vim",
lazy = false,
}

37
lua/plugins/mason.lua Normal file
View File

@@ -0,0 +1,37 @@
-- customize mason plugins
return {
-- use mason-lspconfig to configure LSP installations
{
"williamboman/mason-lspconfig.nvim",
-- overrides `require("mason-lspconfig").setup(...)`
opts = function(_, opts)
-- add more things to the ensure_installed table protecting against community packs modifying it
opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, {
-- "lua_ls",
})
end,
},
-- use mason-null-ls to configure Formatters/Linter installation for null-ls sources
{
"jay-babu/mason-null-ls.nvim",
-- overrides `require("mason-null-ls").setup(...)`
opts = function(_, opts)
-- add more things to the ensure_installed table protecting against community packs modifying it
opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, {
-- "prettier",
-- "stylua",
})
end,
},
{
"jay-babu/mason-nvim-dap.nvim",
-- overrides `require("mason-nvim-dap").setup(...)`
opts = function(_, opts)
-- add more things to the ensure_installed table protecting against community packs modifying it
opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, {
-- "python",
"cppdbg",
})
end,
},
}

5
lua/plugins/neo-tree.lua Normal file
View File

@@ -0,0 +1,5 @@
return {
"nvim-neo-tree/neo-tree.nvim",
dependencies = "nvim-lua/plenary.nvim",
lazy = false,
}

7
lua/plugins/neoclip.lua Normal file
View File

@@ -0,0 +1,7 @@
return {
"matveyt/neoclip",
lazy = false,
config = function(plugin, opts)
require("neoclip"):setup()
end,
}

35
lua/plugins/noice.lua Normal file
View File

@@ -0,0 +1,35 @@
return {
{ "rcarriga/nvim-notify", init = false, config = true },
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
if opts.ensure_installed ~= "all" then
opts.ensure_installed = require("astrocore").list_insert_unique(
opts.ensure_installed,
{ "bash", "markdown", "markdown_inline", "regex", "vim" }
)
end
end,
},
{
"folke/noice.nvim",
event = "VeryLazy",
opts = {
cmdline = { view = "cmdline" },
messages = { view_search = false },
lsp = {
progress = { enabled = false },
hover = { enabled = false },
signature = { enabled = false },
},
routes = {
{ filter = { event = "msg_show", min_height = 20 }, view = "messages" }, -- send long messages to split
{ filter = { event = "msg_show", find = "%d+L,%s%d+B" }, opts = { skip = true } }, -- skip save notifications
{ filter = { event = "msg_show", find = "^%d+ more lines$" }, opts = { skip = true } }, -- skip paste notifications
{ filter = { event = "msg_show", find = "^%d+ fewer lines$" }, opts = { skip = true } }, -- skip delete notifications
{ filter = { event = "msg_show", find = "^%d+ lines yanked$" }, opts = { skip = true } }, -- skip yank notifications
},
},
},
lazy = false,
}

22
lua/plugins/none-ls.lua Normal file
View File

@@ -0,0 +1,22 @@
if true then return {} end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE
-- Customize None-ls sources
---@type LazySpec
return {
"nvimtools/none-ls.nvim",
opts = function(_, config)
-- config variable is the default configuration table for the setup function call
-- local null_ls = require "null-ls"
-- Check supported formatters and linters
-- https://github.com/nvimtools/none-ls.nvim/tree/main/lua/null-ls/builtins/formatting
-- https://github.com/nvimtools/none-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics
config.sources = {
-- Set a formatter
-- null_ls.builtins.formatting.stylua,
-- null_ls.builtins.formatting.prettier,
}
return config -- return final config table
end,
}

15
lua/plugins/nvim-cmp.lua Normal file
View File

@@ -0,0 +1,15 @@
return {
"hrsh7th/nvim-cmp",
config = function(plugin, opts)
local cmp = require "cmp"
cmp.setup(opts)
cmp.setup {
experimental = {
ghost_text = true
}
}
end
}

23
lua/plugins/repl.lua Normal file
View File

@@ -0,0 +1,23 @@
return {
{
"jupyter-vim/jupyter-vim",
ft = { "pyhon", "julia" },
config = function()
require("astrocore").set_mappings {
n = {
["<leader>J"] = { "<cmd>JupyterConnect<cr>", desc = "Connect to Jupyter" },
["<leader>j"] = { "<Plug>JupyterRunTextObj", desc = "Send to Jupyter" },
},
v = {
["<leader>j"] = { "<Plug>JupyterRunVisual", desc = "Send to Jupyter" },
},
}
end,
},
{
"mtikekar/nvim-send-to-term",
init = function() vim.g.send_disable_mapping = true end,
keys = { "<Plug>Send", "<Plug>SendLine" },
cmd = "SendHere",
},
}

107
lua/plugins/telescope.lua Normal file
View File

@@ -0,0 +1,107 @@
return {
"nvim-telescope/telescope.nvim",
dependencies = {
{ "nvim-telescope/telescope-fzf-native.nvim", enabled = false },
"nvim-telescope/telescope-fzy-native.nvim",
"nvim-telescope/telescope-live-grep-args.nvim",
"nvim-telescope/telescope-hop.nvim",
"nvim-telescope/telescope-bibtex.nvim",
"nvim-telescope/telescope-file-browser.nvim",
{
"jay-babu/project.nvim",
name = "project_nvim",
event = "VeryLazy",
opts = { ignore_lsp = { "lua_ls", "julials" } },
},
},
opts = function(_, opts)
local telescope = require "telescope"
local actions = require "telescope.actions"
local fb_actions = require("telescope").extensions.file_browser.actions
local lga_actions = require "telescope-live-grep-args.actions"
local hop = telescope.extensions.hop
return require("astrocore").extend_tbl(opts, {
defaults = {
results_title = "",
selection_caret = " ",
layout_config = {
width = 0.90,
height = 0.85,
preview_cutoff = 120,
horizontal = {
preview_width = 0.6,
},
vertical = {
width = 0.9,
height = 0.95,
preview_height = 0.5,
},
flex = {
horizontal = {
preview_width = 0.9,
},
},
},
mappings = {
i = {
["<C-h>"] = hop.hop,
["<C-space>"] = function(prompt_bufnr)
hop._hop_loop(
prompt_bufnr,
{ callback = actions.toggle_selection, loop_callback = actions.send_selected_to_qflist }
)
end,
},
},
},
extensions = {
bibtex = { context = true, context_fallback = false },
file_browser = {
mappings = {
i = {
["<C-z>"] = fb_actions.toggle_hidden,
},
n = {
z = fb_actions.toggle_hidden,
},
},
},
live_grep_args = {
auto_quoting = true, -- enable/disable auto-quoting
mappings = { -- extend mappings
i = {
["<C-a>"] = lga_actions.quote_prompt(),
["<C-f>"] = lga_actions.quote_prompt { postfix = " --iglob " },
},
},
},
},
pickers = {
find_files = {
hidden = true,
find_command = function(cfg)
local find_command = { "rg", "--files", "--color", "never" }
if not cfg.no_ignore then vim.list_extend(find_command, { "--glob", "!**/.git/**" }) end
return find_command
end,
},
buffers = {
path_display = { "smart" },
mappings = {
i = { ["<c-d>"] = actions.delete_buffer },
n = { ["d"] = actions.delete_buffer },
},
},
},
})
end,
config = function(...)
-- require "plugins.configs.telescope"(...)
local telescope = require "telescope"
telescope.load_extension "fzy_native"
telescope.load_extension "live_grep_args"
telescope.load_extension "bibtex"
telescope.load_extension "file_browser"
telescope.load_extension "projects"
end,
}

View File

@@ -0,0 +1,6 @@
return {
"akinsho/toggleterm.nvim",
opts = {
open_mapping = [[<C-'>]],
},
}

View File

@@ -0,0 +1,25 @@
return {
{
"nvim-treesitter/nvim-treesitter",
lazy = false,
opts = function(_, opts)
-- add more things to the ensure_installed table protecting against community packs modifying it
opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, {
-- "lua"
})
end,
config = function()
require("nvim-treesitter.configs").setup {
highlight = {
enable = true,
},
autotag = {
enable = true,
enable_rename = true,
enable_close = true,
enable_close_on_slash = true,
}
}
end
}
}

12
lua/plugins/user.lua Normal file
View File

@@ -0,0 +1,12 @@
return {
-- You can also add new plugins here as well:
-- Add plugins, the lazy syntax
-- "andweeb/presence.nvim",
-- {
-- "ray-x/lsp_signature.nvim",
-- event = "BufRead",
-- config = function()
-- require("lsp_signature").setup()
-- end,
-- },
}

View File

@@ -0,0 +1,7 @@
return {
{
"akielaries/vim-s-asm",
lazy = false,
name = "vim-s-asm",
}
}

4
lua/plugins/wiki.lua Normal file
View File

@@ -0,0 +1,4 @@
return {
"lervag/wiki.vim",
lazy = false,
}