Skip to content

Commit

Permalink
Try to improve completion loading
Browse files Browse the repository at this point in the history
  • Loading branch information
serverwentdown committed Sep 4, 2023
1 parent ee2dd3f commit 5af918e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .config/sway/config
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ bindsym $mod+F5 \
#
# Firefox
#
for_window [title="Firefox — Sharing Indicator"] floating enable
for_window [title="Firefox — Sharing Indicator"] floating enable, move position 50 ppt 0 px
for_window [title="About Mozilla Firefox"] floating enable
for_window [title="Picture-in-Picture"] floating enable, sticky enable
for_window [title="Picture-in-picture"] floating enable, sticky enable
Expand Down
20 changes: 15 additions & 5 deletions .local/bin/stignore-gen
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

from typing import Optional, Iterable
from pathlib import Path
Expand Down Expand Up @@ -29,6 +29,7 @@ def write_line(path: Path, line: str):
def resolve(parent: Path, line: str) -> Iterable[str]:
if line.startswith("#") or len(line.strip()) == 0:
return

negate = line.startswith("!")
path = line.removeprefix("!").strip()
absolute = "/" in line.removesuffix("/")
Expand All @@ -37,6 +38,7 @@ def resolve(parent: Path, line: str) -> Iterable[str]:
if negate:
prefix += "!"
else:
# gitignore lines to recursively delete
if (
"target" in path
or "generated" in path
Expand All @@ -46,6 +48,9 @@ def resolve(parent: Path, line: str) -> Iterable[str]:
or "node_modules" in path
):
prefix += "(?d)"
# gitignore lines to exclude
if "[._]" in path:
return

yield "// " + str(parent) + ": " + line.strip()
if absolute:
Expand Down Expand Up @@ -74,22 +79,27 @@ if __name__ == "__main__":
parser.add_argument(
"-w", "--write", action="store_const", const=True, default=False
)
parser.add_argument(
"path", type=Path, nargs="*", default=[Path(".")]
)
args = parser.parse_args()

if args.write:
ignore = Path(".stignore")
ignore_gen = Path(".stignore.gen")
with open(ignore_gen, "w") as f:
for line in scan(Path(".")):
f.write(line + "\n")
for path in args.path:
for line in scan(Path(path)):
f.write(line + "\n")
ignore_line = "#include " + str(ignore_gen)
if not check_line(ignore, ignore_line):
print("WARNING: .stignore does not exist or is missing the include line")
response = input("append an include line for the generated file? (y/n) ")
if response.lower() == "y":
write_line(ignore, ignore_line)
else:
for line in scan(Path(".")):
print(line)
for path in args.path:
for line in scan(Path(path)):
print(line)

# vim: set et ts=4 sw=4:
52 changes: 25 additions & 27 deletions .zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -216,33 +216,31 @@ fi

# completion

# Add default completions
fpath+="$HOME/.config/zsh-completions"
# Style completions
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' auto-description 'specify: %d'
zstyle ':completion:*' completer _expand _complete _correct _approximate
zstyle ':completion:*' format '%F{blue}-- %d --%f'
zstyle ':completion:*' group-name ''
zstyle ':completion:*' menu select=2
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*'
zstyle ':completion:*' menu select=long
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
zstyle ':completion:*' use-compctl false
zstyle ':completion:*' verbose true
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
setup_completion() {
if ! command -v compinit >/dev/null; then
autoload -Uz compinit
compinit
fi
if ! command -v bashcompinit >/dev/null; then
autoload -Uz bashcompinit
bashcompinit
fi
# Add default completions
fpath+="$HOME/.config/zsh-completions"
# Style completions
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' auto-description 'specify: %d'
zstyle ':completion:*' completer _expand _complete _correct _approximate
zstyle ':completion:*' format '%F{blue}-- %d --%f'
zstyle ':completion:*' group-name ''
zstyle ':completion:*' menu select=2
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*'
zstyle ':completion:*' menu select=long
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
zstyle ':completion:*' use-compctl false
zstyle ':completion:*' verbose true
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
# Load completions
autoload -Uz compinit
compinit
autoload -Uz bashcompinit
bashcompinit

# Setup fast apps
if which mc >/dev/null 2>/dev/null; then
complete -o nospace -C mc mc
Expand All @@ -254,7 +252,7 @@ setup_completion() {
slower_functions+=( setup_completion )
setup_completion_more() {
# Depends:
setup_completion
#setup_completion

if which kubectl >/dev/null 2>/dev/null; then
source <(kubectl completion zsh)
Expand Down

0 comments on commit 5af918e

Please sign in to comment.