From d7df1cba3423d97d7d4e7070cbc72f87456470de Mon Sep 17 00:00:00 2001 From: Egor Kovetskiy Date: Sat, 20 Jul 2024 08:08:09 +0000 Subject: [PATCH] update configs Signed-off-by: Egor Kovetskiy --- .config/coc/extensions/package.json | 7 +-- .config/i3/config.base | 4 +- .config/prols/prols.conf | 2 +- .ssh/config | 5 ++- .vim/coc-settings.json | 5 +-- .vim/snippets/go.snippets | 2 +- .zshrc | 28 ++++++++++++ bin/browser | 4 ++ bin/bumpver | 57 ++++++++++++++++++++++++ bin/frename | 69 +++++++++++++++++++++++++++++ bin/github-link | 17 ++++--- bin/go-mod-watch | 2 +- bin/screen-lock | 11 +++-- bin/xdg-open | 3 +- vim.d/01-plugins.vim | 23 ++++++++-- vim.d/11-fzf.vim | 11 +++-- vim.d/32-misc-func.vim | 4 ++ vim.d/63-langs-go.vim | 4 +- 18 files changed, 227 insertions(+), 31 deletions(-) create mode 100755 bin/bumpver create mode 100755 bin/frename diff --git a/.config/coc/extensions/package.json b/.config/coc/extensions/package.json index 6586cdcd..e9f7f59b 100755 --- a/.config/coc/extensions/package.json +++ b/.config/coc/extensions/package.json @@ -3,7 +3,7 @@ "coc-css": ">=1.3.0", "coc-eslint": ">=1.5.8", "coc-git": ">=2.5.1", - "coc-go": ">=1.3.0", + "coc-go": ">=1.3.33", "coc-java": ">=1.5.5", "coc-java-lombok": ">=1.0.0", "coc-json": ">=1.8.0", @@ -17,9 +17,10 @@ "coc-zig": ">=0.6.1", "coc-clangd": ">=0.29.3", "coc-prettier": ">=9.3.1", - "coc-rust-analyzer": ">=0.75.0" + "coc-rust-analyzer": ">=0.76.1", + "coc-protobuf": ">=0.0.2" }, "disabled": [], "locked": [], - "lastUpdate": 1709112918684 + "lastUpdate": 1720414299582 } \ No newline at end of file diff --git a/.config/i3/config.base b/.config/i3/config.base index 27631b32..844e9203 100644 --- a/.config/i3/config.base +++ b/.config/i3/config.base @@ -98,8 +98,8 @@ for_window [title="^feh "] floating enable for_window [title="^sxiv"] floating disable for_window [title="Viewer"] floating disable for_window [title="Chat - Twitch - Chromium"] sticky enable -for_window [title="webcam"] floating enable -for_window [title="webcam"] sticky enable +#for_window [title="webcam"] floating enable +#for_window [title="webcam"] sticky enable for_window [class="obsidian"] floating enable diff --git a/.config/prols/prols.conf b/.config/prols/prols.conf index ad7bb424..bae53c36 100755 --- a/.config/prols/prols.conf +++ b/.config/prols/prols.conf @@ -21,7 +21,7 @@ rules: - suffix: .png score: -10 - suffix: .go - score: 10 + score: 30 - suffix: .tsx score: 20 - suffix: .ts diff --git a/.ssh/config b/.ssh/config index e3ee2b15..3a68d9ed 100644 --- a/.ssh/config +++ b/.ssh/config @@ -25,9 +25,12 @@ Host * User root #SendEnv TERM=xterm ServerAliveInterval 100 - TCPKeepAlive no + TCPKeepAlive yes ServerAliveInterval 60 ServerAliveCountMax 10 + ControlMaster auto + ControlPersist 5m + ControlPath ~/.cache/ssh_%r_%h_%p Host bitbucket.org HostKeyAlgorithms +ssh-rsa diff --git a/.vim/coc-settings.json b/.vim/coc-settings.json index ebd6e88f..10acc558 100755 --- a/.vim/coc-settings.json +++ b/.vim/coc-settings.json @@ -56,7 +56,7 @@ "ignoredRootPaths": ["~"] }, "golang": { - "command": "gopls", + "command": "/usr/bin/gopls", "rootPatterns": ["go.mod", ".vim/", ".git/", ".hg/"], "filetypes": ["go"], "initializationOptions": { @@ -78,9 +78,8 @@ "typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": true, "javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": true, "go.trace.server": "verbose", + "go.goplsUseDaemon": true, "go.goplsOptions": { - "allowModfileModifications": true, - "allowImplicitNetworkAccess":true, "gofumpt": false, "codelenses": { "generate": true, diff --git a/.vim/snippets/go.snippets b/.vim/snippets/go.snippets index e05e5847..2bb003d1 100644 --- a/.vim/snippets/go.snippets +++ b/.vim/snippets/go.snippets @@ -208,7 +208,7 @@ endsnippet global !p def is_inside_var(snip): return px.whitespaces.match_higher_indent( - snip.buffer, snip.cursor, 'var \($' + snip.buffer, snip.cursor, r'var \($' ) endglobal diff --git a/.zshrc b/.zshrc index 3ed84a59..b94f35d5 100644 --- a/.zshrc +++ b/.zshrc @@ -1,6 +1,7 @@ . ~/bin/environment-variables export TERM=alacritty +export DISABLE_MAGIC_FUNCTIONS=true export KEYTIMEOUT=100 export WORDCHARS=- @@ -1215,6 +1216,25 @@ git-pr() { git checkout pr-$1 } +git-mr() { + local branch=$(:git:branch) + if [[ "$branch" == "mr-$1" ]]; then + if ! git checkout $(:git:get-master); then + echo "[!] dirty git?" >&2 + return 1 + fi + fi + git branch -D mr-$1 2>/dev/null + for remote in origin upstream; do + echo "[!] fetching $remote merge-requests/$1/head" >&2 + if git fetch $remote merge-requests/$1/head:mr-$1 2>/dev/null; then + break + fi + done + + git checkout mr-$1 +} + git-commit-smart() { local args=() local message=() @@ -1636,6 +1656,14 @@ alias -g -- '\kow'='-o wide' alias gmf='sed -i "/replace/d" go.mod; go mod tidy' +go-get-but-move-to-gopath() { + if result=$(gogetsrc "${@}"); then + cd $result + fi +} + +alias gog=go-get-but-move-to-gopath + stty -ixon FZF_TMUX_HEIGHT=0 diff --git a/bin/browser b/bin/browser index 0aee99af..bd731275 100755 --- a/bin/browser +++ b/bin/browser @@ -41,6 +41,7 @@ if parsed_url.scheme == '' and url != '': file_path = parsed_url.path if os.path.exists(file_path): scheme = 'file' + file_path = os.path.abspath(file_path) url = urlunparse((scheme, '', file_path, '', '', '')) else: raise Exception(f'File {file_path} does not exist') @@ -56,5 +57,8 @@ if url: else: i3_cmd = f"exec {browser}" +with open('/tmp/browser.log', 'w') as f: + f.write(i3_cmd) + print(i3_cmd) subprocess.run(['i3-msg', i3_cmd]) diff --git a/bin/bumpver b/bin/bumpver new file mode 100755 index 00000000..dd995997 --- /dev/null +++ b/bin/bumpver @@ -0,0 +1,57 @@ +#!/bin/env python3 + +import os +import re +import sys + +def update_version(file_path, version_type): + with open(file_path, 'r') as file: + content = file.read() + + version_pattern = r'(version\s*=\s*")(\d+\.\d+\.\d+)(")' + match = re.search(version_pattern, content) + + if match: + current_version = match.group(2) + major, minor, patch = map(int, current_version.split('.')) + + if version_type == 'major': + major += 1 + minor = 0 + patch = 0 + elif version_type == 'minor': + minor += 1 + patch = 0 + elif version_type == 'patch': + patch += 1 + else: + print(f"Invalid version type: {version_type}") + return + + new_version = f"{major}.{minor}.{patch}" + new_content = re.sub(version_pattern, r'\g<1>' + new_version + r'\g<3>', content) + + with open(file_path, 'w') as file: + file.write(new_content) + + print(f"Updated {file_path}: {current_version} -> {new_version}") + else: + print(f"No version found in {file_path}") + +def update_versions_in_directory(directory, version_type): + for root, dirs, files in os.walk(directory): + for file in files: + if file.endswith('.go'): + file_path = os.path.join(root, file) + update_version(file_path, version_type) + +if __name__ == '__main__': + if len(sys.argv) != 3: + print("Usage: python script.py ") + print("version_type can be 'major', 'minor', or 'patch'") + sys.exit(1) + + directory = sys.argv[1] + version_type = sys.argv[2] + + update_versions_in_directory(directory, version_type) diff --git a/bin/frename b/bin/frename new file mode 100755 index 00000000..930a9907 --- /dev/null +++ b/bin/frename @@ -0,0 +1,69 @@ +#!/usr/bin/env python3 +"""frename - File and Directory Renaming Tool + +This script recursively renames files and directories using sed. + +Usage: + frename [options] [] + +Options: + -h --help Show this help message and exit. + -v --verbose Increase verbosity of output. + +Arguments: + Regular expression for renaming (sed-style substitution). + Directory to start from [default: current directory]. +""" + +from docopt import docopt +import os +import sys +import subprocess + +def rename_with_sed(old_path, regexp, verbose=False): + try: + new_name = subprocess.check_output(['sed', '-r', regexp], input=os.path.basename(old_path), universal_newlines=True).strip() + new_path = os.path.join(os.path.dirname(old_path), new_name) + + if old_path != new_path: + os.rename(old_path, new_path) + if verbose: + print(f"Renamed: {old_path} -> {new_path}") + + return new_path + except subprocess.CalledProcessError as e: + print(f"Error applying sed to {old_path}: {e}", file=sys.stderr) + sys.exit(1) + except OSError as e: + print(f"Error renaming {old_path}: {e}", file=sys.stderr) + + return old_path + +def rename_recursive(start_dir, regexp, verbose=False): + for root, dirs, files in os.walk(start_dir, topdown=False): + # Rename directories first (bottom-up) + for i, name in enumerate(dirs): + old_path = os.path.join(root, name) + new_path = rename_with_sed(old_path, regexp, verbose) + dirs[i] = os.path.basename(new_path) + + # Then rename files + for name in files: + old_path = os.path.join(root, name) + rename_with_sed(old_path, regexp, verbose) + + # Rename the start directory if needed + if start_dir != '.': + rename_with_sed(start_dir, regexp, verbose) + +if __name__ == '__main__': + arguments = docopt(__doc__) + regexp = arguments[''] + start_dir = arguments[''] or '.' + verbose = arguments['--verbose'] + + if not os.path.exists(start_dir): + print(f"Error: Directory '{start_dir}' does not exist.", file=sys.stderr) + sys.exit(1) + + rename_recursive(start_dir, regexp, verbose) diff --git a/bin/github-link b/bin/github-link index 72fabb73..796a11fb 100755 --- a/bin/github-link +++ b/bin/github-link @@ -15,23 +15,30 @@ set -euo pipefail local origin origin=$(git -C $root remote get-url origin) + local hostname + hostname=$(sed -E 's#^(https?://|git@)([^:/]+).*#\2#' <<< "$origin") + local repo - repo=$(grep -Po '[:/]\K[^/]+/[^/]+$' <<< "$origin" | sed 's|\.git$||') + repo=$(sed -E 's#^(https?://|git@)[^:/]+[:/]([^/]+/[^/]+)(\.git)?#\2#' <<< "$origin") local branch branch=$(git -C $root rev-parse --abbrev-ref HEAD) local link - link="https://github.com/$repo/blob/$branch/$filename" + if [[ "$hostname" == *"gitlab"* ]]; then + link="https://$hostname/$repo/-/blob/$branch/$filename" + else + link="https://$hostname/$repo/blob/$branch/$filename" + fi if [[ "$line" ]]; then link="$link#L$line" fi - notify-send 1 $link + notify-send 1 "$link" - echo -n $link | xclip -selection primary - echo -n $link | xclip -selection clipboard + echo -n "$link" | xclip -selection primary + echo -n "$link" | xclip -selection clipboard } :log() { diff --git a/bin/go-mod-watch b/bin/go-mod-watch index a168bc54..9120a12b 100755 --- a/bin/go-mod-watch +++ b/bin/go-mod-watch @@ -13,7 +13,7 @@ } if [[ ! "$1" ]]; then - exec watcher -x vendor '\.go$' -- "$0" "%s" + exec with-lock watcher -x vendor '\.go$' -- "$0" "%s" fi :blue ":: go build because of $1" diff --git a/bin/screen-lock b/bin/screen-lock index 8d9c4625..a4371c2e 100755 --- a/bin/screen-lock +++ b/bin/screen-lock @@ -1,8 +1,13 @@ #!/bin/bash -import -window root /tmp/s.png -convert /tmp/s.png /tmp/s_blurred.png -exec i3lock -i /tmp/s_blurred.png +#ffmpeg -y -f x11grab -i :0.0 -vframes 1 -vf "curves=all='0/0 0.7/0.7 1/0.5'" -vf "boxblur=5:1" /tmp/ffmpeg.png +ffmpeg -y -f x11grab -i :0.0 -vframes 1 -vf "boxblur=40:1,curves=all='0/0 0.7/0.7 1/0.5'" /tmp/ffmpeg.png +#import -window root /tmp/s.png +##convert /tmp/s.png /tmp/s_blurred.png +##blur +#convert /tmp/s.png -blur 0x5 /tmp/s_blurred.png +exec i3lock -k -i /tmp/ffmpeg.png +#i3lock -B 10 -k #export XSECURELOCK_DISCARD_FIRST_KEYPRESS=0 #export XSECURELOCK_SHOW_DATETIME=1 diff --git a/bin/xdg-open b/bin/xdg-open index 3c13464c..f683a835 100755 --- a/bin/xdg-open +++ b/bin/xdg-open @@ -1,8 +1,9 @@ #!/bin/bash - url="$1" +echo "$*" >> /tmp/xdg-open.log + if [[ "$url" =~ "open.spotify.com" ]] || [[ "$url" =~ "spotify://" ]]; then spotify_uri=$(grep -Po '(open.spotify.com/|spotify://)\K\w+/[^?]+' <<< "$url" | sed 's@/@:@') exec dbus-send \ diff --git a/vim.d/01-plugins.vim b/vim.d/01-plugins.vim index 9cd96431..83565a23 100644 --- a/vim.d/01-plugins.vim +++ b/vim.d/01-plugins.vim @@ -130,10 +130,18 @@ Plug 'yuezk/vim-js' Plug 'HerringtonDarkholme/yats.vim' Plug 'MaxMEllon/vim-jsx-pretty' -Plug 'github/copilot.vim' - imap