From 5e25828335ef68c2127f18e1d7b66a6791e95c6b Mon Sep 17 00:00:00 2001 From: Allann Cintra Date: Tue, 17 Sep 2024 15:02:57 -0300 Subject: [PATCH] My neovim config --- .neoconf.json | 20 ++ .stylua.toml | 7 + README.md | 34 ++++ init.lua | 19 ++ lazy-lock.json | 99 ++++++++++ lua/community.lua | 47 +++++ lua/init.lua | 94 +++++++++ lua/lazy_setup.lua | 32 ++++ lua/plugins/astrocore.lua | 308 ++++++++++++++++++++++++++++++ lua/plugins/astrolsp.lua | 124 ++++++++++++ lua/plugins/astroui.lua | 41 ++++ lua/plugins/clangd_extensions.lua | 17 ++ lua/plugins/competitest.lua | 15 ++ lua/plugins/core.lua | 77 ++++++++ lua/plugins/diffview.lua | 123 ++++++++++++ lua/plugins/editor.lua | 138 +++++++++++++ lua/plugins/heirline.lua | 27 +++ lua/plugins/info.lua | 4 + lua/plugins/mason.lua | 37 ++++ lua/plugins/neo-tree.lua | 5 + lua/plugins/neoclip.lua | 7 + lua/plugins/noice.lua | 35 ++++ lua/plugins/none-ls.lua | 22 +++ lua/plugins/nvim-cmp.lua | 15 ++ lua/plugins/repl.lua | 23 +++ lua/plugins/telescope.lua | 107 +++++++++++ lua/plugins/toggleterm.lua | 6 + lua/plugins/treesitter.lua | 25 +++ lua/plugins/user.lua | 12 ++ lua/plugins/vim-s-asm.lua | 7 + lua/plugins/wiki.lua | 4 + lua/polish.lua | 18 ++ lua/utils.lua | 60 ++++++ neovim.yml | 6 + selene.toml | 8 + templates/template.c | 13 ++ templates/template.cpp | 76 ++++++++ 37 files changed, 1712 insertions(+) create mode 100644 .neoconf.json create mode 100644 .stylua.toml create mode 100644 README.md create mode 100644 init.lua create mode 100644 lazy-lock.json create mode 100644 lua/community.lua create mode 100644 lua/init.lua create mode 100644 lua/lazy_setup.lua create mode 100644 lua/plugins/astrocore.lua create mode 100644 lua/plugins/astrolsp.lua create mode 100644 lua/plugins/astroui.lua create mode 100644 lua/plugins/clangd_extensions.lua create mode 100644 lua/plugins/competitest.lua create mode 100644 lua/plugins/core.lua create mode 100644 lua/plugins/diffview.lua create mode 100644 lua/plugins/editor.lua create mode 100644 lua/plugins/heirline.lua create mode 100644 lua/plugins/info.lua create mode 100644 lua/plugins/mason.lua create mode 100644 lua/plugins/neo-tree.lua create mode 100644 lua/plugins/neoclip.lua create mode 100644 lua/plugins/noice.lua create mode 100644 lua/plugins/none-ls.lua create mode 100644 lua/plugins/nvim-cmp.lua create mode 100644 lua/plugins/repl.lua create mode 100644 lua/plugins/telescope.lua create mode 100644 lua/plugins/toggleterm.lua create mode 100644 lua/plugins/treesitter.lua create mode 100644 lua/plugins/user.lua create mode 100644 lua/plugins/vim-s-asm.lua create mode 100644 lua/plugins/wiki.lua create mode 100644 lua/polish.lua create mode 100644 lua/utils.lua create mode 100644 neovim.yml create mode 100644 selene.toml create mode 100644 templates/template.c create mode 100644 templates/template.cpp diff --git a/.neoconf.json b/.neoconf.json new file mode 100644 index 0000000..2d7a81f --- /dev/null +++ b/.neoconf.json @@ -0,0 +1,20 @@ +{ + "neodev": { + "library": { + "enabled": true, + "plugins": true + } + }, + "neoconf": { + "plugins": { + "lua_ls": { + "enabled": true + } + } + }, + "lspconfig": { + "lua_ls": { + "Lua.format.enable": false + } + } +} diff --git a/.stylua.toml b/.stylua.toml new file mode 100644 index 0000000..bfcffff --- /dev/null +++ b/.stylua.toml @@ -0,0 +1,7 @@ +column_width = 120 +line_endings = "Unix" +indent_type = "Spaces" +indent_width = 2 +quote_style = "AutoPreferDouble" +call_parentheses = "None" +collapse_simple_statement = "Always" diff --git a/README.md b/README.md new file mode 100644 index 0000000..365674b --- /dev/null +++ b/README.md @@ -0,0 +1,34 @@ +# AstroNvim Template + +**NOTE:** This is for AstroNvim v4+ + +A template for getting started with [AstroNvim](https://github.com/AstroNvim/AstroNvim) + +## 🛠️ Installation + +#### Make a backup of your current nvim and shared folder + +```shell +mv ~/.config/nvim ~/.config/nvim.bak +mv ~/.local/share/nvim ~/.local/share/nvim.bak +mv ~/.local/state/nvim ~/.local/state/nvim.bak +mv ~/.cache/nvim ~/.cache/nvim.bak +``` + +#### Create a new user repository from this template + +Press the "Use this template" button above to create a new repository to store your user configuration. + +You can also just clone this repository directly if you do not want to track your user configuration in GitHub. + +#### Clone the repository + +```shell +git clone https://github.com// ~/.config/nvim +``` + +#### Start Neovim + +```shell +nvim +``` diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..2ce1cdd --- /dev/null +++ b/init.lua @@ -0,0 +1,19 @@ +-- This file simply bootstraps the installation of Lazy.nvim and then calls other files for execution +-- This file doesn't necessarily need to be touched, BE CAUTIOUS editing this file and proceed at your own risk. +local lazypath = vim.env.LAZY or vim.fn.stdpath "data" .. "/lazy/lazy.nvim" +if not (vim.env.LAZY or (vim.uv or vim.loop).fs_stat(lazypath)) then + -- stylua: ignore + vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath }) +end +vim.opt.rtp:prepend(lazypath) + +-- validate that lazy is available +if not pcall(require, "lazy") then + -- stylua: ignore + vim.api.nvim_echo({ { ("Unable to load lazy from: %s\n"):format(lazypath), "ErrorMsg" }, { "Press any key to exit...", "MoreMsg" } }, true, {}) + vim.fn.getchar() + vim.cmd.quit() +end + +require "lazy_setup" +require "polish" diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..5f36110 --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,99 @@ +{ + "AstroNvim": { "branch": "main", "commit": "d771094986abced8c3ceae29a5a55585ecb0523a" }, + "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, + "LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" }, + "aerial.nvim": { "branch": "master", "commit": "b59e01e4380932b375ecff165b48a9400c4af929" }, + "alpha-nvim": { "branch": "main", "commit": "b6f4129302db197a7249e67a90de3f2b676de13e" }, + "arshlib.nvim": { "branch": "master", "commit": "111fd439268adda206a24b133096893869a50764" }, + "astrocommunity": { "branch": "main", "commit": "b6f8a518e527d5372e42cec767d211bb969fb6a6" }, + "astrocore": { "branch": "main", "commit": "cf5823e2b59aa9666445e3f3531296ad8f417b7c" }, + "astrolsp": { "branch": "main", "commit": "5d92b868586c4b79298003b307e8dc3e9a357816" }, + "astrotheme": { "branch": "main", "commit": "037c3dbd161d6744d274243dd71314b2964753b2" }, + "astroui": { "branch": "main", "commit": "7adeb60d76939d3cd66c9852e0e8621bd42014dd" }, + "better-escape.nvim": { "branch": "master", "commit": "f45b52f8f87792e8659526f23261ffe278a54be5" }, + "catppuccin": { "branch": "main", "commit": "4fd72a9ab64b393c2c22b168508fd244877fec96" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-dap": { "branch": "master", "commit": "ea92773e84c0ad3288c3bc5e452ac91559669087" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "competitest.nvim": { "branch": "master", "commit": "c3cb0e2b0916a879c4d3dcb5737e6c046dd0afc5" }, + "compiler.nvim": { "branch": "main", "commit": "e889774c7f2fefad60f8e6638d324223b07d2624" }, + "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, + "dressing.nvim": { "branch": "master", "commit": "71349f24c6e07b39f33600985843c289ca735308" }, + "friendly-snippets": { "branch": "main", "commit": "00ebcaa159e817150bd83bfe2d51fa3b3377d5c4" }, + "gitsigns.nvim": { "branch": "main", "commit": "0b04035bb7b3c83e999b9676e2fb46fd0aa9f910" }, + "glow.nvim": { "branch": "main", "commit": "238070a686c1da3bccccf1079700eb4b5e19aea4" }, + "guess-indent.nvim": { "branch": "main", "commit": "6cd61f7a600bb756e558627cd2e740302c58e32d" }, + "headlines.nvim": { "branch": "master", "commit": "7671eec1065982cdf2ba4136beb1600fe1279431" }, + "heirline.nvim": { "branch": "master", "commit": "0d797435e54645a5f98bad7ad6046aac1ef95c1e" }, + "hologram.nvim": { "branch": "main", "commit": "f5194f71ec1578d91b2e3119ff08e574e2eab542" }, + "indent-blankline.nvim": { "branch": "master", "commit": "18603eb949eba08300799f64027af11ef922283f" }, + "indent-tools.nvim": { "branch": "master", "commit": "31b839d65aa04b568fabe5e100a63cc44ef3f5d5" }, + "info.vim": { "branch": "master", "commit": "b1acda75344f36b91d9c51a33201eada38cf33e9" }, + "jupyter-vim": { "branch": "master", "commit": "91eef96d0f26ce37db241833341d08d11c8e5215" }, + "lazy.nvim": { "branch": "main", "commit": "077102c5bfc578693f12377846d427f49bc50076" }, + "lazydev.nvim": { "branch": "main", "commit": "491452cf1ca6f029e90ad0d0368848fac717c6d2" }, + "lsp_signature.nvim": { "branch": "master", "commit": "a38da0a61c172bb59e34befc12efe48359884793" }, + "lspkind.nvim": { "branch": "master", "commit": "cff4ae321a91ee3473a92ea1a8c637e3a9510aec" }, + "luvit-meta": { "branch": "main", "commit": "ce76f6f6cdc9201523a5875a4471dcfe0186eb60" }, + "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "62360f061d45177dda8afc1b0fd1327328540301" }, + "mason-null-ls.nvim": { "branch": "main", "commit": "2b8433f76598397fcc97318d410e0c4f7a4bea6a" }, + "mason-nvim-dap.nvim": { "branch": "main", "commit": "8b9363d83b5d779813cdd2819b8308651cec2a09" }, + "mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" }, + "mini.bufremove": { "branch": "main", "commit": "e6044aa28e61d4dd9ec86194d6f81743eced0c1c" }, + "mini.indentscope": { "branch": "main", "commit": "da9af64649e114aa79480c238fd23f6524bc0903" }, + "mini.move": { "branch": "main", "commit": "4caa1c212f5ca3d1633d21cfb184808090ed74b1" }, + "mini.surround": { "branch": "main", "commit": "0e67c4bc147f2a15cee94e7c94dcc0e115b9f55e" }, + "neo-tree.nvim": { "branch": "main", "commit": "8c75e8a2949cd6cd35525799200a8d34471ee9eb" }, + "neoclip": { "branch": "master", "commit": "adfb1430c7308f0b3036f89b037509b3d0b4610a" }, + "neoconf.nvim": { "branch": "main", "commit": "8ee287dccee562857b0abe9fe3acd6ad147f8a70" }, + "neogen": { "branch": "main", "commit": "e932ba918b56723436b77aa3efb844a11b2851ab" }, + "noice.nvim": { "branch": "main", "commit": "448bb9c524a7601035449210838e374a30153172" }, + "none-ls.nvim": { "branch": "main", "commit": "9b98991e15dce8fc502993e23caac2528b8b667f" }, + "nui.nvim": { "branch": "main", "commit": "a0fd35fcbb4cb479366f1dc5f20145fd718a3733" }, + "nvim-bqf": { "branch": "main", "commit": "1b24dc6050c34e8cd377b6b4cd6abe40509e0187" }, + "nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" }, + "nvim-colorizer.lua": { "branch": "master", "commit": "194ec600488f7c7229668d0e80bd197f3a2b84ff" }, + "nvim-dap": { "branch": "master", "commit": "20a4859ebde1c9bc8e96f8cc11a20667e7fdd516" }, + "nvim-dap-ui": { "branch": "master", "commit": "1c351e4e417d4691da12948b6ecf966936a56d28" }, + "nvim-lspconfig": { "branch": "master", "commit": "0ef64599b8aa0187ee5f6d92cb39c951f348f041" }, + "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, + "nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" }, + "nvim-send-to-term": { "branch": "master", "commit": "e0aa448d417a553d19cba8c78d91993387f1ff2d" }, + "nvim-spectre": { "branch": "master", "commit": "ba7fb777edff6c1fbbeffd343e113af64c04e90a" }, + "nvim-treesitter": { "branch": "master", "commit": "00f128dd73086aa578dc3d9142de06c633b7c685" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "fe3deb7f67ce0cc4ebfe2ea6c1c7ae1c7a939d73" }, + "nvim-ts-autotag": { "branch": "main", "commit": "e239a560f338be31337e7abc3ee42515daf23f5e" }, + "nvim-ts-context-commentstring": { "branch": "main", "commit": "375c2d86cee6674afd75b4f727ce3a80065552f7" }, + "nvim-ufo": { "branch": "main", "commit": "a5390706f510d39951dd581f6d2a972741b3fa26" }, + "nvim-web-devicons": { "branch": "master", "commit": "9793801f974bba70e4ac5d7eae6c4f5659993d8e" }, + "nvim-window-picker": { "branch": "main", "commit": "41cfaa428577c53552200a404ae9b3a0b5719706" }, + "overseer.nvim": { "branch": "master", "commit": "236e60cdac6410dd95ea5cecafdb801a304d6a41" }, + "pets.nvim": { "branch": "main", "commit": "8a443e2eae804e5abe21b5d00ceaef4041f882e4" }, + "plenary.nvim": { "branch": "master", "commit": "ec289423a1693aeae6cd0d503bac2856af74edaa" }, + "project_nvim": { "branch": "main", "commit": "4317ce951459a53ba45ffed2495ac6752211364b" }, + "promise-async": { "branch": "main", "commit": "38a4575da9497326badd3995e768b4ccf0bb153e" }, + "rainbow-delimiters.nvim": { "branch": "master", "commit": "5f73b24aeb94f5274c218955573153c69ce4d1ee" }, + "resession.nvim": { "branch": "master", "commit": "cc819b0489938d03e4f3532a583354f0287c015b" }, + "smart-splits.nvim": { "branch": "master", "commit": "1a2b268a7ec7aeef879cdd15973339010ec134f7" }, + "telescope-bibtex.nvim": { "branch": "master", "commit": "289a6f86ebec06e8ae1590533b732b9981d84900" }, + "telescope-file-browser.nvim": { "branch": "master", "commit": "c5a14e0550699a7db575805cdb9ddc969ba0f1f5" }, + "telescope-fzy-native.nvim": { "branch": "master", "commit": "282f069504515eec762ab6d6c89903377252bf5b" }, + "telescope-hop.nvim": { "branch": "master", "commit": "337a1e9f08f972ebf7a7d26251577812ebaadc78" }, + "telescope-live-grep-args.nvim": { "branch": "master", "commit": "649b662a8f476fd2c0289570764459e95ebaa3f3" }, + "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, + "todo-comments.nvim": { "branch": "main", "commit": "313b04e5b02d29ab9275c9295ff5e2b73921b0eb" }, + "toggleterm.nvim": { "branch": "main", "commit": "48be57eaba817f038d61bbf64d2c597f578c0827" }, + "trouble.nvim": { "branch": "main", "commit": "6efc446226679fda0547c0fd6a7892fd5f5b15d8" }, + "twilight.nvim": { "branch": "main", "commit": "1584c0b0a979b71fd86b18d302ba84e9aba85b1b" }, + "ultimate-autopair.nvim": { "branch": "v0.6", "commit": "53ed7c65e466963c916251f9ce6df7dd3685dc36" }, + "vim-easy-align": { "branch": "master", "commit": "9815a55dbcd817784458df7a18acacc6f82b1241" }, + "vim-illuminate": { "branch": "master", "commit": "5eeb7951fc630682c322e88a9bbdae5c224ff0aa" }, + "vim-s-asm": { "branch": "master", "commit": "a43fc9a86d9978c449609fcff4cc324e6615421b" }, + "vim-sandwich": { "branch": "master", "commit": "74cf93d58ccc567d8e2310a69860f1b93af19403" }, + "which-key.nvim": { "branch": "main", "commit": "6c1584eb76b55629702716995cca4ae2798a9cca" }, + "wiki.vim": { "branch": "master", "commit": "ba630e2e174f9fe963c4bce17024a4adbcb09624" }, + "zen-mode.nvim": { "branch": "main", "commit": "29b292bdc58b76a6c8f294c961a8bf92c5a6ebd6" } +} diff --git a/lua/community.lua b/lua/community.lua new file mode 100644 index 0000000..28b94cf --- /dev/null +++ b/lua/community.lua @@ -0,0 +1,47 @@ +return { + "AstroNvim/astrocommunity", + + { import = "astrocommunity.colorscheme.catppuccin" }, + -- { + -- "catppuccin", + -- opts = { + -- integrations = { + -- ts_rainbow2 = true, + -- treesitter = true, + -- } + -- }, + -- config = function() + -- vim.api.nvim_set_hl(0, "LspInlayHint", { bg = "#1e1e2f" }) + -- end + -- }, + + -- { import = "astrocommunity.pack.cpp" }, + + { import = "astrocommunity.code-runner.compiler-nvim" }, + + -- { import = "astrocommunity.code-runner.sniprun" }, + + { import = "astrocommunity.color.twilight-nvim" }, + + { import = "astrocommunity.quickfix.nvim-bqf" }, + + -- { import = "astrocommunity.diagnostics.lsp_lines-nvim" }, + + -- { import = "astrocommunity.diagnostics.trouble-nvim" }, + + { import = "astrocommunity.editing-support.rainbow-delimiters-nvim" }, + + { import = "astrocommunity.editing-support.ultimate-autopair-nvim" }, + + { import = "astrocommunity.indent.mini-indentscope" }, + + { import = "astrocommunity.media.pets-nvim" }, + + { import = "astrocommunity.markdown-and-latex.markdown-preview-nvim" }, + + { import = "astrocommunity.markdown-and-latex.glow-nvim" }, + + { import = "astrocommunity.lsp.lsp-signature-nvim" }, + + { import = "astrocommunity.syntax.vim-sandwich" } +} diff --git a/lua/init.lua b/lua/init.lua new file mode 100644 index 0000000..25824d6 --- /dev/null +++ b/lua/init.lua @@ -0,0 +1,94 @@ +return { + -- Configure AstroNvim updates + updater = { + remote = "origin", -- remote to use + channel = "stable", -- "stable" or "nightly" + version = "latest", -- "latest", tag name, or regex search like "v1.*" to only do updates before v2 (STABLE ONLY) + branch = "nightly", -- branch name (NIGHTLY ONLY) + commit = nil, -- commit hash (NIGHTLY ONLY) + pin_plugins = nil, -- nil, true, false (nil will pin plugins on stable only) + skip_prompts = false, -- skip prompts about breaking changes + show_changelog = true, -- show the changelog after performing an update + auto_quit = false, -- automatically quit the current session after a successful update + remotes = { -- easily add new remotes to track + -- ["remote_name"] = "https://remote_url.come/repo.git", -- full remote url + -- ["remote2"] = "github_user/repo", -- GitHub user/repo shortcut, + -- ["remote3"] = "github_user", -- GitHub user assume AstroNvim fork + }, + }, + + -- Configure require("lazy").setup() options + lazy = { + defaults = { lazy = true }, + performance = { + rtp = { + -- customize default disabled vim plugins + disabled_plugins = { "tohtml", "gzip", "matchit", "zipPlugin", "netrwPlugin", "tarPlugin" }, + }, + }, + }, + + -- This function is run last and is a good place to configuring + -- augroups/autocommands and custom filetypes also this just pure lua so + -- anything that doesn't fit in the normal config locations above can go here + polish = function() + -- Set up custom filetypes + -- vim.filetype.add { + -- extension = { + -- foo = "fooscript", + -- }, + -- filename = { + -- ["Foofile"] = "fooscript", + -- }, + -- pattern = { + -- ["~/%.config/foo/.*"] = "fooscript", + -- }, + -- } + + vim.filetype.add { + extension = { + asm = "nasm", + }, + } + + require("catppuccin").compile() + + vim.api.nvim_create_autocmd({ "VimEnter" }, { + command = [[ let $SHELL="/bin/fish" ]] + }) + + vim.api.nvim_create_autocmd({ "FileType", "BufRead", "BufNewFile" }, { + pattern = "*.s", + callback = function() + local indentation = 8 + vim.opt_local.expandtab = true + vim.opt_local.tabstop = indentation + vim.opt_local.shiftwidth = indentation + vim.opt_local.filetype = "s-asm" + vim.opt_local.syntax = "s-asm" + vim.opt_local.formatoptions = vim.opt_local.formatoptions + "r" + end, + }) + + vim.api.nvim_create_autocmd({ "FileType", "BufRead", "BufNewFile" }, { + pattern = "*.hdl", + callback = function() + local indentation = 4 + vim.opt_local.expandtab = true + vim.opt_local.tabstop = indentation + vim.opt_local.shiftwidth = indentation + vim.opt_local.formatoptions = vim.opt_local.formatoptions + "r" + end, + }) + + vim.api.nvim_create_autocmd({ "FileType", "BufRead", "BufNewFile" }, { + pattern = "*.lua", + callback = function() + local indentation = 4 + vim.opt_local.expandtab = true + vim.opt_local.tabstop = indentation + vim.opt_local.shiftwidth = indentation + end, + }) + end, +} diff --git a/lua/lazy_setup.lua b/lua/lazy_setup.lua new file mode 100644 index 0000000..621de3b --- /dev/null +++ b/lua/lazy_setup.lua @@ -0,0 +1,32 @@ +require("lazy").setup({ + { + "AstroNvim/AstroNvim", + version = "^4", -- Remove version tracking to elect for nighly AstroNvim + import = "astronvim.plugins", + opts = { -- AstroNvim options must be set here with the `import` key + mapleader = " ", -- This ensures the leader key must be configured before Lazy is set up + maplocalleader = ",", -- This ensures the localleader key must be configured before Lazy is set up + icons_enabled = true, -- Set to false to disable icons (if no Nerd Font is available) + pin_plugins = nil, -- Default will pin plugins when tracking `version` of AstroNvim, set to true/false to override + update_notifications = true, -- Enable/disable notification about running `:Lazy update` twice to update pinned plugins + }, + }, + { import = "community" }, + { import = "plugins" }, +} --[[@as LazySpec]], { + -- Configure any other `lazy.nvim` configuration options here + install = { colorscheme = { "astrodark", "habamax" } }, + ui = { backdrop = 100 }, + performance = { + rtp = { + -- disable some rtp plugins, add more to your liking + disabled_plugins = { + "gzip", + "netrwPlugin", + "tarPlugin", + "tohtml", + "zipPlugin", + }, + }, + }, +} --[[@as LazyConfig]]) diff --git a/lua/plugins/astrocore.lua b/lua/plugins/astrocore.lua new file mode 100644 index 0000000..c061409 --- /dev/null +++ b/lua/plugins/astrocore.lua @@ -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. + 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" }, + }, + + }, + }, +} diff --git a/lua/plugins/astrolsp.lua b/lua/plugins/astrolsp.lua new file mode 100644 index 0000000..c802b43 --- /dev/null +++ b/lua/plugins/astrolsp.lua @@ -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", + -- }, + -- ["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, + }, +} diff --git a/lua/plugins/astroui.lua b/lua/plugins/astroui.lua new file mode 100644 index 0000000..3262cb4 --- /dev/null +++ b/lua/plugins/astroui.lua @@ -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 = "⠏", + }, + }, +} diff --git a/lua/plugins/clangd_extensions.lua b/lua/plugins/clangd_extensions.lua new file mode 100644 index 0000000..12d63eb --- /dev/null +++ b/lua/plugins/clangd_extensions.lua @@ -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 +-- } +} diff --git a/lua/plugins/competitest.lua b/lua/plugins/competitest.lua new file mode 100644 index 0000000..9ab3435 --- /dev/null +++ b/lua/plugins/competitest.lua @@ -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 +} diff --git a/lua/plugins/core.lua b/lua/plugins/core.lua new file mode 100644 index 0000000..be1fc3e --- /dev/null +++ b/lua/plugins/core.lua @@ -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 + -- :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 = "" }) + -- end, + -- }, +} diff --git a/lua/plugins/diffview.lua b/lua/plugins/diffview.lua new file mode 100644 index 0000000..887c9c5 --- /dev/null +++ b/lua/plugins/diffview.lua @@ -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 = "D" + + utils.set_mappings { + n = { + [prefix] = { name = " Diff View" }, + [prefix .. ""] = { "DiffviewOpen", desc = "Open DiffView" }, + [prefix .. "h"] = { "DiffviewFileHistory %", desc = "Open DiffView File History" }, + [prefix .. "H"] = { "DiffviewFileHistory", 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"] = { "DiffviewClose", 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. + ["e"] = { actions.toggle_files, desc = "Toggle Explorer" }, -- Toggle the file panel. + ["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. + [""] = actions.next_entry, + [""] = actions.prev_entry, + [""] = actions.select_entry, -- Open the diff for the selected entry. + ["<2-LeftMouse>"] = actions.select_entry, + [""] = actions.scroll_view(-0.25), -- Scroll the view up + [""] = actions.scroll_view(0.25), -- Scroll the view down + [""] = actions.select_next_entry, + [""] = 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 + [""] = actions.next_entry, + [""] = actions.prev_entry, + [""] = actions.select_entry, + ["<2-LeftMouse>"] = actions.select_entry, + [""] = actions.open_in_diffview, -- Open the entry under the cursor in a diffview + [""] = actions.scroll_view(-0.25), + [""] = actions.scroll_view(0.25), + [""] = actions.select_next_entry, + [""] = actions.select_prev_entry, + }, + option_panel = { + q = actions.close, + o = actions.select_entry, + [""] = actions.select_entry, + ["<2-LeftMouse"] = actions.select_entry, + }, + }, + } + end, +} diff --git a/lua/plugins/editor.lua b/lua/plugins/editor.lua new file mode 100644 index 0000000..4b00746 --- /dev/null +++ b/lua/plugins/editor.lua @@ -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 = { + { "", mode = { "n", "v" } }, + { "", mode = { "n", "v" } }, + { "", mode = { "n", "v" } }, + { "", mode = { "n", "v" } }, + }, + opts = { + mappings = { + left = '', + right = '', + down = '', + up = '', + + line_down = '', + line_left = '', + line_right = '', + line_up = '', + } + }, + }, + { + "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", "" }, + cancel = "", + }, + }, + }, + { + "nvim-pack/nvim-spectre", + cmd = "Spectre", + opts = function() + local prefix = "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 }, + }, +} diff --git a/lua/plugins/heirline.lua b/lua/plugins/heirline.lua new file mode 100644 index 0000000..71955e0 --- /dev/null +++ b/lua/plugins/heirline.lua @@ -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, +} diff --git a/lua/plugins/info.lua b/lua/plugins/info.lua new file mode 100644 index 0000000..ba382ae --- /dev/null +++ b/lua/plugins/info.lua @@ -0,0 +1,4 @@ +return { + "HiPhish/info.vim", + lazy = false, +} diff --git a/lua/plugins/mason.lua b/lua/plugins/mason.lua new file mode 100644 index 0000000..00cbf78 --- /dev/null +++ b/lua/plugins/mason.lua @@ -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, + }, +} diff --git a/lua/plugins/neo-tree.lua b/lua/plugins/neo-tree.lua new file mode 100644 index 0000000..be22508 --- /dev/null +++ b/lua/plugins/neo-tree.lua @@ -0,0 +1,5 @@ +return { + "nvim-neo-tree/neo-tree.nvim", + dependencies = "nvim-lua/plenary.nvim", + lazy = false, +} diff --git a/lua/plugins/neoclip.lua b/lua/plugins/neoclip.lua new file mode 100644 index 0000000..f2b880e --- /dev/null +++ b/lua/plugins/neoclip.lua @@ -0,0 +1,7 @@ +return { + "matveyt/neoclip", + lazy = false, + config = function(plugin, opts) + require("neoclip"):setup() + end, +} diff --git a/lua/plugins/noice.lua b/lua/plugins/noice.lua new file mode 100644 index 0000000..95f618c --- /dev/null +++ b/lua/plugins/noice.lua @@ -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, +} diff --git a/lua/plugins/none-ls.lua b/lua/plugins/none-ls.lua new file mode 100644 index 0000000..382368d --- /dev/null +++ b/lua/plugins/none-ls.lua @@ -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, +} diff --git a/lua/plugins/nvim-cmp.lua b/lua/plugins/nvim-cmp.lua new file mode 100644 index 0000000..7405db1 --- /dev/null +++ b/lua/plugins/nvim-cmp.lua @@ -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 +} diff --git a/lua/plugins/repl.lua b/lua/plugins/repl.lua new file mode 100644 index 0000000..f2e334e --- /dev/null +++ b/lua/plugins/repl.lua @@ -0,0 +1,23 @@ +return { + { + "jupyter-vim/jupyter-vim", + ft = { "pyhon", "julia" }, + config = function() + require("astrocore").set_mappings { + n = { + ["J"] = { "JupyterConnect", desc = "Connect to Jupyter" }, + ["j"] = { "JupyterRunTextObj", desc = "Send to Jupyter" }, + }, + v = { + ["j"] = { "JupyterRunVisual", desc = "Send to Jupyter" }, + }, + } + end, + }, + { + "mtikekar/nvim-send-to-term", + init = function() vim.g.send_disable_mapping = true end, + keys = { "Send", "SendLine" }, + cmd = "SendHere", + }, +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..b7b80f3 --- /dev/null +++ b/lua/plugins/telescope.lua @@ -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 = { + [""] = hop.hop, + [""] = 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 = { + [""] = fb_actions.toggle_hidden, + }, + n = { + z = fb_actions.toggle_hidden, + }, + }, + }, + live_grep_args = { + auto_quoting = true, -- enable/disable auto-quoting + mappings = { -- extend mappings + i = { + [""] = lga_actions.quote_prompt(), + [""] = 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 = { [""] = 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, +} diff --git a/lua/plugins/toggleterm.lua b/lua/plugins/toggleterm.lua new file mode 100644 index 0000000..647910d --- /dev/null +++ b/lua/plugins/toggleterm.lua @@ -0,0 +1,6 @@ +return { + "akinsho/toggleterm.nvim", + opts = { + open_mapping = [[]], + }, +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 0000000..41d3c86 --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -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 + } +} diff --git a/lua/plugins/user.lua b/lua/plugins/user.lua new file mode 100644 index 0000000..acdbf63 --- /dev/null +++ b/lua/plugins/user.lua @@ -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, + -- }, +} diff --git a/lua/plugins/vim-s-asm.lua b/lua/plugins/vim-s-asm.lua new file mode 100644 index 0000000..2728000 --- /dev/null +++ b/lua/plugins/vim-s-asm.lua @@ -0,0 +1,7 @@ +return { + { + "akielaries/vim-s-asm", + lazy = false, + name = "vim-s-asm", + } +} diff --git a/lua/plugins/wiki.lua b/lua/plugins/wiki.lua new file mode 100644 index 0000000..b58b7fb --- /dev/null +++ b/lua/plugins/wiki.lua @@ -0,0 +1,4 @@ +return { + "lervag/wiki.vim", + lazy = false, +} diff --git a/lua/polish.lua b/lua/polish.lua new file mode 100644 index 0000000..14c38cd --- /dev/null +++ b/lua/polish.lua @@ -0,0 +1,18 @@ +if true then return end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE + +-- This will run last in the setup process and is a good place to configure +-- things like custom filetypes. This just pure lua so anything that doesn't +-- fit in the normal config locations above can go here + +-- Set up custom filetypes +vim.filetype.add { + extension = { + foo = "fooscript", + }, + filename = { + ["Foofile"] = "fooscript", + }, + pattern = { + ["~/%.config/foo/.*"] = "fooscript", + }, +} diff --git a/lua/utils.lua b/lua/utils.lua new file mode 100644 index 0000000..3c65cf3 --- /dev/null +++ b/lua/utils.lua @@ -0,0 +1,60 @@ +local M = {} + +function M.vim_opt_toggle(opt, on, off, name) + if on == nil then on = true end + if off == nil then off = false end + if not name then name = opt end + local is_off = vim.opt[opt]:get() == off + vim.opt[opt] = is_off and on or off + require("astrocore").notify(name .. " " .. (is_off and "Enabled" or "Disabled")) +end + +function M.async_run(cmd, on_finish) + local lines = { "" } + + local function on_event(_, data, event) + if (event == "stdout" or event == "stderr") and data then vim.list_extend(lines, data) end + + if event == "exit" then + vim.fn.setqflist({}, " ", { + title = table.concat(cmd, " "), + lines = lines, + efm = "%f:%l:%c: %t%n %m", + }) + if on_finish then on_finish() end + end + end + + vim.fn.jobstart(cmd, { + on_stdout = on_event, + on_stderr = on_event, + on_exit = on_event, + stdout_buffered = true, + stderr_buffered = true, + }) +end + +function M.toggle_qf() + local qf_exists = false + for _, win in pairs(vim.fn.getwininfo()) do + if win["quickfix"] == 1 then + qf_exists = true + break + end + end + if qf_exists then + vim.cmd.cclose() + elseif not vim.tbl_isempty(vim.fn.getqflist()) then + vim.cmd.copen() + end +end + +function M.better_search(key) + return function() + local searched, error = + pcall(vim.cmd.normal, { args = { (vim.v.count > 0 and vim.v.count or "") .. key }, bang = true }) + if not searched and type(error) == "string" then require("astrocore").notify(error, vim.log.levels.ERROR) end + end +end + +return M diff --git a/neovim.yml b/neovim.yml new file mode 100644 index 0000000..b9235ab --- /dev/null +++ b/neovim.yml @@ -0,0 +1,6 @@ +--- +base: lua51 + +globals: + vim: + any: true diff --git a/selene.toml b/selene.toml new file mode 100644 index 0000000..e7005c3 --- /dev/null +++ b/selene.toml @@ -0,0 +1,8 @@ +std = "neovim" + +[rules] +global_usage = "allow" +if_same_then_else = "allow" +incorrect_standard_library_use = "allow" +mixed_table = "allow" +multiple_statements = "allow" diff --git a/templates/template.c b/templates/template.c new file mode 100644 index 0000000..a3cc909 --- /dev/null +++ b/templates/template.c @@ -0,0 +1,13 @@ +#include +#include +#include + +#define ll long long +#define rep(i, lim) for (size_t i; i < lim; i++) + +int main() +{ + + + return 0; +} diff --git a/templates/template.cpp b/templates/template.cpp new file mode 100644 index 0000000..ad113a7 --- /dev/null +++ b/templates/template.cpp @@ -0,0 +1,76 @@ +#include + +using namespace std; + +#define V vector + +#define rmin(a, b) a = min(a, b) +#define rmax(a, b) a = max(a, b) + +#define rep(i, lim) for (size_t i = 0; i < (lim); i++) +#define nrep(i, s, lim) for (size_t i = s; i < (lim); i++) + +#define repv(i, v) for (auto &i : (v)) +#define fillv(v) for (auto &itr_ : (v)) { cin >> itr_; } +#define sortv(v) sort(v.begin(), v.end()) +#define all(v) (v).begin(), (v).end() + +using vi = vector; +using vvi = vector; +using vvvi = vector; +using vvvvi = vector; + +using ll = long long; + +using vl = vector; +using vvl = vector; +using vvvl = vector; +using vvvvl = vector; + +template +auto operator<<(ostream &os, const vector &vec)->ostream& { + os << vec[0]; + for (size_t i = 1; i < vec.size(); i++) { + os << ' ' << vec[i]; + } + os << '\n'; + return os; +} + +template +auto operator>>(istream &is, vector &vec)->istream& { + for (auto &i : vec) { + is >> i; + } + return is; +} + +template +auto operator<<(ostream &os, const vector> &vec)->ostream& { + for (auto &i : vec) { + os << i[0]; + for (size_t j = 1; j < i.size(); j++) { + os << ' ' << i[j]; + } + os << '\n'; + } + return os; +} + +template +auto operator>>(istream &is, vector> &vec)->istream& { + for (auto &i : vec) { + for (auto &j : i) { + is >> j; + } + } + return is; +} + +int main() +{ + ios::sync_with_stdio(false); + cin.tie(nullptr); + + +}