Skip to content

Commit

Permalink
update configs
Browse files Browse the repository at this point in the history
Signed-off-by: Egor Kovetskiy <[email protected]>
  • Loading branch information
kovetskiy committed Jul 20, 2024
1 parent 6f6c46d commit d7df1cb
Show file tree
Hide file tree
Showing 18 changed files with 227 additions and 31 deletions.
7 changes: 4 additions & 3 deletions .config/coc/extensions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
}
4 changes: 2 additions & 2 deletions .config/i3/config.base
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .config/prols/prols.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ rules:
- suffix: .png
score: -10
- suffix: .go
score: 10
score: 30
- suffix: .tsx
score: 20
- suffix: .ts
Expand Down
5 changes: 4 additions & 1 deletion .ssh/config
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions .vim/coc-settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"ignoredRootPaths": ["~"]
},
"golang": {
"command": "gopls",
"command": "/usr/bin/gopls",
"rootPatterns": ["go.mod", ".vim/", ".git/", ".hg/"],
"filetypes": ["go"],
"initializationOptions": {
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion .vim/snippets/go.snippets
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
28 changes: 28 additions & 0 deletions .zshrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
. ~/bin/environment-variables

export TERM=alacritty
export DISABLE_MAGIC_FUNCTIONS=true

export KEYTIMEOUT=100
export WORDCHARS=-
Expand Down Expand Up @@ -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=()
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions bin/browser
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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])
57 changes: 57 additions & 0 deletions bin/bumpver
Original file line number Diff line number Diff line change
@@ -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 <directory> <version_type>")
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)
69 changes: 69 additions & 0 deletions bin/frename
Original file line number Diff line number Diff line change
@@ -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] <regexp> [<dir>]
Options:
-h --help Show this help message and exit.
-v --verbose Increase verbosity of output.
Arguments:
<regexp> Regular expression for renaming (sed-style substitution).
<dir> 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['<regexp>']
start_dir = arguments['<dir>'] 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)
17 changes: 12 additions & 5 deletions bin/github-link
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion bin/go-mod-watch
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 8 additions & 3 deletions bin/screen-lock
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion bin/xdg-open
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
23 changes: 19 additions & 4 deletions vim.d/01-plugins.vim
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,18 @@ Plug 'yuezk/vim-js'
Plug 'HerringtonDarkholme/yats.vim'
Plug 'MaxMEllon/vim-jsx-pretty'

Plug 'github/copilot.vim'
imap <silent><script><expr> <C-Q> copilot#Accept("\<CR>")
let g:copilot_no_tab_map = v:true
let g:copilot_filetypes = { '*': v:true }
Plug 'Exafunction/codeium.vim'
let g:codeium_no_map_tab = v:true
let g:codeium_log_file = "~/.codeium/codeium.log"

imap <script><silent><nowait><expr> <C-q> codeium#Accept()
imap <C-;> <Cmd>call codeium#CycleCompletions(1)<CR>
imap <C-,> <Cmd>call codeium#CycleCompletions(-1)<CR>
imap <C-x> <Cmd>call codeium#Clear()<CR>
"Plug 'github/copilot.vim'
" imap <silent><script><expr> <C-Q> copilot#Accept("\<CR>")
" let g:copilot_no_tab_map = v:true
" let g:copilot_filetypes = { '*': v:true }

Plug 'mogelbrod/vim-jsonpath'
noremap <buffer> <silent> <C-J><C-D> :call jsonpath#echo()<CR>
Expand All @@ -146,6 +154,13 @@ Plug 'sonph/onehalf', { 'rtp': 'vim' }
Plug 'sebdah/vim-delve'
Plug 'towolf/vim-helm'
Plug 'terrastruct/d2-vim'
Plug 'CoderCookE/vim-chatgpt'
let g:chat_gpt_max_tokens = 2000
let g:chat_gpt_model = 'gpt-4'
let g:chat_gpt_session_mode = 0
let g:chat_gpt_temperature = 0.7
let g:chat_gpt_split_direction = 'vertical'
let g:split_ratio = 4


call plug#end()
Loading

0 comments on commit d7df1cb

Please sign in to comment.