diff options
author | Daniil Rozanov <dev@drozanov.info> | 2024-11-12 13:26:52 +0400 |
---|---|---|
committer | Daniil Rozanov <dev@drozanov.info> | 2024-11-12 13:26:52 +0400 |
commit | 056efe4b5af41ad23426b9fb78b23d235b7e373f (patch) | |
tree | 049543fa5cf9a44af0a4d144586bf60cba1d1c84 | |
parent | c7e9ba4c96f73b650d5a1831f934ddac90cd019a (diff) |
zsh, delete rest.nvim
-rw-r--r-- | nvim/.config/nvim/lua/custom/plugins/rest.lua | 16 | ||||
-rw-r--r-- | nvim/.config/nvim/lua/custom/rest.lua | 14 | ||||
-rw-r--r-- | zsh/.config/zsh/.zshrc | 32 | ||||
-rw-r--r-- | zsh/.config/zsh/aliases.zsh | 2 | ||||
-rw-r--r-- | zsh/.config/zsh/bindings.zsh | 23 | ||||
-rw-r--r-- | zsh/.config/zsh/functions.zsh | 31 | ||||
-rw-r--r-- | zsh/.config/zsh/plugins.zsh | 5 | ||||
-rw-r--r-- | zsh/.config/zsh/prompt.zsh | 73 | ||||
-rw-r--r-- | zsh/.zshenv | 10 |
9 files changed, 176 insertions, 30 deletions
diff --git a/nvim/.config/nvim/lua/custom/plugins/rest.lua b/nvim/.config/nvim/lua/custom/plugins/rest.lua deleted file mode 100644 index 2d53a70..0000000 --- a/nvim/.config/nvim/lua/custom/plugins/rest.lua +++ /dev/null @@ -1,16 +0,0 @@ -return { - { - "vhyrro/luarocks.nvim", - priority = 1000, - config = true, - opts = { rocks = { "lua-curl", "nvim-nio", "mimetypes", "xml2lua" } }, - }, - { - "rest-nvim/rest.nvim", - ft = "http", - dependencies = { "luarocks.nvim", "nvim-treesitter/nvim-treesitter" }, - config = function() - require "custom.rest" - end, - }, -} diff --git a/nvim/.config/nvim/lua/custom/rest.lua b/nvim/.config/nvim/lua/custom/rest.lua deleted file mode 100644 index b058279..0000000 --- a/nvim/.config/nvim/lua/custom/rest.lua +++ /dev/null @@ -1,14 +0,0 @@ -require("rest-nvim").setup { - keybinds = { - { - "<leader>rr", - "<cmd>Rest run<cr>", - "Run requesti under the cursor", - }, - { - "<leader>rl", - "<cmd>Rest run last<cr>", - "Re-run latest request", - }, - }, -} diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc new file mode 100644 index 0000000..e2a13bd --- /dev/null +++ b/zsh/.config/zsh/.zshrc @@ -0,0 +1,32 @@ +#!/bin/sh + +# some useful options (man zshoptions) +setopt autocd extendedglob nomatch menucomplete +setopt interactive_comments +stty stop undef # Disable ctrl-s to freeze terminal. +zle_highlight=('paste:none') + +# beeping is annoying +unsetopt BEEP + + +# completions +autoload -Uz compinit +zstyle ':completion:*' menu select +# zstyle ':completion::complete:lsof:*' menu yes select +zmodload zsh/complist +# compinit +_comp_options+=(globdots) # Include hidden files. + + +# Colors +autoload -Uz colors && colors + +# Plugins +source $ZDOTDIR/plugins.zsh + +# Aliases +source $ZDOTDIR/aliases.zsh + +# Prompt +source $ZDOTDIR/prompt.zsh diff --git a/zsh/.config/zsh/aliases.zsh b/zsh/.config/zsh/aliases.zsh new file mode 100644 index 0000000..937dffc --- /dev/null +++ b/zsh/.config/zsh/aliases.zsh @@ -0,0 +1,2 @@ +alias v=nvim +alias la="ls -la" diff --git a/zsh/.config/zsh/bindings.zsh b/zsh/.config/zsh/bindings.zsh new file mode 100644 index 0000000..82a4fd3 --- /dev/null +++ b/zsh/.config/zsh/bindings.zsh @@ -0,0 +1,23 @@ +bindkey -s '^o' 'ranger^M' +bindkey -s '^f' 'zi^M' +bindkey -s '^s' 'ncdu^M' +bindkey -s '^z' 'zi^M' +bindkey '^[[P' delete-char + +# Search navigation +autoload -U up-line-or-beginning-search +autoload -U down-line-or-beginning-search +zle -N up-line-or-beginning-search +zle -N down-line-or-beginning-search +bindkey "^p" up-line-or-beginning-search # Up +bindkey "^n" down-line-or-beginning-search # Down +bindkey "^k" up-line-or-beginning-search # Up +bindkey "^j" down-line-or-beginning-search # Down + +# Edit line in vim with ctrl-e: +autoload edit-command-line; zle -N edit-command-line +bindkey '^e' edit-command-line + +# Unbind +bindkey -r "^u" +bindkey -r "^d" diff --git a/zsh/.config/zsh/functions.zsh b/zsh/.config/zsh/functions.zsh new file mode 100644 index 0000000..e854a4a --- /dev/null +++ b/zsh/.config/zsh/functions.zsh @@ -0,0 +1,31 @@ +ZSH_PLUGIN_DIR=${XDG_DATA_HOME:-$HOME/.local/share}/zsh/plugins + +# Function to source files if they exist +function zsh_source_file() { + [ -f $1 ] && source $1 +} + +function zsh_add_plugin() { + PLUGIN_NAME=$(echo $1 | cut -d "/" -f 2) + if [ ! -d "$ZSH_PLUGIN_DIR/$PLUGIN_NAME" ]; then + git clone "https://github.com/$1.git" "$ZSH_PLUGIN_DIR/$PLUGIN_NAME" + fi + zsh_source_file "$ZSH_PLUGIN_DIR/$PLUGIN_NAME/$PLUGIN_NAME.plugin.zsh" || \ + zsh_source_file "$ZSH_PLUGIN_DIR/$PLUGIN_NAME/$PLUGIN_NAME.zsh" +} + +function zsh_add_completion() { + PLUGIN_NAME=$(echo $1 | cut -d "/" -f 2) + if [ -d "$ZDOTDIR/plugins/$PLUGIN_NAME" ]; then + # For completions + completion_file_path=$(ls $ZDOTDIR/plugins/$PLUGIN_NAME/_*) + fpath+="$(dirname "${completion_file_path}")" + zsh_source_file "$ZSH_PLUGIN_DIR/$PLUGIN_NAME/$PLUGIN_NAME.plugin.zsh" + else + git clone "https://github.com/$1.git" "$ZDOTDIR/plugins/$PLUGIN_NAME" + fpath+=$(ls $ZDOTDIR/plugins/$PLUGIN_NAME/_*) + [ -f $ZDOTDIR/.zccompdump ] && $ZDOTDIR/.zccompdump + fi + completion_file="$(basename "${completion_file_path}")" + if [ "$2" = true ] && compinit "${completion_file:1}" +} diff --git a/zsh/.config/zsh/plugins.zsh b/zsh/.config/zsh/plugins.zsh new file mode 100644 index 0000000..177835a --- /dev/null +++ b/zsh/.config/zsh/plugins.zsh @@ -0,0 +1,5 @@ +source $ZDOTDIR/functions.zsh + +# Plugins +zsh_add_plugin "zsh-users/zsh-autosuggestions" +zsh_add_plugin "zsh-users/zsh-syntax-highlighting" diff --git a/zsh/.config/zsh/prompt.zsh b/zsh/.config/zsh/prompt.zsh new file mode 100644 index 0000000..3e74427 --- /dev/null +++ b/zsh/.config/zsh/prompt.zsh @@ -0,0 +1,73 @@ +COLOR_PROMPT_TEXT='009' +COLOR_PROMPT_GLYPH='255' +NUM_DIRS_LEFT_OF_TRUNCATION=1 +NUM_DIRS_RIGHT_OF_TRUNCATION=2 +GLYPH_PROMPT_TRUNCATION_SYMBOL='⋯' +GLYPH_PROMPT_END_SYMBOL='❯' + +set_prompt() { + [[ $NUM_DIRS_LEFT_OF_TRUNCATION -le 0 ]] && NUM_DIRS_LEFT_OF_TRUNCATION=1 + [[ $NUM_DIRS_RIGHT_OF_TRUNCATION -le 0 ]] && NUM_DIRS_RIGHT_OF_TRUNCATION=2 + + local prompt_truncation_symbol="%F{${COLOR_PROMPT_GLYPH}}%B${GLYPH_PROMPT_TRUNCATION_SYMBOL}%b%f" + local prompt_end_symbol="%F{${COLOR_PROMPT_GLYPH}}%B${GLYPH_PROMPT_END_SYMBOL}%b%f" + local total_dirs=$(($NUM_DIRS_LEFT_OF_TRUNCATION+$NUM_DIRS_RIGHT_OF_TRUNCATION+1)) + local dir_path_full="%F{${COLOR_PROMPT_TEXT}}%d%f" + local dir_path_truncated="%F{${COLOR_PROMPT_TEXT}}%-${NUM_DIRS_LEFT_OF_TRUNCATION}d/%f${prompt_truncation_symbol}%F{${COLOR_PROMPT_TEXT}}/%${NUM_DIRS_RIGHT_OF_TRUNCATION}d%f" + + PROMPT="%(${total_dirs}C.${dir_path_truncated}.${dir_path_full}) ${prompt_end_symbol} " +} + +precmd_functions+=(set_prompt) + + +COLOR_GIT_REPOSITORY_TEXT='245' +COLOR_GIT_BRANCH_TEXT='255' +COLOR_GIT_STATUS_CLEAN='010' +COLOR_GIT_STATUS_DIRTY='009' +GLYPH_GIT_BRANCH_SYNC_SYMBOL='«' +GLYPH_GIT_STASH_SYMBOL='∘' +GLYPH_GIT_STATUS_SYMBOL='»' + +set_rprompt() { + local git_branch_name=$(git symbolic-ref --short HEAD 2> /dev/null) + if [[ -z $git_branch_name ]]; then + RPROMPT="" + + return + fi + + local git_remote_commit=$(git rev-parse "origin/$git_branch_name" 2> /dev/null) + local git_local_commit=$(git rev-parse "$git_branch_name" 2> /dev/null) + local git_branch_sync_color=$COLOR_GIT_STATUS_DIRTY + if [[ $git_remote_commit == $git_local_commit ]]; then + git_branch_sync_color=$COLOR_GIT_STATUS_CLEAN + fi + + local git_stash=$(git stash list) + local git_stash_symbol=$GLYPH_GIT_STASH_SYMBOL + if [[ -z $git_stash ]]; then + git_stash_symbol="" + fi + + local git_status=$(git status --porcelain) + local git_stash_color=$COLOR_GIT_STATUS_DIRTY + local git_status_color=$COLOR_GIT_STATUS_DIRTY + if [[ -z $git_status ]]; then + git_stash_color=$COLOR_GIT_STATUS_CLEAN + git_status_color=$COLOR_GIT_STATUS_CLEAN + fi + + local git_repository_path=$(git rev-parse --show-toplevel) + local git_repository_name=$(basename "$git_repository_path") + + local git_repository_text="%F{${COLOR_GIT_REPOSITORY_TEXT}}${git_repository_name}%f" + local git_branch_sync_symbol="%F{${git_branch_sync_color}}%B${GLYPH_GIT_BRANCH_SYNC_SYMBOL}%b%f" + local git_stash_symbol="%F{${git_stash_color}}%B${git_stash_symbol}%b%f" + local git_status_symbol="%F{${git_status_color}}%B${GLYPH_GIT_STATUS_SYMBOL}%b%f" + local git_branch_text="%F{${COLOR_GIT_BRANCH_TEXT}}${git_branch_name}%f" + + RPROMPT="${git_repository_text} ${git_branch_sync_symbol}${git_stash_symbol}${git_status_symbol} ${git_branch_text}" +} + +precmd_functions+=(set_rprompt) diff --git a/zsh/.zshenv b/zsh/.zshenv new file mode 100644 index 0000000..270817e --- /dev/null +++ b/zsh/.zshenv @@ -0,0 +1,10 @@ +# XDG Paths +export XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config} +export XDG_CACHE_HOME=${XDG_CACHE_HOME:-$HOME/.cache} +export XDG_DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share} + +# ZSH config dir +export ZDOTDIR=$XDG_CONFIG_HOME/zsh + +# User environment variables +export EDITOR="nvim" |