diff --git a/.github/workflows/lint_code.yml b/.github/workflows/lint_code.yml index 9e88fa59e..71d11c5e2 100644 --- a/.github/workflows/lint_code.yml +++ b/.github/workflows/lint_code.yml @@ -8,4 +8,4 @@ jobs: - uses: actions/checkout@v4 - uses: lunarmodules/luacheck@v1 with: - args: . --std luajit --globals vim _toggle_lazygit _buf_vtext _command_panel _flash_esc_or_noh _debugging --max-line-length 150 --no-config + args: . --std luajit --globals vim _debugging _command_panel _flash_esc_or_noh _telescope_collections _toggle_lazygit --max-line-length 150 --no-config diff --git a/.github/workflows/update_flake.yml b/.github/workflows/update_flake.yml index 88090f3b7..9d9e31c51 100644 --- a/.github/workflows/update_flake.yml +++ b/.github/workflows/update_flake.yml @@ -11,8 +11,6 @@ jobs: contents: write steps: - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Required to count the commits - uses: cachix/install-nix-action@v26 with: nix_path: nixpkgs=channel:nixos-unstable diff --git a/LICENSE b/LICENSE index 0203a8bed..33895b644 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,30 @@ -MIT License +BSD 3-Clause License Copyright (c) 2021 ayamir +Copyright (c) 2022 Jint-lzxy, CharlesChiuGit +Copyright (c) 2023 aarnphm, misumisumi -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md index c8c20d666..f4af58f74 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ Chinese introduction is [here](https://zhuanlan.zhihu.com/p/382092667). ### 🎐 Features -- **Fast.** Less than **30ms** to start (Depends on SSD and CPU, tested on Zephyrus G14 2022 version). +- **Fast.** Less than **50ms** to start (Depends on SSD and CPU, tested on Zephyrus G14 2022 version). - **Simple.** Runs out of the box. - **Modern.** Pure `lua` config. - **Modular.** Easy to customize. @@ -197,6 +197,8 @@ It's strongly recommended to read [Wiki: Prerequisites](https://github.com/ayami - [ayamir](https://github.com/ayamir) - [Jint-lzxy](https://github.com/Jint-lzxy) - [CharlesChiuGit](https://github.com/CharlesChiuGit) +- [aarnphm](https://github.com/aarnphm) +- [misumisumi](https://github.com/misumisumi) ## 🎉 Acknowledgement @@ -204,7 +206,7 @@ It's strongly recommended to read [Wiki: Prerequisites](https://github.com/ayami ## 📜 License -This Neovim configuration is released under the MIT license, which grants the following permissions: +This Neovim configuration is released under the BSD 3-Clause license, which grants the following permissions: - Commercial use - Distribution diff --git a/flake.lock b/flake.lock index ef96466e1..444568f60 100644 --- a/flake.lock +++ b/flake.lock @@ -2,15 +2,14 @@ "nodes": { "devshell": { "inputs": { - "flake-utils": "flake-utils", "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1713532798, - "narHash": "sha256-wtBhsdMJA3Wa32Wtm1eeo84GejtI43pMrFrmwLXrsEc=", + "lastModified": 1722113426, + "narHash": "sha256-Yo/3loq572A8Su6aY5GP56knpuKYRvM2a1meP9oJZCw=", "owner": "numtide", "repo": "devshell", - "rev": "12e914740a25ea1891ec619bb53cf5e6ca922e40", + "rev": "67cce7359e4cd3c45296fb4aaf6a19e2a9c757ae", "type": "github" }, "original": { @@ -24,11 +23,11 @@ "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1715865404, - "narHash": "sha256-/GJvTdTpuDjNn84j82cU6bXztE0MSkdnTWClUCRub78=", + "lastModified": 1725024810, + "narHash": "sha256-ODYRm8zHfLTH3soTFWE452ydPYz2iTvr9T8ftDMUQ3E=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "8dc45382d5206bd292f9c2768b8058a8fd8311d9", + "rev": "af510d4a62d071ea13925ce41c95e3dec816c01d", "type": "github" }, "original": { @@ -37,24 +36,6 @@ "type": "github" } }, - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1701680307, - "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "home-manager": { "inputs": { "nixpkgs": [ @@ -62,11 +43,11 @@ ] }, "locked": { - "lastModified": 1717097707, - "narHash": "sha256-HC5vJ3oYsjwsCaSbkIPv80e4ebJpNvFKQTBOGlHvjLs=", + "lastModified": 1724435763, + "narHash": "sha256-UNky3lJNGQtUEXT2OY8gMxejakSWPTfWKvpFkpFlAfM=", "owner": "nix-community", "repo": "home-manager", - "rev": "0eb314b4f0ba337e88123e0b1e57ef58346aafd9", + "rev": "c2cd2a52e02f1dfa1c88f95abeb89298d46023be", "type": "github" }, "original": { @@ -77,11 +58,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1704161960, - "narHash": "sha256-QGua89Pmq+FBAro8NriTuoO/wNaUtugt29/qqA8zeeM=", + "lastModified": 1722073938, + "narHash": "sha256-OpX0StkL8vpXyWOGUD6G+MA26wAXK6SpT94kLJXo6B4=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "63143ac2c9186be6d9da6035fa22620018c85932", + "rev": "e36e9f57337d0ff0cf77aceb58af4c805472bfae", "type": "github" }, "original": { @@ -93,23 +74,23 @@ }, "nixpkgs-lib": { "locked": { - "lastModified": 1714640452, - "narHash": "sha256-QBx10+k6JWz6u7VsohfSw8g8hjdBZEf8CFzXH1/1Z94=", + "lastModified": 1722555339, + "narHash": "sha256-uFf2QeW7eAHlYXuDktm9c25OxOyCoUOQmh5SZ9amE5Q=", "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/50eb7ecf4cd0a5756d7275c8ba36790e5bd53e33.tar.gz" + "url": "https://github.com/NixOS/nixpkgs/archive/a5d394176e64ab29c852d03346c1fc9b0b7d33eb.tar.gz" }, "original": { "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/50eb7ecf4cd0a5756d7275c8ba36790e5bd53e33.tar.gz" + "url": "https://github.com/NixOS/nixpkgs/archive/a5d394176e64ab29c852d03346c1fc9b0b7d33eb.tar.gz" } }, "nixpkgs_2": { "locked": { - "lastModified": 1717112898, - "narHash": "sha256-7R2ZvOnvd9h8fDd65p0JnB7wXfUvreox3xFdYWd1BnY=", + "lastModified": 1725099143, + "narHash": "sha256-CHgumPZaC7z+WYx72WgaLt2XF0yUVzJS60rO4GZ7ytY=", "owner": "nixos", "repo": "nixpkgs", - "rev": "6132b0f6e344ce2fe34fc051b72fb46e34f668e0", + "rev": "5629520edecb69630a3f4d17d3d33fc96c13f6fe", "type": "github" }, "original": { @@ -126,21 +107,6 @@ "home-manager": "home-manager", "nixpkgs": "nixpkgs_2" } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index f24cfc588..9dd3840c7 100644 --- a/flake.nix +++ b/flake.nix @@ -33,21 +33,21 @@ name = "check-linker"; text = let - ldd_cmd = if pkgs.stdenv.isDarwin then "otool -L" else "${pkgs.glibc.bin}/bin/ldd"; + ldd_cmd = if pkgs.stdenv.isDarwin then "xcrun otool -L" else "${pkgs.glibc.bin}/bin/ldd"; in '' #shellcheck disable=SC1090 - source <(sed -ne :1 -e 'N;1,1b1' -e 'P;D' "${self.packages.${system}.testEnv}/home-path/bin/nvim") - echo "check file under ''${XDG_DATA_HOME}/''${NVIM_APPNAME:-nvim}/mason/bin" + source <(sed -ne :1 -e 'N;1,1b1' -e 'P;D' "${self.packages.${system}.testEnv}/home-path/bin/nvim") + echo "Checking files under ''${XDG_DATA_HOME}/''${NVIM_APPNAME:-nvim}/mason/bin..." find "''${XDG_DATA_HOME}/''${NVIM_APPNAME:-nvim}/mason/bin" -type l | while read -r link; do "${ldd_cmd}" "$(readlink -f "$link")" > /dev/zero 2>&1 || continue linkers=$("${ldd_cmd}" "$(readlink -f "$link")" | tail -n+2) echo "$linkers" | while read -r line; do [ -z "$line" ] && continue - echo "$line" | grep -q "/nix/store" || printf '%s: %s do not link to /nix/store \n' "$(basename "$link")" "$line" + echo "$line" | grep -q "/nix/store" || printf '%s: %s does not link to /nix/store \n' "$(basename "$link")" "$line" done done - echo "check done" + echo "*** Done ***" ''; }; }; @@ -69,7 +69,7 @@ motd = '' {202}🔨 Welcome to devshell{reset} Symlink configs to "''${XDG_CONFIG_HOME}"/nvimdots! - And NVIM_APPNAME=nvimdots is already configured, so neovim will put file under "\$XDG_xxx_HOME"/nvimdots. + And NVIM_APPNAME=nvimdots is already configured, so neovim will put files under "\$XDG_xxx_HOME"/nvimdots. To uninstall, remove "\$XDG_xxx_HOME"/nvimdots. $(type -p menu &>/dev/null && menu) diff --git a/lazy-lock.json b/lazy-lock.json index 70298a7f3..8ddb5fc7d 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,12 +1,13 @@ { "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, - "LuaSnip": { "branch": "master", "commit": "50fcf17db7c75af80e6b6109acfbfb4504768780" }, - "aerial.nvim": { "branch": "master", "commit": "75de06f8edbd0006997a19b760045753d4f6693c" }, - "alpha-nvim": { "branch": "main", "commit": "41283fb402713fc8b327e60907f74e46166f4cfd" }, - "autoclose.nvim": { "branch": "main", "commit": "dc42806540dcf448ecb2bad6b67204410cfbe629" }, + "LuaSnip": { "branch": "master", "commit": "e808bee352d1a6fcf902ca1a71cee76e60e24071" }, + "advanced-git-search.nvim": { "branch": "main", "commit": "1c5a10f5c838cfad2c17d7464311d6fb416cb319" }, + "aerial.nvim": { "branch": "master", "commit": "140f48fb068d21c02e753c63f7443649e55576f0" }, + "alpha-nvim": { "branch": "main", "commit": "b6f4129302db197a7249e67a90de3f2b676de13e" }, + "autoclose.nvim": { "branch": "main", "commit": "b2077aa2c83df7ebc19b2a20a3a0654b24ae9c8f" }, "bigfile.nvim": { "branch": "main", "commit": "33eb067e3d7029ac77e081cfe7c45361887a311a" }, - "bufferline.nvim": { "branch": "main", "commit": "99337f63f0a3c3ab9519f3d1da7618ca4f91cffe" }, - "catppuccin": { "branch": "refactor/syntax-highlighting", "commit": "e34171a3273e6a2c881f28ae36b8b37a2c84f196" }, + "bufferline.nvim": { "branch": "main", "commit": "0b2fd861eee7595015b6561dade52fb060be10c4" }, + "catppuccin": { "branch": "refactor/syntax-highlighting", "commit": "4ba8c8bd0c6076773dea6e3831d36fc2e40576fc" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-latex-symbols": { "branch": "main", "commit": "165fb66afdbd016eaa1570e41672c4c557b57124" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, @@ -18,88 +19,90 @@ "cmp-treesitter": { "branch": "master", "commit": "c8e3a74b51597d69d240085a258636972ce98e15" }, "cmp-under-comparator": { "branch": "master", "commit": "6857f10272c3cfe930cece2afa2406e1385bfef8" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, - "copilot-cmp": { "branch": "master", "commit": "72fbaa03695779f8349be3ac54fa8bd77eed3ee3" }, - "copilot.lua": { "branch": "master", "commit": "f7612f5af4a7d7615babf43ab1e67a2d790c13a6" }, - "crates.nvim": { "branch": "main", "commit": "3ab99ade2c9a9d4291a8424c03db9a3be9862a72" }, - "csv.vim": { "branch": "master", "commit": "4d5255829afe3b6badb0c8a040116704c0d3213c" }, - "diffview.nvim": { "branch": "main", "commit": "3afa6a053f680e9f1329c4a151db988a482306cd" }, - "dropbar.nvim": { "branch": "master", "commit": "2b546383bdf4daa254ac70c760ee1e5524bc60b1" }, - "fidget.nvim": { "branch": "main", "commit": "ef99df04a1c53a453602421bc0f756997edc8289" }, - "flash.nvim": { "branch": "main", "commit": "43f67935d388fbb540f8b40e8cbfd80de54f978a" }, - "focus.nvim": { "branch": "master", "commit": "948b32e35f54b6900632312d51a1706fabdc12b8" }, - "friendly-snippets": { "branch": "main", "commit": "700c4a25caacbb4648c9a27972c2fe203948e0c2" }, - "fzf": { "branch": "master", "commit": "e023736c30e789073211ec5b3d49af860c3c3562" }, + "crates.nvim": { "branch": "main", "commit": "5a24e3ba60e28e0cfde540696630b3c5a4db6dfd" }, + "csv.vim": { "branch": "master", "commit": "bddfcbadd788ab11eb3dbba4550a38a412fe3705" }, + "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, + "dropbar.nvim": { "branch": "master", "commit": "cc9e637cc7e43214cd3c8a9c2d38ce19089d2fb3" }, + "fidget.nvim": { "branch": "main", "commit": "d855eed8a06531a7e8fd0684889b2943f373c469" }, + "flash.nvim": { "branch": "main", "commit": "34c7be146a91fec3555c33fe89c7d643f6ef5cf1" }, + "focus.nvim": { "branch": "master", "commit": "3841a38df972534567e85840d7ead20d3a26faa6" }, + "friendly-snippets": { "branch": "main", "commit": "ff09e074e2af424f0190081bb3f8d1db2881e80b" }, + "fzf": { "branch": "master", "commit": "855f90727af7827d9934b7fa00ea5ed51f5e4e81" }, "fzy-lua-native": { "branch": "master", "commit": "820f745b7c442176bcc243e8f38ef4b985febfaf" }, - "gitsigns.nvim": { "branch": "main", "commit": "de18f6b749f6129eb9042a2038590872df4c94a9" }, - "glance.nvim": { "branch": "master", "commit": "51059bcf21016387b6233c89eed220cf47fca752" }, - "hop.nvim": { "branch": "master", "commit": "036462a345792279c58f2f6445756efab706f04a" }, - "indent-blankline.nvim": { "branch": "master", "commit": "d98f537c3492e87b6dc6c2e3f66ac517528f406f" }, - "knap": { "branch": "main", "commit": "00e94c10b5b969b2aca791f1b2d36ad77c89a252" }, - "lazy.nvim": { "branch": "main", "commit": "eb4957442e3182f051b0ae11da32e06d22c190e3" }, + "gitsigns.nvim": { "branch": "main", "commit": "0b04035bb7b3c83e999b9676e2fb46fd0aa9f910" }, + "glance.nvim": { "branch": "master", "commit": "cdf1ec8136cfbdf73edbe1163097223c763a84b7" }, + "hop.nvim": { "branch": "master", "commit": "8f51ef02700bb3cdcce94e92eff16170a6343c4f" }, + "indent-blankline.nvim": { "branch": "master", "commit": "18603eb949eba08300799f64027af11ef922283f" }, + "knap": { "branch": "main", "commit": "0040760bb504a713ea5988c7c490a15faf477c57" }, + "lazy.nvim": { "branch": "main", "commit": "460e1cd8f24e364d54543a4b0e83f6f4ec1f65fb" }, "local-highlight.nvim": { "branch": "master", "commit": "ae3ada3a332128b1036c84c8587b9069891c63da" }, "lsp-format-modifications.nvim": { "branch": "main", "commit": "006d4cd88f4f09fdc4375fcb75dd5b7d981a723b" }, - "lspsaga.nvim": { "branch": "main", "commit": "6f920cfabddb9b7de5a3a4d0b7cd4f0774ae23e2" }, - "lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" }, + "lspsaga.nvim": { "branch": "main", "commit": "e64351d0e6335eadf089aa2b9f17221e54ca10a4" }, + "lualine.nvim": { "branch": "master", "commit": "b431d228b7bbcdaea818bdc3e25b8cdbe861f056" }, "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "37a336b653f8594df75c827ed589f1c91d91ff6c" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "25c11854aa25558ee6c03432edfa0df0217324be" }, "mason-null-ls.nvim": { "branch": "main", "commit": "de19726de7260c68d94691afb057fa73d3cc53e7" }, - "mason-nvim-dap.nvim": { "branch": "main", "commit": "f5425eb1d0d794f0305d5eeebddabb74614683ff" }, - "mason.nvim": { "branch": "main", "commit": "0950b15060067f752fde13a779a994f59516ce3d" }, - "mini.align": { "branch": "main", "commit": "68a8d3205f0e7ce1bded057f4a851f42ef8fc584" }, - "neoconf.nvim": { "branch": "main", "commit": "7b3e819a713ee7d289e07727ab98761e1bceb895" }, - "neodim": { "branch": "master", "commit": "0543414f1205d8937d8e703a73ae1f9948940b14" }, - "neoscroll.nvim": { "branch": "master", "commit": "a731f66f1d39ec6175fd201c5bf849e54abda99c" }, - "none-ls.nvim": { "branch": "main", "commit": "8691504118b252d64fc5023a104aedd100ab754a" }, + "mason-nvim-dap.nvim": { "branch": "main", "commit": "8b9363d83b5d779813cdd2819b8308651cec2a09" }, + "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, + "mini.align": { "branch": "main", "commit": "26111a737494bc39576ad67b52bbc2638ca23553" }, + "neoconf.nvim": { "branch": "main", "commit": "61b10cd334dc8f693e391c5ef8c5832093a46cf5" }, + "neodim": { "branch": "master", "commit": "d87470828690342d0139efc2fd56ea0b29e9ecb3" }, + "neoscroll.nvim": { "branch": "master", "commit": "4e0428a41c6ec191df543fc95349f6e1c598e53f" }, + "none-ls.nvim": { "branch": "main", "commit": "9b98991e15dce8fc502993e23caac2528b8b667f" }, "nvim-bqf": { "branch": "main", "commit": "1b24dc6050c34e8cd377b6b4cd6abe40509e0187" }, "nvim-bufdel": { "branch": "main", "commit": "523d58e94e7212fff3e05c247b962dc8f93bcfde" }, - "nvim-cmp": { "branch": "main", "commit": "a110e12d0b58eefcf5b771f533fc2cf3050680ac" }, - "nvim-colorizer.lua": { "branch": "master", "commit": "85855b38011114929f4058efc97af1059ab3e41d" }, - "nvim-dap": { "branch": "master", "commit": "6f79b822997f2e8a789c6034e147d42bc6706770" }, - "nvim-dap-ui": { "branch": "master", "commit": "b7267003ba4dd860350be86f75b9d9ea287cedca" }, - "nvim-lspconfig": { "branch": "master", "commit": "4d38bece98300e3e5cd24a9aa0d0ebfea4951c16" }, - "nvim-nio": { "branch": "master", "commit": "7969e0a8ffabdf210edd7978ec954a47a737bbcc" }, - "nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" }, - "nvim-scrollview": { "branch": "main", "commit": "af4a83c4e539313255de2589b61fe25c8fe396d8" }, - "nvim-spectre": { "branch": "master", "commit": "ec67d4b5370094b923dfcf6b09b39142f2964861" }, - "nvim-tree.lua": { "branch": "master", "commit": "2086e564c4d23fea714e8a6d63b881e551af2f41" }, + "nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" }, + "nvim-dap": { "branch": "master", "commit": "90616ae6ae40053103dc66872886fc26b94c70c8" }, + "nvim-dap-ui": { "branch": "master", "commit": "1c351e4e417d4691da12948b6ecf966936a56d28" }, + "nvim-highlight-colors": { "branch": "main", "commit": "a411550ef85cae467b889ba7d1a96bd78332d90e" }, + "nvim-lspconfig": { "branch": "master", "commit": "f4fef355efa3c5d0813512480ee7b2c050b09fe4" }, + "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, + "nvim-notify": { "branch": "master", "commit": "fbef5d32be8466dd76544a257d3f3dce20082a07" }, + "nvim-scrollview": { "branch": "main", "commit": "401c0498689dcaa54b2e7483d823e33cdc051e72" }, + "nvim-spectre": { "branch": "master", "commit": "ba7fb777edff6c1fbbeffd343e113af64c04e90a" }, + "nvim-surround": { "branch": "main", "commit": "ec2dc7671067e0086cdf29c2f5df2dd909d5f71f" }, + "nvim-tree.lua": { "branch": "master", "commit": "8405ecfbd6bb08a94ffc9c68fef211eea56e8a3b" }, "nvim-treehopper": { "branch": "master", "commit": "13559079e33665a310d9ccf0e43f4e9bb9f337e2" }, - "nvim-treesitter": { "branch": "master", "commit": "26171d8f105d97746371d1b6c07c8d88bf13fec2" }, - "nvim-treesitter-context": { "branch": "master", "commit": "5efba33af0f39942e426340da7bc15d7dec16474" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "34867c69838078df7d6919b130c0541c0b400c47" }, - "nvim-ts-autotag": { "branch": "main", "commit": "06fe07d7523ba8c755fac7c913fceba43b1720ee" }, - "nvim-ts-context-commentstring": { "branch": "main", "commit": "cb064386e667def1d241317deed9fd1b38f0dc2e" }, - "nvim-web-devicons": { "branch": "master", "commit": "c0cfc1738361b5da1cd0a962dd6f774cc444f856" }, - "obsidian.nvim": { "branch": "main", "commit": "c6bd6d93e4724ac2dc0cae73ebe1d568bf406537" }, - "paint.nvim": { "branch": "main", "commit": "6ce64212804f425073c61ab0d9c2b034f0435260" }, - "persisted.nvim": { "branch": "main", "commit": "e50e0b65b06298a7b937a3d42550a4bc27d13ce7" }, - "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" }, + "nvim-treesitter": { "branch": "master", "commit": "20b5cbfa92cac93ab78f3fefeb6169e4ea303189" }, + "nvim-treesitter-context": { "branch": "master", "commit": "3d5390c49e3f8fe457b376df2a49aa39d75b7911" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "bf8d2ad35d1d1a687eae6c065c3d524f7ab61b23" }, + "nvim-ts-autotag": { "branch": "main", "commit": "e239a560f338be31337e7abc3ee42515daf23f5e" }, + "nvim-ts-context-commentstring": { "branch": "main", "commit": "375c2d86cee6674afd75b4f727ce3a80065552f7" }, + "nvim-web-devicons": { "branch": "master", "commit": "26220156aafb198b2de6a4cf80c1b120a3768da0" }, + "obsidian.nvim": { "branch": "main", "commit": "14e0427bef6c55da0d63f9a313fd9941be3a2479" }, + "paint.nvim": { "branch": "main", "commit": "ef6f717a8669619ebbd098fb72f85115d64c6c92" }, + "persisted.nvim": { "branch": "main", "commit": "3006e641e2892b58fe51511c31595515e1a7dc00" }, + "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, "project.nvim": { "branch": "main", "commit": "8c6bad7d22eef1b71144b401c9f74ed01526a4fb" }, - "rainbow-delimiters.nvim": { "branch": "master", "commit": "073e45546acaff6b4248e3faea8e67b399d3e864" }, - "rustaceanvim": { "branch": "master", "commit": "2fa45427c01ded4d3ecca72e357f8a60fd8e46d4" }, - "smart-splits.nvim": { "branch": "master", "commit": "d99162711fa619595b8cb0e1f0981e3d301debc9" }, + "rainbow-delimiters.nvim": { "branch": "master", "commit": "5f73b24aeb94f5274c218955573153c69ce4d1ee" }, + "render-markdown.nvim": { "branch": "main", "commit": "f187721a5381f4443ef97ad1a7c0681a65511d28" }, + "rustaceanvim": { "branch": "master", "commit": "6511cb09310972f07c859836e5051e7434a19fc7" }, + "search.nvim": { "branch": "main", "commit": "7b8f2315d031be73e14bc2d82386dfac15952614" }, + "smart-splits.nvim": { "branch": "master", "commit": "3737faa521d12a0c77d0d28bb15ad903a9e8cfe0" }, "smartyank.nvim": { "branch": "master", "commit": "d9e078fe08d6466e37ea45ac446a9f60e6866789" }, - "sniprun": { "branch": "master", "commit": "1420cff041a0582636f63960d7160f7832463c10" }, + "sniprun": { "branch": "master", "commit": "c9f0a37736a90997a3868735ede0d33e49f79182" }, "suda.vim": { "branch": "master", "commit": "b97fab52f9cdeabe2bbb5eb98d82356899f30829" }, "telescope-bibtex.nvim": { "branch": "master", "commit": "289a6f86ebec06e8ae1590533b732b9981d84900" }, - "telescope-frecency.nvim": { "branch": "master", "commit": "1f2e9b07ac7f927f36c17313071cc12759670767" }, - "telescope-fzf-native.nvim": { "branch": "main", "commit": "9ef21b2e6bb6ebeaf349a0781745549bbb870d27" }, - "telescope-live-grep-args.nvim": { "branch": "master", "commit": "8ad632f793fd437865f99af5684f78300dac93fb" }, - "telescope-undo.nvim": { "branch": "main", "commit": "95b61c01ea3a4c9e8747731148e905bbcf0ccaee" }, - "telescope-zoxide": { "branch": "main", "commit": "68966349aa1b8e9ade403e18479ecf79447389a7" }, - "telescope.nvim": { "branch": "master", "commit": "f12b15e1b3a33524eb06a1ae7bc852fb1fd92197" }, - "todo-comments.nvim": { "branch": "main", "commit": "51e10f838e84b4756c16311d0b1ef0972c6482d2" }, - "toggleterm.nvim": { "branch": "main", "commit": "fee58a0473fd92b28c34f8f724e4918b15ba30a3" }, - "trouble.nvim": { "branch": "main", "commit": "60b0ac3772e991bc194207afc28368a5f15d913a" }, + "telescope-frecency.nvim": { "branch": "master", "commit": "f67baca08423a6fd00167801a54db38e0b878063" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" }, + "telescope-live-grep-args.nvim": { "branch": "master", "commit": "649b662a8f476fd2c0289570764459e95ebaa3f3" }, + "telescope-undo.nvim": { "branch": "main", "commit": "51be9ae7c42fc27c0b05505e3a0162e0f05fbb6a" }, + "telescope-zoxide": { "branch": "main", "commit": "54bfe630bad08dc9891ec78c7cf8db38dd725c97" }, + "telescope.nvim": { "branch": "master", "commit": "b324469959908c1c7434eb65d80e87895e6828f7" }, + "todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" }, + "toggleterm.nvim": { "branch": "main", "commit": "137d06fb103952a0fb567882bb8527e2f92d327d" }, + "trouble.nvim": { "branch": "main", "commit": "6efc446226679fda0547c0fd6a7892fd5f5b15d8" }, "typst-preview.nvim": { "branch": "master", "commit": "5867db936576741f378b558a9d7428b928819df5" }, - "typst.vim": { "branch": "main", "commit": "d9a7650e76c85f8ba437e056d08dd43b01b8bfd6" }, + "typst.vim": { "branch": "main", "commit": "4d18ced62599ffe5b3c0e5e49566d5456121bc02" }, "vim-cool": { "branch": "master", "commit": "662e7b11064cbeedad17c45d2fe926e78d3cd0b6" }, - "vim-fugitive": { "branch": "master", "commit": "64d6cafb9dcbacce18c26d7daf617ebb96b273f3" }, - "vim-matchup": { "branch": "master", "commit": "1535a769d5dca851fe7d41b0be95f7c7203a4bef" }, + "vim-fugitive": { "branch": "master", "commit": "d4877e54cef67f5af4f950935b1ade19ed6b7370" }, + "vim-matchup": { "branch": "master", "commit": "1975afe63198ab6a0dff7200919828e5cd4330b9" }, "vim-pencil": { "branch": "master", "commit": "6d70438a8886eaf933c38a7a43a61adb0a7815ed" }, - "vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" }, - "vimtex": { "branch": "master", "commit": "0587a064f675fd85cdfb8a76d6a3ff698af3944b" }, - "which-key.nvim": { "branch": "main", "commit": "0099511294f16b81c696004fa6a403b0ae61f7a0" }, + "vim-rhubarb": { "branch": "master", "commit": "ee69335de176d9325267b0fd2597a22901d927b1" }, + "vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }, + "vimtex": { "branch": "master", "commit": "a61db58f39b7ef3060bc9c60bbc813436f414bac" }, + "which-key.nvim": { "branch": "main", "commit": "fb070344402cfc662299d9914f5546d840a22126" }, "wilder.nvim": { "branch": "master", "commit": "679f348dc90d80ff9ba0e7c470c40a4d038dcecf" }, - "wrapping.nvim": { "branch": "master", "commit": "3a823200c297885b70515fa8d974e1763c578e26" }, - "zen-mode.nvim": { "branch": "main", "commit": "78557d972b4bfbb7488e17b5703d25164ae64e6a" } -} \ No newline at end of file + "wrapping.nvim": { "branch": "master", "commit": "a5210c29be19ed736eb3333677e08a57efebce78" }, + "zen-mode.nvim": { "branch": "main", "commit": "29b292bdc58b76a6c8f294c961a8bf92c5a6ebd6" } +} diff --git a/lua/core/event.lua b/lua/core/event.lua index f9460dfe6..0d70cc169 100644 --- a/lua/core/event.lua +++ b/lua/core/event.lua @@ -3,7 +3,8 @@ local autocmd = {} function autocmd.nvim_create_augroups(definitions) for group_name, definition in pairs(definitions) do - vim.api.nvim_command("augroup " .. group_name) + -- Prepend an underscore to avoid name clashes + vim.api.nvim_command("augroup _" .. group_name) vim.api.nvim_command("autocmd!") for _, def in ipairs(definition) do local command = table.concat(vim.iter({ "autocmd", def }):flatten(math.huge):totable(), " ") @@ -68,7 +69,7 @@ vim.api.nvim_create_autocmd("FileType", { }, callback = function(event) vim.bo[event.buf].buflisted = false - vim.api.nvim_buf_set_keymap(event.buf, "n", "q", "close", { silent = true }) + vim.api.nvim_buf_set_keymap(event.buf, "n", "q", "close", { silent = true }) end, }) diff --git a/lua/core/global.lua b/lua/core/global.lua index 523fd78d9..0f01edc16 100644 --- a/lua/core/global.lua +++ b/lua/core/global.lua @@ -7,12 +7,10 @@ function global:load_variables() self.is_windows = os_name == "Windows_NT" self.is_wsl = vim.fn.has("wsl") == 1 self.vim_path = vim.fn.stdpath("config") - local path_sep = self.is_windows and "\\" or "/" - local home = self.is_windows and os.getenv("USERPROFILE") or os.getenv("HOME") - self.cache_dir = home .. path_sep .. ".cache" .. path_sep .. "nvim" .. path_sep - self.modules_dir = self.vim_path .. path_sep .. "modules" - self.home = home + self.cache_dir = vim.fn.stdpath("cache") self.data_dir = string.format("%s/site/", vim.fn.stdpath("data")) + self.modules_dir = self.vim_path .. "/modules" + self.home = self.is_windows and os.getenv("USERPROFILE") or os.getenv("HOME") end global:load_variables() diff --git a/lua/core/init.lua b/lua/core/init.lua index 7a9edd25a..7c92a2a35 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -3,76 +3,25 @@ local global = require("core.global") -- Create cache dir and data dirs local createdir = function() - local data_dir = { - global.cache_dir .. "backup", - global.cache_dir .. "session", - global.cache_dir .. "swap", - global.cache_dir .. "tags", - global.cache_dir .. "undo", + local data_dirs = { + global.cache_dir .. "/backup", + global.cache_dir .. "/session", + global.cache_dir .. "/swap", + global.cache_dir .. "/tags", + global.cache_dir .. "/undo", } -- Only check whether cache_dir exists, this would be enough. if vim.fn.isdirectory(global.cache_dir) == 0 then - os.execute("mkdir -p " .. global.cache_dir) - for _, v in pairs(data_dir) do - if vim.fn.isdirectory(v) == 0 then - os.execute("mkdir -p " .. v) + ---@diagnostic disable-next-line: param-type-mismatch + vim.fn.mkdir(global.cache_dir, "p") + for _, dir in pairs(data_dirs) do + if vim.fn.isdirectory(dir) == 0 then + vim.fn.mkdir(dir, "p") end end end end -local disable_distribution_plugins = function() - -- Disable menu loading - vim.g.did_install_default_menus = 1 - vim.g.did_install_syntax_menu = 1 - - -- Comment this if you define your own filetypes in `after/ftplugin` - -- vim.g.did_load_filetypes = 1 - - -- Do not load native syntax completion - vim.g.loaded_syntax_completion = 1 - - -- Do not load spell files - vim.g.loaded_spellfile_plugin = 1 - - -- Whether to load netrw by default - -- vim.g.loaded_netrw = 1 - -- vim.g.loaded_netrwFileHandlers = 1 - -- vim.g.loaded_netrwPlugin = 1 - -- vim.g.loaded_netrwSettings = 1 - -- newtrw liststyle: https://medium.com/usevim/the-netrw-style-options-3ebe91d42456 - vim.g.netrw_liststyle = 3 - - -- Do not load tohtml.vim - vim.g.loaded_2html_plugin = 1 - - -- Do not load zipPlugin.vim, gzip.vim and tarPlugin.vim (all of these plugins are - -- related to reading files inside compressed containers) - vim.g.loaded_gzip = 1 - vim.g.loaded_tar = 1 - vim.g.loaded_tarPlugin = 1 - vim.g.loaded_vimball = 1 - vim.g.loaded_vimballPlugin = 1 - vim.g.loaded_zip = 1 - vim.g.loaded_zipPlugin = 1 - - -- Do not use builtin matchit.vim and matchparen.vim because we're using vim-matchup - vim.g.loaded_matchit = 1 - vim.g.loaded_matchparen = 1 - - -- Disable sql omni completion - vim.g.loaded_sql_completion = 1 - - -- Set this to 0 in order to disable native EditorConfig support - vim.g.editorconfig = 1 - - -- Disable remote plugins - -- NOTE: - -- > Disabling rplugin.vim will make `wilder.nvim` complain about missing rplugins during :checkhealth, - -- > but since it's config doesn't require python rtp (strictly), it's fine to ignore that for now. - -- vim.g.loaded_remote_plugins = 1 -end - local leader_map = function() vim.g.mapleader = " " -- NOTE: @@ -148,7 +97,6 @@ end local load_core = function() createdir() - disable_distribution_plugins() leader_map() gui_config() @@ -162,12 +110,8 @@ local load_core = function() require("core.pack") require("keymap") - local colorscheme = settings.colorscheme - local background = settings.background - vim.api.nvim_command("set background=" .. background) - vim.api.nvim_command("colorscheme " .. colorscheme) - vim.api.nvim_command("set modelines=" .. 0) - vim.api.nvim_command("hi SpellBad cterm=underline guifg=red") + vim.api.nvim_set_option_value("background", settings.background, {}) + vim.cmd.colorscheme(settings.colorscheme) end load_core() diff --git a/lua/core/mapping.lua b/lua/core/mapping.lua index cb0c061de..351216925 100644 --- a/lua/core/mapping.lua +++ b/lua/core/mapping.lua @@ -34,6 +34,7 @@ local core_map = { ["n|"] = map_cr("wq"):with_desc("edit: Save file and quit"), ["n|"] = map_cr("q!"):with_desc("edit: Force quit"), ["n|o"] = map_cr("setlocal spell! spelllang=en_us"):with_desc("edit: Toggle spell check"), + ["n|bn"] = map_cu("enew"):with_noremap():with_silent():with_desc("buffer: New"), ["n|tn"] = map_cr("tabnew"):with_noremap():with_silent():with_desc("tab: Create a new tab"), ["n|tk"] = map_cr("tabnext"):with_noremap():with_silent():with_desc("tab: Move to next tab"), ["n|tj"] = map_cr("tabprevious"):with_noremap():with_silent():with_desc("tab: Move to previous tab"), diff --git a/lua/core/options.lua b/lua/core/options.lua index 6b9208606..d814faa14 100644 --- a/lua/core/options.lua +++ b/lua/core/options.lua @@ -2,10 +2,10 @@ local global = require("core.global") local function load_options() local global_local = { - -- backupdir = global.cache_dir .. "backup/", - -- directory = global.cache_dir .. "swap/", - spellfile = global.vim_path .. "/spell/en.uft-8.add", - -- viewdir = global.cache_dir .. "view/", + -- backupdir = global.cache_dir .. "/backup/", + -- directory = global.cache_dir .. "/swap/", + -- spellfile = global.cache_dir .. "/spell/en.uft-8.add", + -- viewdir = global.cache_dir .. "/view/", autoindent = true, autoread = true, autowrite = true, @@ -84,7 +84,7 @@ local function load_options() timeoutlen = 300, ttimeout = true, ttimeoutlen = 0, - undodir = global.cache_dir .. "undo/", + undodir = global.cache_dir .. "/undo/", undofile = true, -- Please do NOT set `updatetime` to above 500, otherwise most plugins may not function correctly updatetime = 200, @@ -126,4 +126,7 @@ local function load_options() vim.g.c_syntax_for_h = true end +-- Newtrw liststyle: https://medium.com/usevim/the-netrw-style-options-3ebe91d42456 +vim.g.netrw_liststyle = 3 + load_options() diff --git a/lua/core/pack.lua b/lua/core/pack.lua index 326bf3df9..28e21d539 100644 --- a/lua/core/pack.lua +++ b/lua/core/pack.lua @@ -124,6 +124,29 @@ function Lazy:load_lazy() reset = true, -- reset the runtime path to $VIMRUNTIME and the config directory ---@type string[] paths = {}, -- add any custom paths here that you want to include in the rtp + disabled_plugins = { + -- Comment out `"editorconfig"` to enable native EditorConfig support + -- WARN: Sleuth.vim already includes all the features provided by this plugin. + -- Do NOT enable both at the same time, or you risk breaking the entire detection system. + "editorconfig", + -- Do not load spell files + "spellfile", + -- Do not use builtin matchit.vim and matchparen.vim because we're using vim-matchup + "matchit", + "matchparen", + -- Do not load tohtml.vim + "tohtml", + -- Do not load zipPlugin.vim, gzip.vim and tarPlugin.vim (all of these plugins are + -- related to reading files inside compressed containers) + "gzip", + "tarPlugin", + "zipPlugin", + -- Disable remote plugins + -- NOTE: + -- > Disabling rplugin.vim will make `wilder.nvim` complain about missing rplugins during :checkhealth, + -- > but since it's config doesn't require python rtp (strictly), it's fine to ignore that for now. + -- "rplugin", + }, }, }, } diff --git a/lua/core/settings.lua b/lua/core/settings.lua index 58ff3df9d..7f0230b38 100644 --- a/lua/core/settings.lua +++ b/lua/core/settings.lua @@ -6,16 +6,16 @@ settings["use_ssh"] = true -- Set it to false if you don't use copilot ---@type boolean -settings["use_copilot"] = true - --- Set it to false if you want to turn off LSP Inlay Hints ----@type boolean -settings["lsp_inlayhints"] = true +settings["use_copilot"] = false -- Set it to false if there is no need to format on save. ---@type boolean settings["format_on_save"] = true +-- Set format timeout here (in ms). +---@type number +settings["format_timeout"] = 1000 + -- Set it to false if the notification after formatting is annoying. ---@type boolean settings["format_notify"] = true @@ -37,6 +37,24 @@ settings["format_disabled_dirs"] = { "~/format_disabled_dir", } +-- Filetypes in this list will skip lsp formatting if rhs is true. +---@type table +settings["formatter_block_list"] = { + lua = false, -- example +} + +-- Servers in this list will skip setting formatting capabilities if rhs is true. +---@type table +settings["server_formatting_block_list"] = { + clangd = true, + lua_ls = true, + ts_ls = true, +} + +-- Set it to false if you want to turn off LSP Inlay Hints +---@type boolean +settings["lsp_inlayhints"] = true + -- Set it to false if diagnostics virtual text is annoying. -- If disabled, you may browse lsp diagnostics using trouble.nvim (press `gt` to toggle it). ---@type boolean @@ -85,20 +103,6 @@ settings["background"] = "dark" ---@type string settings["external_browser"] = "chrome-cli open" --- Filetypes in this list will skip lsp formatting if rhs is true. ----@type table -settings["formatter_block_list"] = { - lua = false, -- example -} - --- Servers in this list will skip setting formatting capabilities if rhs is true. ----@type table -settings["server_formatting_block_list"] = { - lua_ls = true, - tsserver = true, - clangd = true, -} - -- Set the language servers that will be installed during bootstrap here. -- check the below link for all the supported LSPs: -- https://github.com/neovim/nvim-lspconfig/tree/master/lua/lspconfig/server_configurations @@ -110,7 +114,6 @@ settings["lsp_deps"] = { "jsonls", "lua_ls", "pylsp", - "gopls", } -- Set the general-purpose servers that will be installed during bootstrap here. @@ -120,8 +123,6 @@ settings["lsp_deps"] = { ---@type string[] settings["null_ls_deps"] = { "clang_format", - "gofumpt", - "goimports", "prettier", "shfmt", "stylua", @@ -134,8 +135,6 @@ settings["null_ls_deps"] = { ---@type string[] settings["dap_deps"] = { "codelldb", -- C-Family - "delve", -- Go - "python", -- Python (debugpy) } -- Set the Treesitter parsers that will be installed during bootstrap here. @@ -145,14 +144,9 @@ settings["dap_deps"] = { settings["treesitter_deps"] = { "bash", "c", - "cpp", "css", - "go", - "gomod", "html", "javascript", - "json", - "jsonc", "latex", "lua", "make", @@ -162,7 +156,6 @@ settings["treesitter_deps"] = { "rust", "typescript", "vimdoc", - "vue", "yaml", } diff --git a/lua/keymap/helpers.lua b/lua/keymap/helpers.lua index b411bcd79..60d99e46f 100644 --- a/lua/keymap/helpers.lua +++ b/lua/keymap/helpers.lua @@ -11,6 +11,33 @@ _G._command_panel = function() }) end +_G._telescope_collections = function(picker_type) + local actions = require("telescope.actions") + local action_state = require("telescope.actions.state") + local conf = require("telescope.config").values + local finder = require("telescope.finders") + local pickers = require("telescope.pickers") + picker_type = picker_type or {} + + local collections = vim.tbl_keys(require("search.tabs").collections) + pickers + .new(picker_type, { + prompt_title = "Telescope Collections", + finder = finder.new_table({ results = collections }), + sorter = conf.generic_sorter(picker_type), + attach_mappings = function(bufnr) + actions.select_default:replace(function() + actions.close(bufnr) + local selection = action_state.get_selected_entry() + require("search").open({ collection = selection[1] }) + end) + + return true + end, + }) + :find() +end + _G._flash_esc_or_noh = function() local flash_active, state = pcall(function() return require("flash.plugins.char").state diff --git a/lua/keymap/lang.lua b/lua/keymap/lang.lua index 46ec703ff..aef337350 100644 --- a/lua/keymap/lang.lua +++ b/lua/keymap/lang.lua @@ -5,6 +5,11 @@ local map_cr = bind.map_cr -- local map_callback = bind.map_callback local plug_map = { + -- Plugin render-markdown.nvim + ["n|"] = map_cr("RenderMarkdown toggle") + :with_noremap() + :with_silent() + :with_desc("tool: toggle markdown preview within nvim"), -- Plugin MarkdownPreview ["n|"] = map_cr("MarkdownPreviewToggle"):with_noremap():with_silent():with_desc("tool: Preview markdown"), } diff --git a/lua/keymap/tool.lua b/lua/keymap/tool.lua index 4df37a5f6..617a2d082 100644 --- a/lua/keymap/tool.lua +++ b/lua/keymap/tool.lua @@ -84,54 +84,46 @@ local plug_map = { :with_noremap() :with_silent() :with_desc("tool: Toggle command panel"), - ["n|u"] = map_callback(function() - require("telescope").extensions.undo.undo() + ["n|fc"] = map_callback(function() + _telescope_collections(require("telescope.themes").get_dropdown()) end) :with_noremap() :with_silent() - :with_desc("edit: Show undo history"), - ["n|fp"] = map_callback(function() - require("telescope").extensions.projects.projects({}) + :with_desc("tool: Open Telescope collections"), + ["n|ff"] = map_callback(function() + require("search").open({ collection = "file" }) end) :with_noremap() :with_silent() - :with_desc("find: Project"), - ["n|fr"] = map_callback(function() - require("telescope").extensions.frecency.frecency({}) + :with_desc("tool: Find files"), + ["n|fp"] = map_callback(function() + require("search").open({ collection = "pattern" }) end) :with_noremap() :with_silent() - :with_desc("find: File by frecency"), - ["n|fw"] = map_callback(function() - require("telescope").extensions.live_grep_args.live_grep_args() - end) + :with_desc("tool: Find patterns"), + ["v|fs"] = map_cu("Telescope grep_string") :with_noremap() :with_silent() - :with_desc("find: Word in project"), - ["n|fe"] = map_cu("Telescope oldfiles"):with_noremap():with_silent():with_desc("find: File by history"), - ["n|ff"] = map_cu("Telescope find_files"):with_noremap():with_silent():with_desc("find: File in project"), - ["n|fc"] = map_callback(function() - require("telescope.builtin").colorscheme({ enable_preview = true }) + :with_desc("tool: Find word under cursor"), + ["n|fg"] = map_callback(function() + require("search").open({ collection = "git" }) end) :with_noremap() :with_silent() - :with_desc("ui: Change colorscheme for current session"), - ["n|fC"] = map_cu("Telescope bibtex") - :with_noremap() - :with_silent() - :with_desc("cite: Insert citation from bibtex"), - ["n|bn"] = map_cu(":enew"):with_noremap():with_silent():with_desc("buffer: New"), - ["n|fg"] = map_cu("Telescope git_files") + :with_desc("tool: Locate Git objects"), + ["n|fd"] = map_callback(function() + require("search").open({ collection = "dossier" }) + end) :with_noremap() :with_silent() - :with_desc("find: file in git project"), - ["n|fz"] = map_cu("Telescope zoxide list") + :with_desc("tool: Retrieve dossiers"), + ["n|fm"] = map_callback(function() + require("search").open({ collection = "misc" }) + end) :with_noremap() :with_silent() - :with_desc("edit: Change current directory by zoxide"), - ["n|fb"] = map_cu("Telescope buffers"):with_noremap():with_silent():with_desc("find: Buffer opened"), - ["nv|fs"] = map_cu("Telescope grep_string"):with_noremap():with_silent():with_desc("find: Current word"), - ["n|fd"] = map_cu("Telescope persisted"):with_noremap():with_silent():with_desc("find: Session"), + :with_desc("tool: Miscellaneous"), -- Plugin: dap ["n|"] = map_callback(function() diff --git a/lua/modules/configs/completion/cmp.lua b/lua/modules/configs/completion/cmp.lua index dfed6246f..109ee9878 100644 --- a/lua/modules/configs/completion/cmp.lua +++ b/lua/modules/configs/completion/cmp.lua @@ -90,6 +90,7 @@ return function() vim_item.kind = string.format(" %s %s", lspkind_icons[vim_item.kind] or icons.cmp.undefined, vim_item.kind or "") + -- set up labels for completion entries vim_item.menu = setmetatable({ cmp_tabnine = "[TN]", copilot = "[CPLT]", @@ -110,12 +111,18 @@ return function() end, })[entry.source.name] + -- cut down long results local label = vim_item.abbr local truncated_label = vim.fn.strcharpart(label, 0, 80) if truncated_label ~= label then vim_item.abbr = truncated_label .. "..." end + -- deduplicate results from nvim_lsp + if entry.source.name == "nvim_lsp" then + vim_item.dup = 0 + end + return vim_item end, }, @@ -128,15 +135,14 @@ return function() }, -- You can set mappings if you want mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.confirm({ select = false, behavior = cmp.ConfirmBehavior.Replace }), - [""] = cmp.mapping.select_prev_item(), - [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }), + [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }), [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.close(), + [""] = cmp.mapping.abort(), [""] = cmp.mapping(function(fallback) if cmp.visible() then - cmp.select_next_item() + cmp.select_next_item({ behavior = cmp.SelectBehavior.Select }) elseif require("luasnip").expand_or_locally_jumpable() then require("luasnip").expand_or_jump() else @@ -145,13 +151,24 @@ return function() end, { "i", "s" }), [""] = cmp.mapping(function(fallback) if cmp.visible() then - cmp.select_prev_item() + cmp.select_prev_item({ behavior = cmp.SelectBehavior.Select }) elseif require("luasnip").jumpable(-1) then require("luasnip").jump(-1) else fallback() end end, { "i", "s" }), + [""] = cmp.mapping({ + i = function(fallback) + if cmp.visible() and cmp.get_active_entry() then + cmp.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = false }) + else + fallback() + end + end, + s = cmp.mapping.confirm({ select = true }), + c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true }), + }), }), snippet = { expand = function(args) @@ -172,7 +189,7 @@ return function() name = "buffer", option = { get_bufnrs = function() - return vim.api.nvim_list_bufs() + return vim.api.nvim_buf_line_count(0) < 7500 and vim.api.nvim_list_bufs() or {} end, }, }, diff --git a/lua/modules/configs/completion/formatting.lua b/lua/modules/configs/completion/formatting.lua index 4634d0451..0368efef7 100644 --- a/lua/modules/configs/completion/formatting.lua +++ b/lua/modules/configs/completion/formatting.lua @@ -6,12 +6,13 @@ local format_on_save = settings.format_on_save local format_notify = settings.format_notify local format_modifications_only = settings.format_modifications_only local server_formatting_block_list = settings.server_formatting_block_list +local format_timeout = settings.format_timeout vim.api.nvim_create_user_command("FormatToggle", function() M.toggle_format_on_save() end, {}) -local block_list = require("core.settings").formatter_block_list +local block_list = settings.formatter_block_list vim.api.nvim_create_user_command("FormatterToggleFt", function(opts) if block_list[opts.args] == nil then vim.notify( @@ -35,7 +36,7 @@ vim.api.nvim_create_user_command("FormatterToggleFt", function(opts) end, { nargs = 1, complete = "filetype" }) function M.enable_format_on_save(is_configured) - local opts = { pattern = "*", timeout = 1000 } + local opts = { pattern = "*", timeout = format_timeout } vim.api.nvim_create_augroup("format_on_save", { clear = true }) vim.api.nvim_create_autocmd("BufWritePre", { group = "format_on_save", @@ -156,7 +157,9 @@ function M.format(opts) { title = "LSP Formatter Warning" } ) return - elseif + end + + if format_modifications_only and require("lsp-format-modifications").format_modifications(client, bufnr).success then diff --git a/lua/modules/configs/completion/mason-lspconfig.lua b/lua/modules/configs/completion/mason-lspconfig.lua index c345c7f78..567ff9f94 100644 --- a/lua/modules/configs/completion/mason-lspconfig.lua +++ b/lua/modules/configs/completion/mason-lspconfig.lua @@ -25,7 +25,11 @@ M.setup = function() }) local opts = { - capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()), + capabilities = vim.tbl_deep_extend( + "force", + vim.lsp.protocol.make_client_capabilities(), + require("cmp_nvim_lsp").default_capabilities() + ), } ---A handler to setup all servers defined under `completion/servers/*.lua` ---@param lsp_name string diff --git a/lua/modules/configs/completion/null-ls.lua b/lua/modules/configs/completion/null-ls.lua index ff2efab17..d699e556b 100644 --- a/lua/modules/configs/completion/null-ls.lua +++ b/lua/modules/configs/completion/null-ls.lua @@ -17,7 +17,7 @@ return function() -- Don't specify any config here if you are using the default one. local sources = { btns.formatting.clang_format.with({ - filetypes = { "c", "cpp", "objc", "objcpp", "cs", "java", "cuda", "proto" }, + filetypes = { "c", "cpp", "objc", "objcpp", "cs", "cuda", "proto" }, extra_args = formatter_args("clang_format"), }), btns.formatting.prettier.with({ @@ -42,6 +42,7 @@ return function() log_level = "warn", update_in_insert = false, sources = sources, + default_timeout = require("core.settings").format_timeout, }) require("completion.mason-null-ls").setup() diff --git a/lua/modules/configs/editor/bigfile.lua b/lua/modules/configs/editor/bigfile.lua index 28071772a..6c4e79d1f 100644 --- a/lua/modules/configs/editor/bigfile.lua +++ b/lua/modules/configs/editor/bigfile.lua @@ -16,15 +16,16 @@ return function() } require("modules.utils").load_plugin("bigfile", { - filesize = 1, -- size of the file in MiB + filesize = 2, -- size of the file in MiB pattern = { "*" }, -- autocmd pattern features = { -- features to disable + "indent_blankline", "lsp", - "treesitter", "syntax", + "treesitter", "vimopts", - ftdetect, cmp, + ftdetect, }, }) end diff --git a/lua/modules/configs/editor/colorizer.lua b/lua/modules/configs/editor/colorizer.lua deleted file mode 100644 index efee45019..000000000 --- a/lua/modules/configs/editor/colorizer.lua +++ /dev/null @@ -1,3 +0,0 @@ -return function() - require("modules.utils").load_plugin("colorizer", {}) -end diff --git a/lua/modules/configs/editor/highlight-colors.lua b/lua/modules/configs/editor/highlight-colors.lua new file mode 100644 index 000000000..06a0f6acd --- /dev/null +++ b/lua/modules/configs/editor/highlight-colors.lua @@ -0,0 +1,31 @@ +return function() + require("modules.utils").load_plugin("nvim-highlight-colors", { + render = "background", + enable_hex = true, + enable_short_hex = true, + enable_rgb = true, + enable_hsl = true, + enable_var_usage = true, + enable_named_colors = false, + enable_tailwind = false, + -- Exclude filetypes or buftypes from highlighting + exclude_filetypes = { + "alpha", + "bigfile", + "dap-repl", + "fugitive", + "git", + "notify", + "NvimTree", + "Outline", + "TelescopePrompt", + "toggleterm", + "undotree", + }, + exclude_buftypes = { + "nofile", + "prompt", + "terminal", + }, + }) +end diff --git a/lua/modules/configs/editor/persisted.lua b/lua/modules/configs/editor/persisted.lua index 003d8cb9d..2f1f43492 100644 --- a/lua/modules/configs/editor/persisted.lua +++ b/lua/modules/configs/editor/persisted.lua @@ -1,23 +1,13 @@ return function() require("modules.utils").load_plugin("persisted", { - save_dir = vim.fn.expand(vim.fn.stdpath("data") .. "/sessions/"), -- directory where session files are saved - silent = false, -- silent nvim message when sourcing session file - use_git_branch = true, -- create session files based on the branch of the git enabled repository - autosave = true, -- automatically save session files when exiting Neovim - should_autosave = function() - if vim.bo.filetype == "alpha" then - return false - end - return true - end, -- function to determine if a session should be autosaved + save_dir = vim.fn.expand(vim.fn.stdpath("data") .. "/sessions/"), + autostart = true, -- Set `lazy = false` in `plugins/editor.lua` to enable this - autoload = false, -- automatically load the session for the cwd on Neovim startup - on_autoload_no_session = nil, -- function to run when `autoload = true` but there is no session to load - follow_cwd = true, -- change session file name to match current working directory if it changes - allowed_dirs = nil, -- table of dirs that the plugin will auto-save and auto-load from - ignored_dirs = nil, -- table of dirs that are ignored when auto-saving and auto-loading - telescope = { -- options for the telescope extension - reset_prompt_after_deletion = true, -- whether to reset prompt after session deleted - }, + autoload = false, + follow_cwd = true, + use_git_branch = true, + should_save = function() + return vim.bo.filetype == "alpha" and false or true + end, }) end diff --git a/lua/modules/configs/editor/rainbow_delims.lua b/lua/modules/configs/editor/rainbow_delims.lua index 0f1a50aa2..d2e681d23 100644 --- a/lua/modules/configs/editor/rainbow_delims.lua +++ b/lua/modules/configs/editor/rainbow_delims.lua @@ -2,6 +2,13 @@ return function() ---@param threshold number @Use global strategy if nr of lines exceeds this value local function init_strategy(threshold) return function() + -- Disable on very large files + local line_count = vim.api.nvim_buf_line_count(0) + if line_count > 7500 then + return nil + end + + -- Disable on parser error local errors = 200 vim.treesitter.get_parser():for_each_tree(function(lt) if lt:root():has_error() and errors >= 0 then @@ -11,7 +18,8 @@ return function() if errors < 0 then return nil end - return vim.fn.line("$") > threshold and require("rainbow-delimiters").strategy["global"] + + return line_count > threshold and require("rainbow-delimiters").strategy["global"] or require("rainbow-delimiters").strategy["local"] end end @@ -19,8 +27,8 @@ return function() vim.g.rainbow_delimiters = { strategy = { [""] = init_strategy(500), - c = init_strategy(200), - cpp = init_strategy(200), + c = init_strategy(300), + cpp = init_strategy(300), lua = init_strategy(500), vimdoc = init_strategy(300), vim = init_strategy(300), @@ -40,5 +48,6 @@ return function() "RainbowDelimiterViolet", }, } + require("modules.utils").load_plugin("rainbow_delimiters", nil, true) end diff --git a/lua/modules/configs/editor/treesitter.lua b/lua/modules/configs/editor/treesitter.lua index e9fe90151..5b25ebe95 100644 --- a/lua/modules/configs/editor/treesitter.lua +++ b/lua/modules/configs/editor/treesitter.lua @@ -9,7 +9,10 @@ return vim.schedule_wrap(function() highlight = { enable = true, disable = function(ft, bufnr) - if vim.tbl_contains({ "vim" }, ft) then + if + vim.tbl_contains({ "gitcommit" }, ft) + or (vim.api.nvim_buf_line_count(bufnr) > 7500 and ft ~= "vimdoc") + then return true end @@ -21,6 +24,7 @@ return vim.schedule_wrap(function() textobjects = { select = { enable = true, + lookahead = true, keymaps = { ["af"] = "@function.outer", ["if"] = "@function.inner", @@ -30,7 +34,7 @@ return vim.schedule_wrap(function() }, move = { enable = true, - set_jumps = true, -- whether to set jumps in the jumplist + set_jumps = true, goto_next_start = { ["]["] = "@function.outer", ["]m"] = "@class.outer", @@ -55,8 +59,8 @@ return vim.schedule_wrap(function() require("nvim-treesitter.install").prefer_git = true if use_ssh then local parsers = require("nvim-treesitter.parsers").get_parser_configs() - for _, p in pairs(parsers) do - p.install_info.url = p.install_info.url:gsub("https://github.com/", "git@github.com:") + for _, parser in pairs(parsers) do + parser.install_info.url = parser.install_info.url:gsub("https://github.com/", "git@github.com:") end end end) diff --git a/lua/modules/configs/editor/zen-mode.lua b/lua/modules/configs/editor/zen-mode.lua index bd41637d0..7add28f10 100644 --- a/lua/modules/configs/editor/zen-mode.lua +++ b/lua/modules/configs/editor/zen-mode.lua @@ -3,12 +3,12 @@ return function() window = { backdrop = 0.95, width = 85, - height = 0.8, + height = 1.0, options = { list = false, -- foldcolumn = "0", -- signcolumn = "no", - cursorcolumn = false, + cursorcolumn = true, cursorline = false, }, }, diff --git a/lua/modules/configs/lang/render-markdown.lua b/lua/modules/configs/lang/render-markdown.lua new file mode 100644 index 000000000..65ad80fec --- /dev/null +++ b/lua/modules/configs/lang/render-markdown.lua @@ -0,0 +1,21 @@ +return function() + require("modules.utils").load_plugin("render-markdown", { + -- Whether Markdown should be rendered by default or not + enabled = true, + -- Maximum file size (in MB) that this plugin will attempt to render + -- Any file larger than this will effectively be ignored + max_file_size = 2.0, + -- Milliseconds that must pass before updating marks, updates occur + -- within the context of the visible window, not the entire buffer + debounce = 100, + -- Vim modes that will show a rendered view of the markdown file + -- All other modes will be uneffected by this plugin + render_modes = { "n", "c", "t" }, + -- This enables hiding any added text on the line the cursor is on + -- This does have a performance penalty as we must listen to the 'CursorMoved' event + anti_conceal = { enabled = true }, + -- The level of logs to write to file: vim.fn.stdpath('state') .. '/render-markdown.log' + -- Only intended to be used for plugin development / debugging + log_level = "error", + }) +end diff --git a/lua/modules/configs/tool/search.lua b/lua/modules/configs/tool/search.lua new file mode 100644 index 000000000..ffad69cbc --- /dev/null +++ b/lua/modules/configs/tool/search.lua @@ -0,0 +1,141 @@ +return function() + local builtin = require("telescope.builtin") + local extensions = require("telescope").extensions + + require("modules.utils").load_plugin("search", { + collections = { + -- Search using filenames + file = { + initial_tab = 1, + tabs = { + { + name = "Files", + tele_func = function(opts) + opts = opts or {} + if vim.fn.isdirectory(".git") == 1 then + builtin.git_files(opts) + else + builtin.find_files(opts) + end + end, + }, + { + name = "Frecency", + tele_func = function() + extensions.frecency.frecency() + end, + }, + { + name = "Oldfiles", + tele_func = function() + builtin.oldfiles() + end, + }, + { + name = "Buffers", + tele_func = function() + builtin.buffers() + end, + }, + }, + }, + -- Search using patterns + pattern = { + initial_tab = 1, + tabs = { + { + name = "Word in project", + tele_func = function() + extensions.live_grep_args.live_grep_args() + end, + }, + { + name = "Word under cursor", + tele_func = function(opts) + opts = opts or {} + builtin.grep_string(opts) + end, + }, + }, + }, + -- Search Git objects (branches, commits) + git = { + initial_tab = 1, + tabs = { + { + name = "Branches", + tele_func = function() + builtin.git_branches() + end, + }, + { + name = "Commits", + tele_func = function() + builtin.git_commits() + end, + }, + { + name = "Commit content", + tele_func = function() + extensions.advanced_git_search.search_log_content() + end, + }, + { + name = "Diff current file with commit", + tele_func = function() + extensions.advanced_git_search.diff_commit_file() + end, + }, + }, + }, + -- Retrieve dossiers + dossier = { + initial_tab = 1, + tabs = { + { + name = "Sessions", + tele_func = function() + extensions.persisted.persisted() + end, + }, + { + name = "Projects", + tele_func = function() + extensions.projects.projects({}) + end, + }, + { + name = "Zoxide", + tele_func = function() + extensions.zoxide.list() + end, + }, + }, + }, + -- Miscellaneous + misc = { + initial_tab = 1, + tabs = { + { + name = "Colorschemes", + tele_func = function() + builtin.colorscheme({ enable_preview = true }) + end, + }, + { + name = "Notify", + tele_func = function() + extensions.notify.notify() + end, + }, + { + name = "Undo History", + tele_func = function() + extensions.undo.undo() + end, + }, + }, + }, + }, + }) +end diff --git a/lua/modules/configs/tool/telescope.lua b/lua/modules/configs/tool/telescope.lua index 41ca3c3b2..6b144d7aa 100644 --- a/lua/modules/configs/tool/telescope.lua +++ b/lua/modules/configs/tool/telescope.lua @@ -69,7 +69,6 @@ return function() }, live_grep_args = { auto_quoting = true, -- enable/disable auto-quoting - -- define mappings, e.g. mappings = { -- extend mappings i = { [""] = lga_actions.quote_prompt(), @@ -79,18 +78,19 @@ return function() }, undo = { side_by_side = true, - mappings = { -- this whole table is the default + mappings = { i = { - -- IMPORTANT: Note that telescope-undo must be available when telescope is configured if - -- you want to use the following actions. This means installing as a dependency of - -- telescope in it's `requirements` and loading this extension from there instead of - -- having the separate plugin definition as outlined above. See issue #6. [""] = require("telescope-undo.actions").yank_additions, [""] = require("telescope-undo.actions").yank_deletions, [""] = require("telescope-undo.actions").restore, }, }, }, + advanced_git_search = { + diff_plugin = "diffview", + git_flags = { "-c", "delta.side-by-side=true" }, + entry_default_author_or_date = "author", -- one of "author" or "date" + }, }, }) @@ -104,4 +104,5 @@ return function() require("telescope").load_extension("persisted") require("telescope").load_extension("bibtex") require("telescope").load_extension("aerial") + require("telescope").load_extension("advanced_git_search") end diff --git a/lua/modules/configs/tool/which-key.lua b/lua/modules/configs/tool/which-key.lua index c9d687ee6..e04e70117 100644 --- a/lua/modules/configs/tool/which-key.lua +++ b/lua/modules/configs/tool/which-key.lua @@ -6,66 +6,70 @@ return function() cmp = require("modules.utils.icons").get("cmp", true), } - require("which-key").register({ - [""] = { - b = { - name = icons.ui.Buffer .. " Buffer", - }, - d = { - name = icons.ui.Bug .. " Debug", - }, - f = { - name = icons.ui.Telescope .. " Fuzzy Find", - }, - g = { - name = icons.git.Git .. "Git", - }, - l = { - name = icons.misc.LspAvailable .. " Lsp", - }, - n = { - name = icons.ui.FolderOpen .. " Nvim Tree", - }, - p = { - name = icons.ui.Package .. " Package", - }, - s = { - name = icons.cmp.tmux .. "Session", - }, - S = { - name = icons.ui.Search .. " Search", - }, - W = { - name = icons.ui.Window .. " Window", - }, - }, - }) - require("modules.utils").load_plugin("which-key", { + preset = "classic", + delay = vim.o.timeoutlen, + triggers = { + { "", mode = "nixso" }, + }, plugins = { + marks = true, + registers = true, + spelling = { + enabled = true, + suggestions = 20, + }, presets = { - operators = false, motions = false, - text_objects = false, - windows = false, - nav = false, + operators = false, + text_objects = true, + windows = true, + nav = true, z = true, g = true, }, }, - + win = { + border = "none", + padding = { 1, 2 }, + wo = { winblend = 0 }, + }, + expand = 1, icons = { + group = "", + rules = false, + colors = false, breadcrumb = icons.ui.Separator, separator = icons.misc.Vbar, - group = "", + keys = { + C = "C-", + M = "A-", + S = "S-", + BS = " ", + CR = " ", + NL = " ", + Esc = " ", + Tab = " ", + Up = " ", + Down = " ", + Left = " ", + Right = " ", + Space = " ", + ScrollWheelUp = " ", + ScrollWheelDown = " ", + }, }, - - window = { - border = "none", - position = "bottom", - margin = { 1, 0, 1, 0 }, - padding = { 1, 1, 1, 1 }, - winblend = 0, + spec = { + { "g", group = icons.git.Git .. "Git" }, + { "d", group = icons.ui.Bug .. " Debug" }, + { "s", group = icons.cmp.tmux .. "Session" }, + { "b", group = icons.ui.Buffer .. " Buffer" }, + { "S", group = icons.ui.Search .. " Search" }, + { "W", group = icons.ui.Window .. " Window" }, + { "p", group = icons.ui.Package .. " Package" }, + { "l", group = icons.misc.LspAvailable .. " Lsp" }, + { "f", group = icons.ui.Telescope .. " Fuzzy Find" }, + { "n", group = icons.ui.FolderOpen .. " Nvim Tree" }, }, }) end diff --git a/lua/modules/configs/ui/alpha.lua b/lua/modules/configs/ui/alpha.lua index 73a489c12..befcbd2e3 100644 --- a/lua/modules/configs/ui/alpha.lua +++ b/lua/modules/configs/ui/alpha.lua @@ -39,55 +39,56 @@ return function() end local leader = " " + local icons = { + documents = require("modules.utils.icons").get("documents", true), + git = require("modules.utils.icons").get("git", true), + ui = require("modules.utils.icons").get("ui", true), + misc = require("modules.utils.icons").get("misc", true), + } + dashboard.section.buttons.val = { - button("space f c", " Scheme change", leader, nil, { - noremap = true, - silent = true, - nowait = true, - callback = function() - require("telescope.builtin").colorscheme() - end, - }), - button("space f r", " File frecency", leader, nil, { - noremap = true, - silent = true, - nowait = true, - callback = function() - require("telescope").extensions.frecency.frecency({}) - end, - }), - button("space f e", "󰋚 File history", leader, nil, { - noremap = true, - silent = true, - nowait = true, - callback = function() - require("telescope.builtin").oldfiles() - end, - }), - button("space f p", " Project find", leader, nil, { - noremap = true, - silent = true, - nowait = true, - callback = function() - require("telescope").extensions.projects.projects({}) - end, - }), - button("space f f", "󰈞 File find", leader, nil, { - noremap = true, - silent = true, - nowait = true, - callback = function() - require("telescope.builtin").find_files() - end, - }), - button("space f w", " Word find", leader, nil, { - noremap = true, - silent = true, - nowait = true, - callback = function() - require("telescope.builtin").live_grep() - end, - }), + button( + "space f c", + icons.misc.Neovim .. "Telescope collections", + leader, + nil, + { noremap = true, silent = true, nowait = true } + ), + button( + "space f f", + icons.documents.FileFind .. "Find files", + leader, + nil, + { noremap = true, silent = true, nowait = true } + ), + button( + "space f d", + icons.ui.FolderWithHeart .. "Retrieve dossiers", + leader, + nil, + { noremap = true, silent = true, nowait = true } + ), + button( + "space f p", + icons.documents.Word .. "Find patterns", + leader, + nil, + { noremap = true, silent = true, nowait = true } + ), + button( + "space f g", + icons.git.Git .. "Locate Git objects", + leader, + nil, + { noremap = true, silent = true, nowait = true } + ), + button( + "space f m", + icons.misc.Ghost .. "Miscellaneous artifacts", + leader, + nil, + { noremap = true, silent = true, nowait = true } + ), } dashboard.section.buttons.opts.hl = "AlphaButtons" diff --git a/lua/modules/configs/ui/catppuccin.lua b/lua/modules/configs/ui/catppuccin.lua index b7e933346..56cdfd5e8 100644 --- a/lua/modules/configs/ui/catppuccin.lua +++ b/lua/modules/configs/ui/catppuccin.lua @@ -83,6 +83,7 @@ return function() overseer = false, pounce = false, rainbow_delimiters = true, + render_markdown = true, sandwich = false, semantic_tokens = true, symbols_outline = false, diff --git a/lua/modules/configs/ui/gitsigns.lua b/lua/modules/configs/ui/gitsigns.lua index c70684266..de14cd5f5 100644 --- a/lua/modules/configs/ui/gitsigns.lua +++ b/lua/modules/configs/ui/gitsigns.lua @@ -2,45 +2,22 @@ return function() local mapping = require("keymap.ui") require("modules.utils").load_plugin("gitsigns", { signs = { - add = { - hl = "GitSignsAdd", - text = "│", - numhl = "GitSignsAddNr", - linehl = "GitSignsAddLn", - }, - change = { - hl = "GitSignsChange", - text = "│", - numhl = "GitSignsChangeNr", - linehl = "GitSignsChangeLn", - }, - delete = { - hl = "GitSignsDelete", - text = "_", - numhl = "GitSignsDeleteNr", - linehl = "GitSignsDeleteLn", - }, - topdelete = { - hl = "GitSignsDelete", - text = "‾", - numhl = "GitSignsDeleteNr", - linehl = "GitSignsDeleteLn", - }, - changedelete = { - hl = "GitSignsChange", - text = "~", - numhl = "GitSignsChangeNr", - linehl = "GitSignsChangeLn", - }, + add = { text = "┃" }, + change = { text = "┃" }, + delete = { text = "_" }, + topdelete = { text = "‾" }, + changedelete = { text = "~" }, + untracked = { text = "┆" }, }, + auto_attach = true, on_attach = mapping.gitsigns, - watch_gitdir = { interval = 1000, follow_files = true }, - current_line_blame = true, - current_line_blame_opts = { delay = 1000, virtual_text_pos = "eol" }, + signcolumn = true, sign_priority = 6, update_debounce = 100, - status_formatter = nil, -- Use default word_diff = false, + current_line_blame = true, diff_opts = { internal = true }, + watch_gitdir = { follow_files = true }, + current_line_blame_opts = { delay = 1000, virt_text = true, virtual_text_pos = "eol" }, }) end diff --git a/lua/modules/configs/ui/lualine.lua b/lua/modules/configs/ui/lualine.lua index c9431b75e..2293570e1 100644 --- a/lua/modules/configs/ui/lualine.lua +++ b/lua/modules/configs/ui/lualine.lua @@ -311,6 +311,7 @@ return function() lualine_x = { { "encoding", + show_bomb = true, fmt = string.upper, padding = { left = 1 }, cond = conditionals.has_enough_room, diff --git a/lua/modules/plugins/completion.lua b/lua/modules/plugins/completion.lua index 7f26adf85..b7802ce97 100644 --- a/lua/modules/plugins/completion.lua +++ b/lua/modules/plugins/completion.lua @@ -26,7 +26,7 @@ completion["stevearc/aerial.nvim"] = { event = "LspAttach", config = require("completion.aerial"), } -completion["dnlhc/glance.nvim"] = { +completion["DNLHC/glance.nvim"] = { lazy = true, event = "LspAttach", config = require("completion.glance"), @@ -51,8 +51,9 @@ completion["hrsh7th/nvim-cmp"] = { dependencies = { { "L3MON4D3/LuaSnip", - dependencies = { "rafamadriz/friendly-snippets" }, + build = "make install_jsregexp", config = require("completion.luasnip"), + dependencies = { "rafamadriz/friendly-snippets" }, }, { "lukas-reineke/cmp-under-comparator" }, { "saadparwaiz1/cmp_luasnip" }, diff --git a/lua/modules/plugins/editor.lua b/lua/modules/plugins/editor.lua index e7aea1ef0..0bce48097 100644 --- a/lua/modules/plugins/editor.lua +++ b/lua/modules/plugins/editor.lua @@ -63,9 +63,14 @@ editor["smoka7/hop.nvim"] = { } editor["tzachar/local-highlight.nvim"] = { lazy = true, - event = { "CursorHold", "CursorHoldI" }, + event = { "BufReadPost", "BufAdd", "BufNewFile" }, config = require("editor.local-highlight"), } +editor["brenoprata10/nvim-highlight-colors"] = { + lazy = true, + event = { "CursorHold", "CursorHoldI" }, + config = require("editor.highlight-colors"), +} editor["romainl/vim-cool"] = { lazy = true, event = { "CursorMoved", "InsertEnter" }, @@ -95,7 +100,7 @@ editor["mrjones2014/smart-splits.nvim"] = { editor["nvim-treesitter/nvim-treesitter"] = { lazy = true, build = function() - if #vim.api.nvim_list_uis() ~= 0 then + if #vim.api.nvim_list_uis() > 0 then vim.api.nvim_command([[TSUpdate]]) end end, @@ -109,10 +114,6 @@ editor["nvim-treesitter/nvim-treesitter"] = { "windwp/nvim-ts-autotag", config = require("editor.autotag"), }, - { - "NvChad/nvim-colorizer.lua", - config = require("editor.colorizer"), - }, { "hiphish/rainbow-delimiters.nvim", config = require("editor.rainbow_delims"), @@ -140,4 +141,14 @@ editor["andrewferrier/wrapping.nvim"] = { editor["folke/zen-mode.nvim"] = { config = require("editor.zen-mode"), } + +editor["kylechui/nvim-surround"] = { + version = "*", -- Use for stability; omit to use `main` branch for the latest features + event = "VeryLazy", + config = function() + require("nvim-surround").setup({ + -- Configuration here, or leave empty to use defaults + }) + end, +} return editor diff --git a/lua/modules/plugins/lang.lua b/lua/modules/plugins/lang.lua index 0a73cfadd..768f10ff9 100644 --- a/lua/modules/plugins/lang.lua +++ b/lua/modules/plugins/lang.lua @@ -21,6 +21,15 @@ lang["Saecki/crates.nvim"] = { config = require("lang.crates"), dependencies = { "nvim-lua/plenary.nvim" }, } +lang["MeanderingProgrammer/render-markdown.nvim"] = { + lazy = true, + ft = "markdown", + config = require("lang.render-markdown"), + dependencies = { + "nvim-tree/nvim-web-devicons", + "nvim-treesitter/nvim-treesitter", + }, +} lang["iamcco/markdown-preview.nvim"] = { lazy = true, ft = "markdown", diff --git a/lua/modules/plugins/tool.lua b/lua/modules/plugins/tool.lua index 4bcdec827..2af4bb937 100644 --- a/lua/modules/plugins/tool.lua +++ b/lua/modules/plugins/tool.lua @@ -92,19 +92,32 @@ tool["nvim-telescope/telescope.nvim"] = { cmd = "Telescope", config = require("tool.telescope"), dependencies = { - { "nvim-tree/nvim-web-devicons" }, { "nvim-lua/plenary.nvim" }, + { "nvim-tree/nvim-web-devicons" }, + { "jvgrootveld/telescope-zoxide" }, { "debugloop/telescope-undo.nvim" }, + { "nvim-telescope/telescope-frecency.nvim" }, + { "nvim-telescope/telescope-live-grep-args.nvim" }, + { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, + { + "FabianWirth/search.nvim", + config = require("tool.search"), + }, { "ahmedkhalf/project.nvim", event = { "CursorHold", "CursorHoldI" }, config = require("tool.project"), }, - { "jvgrootveld/telescope-zoxide" }, - { "nvim-telescope/telescope-frecency.nvim" }, - { "nvim-telescope/telescope-live-grep-args.nvim" }, { "nvim-telescope/telescope-bibtex.nvim" }, - { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, + { + "aaronhallaert/advanced-git-search.nvim", + cmd = { "AdvancedGitSearch" }, + dependencies = { + "tpope/vim-rhubarb", + "tpope/vim-fugitive", + "sindrets/diffview.nvim", + }, + }, }, } diff --git a/lua/modules/plugins/ui.lua b/lua/modules/plugins/ui.lua index 5318694b7..29845875e 100644 --- a/lua/modules/plugins/ui.lua +++ b/lua/modules/plugins/ui.lua @@ -23,6 +23,7 @@ ui["j-hui/fidget.nvim"] = { } ui["lewis6991/gitsigns.nvim"] = { lazy = true, + version = "0.9", event = { "CursorHold", "CursorHoldI" }, config = require("ui.gitsigns"), } diff --git a/lua/modules/utils/icons.lua b/lua/modules/utils/icons.lua index eab8da2c7..a050401b6 100644 --- a/lua/modules/utils/icons.lua +++ b/lua/modules/utils/icons.lua @@ -62,9 +62,11 @@ local data = { Default = "", File = "", Files = "", + FileFind = "󰈞", FileTree = "󰙅", Import = "", Symlink = "", + Word = "", }, git = { Add = "", diff --git a/nixos/neovim/default.nix b/nixos/neovim/default.nix index 93134d40f..420e7fac3 100644 --- a/nixos/neovim/default.nix +++ b/nixos/neovim/default.nix @@ -4,8 +4,15 @@ , pkgs , ... }: -with lib; let +let cfg = config.programs.neovim.nvimdots; + inherit (lib) flip warn const; + inherit (lib.attrsets) optionalAttrs; + inherit (lib.lists) optionals; + inherit (lib.modules) mkIf; + inherit (lib.options) mkEnableOption mkOption literalExpression; + inherit (lib.strings) concatStringsSep versionOlder versionAtLeast; + inherit (lib.types) listOf coercedTo package functionTo; in { options = { @@ -19,6 +26,15 @@ in Bind lazy-lock.json in your repository to $XDG_CONFIG_HOME/nvim. Very powerful in terms of keeping the environment consistent, but has the following side effects. You cannot update it even if you run the Lazy command, because it binds read-only. + You need to remove lazy-lock.json before enabling this option if `mergeLazyLock` is set. + ''; + mergeLazyLock = mkEnableOption '' + Merges the managed lazy-lock.json with the existing one under $XDG_CONFIG_HOME/nvim if its hash has changed on activation. + Upstream package version changes have high priority. + This means changes to lazy-lock.json in the config directory (likely due to installing package) will be preserved. + In other words, it achieves environment consistency while remaining adaptable to changes. + You need to unlink lazy-lock.json before enabling this option if `bindLazyLock` is set. + Please refer to the wiki for details on the behavior. ''; setBuildEnv = mkEnableOption '' Sets environment variables that resolve build dependencies as required by `mason.nvim` and `nvim-treesitter` @@ -34,9 +50,11 @@ in use Haskell plugins. ''; extraHaskellPackages = mkOption { - type = with types; - let fromType = listOf package; - in coercedTo fromType + type = + let + fromType = listOf package; + in + coercedTo fromType (flip warn const '' Assigning a plain list to extraHaskellPackages is deprecated. Please assign a function taking a package set as argument, so @@ -56,7 +74,7 @@ in ''; }; extraDependentPackages = mkOption { - type = with types; listOf package; + type = listOf package; default = [ ]; example = literalExpression "[ pkgs.openssl ]"; description = "Extra build depends to add `LIBRARY_PATH` and `CPATH`."; @@ -67,33 +85,30 @@ in config = let # Inspired from https://github.com/NixOS/nixpkgs/blob/nixos-unstable/nixos/modules/programs/nix-ld.nix - build-dependent-pkgs = with pkgs; builtins.filter (package: !package.meta.unsupported) [ + build-dependent-pkgs = builtins.filter (package: !package.meta.unsupported) [ # manylinux - acl - attr - bzip2 - curl - glibc - libsodium - libssh - libxml2 - openssl - stdenv.cc.cc - stdenv.cc.cc.lib - systemd - util-linux - xz - zlib - zstd + pkgs.acl + pkgs.attr + pkgs.bzip2 + pkgs.curl + pkgs.glibc + pkgs.libsodium + pkgs.libssh + pkgs.libxml2 + pkgs.openssl + pkgs.stdenv.cc.cc + pkgs.stdenv.cc.cc.lib + pkgs.systemd + pkgs.util-linux + pkgs.xz + pkgs.zlib + pkgs.zstd # Packages not included in `nix-ld`'s NixOSModule - glib - libcxx + pkgs.glib + pkgs.libcxx ] ++ cfg.extraDependentPackages; - makePkgConfigPath = x: makeSearchPathOutput "dev" "lib/pkgconfig" x; - makeIncludePath = x: makeSearchPathOutput "dev" "include" x; - neovim-build-deps = pkgs.buildEnv { name = "neovim-build-deps"; paths = build-dependent-pkgs; @@ -112,19 +127,37 @@ in ]; in mkIf cfg.enable { + assertions = [ + { + assertion = ! (cfg.bindLazyLock && cfg.mergeLazyLock); + message = "bindLazyLock and mergeLazyLock cannot be enabled at the same time."; + } + ]; xdg.configFile = { "nvim/init.lua".source = ../../init.lua; "nvim/lua".source = ../../lua; "nvim/snips".source = ../../snips; "nvim/tutor".source = ../../tutor; - } // lib.optionalAttrs cfg.bindLazyLock { + } // optionalAttrs cfg.bindLazyLock { "nvim/lazy-lock.json".source = ../../lazy-lock.json; + } // optionalAttrs cfg.mergeLazyLock { + "nvim/lazy-lock.fixed.json" = { + source = ../../lazy-lock.json; + onChange = '' + if [ -f ${config.xdg.configHome}/nvim/lazy-lock.json ]; then + tmp=$(mktemp) + ${pkgs.jq}/bin/jq -r -s '.[0] * .[1]' ${config.xdg.configHome}/nvim/lazy-lock.json ${config.xdg.configFile."nvim/lazy-lock.fixed.json".source} > "''${tmp}" && mv "''${tmp}" ${config.xdg.configHome}/nvim/lazy-lock.json + else + ${pkgs.rsync}/bin/rsync --chmod 644 ${config.xdg.configFile."nvim/lazy-lock.fixed.json".source} ${config.xdg.configHome}/nvim/lazy-lock.json + fi + ''; + }; }; home = { - packages = with pkgs; [ - ripgrep + packages = [ + pkgs.ripgrep ]; - shellAliases = optionalAttrs (cfg.setBuildEnv && (lib.versionOlder config.home.stateVersion "24.05")) { + shellAliases = optionalAttrs (cfg.setBuildEnv && (versionOlder config.home.stateVersion "24.05")) { nvim = concatStringsSep " " buildEnv + " nvim"; }; }; @@ -134,33 +167,32 @@ in withNodeJs = true; withPython3 = true; - extraPackages = with pkgs; - [ - # Dependent packages used by default plugins - doq - tree-sitter - ] - ++ optionals cfg.withBuildTools [ - cargo - clang - cmake - gcc - gnumake - go - lua51Packages.luarocks - ninja - pkg-config - yarn - ] - ++ optionals cfg.withHaskell [ - (pkgs.writeShellApplication { - name = "stack"; - text = '' - exec "${pkgs.stack}/bin/stack" "--extra-include-dirs=${config.home.profileDirectory}/lib/nvim-depends/include" "--extra-lib-dirs=${config.home.profileDirectory}/lib/nvim-depends/lib" "$@" - ''; - }) - (haskellPackages.ghcWithPackages (ps: cfg.extraHaskellPackages ps)) - ]; + extraPackages = [ + # Dependent packages used by default plugins + pkgs.doq + pkgs.tree-sitter + ] + ++ optionals cfg.withBuildTools [ + pkgs.cargo + pkgs.clang + pkgs.cmake + pkgs.gcc + pkgs.gnumake + pkgs.go + pkgs.lua51Packages.luarocks + pkgs.ninja + pkgs.pkg-config + pkgs.yarn + ] + ++ optionals cfg.withHaskell [ + (pkgs.writeShellApplication { + name = "stack"; + text = '' + exec "${pkgs.stack}/bin/stack" "--extra-include-dirs=${config.home.profileDirectory}/lib/nvim-depends/include" "--extra-lib-dirs=${config.home.profileDirectory}/lib/nvim-depends/lib" "$@" + ''; + }) + (pkgs.haskellPackages.ghcWithPackages (ps: cfg.extraHaskellPackages ps)) + ]; extraPython3Packages = ps: with ps; [ docformatter @@ -168,8 +200,8 @@ in pynvim ]; } - // lib.optionalAttrs (lib.versionAtLeast config.home.stateVersion "24.05") { - extraWrapperArgs = lib.optionals cfg.setBuildEnv [ + // optionalAttrs (versionAtLeast config.home.stateVersion "24.05") { + extraWrapperArgs = optionals cfg.setBuildEnv [ "--suffix" "CPATH" ":" diff --git a/tutor/dots.tutor b/tutor/dots.tutor index 7def1078d..c4232b100 100644 --- a/tutor/dots.tutor +++ b/tutor/dots.tutor @@ -1,6 +1,6 @@ # Welcome to the nvimdots Tutor -Nvimdots is a [neovim](https://neovim.io/) config suite designed for extensibility, performance, and ease +Nvimdots is a [Neovim](https://neovim.io/) config suite designed for extensibility, performance, and ease of use. It provides the ability to work with text files yet feels like you are working within an IDE environment. @@ -64,7 +64,7 @@ Consequently, this segment of the status line provides insight into the context your cursor position. It's important to note that this feature relies on LSP, so it is disabled if the corresponding LSP is not attached to the current buffer. -You can press `li`{normal} to check LSP info. Upon doing so, you will notice that +You can press ``{normal}`l`{normal}`i`{normal} to check LSP info. Upon doing so, you will notice that there are two active clients attached to this buffer. Now, press [go](go) to toggle the code outline, which displays all symbols defined in @@ -85,32 +85,33 @@ to the next topic, which covers the basic workflow. # Lesson 1.2: FIND AND SEARCH -Nvimdots utilizes [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim) as the primary fuzzy finder. It offers numerous -features for finding and searching. To open the file finder under the current -working directory, press `ff`{normal}. Then, input the keyword you wish to find and use -``{normal} and ``{normal} to navigate up and down the list of results. You can preview the -content of the selected file in the right window and press ``{normal} to open it -in a new buffer. - -Nvimdots also provide several additional search features. One commonly used keymap is -`fr`{normal}, especially if you frequently edit files across different projects. This -command lists files you have previously opened and sorts them by "frecency," a -concept similar to that used in Firefox's address bar. This feature utilizes "Lua -Bytecode" to permanently store the key-value pairs of file paths and their "frecency" -values at **~/.local/share/nvim/file_frecency.bin**. - -You can press `fw`{normal} to search for a word in the current working directory. This -feature utilizes [ripgrep](https://github.com/BurntSushi/ripgrep) for searching, allowing you to use it naturally as you would -with ripgrep. - -Nvimdots also provides project management features and integrates them seamlessly -with telescope. Press `fp`{normal} to open the recent project list. Please refrain from -quitting this interface; instead, you can add the current working directory to the -project list by pressing ``{normal}, and remove it by pressing ``{normal}. Typically, the -current working directory corresponds to the project directory, which is identified -by LSP and patterns such as *.git/*. However, you have the flexibility to set your own -patterns. Consequently, the project directory will automatically change when you -switch to another buffer whose file belongs to a different project. +Nvimdots utilizes [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim) as the primary fuzzy finder, offering numerous +features for efficient finding and searching. To access the "file finder collection" +within the current working directory, press ``{normal}`f`{normal}`f`{normal}. Subsequently, enter the +desired keyword and use ``{normal} and ``{normal} to navigate through the list of results. The +content of the selected file can be previewed in the adjacent window, and pressing +``{normal} will open it in a new buffer. Additionally, ``{normal} and ``{normal} allow you to +switch between various tabs to locate files with different properties. For instance, +the "Frecency" and "Oldfiles" tabs enable searches based on the most frequently and +recently opened files, respectively, while the "Buffers" tab facilitates searches +among currently opened buffers. + +For pattern searches within the current working directory, press ``{normal}`f`{normal}`p`{normal}. This +functionality leverages [ripgrep](https://github.com/BurntSushi/ripgrep) for its search capabilities, making it as intuitive +to use as ripgrep itself. As with the "file finder collection", ``{normal} and ``{normal} can +be used to cycle through the search tabs. The "Word under cursor" tab displays all +instances of the word located under the current cursor position. + +Nvimdots also offers comprehensive dossier management, seamlessly integrated with +Telescope. Press ``{normal}`f`{normal}`d`{normal} to access the recent dossiers list. The first tab +presents the currently saved sessions; select a session and press ``{normal} to restore +the corresponding session. The second tab lists various projects. Instead of exiting +this interface, you can add the current working directory to the project list by +pressing ``{normal}, and remove it by pressing ``{normal}. Generally, the current working +directory corresponds to the current project's directory, identified by the LSP or +patterns such as *.git/*. You can also define your own patterns. Consequently, the +current working directory will automatically switch when you move to another buffer +containing a file from a different project. # Lesson 1.3: EDIT AND FORMAT