From 40d04ff874577f26ca09cb518d74f5605dfcfffd Mon Sep 17 00:00:00 2001 From: Wynd Date: Mon, 28 Oct 2024 22:14:36 +0200 Subject: [PATCH] Added formatting enable/disable commands for nvim, rg and blockbench to the install script and set the regex engine for git fetches to PCRE2 --- .config/btop/btop.conf | 4 ++-- .config/nvim/lua/nvwynd/autocmds.lua | 19 +++++++++++++++++++ .../nvim/lua/nvwynd/plugins/formatting.lua | 10 ++++++---- install.sh | 4 +++- 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/.config/btop/btop.conf b/.config/btop/btop.conf index 6708d08..119f9c6 100644 --- a/.config/btop/btop.conf +++ b/.config/btop/btop.conf @@ -1,4 +1,4 @@ -#? Config file for btop v. 1.3.2 +#? Config file for btop v. 1.4.0 #* Name of a btop++/bpytop/bashtop formatted ".theme" file, "Default" and "TTY" for builtin themes. #* Themes should be placed in "../share/btop/themes" relative to binary or "$HOME/.config/btop/themes" @@ -47,7 +47,7 @@ graph_symbol_net = "default" graph_symbol_proc = "default" #* Manually set which boxes to show. Available values are "cpu mem net proc" and "gpu0" through "gpu5", separate values with whitespace. -shown_boxes = "cpu mem proc net" +shown_boxes = "cpu proc mem" #* Update time in milliseconds, recommended 2000 ms or above for better sample times for graphs. update_ms = 1000 diff --git a/.config/nvim/lua/nvwynd/autocmds.lua b/.config/nvim/lua/nvwynd/autocmds.lua index 521f740..7d158b8 100644 --- a/.config/nvim/lua/nvwynd/autocmds.lua +++ b/.config/nvim/lua/nvwynd/autocmds.lua @@ -33,3 +33,22 @@ user_command("CountWords", function() local words = vim.fn.wordcount()["words"] print("Words: " .. words) end, {}) + +user_command("FormatDisable", function(args) + if args.bang then + -- FormatDisable! will disable formatting just for this buffer + vim.b.disable_autoformat = true + else + vim.g.disable_autoformat = true + end +end, { + desc = "Disable autoformat-on-save", + bang = true, +}) + +user_command("FormatEnable", function() + vim.b.disable_autoformat = false + vim.g.disable_autoformat = false +end, { + desc = "Re-enable autoformat-on-save", +}) diff --git a/.config/nvim/lua/nvwynd/plugins/formatting.lua b/.config/nvim/lua/nvwynd/plugins/formatting.lua index c48caea..c8b6a8e 100644 --- a/.config/nvim/lua/nvwynd/plugins/formatting.lua +++ b/.config/nvim/lua/nvwynd/plugins/formatting.lua @@ -29,11 +29,13 @@ return { toml = { "taplo" }, c = { "clang-format" }, }, - format_on_save = { - timeout_ms = 500, - lsp_fallback = true, + format_on_save = function(bufnr) + if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then + return + end -- quiet = true, - }, + return { timeout_ms = 500, lsp_fallback = true } + end, }, init = function() vim.o.formatexpr = "v:lua.require('conform').formatexpr()" diff --git a/install.sh b/install.sh index c692d97..73a3532 100755 --- a/install.sh +++ b/install.sh @@ -102,7 +102,7 @@ get_git_release_url() { repo=$1 regex=$2 url=$(curl -s https://api.github.com/repos/$repo/releases/latest \ - | grep "browser_download_url.*${regex}\"" \ + | grep -P "browser_download_url.*${regex}\"" \ | cut -d : -f 2,3 \ | tr -d \") } @@ -183,6 +183,8 @@ deb_install OnlyOffice.deb "https://download.onlyoffice.com/install/desktop/edit deb_install JDGUI.deb "https://github.com/java-decompiler/jd-gui/releases/download/v1.6.6/jd-gui-1.6.6.deb" deb_install Minecraft.deb "https://launcher.mojang.com/download/Minecraft.deb" deb_git_install fastfetch.deb "fastfetch-cli/fastfetch" "fastfetch-linux-amd64.deb" +deb_git_install rg.deb "BurntSushi/ripgrep" "ripgrep_\d+.\d+.\d+-\d+_amd64\.deb" #"ripgrep_\d+.\d+.\d+-\d+_amd64\.deb" +deb_git_install blockbench.deb "JannisX11/blockbench" "Blockbench_\d+.\d+.\d+.deb" # TAR Installs # Zig's case is special mostly because they don't have the 0.13 builds on github so no tar_git_install for that sadly