From b642f2f05561067b1fef537daacdec22edfd4ad1 Mon Sep 17 00:00:00 2001 From: kalle Date: Wed, 23 Sep 2020 17:05:10 +0200 Subject: [PATCH] Create setup script. Add nvim config. Add fish config. --- README.md | 19 +- fish/abbreviations.fish | 4 + fish/completions/fisher.fish | 1 + fish/completions/tide.fish | 9 + fish/conf.d/_pure_init.fish | 8 + fish/conf.d/dracula.fish | 33 ++ fish/conf.d/pure.fish | 66 +++ fish/config.fish | 22 + fish/fish_variables | 71 +++ fish/fishfile | 2 + fish/functions/_pure_format_time.fish | 32 ++ fish/functions/_pure_get_prompt_symbol.fish | 14 + fish/functions/_pure_parse_directory.fish | 14 + fish/functions/_pure_parse_git_branch.fish | 4 + .../_pure_place_iterm2_prompt_mark.fish | 5 + fish/functions/_pure_print_prompt.fish | 11 + fish/functions/_pure_prompt.fish | 11 + fish/functions/_pure_prompt_beginning.fish | 6 + .../_pure_prompt_command_duration.fish | 11 + .../_pure_prompt_current_folder.fish | 11 + fish/functions/_pure_prompt_ending.fish | 3 + fish/functions/_pure_prompt_first_line.fish | 35 ++ fish/functions/_pure_prompt_git.fish | 20 + fish/functions/_pure_prompt_git_branch.fish | 6 + fish/functions/_pure_prompt_git_dirty.fish | 18 + .../_pure_prompt_git_pending_commits.fish | 27 ++ fish/functions/_pure_prompt_jobs.fish | 9 + fish/functions/_pure_prompt_new_line.fish | 11 + fish/functions/_pure_prompt_ssh.fish | 5 + fish/functions/_pure_prompt_ssh_host.fish | 7 + .../functions/_pure_prompt_ssh_separator.fish | 6 + fish/functions/_pure_prompt_ssh_user.fish | 10 + fish/functions/_pure_prompt_symbol.fish | 20 + fish/functions/_pure_prompt_vimode.fish | 5 + fish/functions/_pure_prompt_virtualenv.fish | 8 + fish/functions/_pure_set_color.fish | 19 + fish/functions/_pure_set_default.fish | 8 + fish/functions/_pure_string_width.fish | 9 + fish/functions/fish_greeting.fish | 2 + fish/functions/fish_mode_prompt.fish | 2 + fish/functions/fish_prompt.fish | 11 + fish/functions/fish_title.fish | 16 + fish/functions/fisher.fish | 436 ++++++++++++++++++ nvim/colors/dracula.vim | 351 ++++++++++++++ nvim/init.vim | 243 ++++++++++ setup.sh | 36 ++ 46 files changed, 1676 insertions(+), 1 deletion(-) create mode 100644 fish/abbreviations.fish create mode 100644 fish/completions/fisher.fish create mode 100644 fish/completions/tide.fish create mode 100644 fish/conf.d/_pure_init.fish create mode 100644 fish/conf.d/dracula.fish create mode 100644 fish/conf.d/pure.fish create mode 100644 fish/config.fish create mode 100644 fish/fish_variables create mode 100644 fish/fishfile create mode 100644 fish/functions/_pure_format_time.fish create mode 100644 fish/functions/_pure_get_prompt_symbol.fish create mode 100644 fish/functions/_pure_parse_directory.fish create mode 100644 fish/functions/_pure_parse_git_branch.fish create mode 100644 fish/functions/_pure_place_iterm2_prompt_mark.fish create mode 100644 fish/functions/_pure_print_prompt.fish create mode 100644 fish/functions/_pure_prompt.fish create mode 100644 fish/functions/_pure_prompt_beginning.fish create mode 100644 fish/functions/_pure_prompt_command_duration.fish create mode 100644 fish/functions/_pure_prompt_current_folder.fish create mode 100644 fish/functions/_pure_prompt_ending.fish create mode 100644 fish/functions/_pure_prompt_first_line.fish create mode 100644 fish/functions/_pure_prompt_git.fish create mode 100644 fish/functions/_pure_prompt_git_branch.fish create mode 100644 fish/functions/_pure_prompt_git_dirty.fish create mode 100644 fish/functions/_pure_prompt_git_pending_commits.fish create mode 100644 fish/functions/_pure_prompt_jobs.fish create mode 100644 fish/functions/_pure_prompt_new_line.fish create mode 100644 fish/functions/_pure_prompt_ssh.fish create mode 100644 fish/functions/_pure_prompt_ssh_host.fish create mode 100644 fish/functions/_pure_prompt_ssh_separator.fish create mode 100644 fish/functions/_pure_prompt_ssh_user.fish create mode 100644 fish/functions/_pure_prompt_symbol.fish create mode 100644 fish/functions/_pure_prompt_vimode.fish create mode 100644 fish/functions/_pure_prompt_virtualenv.fish create mode 100644 fish/functions/_pure_set_color.fish create mode 100644 fish/functions/_pure_set_default.fish create mode 100644 fish/functions/_pure_string_width.fish create mode 100644 fish/functions/fish_greeting.fish create mode 100644 fish/functions/fish_mode_prompt.fish create mode 100644 fish/functions/fish_prompt.fish create mode 100644 fish/functions/fish_title.fish create mode 100644 fish/functions/fisher.fish create mode 100755 nvim/colors/dracula.vim create mode 100644 nvim/init.vim create mode 100755 setup.sh diff --git a/README.md b/README.md index 27ef622..1f9d3dd 100644 --- a/README.md +++ b/README.md @@ -1 +1,18 @@ -# dotfiles \ No newline at end of file +# Dot Files +This repository contains the configuration files for some of the programs I use. There is also a handy setup script that should configure everything for you. + +## Usage +To use these configuration files you first have to make sure you have the following programs installed: +- fish +- neovim + +Once you have these programs installed you can clone the repository into a place you like and run the setup script. The setup script will detect existing configuration files and leave them alone. This means that if you are replacing an old configuration you need to delete it first. +```bash +# Clone the repository into the folder .dots in your home directory. +git clone https://github.com/KalleStruik/dotfiles.git ~/.dots + +# Execute the install script. +cd ~/.dots +bash setup.sh +``` + diff --git a/fish/abbreviations.fish b/fish/abbreviations.fish new file mode 100644 index 0000000..b17613d --- /dev/null +++ b/fish/abbreviations.fish @@ -0,0 +1,4 @@ +abbr ls "lsd" +abbr p "sudo pacman" +abbr vim "nvim" +abbr vi "nvim" diff --git a/fish/completions/fisher.fish b/fish/completions/fisher.fish new file mode 100644 index 0000000..271e314 --- /dev/null +++ b/fish/completions/fisher.fish @@ -0,0 +1 @@ +fisher complete diff --git a/fish/completions/tide.fish b/fish/completions/tide.fish new file mode 100644 index 0000000..5970c5f --- /dev/null +++ b/fish/completions/tide.fish @@ -0,0 +1,9 @@ +set -l subcommands (basename -s '.fish' $__fish_config_dir/functions/_tide_sub_* | string replace '_tide_sub_' '') +set -l uninstallIndex (contains --index uninstall $subcommands) +set -l subcommandsWithoutUninstall (printf '%s ' $subcommands[1..(math $uninstallIndex-1)] $subcommands[(math $uninstallIndex+1)..-1]) + +# Disable file completions for the entire command +complete --command tide --no-files + +# Offer subcommands (without uninstall) if no subcommand has been given so far +complete --command tide --condition "not __fish_seen_subcommand_from $subcommands" --arguments=$subcommandsWithoutUninstall \ No newline at end of file diff --git a/fish/conf.d/_pure_init.fish b/fish/conf.d/_pure_init.fish new file mode 100644 index 0000000..04b45d8 --- /dev/null +++ b/fish/conf.d/_pure_init.fish @@ -0,0 +1,8 @@ +# Deactivate the default virtualenv prompt so that we can add our own +set --global --export VIRTUAL_ENV_DISABLE_PROMPT 1 + +# Whether or not is a fresh session +set --global _pure_fresh_session true + +# Register `_pure_prompt_new_line` as an event handler fot `fish_prompt` +functions -q _pure_prompt_new_line diff --git a/fish/conf.d/dracula.fish b/fish/conf.d/dracula.fish new file mode 100644 index 0000000..a396547 --- /dev/null +++ b/fish/conf.d/dracula.fish @@ -0,0 +1,33 @@ +# Dracula Color Palette +set -l foreground f8f8f2 +set -l selection 44475a +set -l comment 6272a4 +set -l red ff5555 +set -l orange ffb86c +set -l yellow f1fa8c +set -l green 50fa7b +set -l purple bd93f9 +set -l cyan 8be9fd +set -l pink ff79c6 + +# Syntax Highlighting Colors +set -g fish_color_normal $foreground +set -g fish_color_command $cyan +set -g fish_color_quote $yellow +set -g fish_color_redirection $foreground +set -g fish_color_end $orange +set -g fish_color_error $red +set -g fish_color_param $purple +set -g fish_color_comment $comment +set -g fish_color_match --background=$selection +set -g fish_color_selection --background=$selection +set -g fish_color_search_match --background=$selection +set -g fish_color_operator $green +set -g fish_color_escape $pink +set -g fish_color_autosuggestion $comment + +# Completion Pager Colors +set -g fish_pager_color_progress $comment +set -g fish_pager_color_prefix $cyan +set -g fish_pager_color_completion $foreground +set -g fish_pager_color_description $comment diff --git a/fish/conf.d/pure.fish b/fish/conf.d/pure.fish new file mode 100644 index 0000000..396fa93 --- /dev/null +++ b/fish/conf.d/pure.fish @@ -0,0 +1,66 @@ +set --global pure_version 2.5.2 # used for bug report + +# Base colors +_pure_set_default pure_color_primary blue +_pure_set_default pure_color_info cyan +_pure_set_default pure_color_mute brblack +_pure_set_default pure_color_success magenta +_pure_set_default pure_color_normal normal +_pure_set_default pure_color_danger red +_pure_set_default pure_color_light white +_pure_set_default pure_color_warning yellow +_pure_set_default pure_color_dark black + +# Prompt +_pure_set_default pure_symbol_prompt "❯" +_pure_set_default pure_symbol_reverse_prompt "❮" # used for VI mode +_pure_set_default pure_color_prompt_on_error pure_color_danger +_pure_set_default pure_color_prompt_on_success pure_color_success + +# Current Working Directory +_pure_set_default pure_color_current_directory pure_color_primary + +# Git +_pure_set_default pure_enable_git true +_pure_set_default pure_symbol_git_unpulled_commits "⇣" +_pure_set_default pure_symbol_git_unpushed_commits "⇡" +_pure_set_default pure_symbol_git_dirty "*" +_pure_set_default pure_color_git_unpulled_commits pure_color_info +_pure_set_default pure_color_git_unpushed_commits pure_color_info +_pure_set_default pure_color_git_branch pure_color_mute +_pure_set_default pure_color_git_dirty pure_color_mute + +# SSH info +_pure_set_default pure_color_ssh_hostname pure_color_mute +_pure_set_default pure_color_ssh_separator pure_color_mute +_pure_set_default pure_color_ssh_user_normal pure_color_mute +_pure_set_default pure_color_ssh_user_root pure_color_light + +# Number of running jobs +_pure_set_default pure_show_jobs false +_pure_set_default pure_color_jobs pure_color_normal + +# Virtualenv for Python +_pure_set_default pure_color_virtualenv pure_color_mute + +# Print current working directory at the beginning of prompt +# true (default): current directory, git, user@hostname (ssh-only), command duration +# false: user@hostname (ssh-only), current directory, git, command duration +_pure_set_default pure_begin_prompt_with_current_directory true + +# Show exit code of last command as a separate prompt character (cf. https://github.com/sindresorhus/pure/wiki#show-exit-code-of-last-command-as-a-separate-prompt-character) +# false - single prompt character, default +# true - separate prompt character +_pure_set_default pure_separate_prompt_on_error false + +# Max execution time of a process before its run time is shown when it exits +_pure_set_default pure_threshold_command_duration 5 +_pure_set_default pure_color_command_duration pure_color_warning + +# VI mode indicator +# true (default): indicate a non-insert mode by reversing the prompt symbol (❮) +# false: indicate vi mode with [I], [N], [V] +_pure_set_default pure_reverse_prompt_symbol_in_vimode true + +# Title +_pure_set_default pure_symbol_title_bar_separator "—" diff --git a/fish/config.fish b/fish/config.fish new file mode 100644 index 0000000..a7173c0 --- /dev/null +++ b/fish/config.fish @@ -0,0 +1,22 @@ +set --export SHELL /bin/fish +set --export EDITOR "nvim" +set -e fish_greeting + +source "$HOME/.config/fish/abbreviations.fish" + +function playlist-dl + echo "Looking up playlist name..." + set pl_line (youtube-dl --flat-playlist "$argv" | grep "\[youtube:playlist\] playlist") + set pl_name (echo $pl_line | cut -d ']' -f2 | sed -e 's/^ playlist //g' | cut -d ':' -f1 | tr '/' ' ') + echo "Found playlist by name: $pl_name" + echo "Downloading it into directory: $pl_name" + + mkdir "$pl_name" + cd "$pl_name" + youtube-dl --extract-audio --audio-format mp3 -o "%(title)s.%(ext)s" "$argv" + cd ../ +end + +function compile + gcc -no-pie -g -o $argv[2] $argv[1] +end diff --git a/fish/fish_variables b/fish/fish_variables new file mode 100644 index 0000000..25d8d15 --- /dev/null +++ b/fish/fish_variables @@ -0,0 +1,71 @@ +# This file contains fish universal variable definitions. +# VERSION: 3.0 +SETUVAR __fish_initialized:3100 +SETUVAR _fish_abbr_ls:lsd +SETUVAR _fish_abbr_p:sudo\x20pacman +SETUVAR _fish_abbr_vi:nvim +SETUVAR _fish_abbr_vim:nvim +SETUVAR fish_color_autosuggestion:555\x1ebrblack +SETUVAR fish_color_cancel:\x2dr +SETUVAR fish_color_command:005fd7 +SETUVAR fish_color_comment:990000 +SETUVAR fish_color_cwd:green +SETUVAR fish_color_cwd_root:red +SETUVAR fish_color_end:009900 +SETUVAR fish_color_error:ff0000 +SETUVAR fish_color_escape:00a6b2 +SETUVAR fish_color_history_current:\x2d\x2dbold +SETUVAR fish_color_host:normal +SETUVAR fish_color_host_remote:yellow +SETUVAR fish_color_match:\x2d\x2dbackground\x3dbrblue +SETUVAR fish_color_normal:normal +SETUVAR fish_color_operator:00a6b2 +SETUVAR fish_color_param:00afff +SETUVAR fish_color_quote:999900 +SETUVAR fish_color_redirection:00afff +SETUVAR fish_color_search_match:bryellow\x1e\x2d\x2dbackground\x3dbrblack +SETUVAR fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrblack +SETUVAR fish_color_status:red +SETUVAR fish_color_user:brgreen +SETUVAR fish_color_valid_path:\x2d\x2dunderline +SETUVAR fish_greeting:Welcome\x20to\x20fish\x2c\x20the\x20friendly\x20interactive\x20shell +SETUVAR fish_key_bindings:fish_default_key_bindings +SETUVAR fish_pager_color_completion:\x1d +SETUVAR fish_pager_color_description:B3A06D\x1eyellow +SETUVAR fish_pager_color_prefix:white\x1e\x2d\x2dbold\x1e\x2d\x2dunderline +SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan +SETUVAR pure_begin_prompt_with_current_directory:true +SETUVAR pure_color_command_duration:pure_color_warning +SETUVAR pure_color_current_directory:pure_color_primary +SETUVAR pure_color_danger:red +SETUVAR pure_color_dark:black +SETUVAR pure_color_git_branch:pure_color_mute +SETUVAR pure_color_git_dirty:pure_color_mute +SETUVAR pure_color_git_unpulled_commits:pure_color_info +SETUVAR pure_color_git_unpushed_commits:pure_color_info +SETUVAR pure_color_info:cyan +SETUVAR pure_color_jobs:pure_color_normal +SETUVAR pure_color_light:white +SETUVAR pure_color_mute:brblack +SETUVAR pure_color_normal:normal +SETUVAR pure_color_primary:blue +SETUVAR pure_color_prompt_on_error:pure_color_danger +SETUVAR pure_color_prompt_on_success:pure_color_success +SETUVAR pure_color_ssh_hostname:pure_color_mute +SETUVAR pure_color_ssh_separator:pure_color_mute +SETUVAR pure_color_ssh_user_normal:pure_color_mute +SETUVAR pure_color_ssh_user_root:pure_color_light +SETUVAR pure_color_success:magenta +SETUVAR pure_color_virtualenv:pure_color_mute +SETUVAR pure_color_warning:yellow +SETUVAR pure_enable_git:true +SETUVAR pure_reverse_prompt_symbol_in_vimode:true +SETUVAR pure_separate_prompt_on_error:false +SETUVAR pure_show_jobs:false +SETUVAR pure_symbol_git_dirty:\x2a +SETUVAR pure_symbol_git_unpulled_commits:\u00e2\u0087\u00a3 +SETUVAR pure_symbol_git_unpushed_commits:\u00e2\u0087\u00a1 +SETUVAR pure_symbol_prompt:\u00e2\u009d\u00af +SETUVAR pure_symbol_reverse_prompt:\u00e2\u009d\u00ae +SETUVAR pure_symbol_title_bar_separator:\u00e2\u0080\u0094 +SETUVAR pure_threshold_command_duration:5 diff --git a/fish/fishfile b/fish/fishfile new file mode 100644 index 0000000..4db4144 --- /dev/null +++ b/fish/fishfile @@ -0,0 +1,2 @@ +dracula/fish +rafaelrinaldi/pure diff --git a/fish/functions/_pure_format_time.fish b/fish/functions/_pure_format_time.fish new file mode 100644 index 0000000..0773f6b --- /dev/null +++ b/fish/functions/_pure_format_time.fish @@ -0,0 +1,32 @@ +set fail 1 + +function _pure_format_time \ + --description="Format milliseconds to a human readable format" \ + --argument-names milliseconds threshold + + if test $milliseconds -lt 0; return $fail; end + + set --local seconds (math -s0 "$milliseconds / 1000 % 60") + set --local minutes (math -s0 "$milliseconds / 60000 % 60") + set --local hours (math -s0 "$milliseconds / 3600000 % 24") + set --local days (math -s0 "$milliseconds / 86400000") + set --local time + + if test $days -gt 0 + set time $time (printf "%sd" $days) + end + + if test $hours -gt 0 + set time $time (printf "%sh" $hours) + end + + if test $minutes -gt 0 + set time $time (printf "%sm" $minutes) + end + + if test $seconds -gt $threshold + set time $time (printf "%ss" $seconds) + end + + echo -e (string join ' ' $time) +end diff --git a/fish/functions/_pure_get_prompt_symbol.fish b/fish/functions/_pure_get_prompt_symbol.fish new file mode 100644 index 0000000..5352f58 --- /dev/null +++ b/fish/functions/_pure_get_prompt_symbol.fish @@ -0,0 +1,14 @@ +function _pure_get_prompt_symbol \ + --description 'Print prompt symbol' \ + --argument-names exit_code + + set --local prompt_symbol $pure_symbol_prompt + set --local is_vi_mode (string match -r "fish_(vi|hybrid)_key_bindings" $fish_key_bindings) + if test -n "$is_vi_mode" \ + -a "$pure_reverse_prompt_symbol_in_vimode" = true \ + -a "$fish_bind_mode" != "insert" + set prompt_symbol $pure_symbol_reverse_prompt + end + + echo "$prompt_symbol" +end diff --git a/fish/functions/_pure_parse_directory.fish b/fish/functions/_pure_parse_directory.fish new file mode 100644 index 0000000..fb3822a --- /dev/null +++ b/fish/functions/_pure_parse_directory.fish @@ -0,0 +1,14 @@ +function _pure_parse_directory \ + --description "Replace '$HOME' with '~'" \ + --argument-names max_path_length + + set --local folder (string replace $HOME '~' $PWD) + + if test -n "$max_path_length"; + if test (string length $folder) -gt $max_path_length; + # If path exceeds maximum symbol limit, use default fish path formating function + set folder (prompt_pwd) + end + end + echo $folder +end diff --git a/fish/functions/_pure_parse_git_branch.fish b/fish/functions/_pure_parse_git_branch.fish new file mode 100644 index 0000000..a666f2a --- /dev/null +++ b/fish/functions/_pure_parse_git_branch.fish @@ -0,0 +1,4 @@ +function _pure_parse_git_branch --description "Parse current Git branch name" + command git symbolic-ref --short HEAD 2>/dev/null; + or command git name-rev --name-only HEAD 2>/dev/null +end diff --git a/fish/functions/_pure_place_iterm2_prompt_mark.fish b/fish/functions/_pure_place_iterm2_prompt_mark.fish new file mode 100644 index 0000000..b999b7a --- /dev/null +++ b/fish/functions/_pure_place_iterm2_prompt_mark.fish @@ -0,0 +1,5 @@ +function _pure_place_iterm2_prompt_mark + if functions -q iterm2_prompt_mark + iterm2_prompt_mark + end +end diff --git a/fish/functions/_pure_print_prompt.fish b/fish/functions/_pure_print_prompt.fish new file mode 100644 index 0000000..9c0174c --- /dev/null +++ b/fish/functions/_pure_print_prompt.fish @@ -0,0 +1,11 @@ +function _pure_print_prompt + set --local prompt + + for prompt_part in $argv + if test (_pure_string_width $prompt_part) -gt 0 + set prompt "$prompt $prompt_part" + end + end + + echo (string trim -l $prompt) +end diff --git a/fish/functions/_pure_prompt.fish b/fish/functions/_pure_prompt.fish new file mode 100644 index 0000000..3f67704 --- /dev/null +++ b/fish/functions/_pure_prompt.fish @@ -0,0 +1,11 @@ +function _pure_prompt \ + --description 'Print prompt symbol' \ + --argument-names exit_code + + set --local jobs (_pure_prompt_jobs) + set --local virtualenv (_pure_prompt_virtualenv) # Python virtualenv name + set --local vimode_indicator (_pure_prompt_vimode) # vi-mode indicator + set --local pure_symbol (_pure_prompt_symbol $exit_code) + + echo (_pure_print_prompt $jobs $virtualenv $vimode_indicator $pure_symbol) +end diff --git a/fish/functions/_pure_prompt_beginning.fish b/fish/functions/_pure_prompt_beginning.fish new file mode 100644 index 0000000..5f00236 --- /dev/null +++ b/fish/functions/_pure_prompt_beginning.fish @@ -0,0 +1,6 @@ +function _pure_prompt_beginning + # Clear existing line content + set --local clear_line "\r\033[K" + + echo $clear_line +end diff --git a/fish/functions/_pure_prompt_command_duration.fish b/fish/functions/_pure_prompt_command_duration.fish new file mode 100644 index 0000000..d35b3a6 --- /dev/null +++ b/fish/functions/_pure_prompt_command_duration.fish @@ -0,0 +1,11 @@ +function _pure_prompt_command_duration + set --local command_duration + + # Get command execution duration + if test -n "$CMD_DURATION" + set command_duration (_pure_format_time $CMD_DURATION $pure_threshold_command_duration) + end + set --local command_duration_color (_pure_set_color $pure_color_command_duration) + + echo "$command_duration_color$command_duration" +end diff --git a/fish/functions/_pure_prompt_current_folder.fish b/fish/functions/_pure_prompt_current_folder.fish new file mode 100644 index 0000000..af8e9ee --- /dev/null +++ b/fish/functions/_pure_prompt_current_folder.fish @@ -0,0 +1,11 @@ +set fail 1 + +function _pure_prompt_current_folder --argument-names current_prompt_width + + if test -z "$current_prompt_width"; return $fail; end + + set --local current_folder (_pure_parse_directory (math $COLUMNS - $current_prompt_width - 1)) + set --local current_folder_color (_pure_set_color $pure_color_current_directory) + + echo "$current_folder_color$current_folder" +end diff --git a/fish/functions/_pure_prompt_ending.fish b/fish/functions/_pure_prompt_ending.fish new file mode 100644 index 0000000..ba92511 --- /dev/null +++ b/fish/functions/_pure_prompt_ending.fish @@ -0,0 +1,3 @@ +function _pure_prompt_ending + echo (set_color normal)" " +end diff --git a/fish/functions/_pure_prompt_first_line.fish b/fish/functions/_pure_prompt_first_line.fish new file mode 100644 index 0000000..6b3f3b6 --- /dev/null +++ b/fish/functions/_pure_prompt_first_line.fish @@ -0,0 +1,35 @@ +function _pure_prompt_first_line \ + --description 'Print contextual information before prompt.' + + if not type -fq git # exit if git is not available + return 1 + end + + set --local prompt_ssh (_pure_prompt_ssh) + set --local prompt_git (_pure_prompt_git) + set --local prompt_command_duration (_pure_prompt_command_duration) + set --local prompt (_pure_print_prompt \ + $prompt_ssh \ + $prompt_git \ + $prompt_command_duration + ) + set --local prompt_width (_pure_string_width $prompt) + set --local current_folder (_pure_prompt_current_folder $prompt_width) + + set --local prompt_components + if test $pure_begin_prompt_with_current_directory = true + set prompt_components \ + $current_folder \ + $prompt_git \ + $prompt_ssh \ + $prompt_command_duration + else + set prompt_components \ + $prompt_ssh \ + $current_folder \ + $prompt_git \ + $prompt_command_duration + end + + echo (_pure_print_prompt $prompt_components) +end diff --git a/fish/functions/_pure_prompt_git.fish b/fish/functions/_pure_prompt_git.fish new file mode 100644 index 0000000..140639a --- /dev/null +++ b/fish/functions/_pure_prompt_git.fish @@ -0,0 +1,20 @@ +function _pure_prompt_git \ + --description 'Print git repository informations: branch name, dirty, upstream ahead/behind' + + if test $pure_enable_git != true + return + end + + set --local is_git_repository (command git rev-parse --is-inside-work-tree 2>/dev/null) + + if test -n "$is_git_repository" + set --local git_prompt (_pure_prompt_git_branch)(_pure_prompt_git_dirty) + set --local git_pending_commits (_pure_prompt_git_pending_commits) + + if test (_pure_string_width $git_pending_commits) -ne 0 + set git_prompt $git_prompt $git_pending_commits + end + + echo $git_prompt + end +end diff --git a/fish/functions/_pure_prompt_git_branch.fish b/fish/functions/_pure_prompt_git_branch.fish new file mode 100644 index 0000000..777cd0e --- /dev/null +++ b/fish/functions/_pure_prompt_git_branch.fish @@ -0,0 +1,6 @@ +function _pure_prompt_git_branch + set --local git_branch (_pure_parse_git_branch) # current git branch + set --local git_branch_color (_pure_set_color $pure_color_git_branch) + + echo "$git_branch_color$git_branch" +end diff --git a/fish/functions/_pure_prompt_git_dirty.fish b/fish/functions/_pure_prompt_git_dirty.fish new file mode 100644 index 0000000..fbf31e3 --- /dev/null +++ b/fish/functions/_pure_prompt_git_dirty.fish @@ -0,0 +1,18 @@ +function _pure_prompt_git_dirty + set --local git_dirty_symbol + set --local git_dirty_color + + set --local is_git_dirty ( + # The first checks for staged changes, the second for unstaged ones. + # We put them in this order because checking staged changes is *fast*. + not command git diff-index --ignore-submodules --cached --quiet HEAD -- >/dev/null 2>&1 + or not command git diff --ignore-submodules --no-ext-diff --quiet --exit-code >/dev/null 2>&1 + and echo "true" + ) + if test -n "$is_git_dirty" # untracked or un-commited files + set git_dirty_symbol "$pure_symbol_git_dirty" + set git_dirty_color (_pure_set_color $pure_color_git_dirty) + end + + echo "$git_dirty_color$git_dirty_symbol" +end diff --git a/fish/functions/_pure_prompt_git_pending_commits.fish b/fish/functions/_pure_prompt_git_pending_commits.fish new file mode 100644 index 0000000..98359c4 --- /dev/null +++ b/fish/functions/_pure_prompt_git_pending_commits.fish @@ -0,0 +1,27 @@ +function _pure_prompt_git_pending_commits + set --local git_unpushed_commits + set --local git_unpulled_commits + + set --local has_upstream (command git rev-parse --abbrev-ref '@{upstream}' 2>/dev/null) + if test -n "$has_upstream" # check there is an upstream repo configured + and test "$has_upstream" != '@{upstream}' # Fixed #179, dont check the empty repo + command git rev-list --left-right --count 'HEAD...@{upstream}' \ + | read --local --array git_status + set --local commit_to_push $git_status[1] + set --local commit_to_pull $git_status[2] + + if test $commit_to_push -gt 0 # upstream is behind local repo + set --local git_unpushed_commits_color \ + (_pure_set_color $pure_color_git_unpushed_commits) + set git_unpushed_commits "$git_unpushed_commits_color$pure_symbol_git_unpushed_commits" + end + + if test $commit_to_pull -gt 0 # upstream is ahead of local repo + set --local git_unpulled_commits_color \ + (_pure_set_color $pure_color_git_unpulled_commits) + set git_unpulled_commits "$git_unpulled_commits_color$pure_symbol_git_unpulled_commits" + end + end + + echo "$git_unpushed_commits$git_unpulled_commits" +end diff --git a/fish/functions/_pure_prompt_jobs.fish b/fish/functions/_pure_prompt_jobs.fish new file mode 100644 index 0000000..b04fd8c --- /dev/null +++ b/fish/functions/_pure_prompt_jobs.fish @@ -0,0 +1,9 @@ +function _pure_prompt_jobs --description "Display number of running jobs" + if test $pure_show_jobs = true + set --local njobs (count (jobs -p)) + set --local jobs_color (_pure_set_color $pure_color_jobs) + if test $njobs -gt 0 + echo "$jobs_color"[$njobs] + end + end +end diff --git a/fish/functions/_pure_prompt_new_line.fish b/fish/functions/_pure_prompt_new_line.fish new file mode 100644 index 0000000..c61a820 --- /dev/null +++ b/fish/functions/_pure_prompt_new_line.fish @@ -0,0 +1,11 @@ +function _pure_prompt_new_line \ + --description "Do not add a line break to a brand new session" \ + --on-event fish_prompt + + set --local new_line + if test $_pure_fresh_session = false + set new_line "\n" + end + + echo -e -n "$new_line" +end diff --git a/fish/functions/_pure_prompt_ssh.fish b/fish/functions/_pure_prompt_ssh.fish new file mode 100644 index 0000000..3ff11ea --- /dev/null +++ b/fish/functions/_pure_prompt_ssh.fish @@ -0,0 +1,5 @@ +function _pure_prompt_ssh + if test "$SSH_CONNECTION" != "" + echo (_pure_prompt_ssh_user)(_pure_prompt_ssh_separator)(_pure_prompt_ssh_host) + end +end diff --git a/fish/functions/_pure_prompt_ssh_host.fish b/fish/functions/_pure_prompt_ssh_host.fish new file mode 100644 index 0000000..d403c80 --- /dev/null +++ b/fish/functions/_pure_prompt_ssh_host.fish @@ -0,0 +1,7 @@ +function _pure_prompt_ssh_host + set --query --global hostname + or set --local hostname (hostname -s) # current host name compatible busybox + set --local hostname_color (_pure_set_color $pure_color_ssh_hostname) + + echo "$hostname_color$hostname" +end diff --git a/fish/functions/_pure_prompt_ssh_separator.fish b/fish/functions/_pure_prompt_ssh_separator.fish new file mode 100644 index 0000000..10ae5e8 --- /dev/null +++ b/fish/functions/_pure_prompt_ssh_separator.fish @@ -0,0 +1,6 @@ +function _pure_prompt_ssh_separator + set --local separator_symbol "@" + set --local separator_symbol_color (_pure_set_color $pure_color_ssh_separator) + + echo "$separator_symbol_color$separator_symbol" +end diff --git a/fish/functions/_pure_prompt_ssh_user.fish b/fish/functions/_pure_prompt_ssh_user.fish new file mode 100644 index 0000000..e0cf879 --- /dev/null +++ b/fish/functions/_pure_prompt_ssh_user.fish @@ -0,0 +1,10 @@ +function _pure_prompt_ssh_user + set --local username (whoami) # current user name + set --local username_color (_pure_set_color $pure_color_ssh_user_normal) # default color + + if test "$username" = "root" + set username_color (_pure_set_color $pure_color_ssh_user_root) # different color for root + end + + echo "$username_color$username" +end diff --git a/fish/functions/_pure_prompt_symbol.fish b/fish/functions/_pure_prompt_symbol.fish new file mode 100644 index 0000000..768eca7 --- /dev/null +++ b/fish/functions/_pure_prompt_symbol.fish @@ -0,0 +1,20 @@ +function _pure_prompt_symbol \ + --description 'Print prompt symbol' \ + --argument-names exit_code + + set --local prompt_symbol (_pure_get_prompt_symbol) + set --local symbol_color_success (_pure_set_color $pure_color_prompt_on_success) + set --local symbol_color_error (_pure_set_color $pure_color_prompt_on_error) + set --local command_succeed 0 + + set --local symbol_color $symbol_color_success # default pure symbol color + if test $exit_code -ne $command_succeed + set symbol_color $symbol_color_error # different pure symbol color when previous command failed + + if test "$pure_separate_prompt_on_error" = true + set symbol_color "$symbol_color_error$prompt_symbol$symbol_color_success" + end + end + + echo "$symbol_color$prompt_symbol" +end diff --git a/fish/functions/_pure_prompt_vimode.fish b/fish/functions/_pure_prompt_vimode.fish new file mode 100644 index 0000000..04d38b4 --- /dev/null +++ b/fish/functions/_pure_prompt_vimode.fish @@ -0,0 +1,5 @@ +function _pure_prompt_vimode + if test $pure_reverse_prompt_symbol_in_vimode = false + echo (fish_default_mode_prompt) + end +end diff --git a/fish/functions/_pure_prompt_virtualenv.fish b/fish/functions/_pure_prompt_virtualenv.fish new file mode 100644 index 0000000..6cb2ed6 --- /dev/null +++ b/fish/functions/_pure_prompt_virtualenv.fish @@ -0,0 +1,8 @@ +function _pure_prompt_virtualenv --description "Display virtualenv directory" + if test -n "$VIRTUAL_ENV" + set --local virtualenv (basename "$VIRTUAL_ENV") + set --local virtualenv_color (_pure_set_color $pure_color_virtualenv) + + echo "$virtualenv_color$virtualenv" + end +end diff --git a/fish/functions/_pure_set_color.fish b/fish/functions/_pure_set_color.fish new file mode 100644 index 0000000..c05769a --- /dev/null +++ b/fish/functions/_pure_set_color.fish @@ -0,0 +1,19 @@ +function _pure_set_color \ + --description 'Set color' \ + --argument-names var + + set --local color $var + # Backwards compatibility for colors defined as control sequencies instead of fish colors + if not string match --quiet --all --regex '\e\[[^m]*m' $color[1] + and set -q $color + set color $$var + end + + set --local result $color + if not string match --quiet --all --regex '\e\[[^m]*m' $result[1] + and not test -z $result[1] + set result (set_color $color) + end + + echo "$result" +end diff --git a/fish/functions/_pure_set_default.fish b/fish/functions/_pure_set_default.fish new file mode 100644 index 0000000..69e6054 --- /dev/null +++ b/fish/functions/_pure_set_default.fish @@ -0,0 +1,8 @@ +function _pure_set_default \ + --description 'Set default value for configuration variable' \ + --argument-names var default + + if not set -q --universal $var + set --universal $var $default + end +end diff --git a/fish/functions/_pure_string_width.fish b/fish/functions/_pure_string_width.fish new file mode 100644 index 0000000..0c1957b --- /dev/null +++ b/fish/functions/_pure_string_width.fish @@ -0,0 +1,9 @@ +function _pure_string_width \ + --description 'returns raw string length, i.e. ignore ANSI-color' \ + --argument-names prompt + + set --local empty '' + set --local raw_prompt (string replace --all --regex '\e\[[^m]*m' $empty -- $prompt) + + string length -- $raw_prompt +end diff --git a/fish/functions/fish_greeting.fish b/fish/functions/fish_greeting.fish new file mode 100644 index 0000000..018520b --- /dev/null +++ b/fish/functions/fish_greeting.fish @@ -0,0 +1,2 @@ +function fish_greeting +end diff --git a/fish/functions/fish_mode_prompt.fish b/fish/functions/fish_mode_prompt.fish new file mode 100644 index 0000000..428a658 --- /dev/null +++ b/fish/functions/fish_mode_prompt.fish @@ -0,0 +1,2 @@ +function fish_mode_prompt +end diff --git a/fish/functions/fish_prompt.fish b/fish/functions/fish_prompt.fish new file mode 100644 index 0000000..9b313e3 --- /dev/null +++ b/fish/functions/fish_prompt.fish @@ -0,0 +1,11 @@ +function fish_prompt + set --local exit_code $status # save previous exit code + + echo -e -n (_pure_prompt_beginning) # init prompt context (clear current line, etc.) + echo -e (_pure_prompt_first_line) # print current path, git branch/status, command duration + _pure_place_iterm2_prompt_mark # place iTerm shell integration mark + echo -e -n (_pure_prompt $exit_code) # print prompt + echo -e (_pure_prompt_ending) # reset colors and end prompt + + set _pure_fresh_session false +end diff --git a/fish/functions/fish_title.fish b/fish/functions/fish_title.fish new file mode 100644 index 0000000..ff918ab --- /dev/null +++ b/fish/functions/fish_title.fish @@ -0,0 +1,16 @@ +function fish_title \ + --description "Set title to current folder and shell name" \ + --argument-names last_command + + set --local basename (string replace -r '^.*/' '' -- $PWD) + set --local current_folder (_pure_parse_directory) + set --local current_command (status current-command 2>/dev/null; or echo $_) + + set --local prompt "$basename: $last_command $pure_symbol_title_bar_separator $current_command" + + if test -z "$last_command" + set prompt "$current_folder $pure_symbol_title_bar_separator $current_command" + end + + echo $prompt +end diff --git a/fish/functions/fisher.fish b/fish/functions/fisher.fish new file mode 100644 index 0000000..71f20a8 --- /dev/null +++ b/fish/functions/fisher.fish @@ -0,0 +1,436 @@ +set -g fisher_version 3.3.2 + +function fisher -a cmd -d "fish plugin manager" + set -q XDG_CACHE_HOME; or set XDG_CACHE_HOME ~/.cache + set -q XDG_CONFIG_HOME; or set XDG_CONFIG_HOME ~/.config + set -q XDG_DATA_HOME; or set XDG_DATA_HOME ~/.local/share + + set -g fish_config $XDG_CONFIG_HOME/fish + set -g fisher_cache $XDG_CACHE_HOME/fisher + set -g fisher_data $XDG_DATA_HOME/fisher + + set -q fisher_path; or set -g fisher_path $fish_config + set -g fishfile $fish_config/fishfile + + for path in {$fish_config,$fisher_path}/{functions,completions,conf.d} $fisher_cache + if test ! -d $path + command mkdir -p $path + end + end + + if test ! -e $fisher_path/completions/fisher.fish + echo "fisher complete" >$fisher_path/completions/fisher.fish + _fisher_complete + end + + if test -e $fisher_path/conf.d/fisher.fish + switch "$version" + case \*-\* + command rm -f $fisher_path/conf.d/fisher.fish + case 2\* + case \* + command rm -f $fisher_path/conf.d/fisher.fish + end + else + switch "$version" + case \*-\* + case 2\* + echo "fisher copy-user-key-bindings" >$fisher_path/conf.d/fisher.fish + end + end + + # 2019-10-22: temp code, migrates fishfile from old path back to $fish_config + if test -e "$fisher_path/fishfile"; and test ! -e "$fishfile" + command mv -f "$fisher_path/fishfile" "$fishfile" + end + + # 2020-06-23: temp code, migrates fisher data from XDG_CONFIG_HOME to XDG_DATA_HOME + set -l fisher_config $XDG_CONFIG_HOME/fisher + if test -d $fisher_config + echo "migrating local data from $fisher_config to $fisher_data" + command rm -rf $fisher_data + command mv -f $fisher_config $fisher_data + end + + switch "$cmd" + case {,self-}complete + _fisher_complete + case copy-user-key-bindings + _fisher_copy_user_key_bindings + case ls + set -e argv[1] + if test -s "$fishfile" + set -l file (_fisher_fmt <$fishfile | _fisher_parse -R | command sed "s|@.*||") + _fisher_ls | _fisher_fmt | command awk -v FILE="$file" " + BEGIN { for (n = split(FILE, f); ++i <= n;) file[f[i]] } \$0 in file && /$argv[1]/ + " | command sed "s|^$HOME|~|" + end + case self-update + _fisher_self_update (status -f) + case self-uninstall + _fisher_self_uninstall + case {,-}-v{ersion,} + echo "fisher version $fisher_version" (status -f | command sed "s|^$HOME|~|") + case {,-}-h{elp,} + _fisher_help + case "" + _fisher_commit -- + case add rm + if not isatty + while read -l arg + set argv $argv $arg + end + end + + if test (count $argv) = 1 + echo "fisher: invalid number of arguments" >&2 + _fisher_help >&2 + return 1 + end + + _fisher_commit $argv + case \* + echo "fisher: unknown flag or command \"$cmd\"" >&2 + _fisher_help >&2 + return 1 + end +end + +function _fisher_complete + complete -ec fisher + complete -xc fisher -n __fish_use_subcommand -a add -d "Add plugins" + complete -xc fisher -n __fish_use_subcommand -a rm -d "Remove plugins" + complete -xc fisher -n __fish_use_subcommand -a ls -d "List installed plugins matching REGEX" + complete -xc fisher -n __fish_use_subcommand -a --help -d "Show usage help" + complete -xc fisher -n __fish_use_subcommand -a --version -d "$fisher_version" + complete -xc fisher -n __fish_use_subcommand -a self-update -d "Update to the latest version" + for pkg in (fisher ls) + complete -xc fisher -n "__fish_seen_subcommand_from rm" -a $pkg + end +end + +function _fisher_copy_user_key_bindings + if functions -q fish_user_key_bindings + functions -c fish_user_key_bindings fish_user_key_bindings_copy + end + function fish_user_key_bindings + for file in $fisher_path/conf.d/*_key_bindings.fish + source $file >/dev/null 2>/dev/null + end + if functions -q fish_user_key_bindings_copy + fish_user_key_bindings_copy + end + end +end + +function _fisher_ls + for pkg in $fisher_data/*/*/* + command readlink $pkg; or echo $pkg + end +end + +function _fisher_fmt + command sed "s|^[[:space:]]*||;s|^$fisher_data/||;s|^~|$HOME|;s|^\.\/*|$PWD/|;s|^https*:/*||;s|^github\.com/||;s|/*\$||" +end + +function _fisher_help + echo "usage: fisher add Add plugin/s" + echo " fisher rm Remove plugin/s" + echo " fisher Update all plugins" + echo " fisher ls [] List installed plugins matching " + echo " fisher --help Show this help" + echo " fisher --version Show the current version" + echo " fisher self-update Update to the latest version" + echo " fisher self-uninstall Uninstall from your system" + echo "examples:" + echo " fisher add jorgebucaran/z rafaelrinaldi/pure" + echo " fisher add gitlab.com/foo/bar@v2" + echo " fisher add ~/path/to/local/pkg" + echo " fisher add &2 + command curl -s "$url?nocache" >$file. + + set -l next_version (command awk '$4 ~ /^[0-9]+\.[0-9]+\.[0-9]+$/ { print v=$4 } { exit !v }' <$file.) + switch "$next_version" + case "" $fisher_version + command rm -f $file. + if test -z "$next_version" + echo "fisher: cannot update fisher -- are you offline?" >&2 + return 1 + end + echo "fisher is already up-to-date" >&2 + case \* + echo "linking $file" | command sed "s|$HOME|~|" >&2 + command mv -f $file. $file + source $file + echo "updated to fisher $fisher_version -- hooray!" >&2 + _fisher_complete + end +end + +function _fisher_self_uninstall + for pkg in (_fisher_ls) + _fisher_rm $pkg + end + + for file in $fisher_cache $fisher_data $fisher_path/{functions,completions,conf.d}/fisher.fish $fishfile + echo "removing $file" + command rm -Rf $file 2>/dev/null + end | command sed "s|$HOME|~|" >&2 + + for name in (set -n | command awk '/^fisher_/') + set -e "$name" + end + + functions -e (functions -a | command awk '/^_fisher/') fisher + complete -c fisher --erase +end + +function _fisher_commit -a cmd + set -e argv[1] + set -l elapsed (_fisher_now) + + if test ! -e "$fishfile" + command touch $fishfile + echo "created new fishfile in $fishfile" | command sed "s|$HOME|~|" >&2 + end + + set -l old_pkgs (_fisher_ls | _fisher_fmt) + for pkg in (_fisher_ls) + _fisher_rm $pkg + end + command rm -Rf $fisher_data + command mkdir -p $fisher_data + + set -l next_pkgs (_fisher_fmt <$fishfile | _fisher_parse -R $cmd (printf "%s\n" $argv | _fisher_fmt)) + set -l actual_pkgs (_fisher_fetch $next_pkgs) + set -l updated_pkgs + for pkg in $old_pkgs + if contains -- $pkg $actual_pkgs + set updated_pkgs $updated_pkgs $pkg + end + end + + if test -z "$actual_pkgs$updated_pkgs$old_pkgs$next_pkgs" + echo "fisher: nothing to commit -- try adding some plugins" >&2 + return 1 + end + + set -l out_pkgs + if test "$cmd" = "rm" + set out_pkgs $next_pkgs + else + for pkg in $next_pkgs + if contains -- (echo $pkg | command sed "s|@.*||") $actual_pkgs + set out_pkgs $out_pkgs $pkg + end + end + end + + printf "%s\n" (_fisher_fmt <$fishfile | _fisher_parse -W $cmd $out_pkgs | command sed "s|^$HOME|~|") >$fishfile + + _fisher_complete + + command awk -v A=(count $actual_pkgs) -v U=(count $updated_pkgs) -v O=(count $old_pkgs) -v E=(_fisher_now $elapsed) ' + BEGIN { + res = fmt("removed", O - U, fmt("updated", U, fmt("added", A - U))) + printf((res ? res : "done") " in %.2fs\n", E / 1000) + } + function fmt(action, n, s) { + return n ? (s ? s ", " : s) action " " n " plugin" (n > 1 ? "s" : "") : s + } + ' >&2 +end + +function _fisher_parse -a mode cmd + set -e argv[1..2] + command awk -v FS="[[:space:]]*#+" -v MODE="$mode" -v CMD="$cmd" -v ARGSTR="$argv" ' + BEGIN { + for (n = split(ARGSTR, a, " "); i++ < n;) pkgs[getkey(a[i])] = a[i] + } + !NF { next } { k = getkey($1) } + MODE == "-R" && !(k in pkgs) && ($0 = $1) + MODE == "-W" && (/^#/ || k in pkgs || CMD != "rm") { print pkgs[k] (sub($1, "") ? $0 : "") } + MODE == "-W" || CMD == "rm" { delete pkgs[k] } + END { + for (k in pkgs) { + if (CMD != "rm" || MODE == "-W") print pkgs[k] + else print "fisher: cannot remove \""k"\" -- plugin is not in fishfile" > "/dev/stderr" + } + } + function getkey(s, a) { + return (split(s, a, /@+|:/) > 2) ? a[2]"/"a[1]"/"a[3] : a[1] + } + ' +end + +function _fisher_fetch + set -l pkg_jobs + set -l out_pkgs + set -l next_pkgs + set -l local_pkgs + set -q fisher_user_api_token; and set -l curl_opts -u $fisher_user_api_token + + for pkg in $argv + switch $pkg + case \~\* /\* + set -l path (echo "$pkg" | command sed "s|^~|$HOME|") + if test -e "$path" + set local_pkgs $local_pkgs $path + else + echo "fisher: cannot add \"$pkg\" -- is this a valid file?" >&2 + end + continue + end + + command awk -v PKG="$pkg" -v FS=/ ' + BEGIN { + split(PKG, tmp, /@/) + pkg = split(PKG, _, "/") <= 2 ? "github.com/"tmp[1] : tmp[1] + tag = tmp[2] ? tmp[2] : "HEAD" + print pkg "\t" (\ + pkg ~ /^github/ ? "https://codeload."pkg"/tar.gz/"tag : \ + pkg ~ /^gitlab/ ? "https://"pkg"/-/archive/"tag"/"tmp[split(pkg, tmp, "/")]"-"tag".tar.gz" : \ + pkg ~ /^bitbucket/ ? "https://"pkg"/get/"tag".tar.gz" : pkg\ + ) + } + ' | read -l pkg url + + if test ! -d "$fisher_data/$pkg" + fish -c " + echo fetching $url >&2 + command mkdir -p $fisher_data/$pkg $fisher_cache/(command dirname $pkg) + if command curl $curl_opts -Ss -w \"\" $url 2>&1 | command tar -xzf- -C $fisher_data/$pkg 2>/dev/null + command rm -Rf $fisher_cache/$pkg + command mv -f $fisher_data/$pkg/* $fisher_cache/$pkg + command rm -Rf $fisher_data/$pkg + command cp -Rf {$fisher_cache,$fisher_data}/$pkg + else if test -d \"$fisher_cache/$pkg\" + echo fisher: cannot connect to server -- looking in \"$fisher_cache/$pkg\" | command sed 's|$HOME|~|' >&2 + command cp -Rf $fisher_cache/$pkg $fisher_data/$pkg/.. + else + command rm -Rf $fisher_data/$pkg + echo fisher: cannot add \"$pkg\" -- is this a valid plugin\? >&2 + end + " >/dev/null & + set pkg_jobs $pkg_jobs (_fisher_jobs --last) + set next_pkgs $next_pkgs "$fisher_data/$pkg" + end + end + + if set -q pkg_jobs[1] + while for job in $pkg_jobs + contains -- $job (_fisher_jobs); and break + end + end + for pkg in $next_pkgs + if test -d "$pkg" + set out_pkgs $out_pkgs $pkg + _fisher_add $pkg + end + end + end + + set -l local_prefix $fisher_data/local/$USER + if test ! -d "$local_prefix" + command mkdir -p $local_prefix + end + for pkg in $local_pkgs + set -l target $local_prefix/(command basename $pkg) + if test ! -L "$target" + command ln -sf $pkg $target + set out_pkgs $out_pkgs $pkg + _fisher_add $pkg --link + end + end + + if set -q out_pkgs[1] + _fisher_fetch ( + for pkg in $out_pkgs + if test -s "$pkg/fishfile" + _fisher_fmt <$pkg/fishfile | _fisher_parse -R + end + end) + printf "%s\n" $out_pkgs | _fisher_fmt + end +end + +function _fisher_add -a pkg opts + for src in $pkg/{functions,completions,conf.d}/**.* $pkg/*.fish + set -l target (command basename $src) + switch $src + case $pkg/conf.d\* + set target $fisher_path/conf.d/$target + case $pkg/completions\* + set target $fisher_path/completions/$target + case $pkg/{functions,}\* + switch $target + case uninstall.fish + continue + case {init,key_bindings}.fish + set target $fisher_path/conf.d/(command basename $pkg)\_$target + case \* + set target $fisher_path/functions/$target + end + end + echo "linking $target" | command sed "s|$HOME|~|" >&2 + if set -q opts[1] + command ln -sf $src $target + else + command cp -f $src $target + end + switch $target + case \*.fish + source $target >/dev/null 2>/dev/null + end + end +end + +function _fisher_rm -a pkg + for src in $pkg/{conf.d,completions,functions}/**.* $pkg/*.fish + set -l target (command basename $src) + set -l filename (command basename $target .fish) + switch $src + case $pkg/conf.d\* + test "$filename.fish" = "$target"; and emit "$filename"_uninstall + set target conf.d/$target + case $pkg/completions\* + test "$filename.fish" = "$target"; and complete -ec $filename + set target completions/$target + case $pkg/{,functions}\* + test "$filename.fish" = "$target"; and functions -e $filename + switch $target + case uninstall.fish + source $src + continue + case {init,key_bindings}.fish + set target conf.d/(command basename $pkg)\_$target + case \* + set target functions/$target + end + end + command rm -f $fisher_path/$target + end + if not functions -q fish_prompt + source "$__fish_datadir$__fish_data_dir/functions/fish_prompt.fish" + end +end + +function _fisher_jobs + jobs $argv | command awk '/^[0-9]+\t/ { print $1 }' +end + +function _fisher_now -a elapsed + switch (command uname) + case Darwin \*BSD + command perl -MTime::HiRes -e 'printf("%.0f\n", (Time::HiRes::time() * 1000) - $ARGV[0])' $elapsed + case \* + math (command date "+%s%3N") - "0$elapsed" + end +end diff --git a/nvim/colors/dracula.vim b/nvim/colors/dracula.vim new file mode 100755 index 0000000..82e3cb2 --- /dev/null +++ b/nvim/colors/dracula.vim @@ -0,0 +1,351 @@ +" Dracula Theme: {{{ +" +" https://github.com/zenorocha/dracula-theme +" +" Copyright 2016, All rights reserved +" +" Code licensed under the MIT license +" http://zenorocha.mit-license.org +" +" @author Trevor Heins <@heinst> +" @author Éverton Ribeiro +" @author Derek Sifford +" @author Zeno Rocha +scriptencoding utf8 +" }}} + +" Configuration: {{{ + +if v:version > 580 + highlight clear + if exists('syntax_on') + syntax reset + endif +endif + +let g:colors_name = 'dracula' + +if !(has('termguicolors') && &termguicolors) && !has('gui_running') && &t_Co != 256 + finish +endif + +" Palette: {{{2 + +let s:fg = ['#F8F8F2', 255] + +let s:bglighter = ['#424450', 238] +let s:bglight = ['#343746', 237] +let s:bg = ['#282A36', 236] +let s:bgdark = ['#21222C', 235] +let s:bgdarker = ['#191A21', 234] + +let s:subtle = ['#424450', 238] + +let s:selection = ['#44475A', 239] +let s:comment = ['#6272A4', 61] +let s:cyan = ['#8BE9FD', 117] +let s:green = ['#50FA7B', 84] +let s:orange = ['#FFB86C', 215] +let s:pink = ['#FF79C6', 212] +let s:purple = ['#BD93F9', 141] +let s:red = ['#FF5555', 203] +let s:yellow = ['#F1FA8C', 228] + +let s:none = ['NONE', 'NONE'] + +let g:dracula_palette = { + \ 'fg': s:fg, + \ 'bg': s:bg, + \ 'selection': s:selection, + \ 'comment': s:comment, + \ 'cyan': s:cyan, + \ 'green': s:green, + \ 'orange': s:orange, + \ 'pink': s:pink, + \ 'purple': s:purple, + \ 'red': s:red, + \ 'yellow': s:yellow, + \ + \ 'bglighter': s:bglighter, + \ 'bglight': s:bglight, + \ 'bgdark': s:bgdark, + \ 'bgdarker': s:bgdarker, + \ 'subtle': s:subtle, + \} + +if has('nvim') + let g:terminal_color_0 = '#21222C' + let g:terminal_color_1 = '#FF5555' + let g:terminal_color_2 = '#50FA7B' + let g:terminal_color_3 = '#F1FA8C' + let g:terminal_color_4 = '#BD93F9' + let g:terminal_color_5 = '#FF79C6' + let g:terminal_color_6 = '#8BE9FD' + let g:terminal_color_7 = '#F8F8F2' + let g:terminal_color_8 = '#6272A4' + let g:terminal_color_9 = '#FF6E6E' + let g:terminal_color_10 = '#69FF94' + let g:terminal_color_11 = '#FFFFA5' + let g:terminal_color_12 = '#D6ACFF' + let g:terminal_color_13 = '#FF92DF' + let g:terminal_color_14 = '#A4FFFF' + let g:terminal_color_15 = '#FFFFFF' +endif + +if has('terminal') + let g:terminal_ansi_colors = [ + \ '#21222C', '#FF5555', '#50FA7B', '#F1FA8C', + \ '#BD93F9', '#FF79C6', '#8BE9FD', '#F8F8F2', + \ '#6272A4', '#FF6E6E', '#69FF94', '#FFFFA5', + \ '#D6ACFF', '#FF92DF', '#A4FFFF', '#FFFFFF' + \] +endif + +" }}}2 +" User Configuration: {{{2 + +if !exists('g:dracula_bold') + let g:dracula_bold = 1 +endif + +if !exists('g:dracula_italic') + let g:dracula_italic = 1 +endif + +if !exists('g:dracula_underline') + let g:dracula_underline = 1 +endif + +if !exists('g:dracula_undercurl') && g:dracula_underline != 0 + let g:dracula_undercurl = 1 +endif + +if !exists('g:dracula_inverse') + let g:dracula_inverse = 1 +endif + +if !exists('g:dracula_colorterm') + let g:dracula_colorterm = 1 +endif + +"}}}2 +" Script Helpers: {{{2 + +let s:attrs = { + \ 'bold': g:dracula_bold == 1 ? 'bold' : 0, + \ 'italic': g:dracula_italic == 1 ? 'italic' : 0, + \ 'underline': g:dracula_underline == 1 ? 'underline' : 0, + \ 'undercurl': g:dracula_undercurl == 1 ? 'undercurl' : 0, + \ 'inverse': g:dracula_inverse == 1 ? 'inverse' : 0, + \} + +function! s:h(scope, fg, ...) " bg, attr_list, special + let l:fg = copy(a:fg) + let l:bg = get(a:, 1, ['NONE', 'NONE']) + + let l:attr_list = filter(get(a:, 2, ['NONE']), 'type(v:val) == 1') + let l:attrs = len(l:attr_list) > 0 ? join(l:attr_list, ',') : 'NONE' + + " Falls back to coloring foreground group on terminals because + " nearly all do not support undercurl + let l:special = get(a:, 3, ['NONE', 'NONE']) + if l:special[0] !=# 'NONE' && l:fg[0] ==# 'NONE' && !has('gui_running') + let l:fg[0] = l:special[0] + let l:fg[1] = l:special[1] + endif + + let l:hl_string = [ + \ 'highlight', a:scope, + \ 'guifg=' . l:fg[0], 'ctermfg=' . l:fg[1], + \ 'guibg=' . l:bg[0], 'ctermbg=' . l:bg[1], + \ 'gui=' . l:attrs, 'cterm=' . l:attrs, + \ 'guisp=' . l:special[0], + \] + + execute join(l:hl_string, ' ') +endfunction + +function! s:Background() + if g:dracula_colorterm || has('gui_running') + return s:bg + else + return s:none + endif +endfunction + +"}}}2 +" Dracula Highlight Groups: {{{2 + +call s:h('DraculaBgLight', s:none, s:bglight) +call s:h('DraculaBgLighter', s:none, s:bglighter) +call s:h('DraculaBgDark', s:none, s:bgdark) +call s:h('DraculaBgDarker', s:none, s:bgdarker) + +call s:h('DraculaFg', s:fg) +call s:h('DraculaFgUnderline', s:fg, s:none, [s:attrs.underline]) +call s:h('DraculaFgBold', s:fg, s:none, [s:attrs.bold]) + +call s:h('DraculaComment', s:comment) +call s:h('DraculaCommentBold', s:comment, s:none, [s:attrs.bold]) + +call s:h('DraculaSelection', s:none, s:selection) + +call s:h('DraculaSubtle', s:subtle) + +call s:h('DraculaCyan', s:cyan) +call s:h('DraculaCyanItalic', s:cyan, s:none, [s:attrs.italic]) + +call s:h('DraculaGreen', s:green) +call s:h('DraculaGreenBold', s:green, s:none, [s:attrs.bold]) +call s:h('DraculaGreenItalic', s:green, s:none, [s:attrs.italic]) +call s:h('DraculaGreenItalicUnderline', s:green, s:none, [s:attrs.italic, s:attrs.underline]) + +call s:h('DraculaOrange', s:orange) +call s:h('DraculaOrangeBold', s:orange, s:none, [s:attrs.bold]) +call s:h('DraculaOrangeItalic', s:orange, s:none, [s:attrs.italic]) +call s:h('DraculaOrangeBoldItalic', s:orange, s:none, [s:attrs.bold, s:attrs.italic]) +call s:h('DraculaOrangeInverse', s:bg, s:orange) + +call s:h('DraculaPink', s:pink) +call s:h('DraculaPinkItalic', s:pink, s:none, [s:attrs.italic]) + +call s:h('DraculaPurple', s:purple) +call s:h('DraculaPurpleBold', s:purple, s:none, [s:attrs.bold]) +call s:h('DraculaPurpleItalic', s:purple, s:none, [s:attrs.italic]) + +call s:h('DraculaRed', s:red) +call s:h('DraculaRedInverse', s:fg, s:red) + +call s:h('DraculaYellow', s:yellow) +call s:h('DraculaYellowItalic', s:yellow, s:none, [s:attrs.italic]) + +call s:h('DraculaError', s:red, s:none, [], s:red) + +call s:h('DraculaErrorLine', s:none, s:none, [s:attrs.undercurl], s:red) +call s:h('DraculaWarnLine', s:none, s:none, [s:attrs.undercurl], s:orange) +call s:h('DraculaInfoLine', s:none, s:none, [s:attrs.undercurl], s:cyan) + +call s:h('DraculaTodo', s:cyan, s:none, [s:attrs.bold, s:attrs.inverse]) +call s:h('DraculaSearch', s:green, s:none, [s:attrs.inverse]) +call s:h('DraculaBoundary', s:comment, s:bgdark) +call s:h('DraculaLink', s:cyan, s:none, [s:attrs.underline]) + +call s:h('DraculaDiffChange', s:orange, s:none) +call s:h('DraculaDiffText', s:bg, s:orange) +call s:h('DraculaDiffDelete', s:red, s:bgdark) + +" }}}2 + +" }}} +" User Interface: {{{ + +set background=dark + +" Required as some plugins will overwrite +call s:h('Normal', s:fg, s:Background()) +call s:h('StatusLine', s:none, s:bglighter, [s:attrs.bold]) +call s:h('StatusLineNC', s:none, s:bglight) +call s:h('StatusLineTerm', s:none, s:bglighter, [s:attrs.bold]) +call s:h('StatusLineTermNC', s:none, s:bglight) +call s:h('WildMenu', s:bg, s:purple, [s:attrs.bold]) +call s:h('CursorLine', s:none, s:subtle) + +hi! link ColorColumn DraculaBgDark +hi! link CursorColumn DraculaBgDark +hi! link CursorLineNr DraculaYellow +hi! link DiffAdd DraculaGreen +hi! link DiffAdded DiffAdd +hi! link DiffChange DraculaDiffChange +hi! link DiffDelete DraculaDiffDelete +hi! link DiffRemoved DiffDelete +hi! link DiffText DraculaDiffText +hi! link Directory DraculaPurpleBold +hi! link ErrorMsg DraculaRedInverse +hi! link FoldColumn DraculaSubtle +hi! link Folded DraculaBoundary +hi! link IncSearch DraculaOrangeInverse +hi! link LineNr DraculaComment +hi! link MoreMsg DraculaFgBold +hi! link NonText DraculaSubtle +hi! link Pmenu DraculaBgDark +hi! link PmenuSbar DraculaBgDark +hi! link PmenuSel DraculaSelection +hi! link PmenuThumb DraculaSelection +hi! link Question DraculaFgBold +hi! link Search DraculaSearch +hi! link SignColumn DraculaComment +hi! link TabLine DraculaBoundary +hi! link TabLineFill DraculaBgDarker +hi! link TabLineSel Normal +hi! link Title DraculaGreenBold +hi! link VertSplit DraculaBoundary +hi! link Visual DraculaSelection +hi! link VisualNOS Visual +hi! link WarningMsg DraculaOrangeInverse + +" }}} +" Syntax: {{{ + +" Required as some plugins will overwrite +call s:h('MatchParen', s:green, s:none, [s:attrs.underline]) +call s:h('Conceal', s:comment, s:bglight) + +" Neovim uses SpecialKey for escape characters only. Vim uses it for that, plus whitespace. +if has('nvim') + hi! link SpecialKey DraculaRed +else + hi! link SpecialKey DraculaSubtle +endif + +hi! link Comment DraculaComment +hi! link Underlined DraculaFgUnderline +hi! link Todo DraculaTodo + +hi! link Error DraculaError +hi! link SpellBad DraculaErrorLine +hi! link SpellLocal DraculaWarnLine +hi! link SpellCap DraculaInfoLine +hi! link SpellRare DraculaInfoLine + +hi! link Constant DraculaPurple +hi! link String DraculaYellow +hi! link Character DraculaPink +hi! link Number Constant +hi! link Boolean Constant +hi! link Float Constant + +hi! link Identifier DraculaFg +hi! link Function DraculaGreen + +hi! link Statement DraculaPink +hi! link Conditional DraculaPink +hi! link Repeat DraculaPink +hi! link Label DraculaPink +hi! link Operator DraculaPink +hi! link Keyword DraculaPink +hi! link Exception DraculaPink + +hi! link PreProc DraculaPink +hi! link Include DraculaPink +hi! link Define DraculaPink +hi! link Macro DraculaPink +hi! link PreCondit DraculaPink +hi! link StorageClass DraculaPink +hi! link Structure DraculaPink +hi! link Typedef DraculaPink + +hi! link Type DraculaCyanItalic + +hi! link Delimiter DraculaFg + +hi! link Special DraculaPink +hi! link SpecialComment DraculaCyanItalic +hi! link Tag DraculaCyan +hi! link helpHyperTextJump DraculaLink +hi! link helpCommand DraculaPurple +hi! link helpExample DraculaGreen +hi! link helpBacktick Special + +"}}} + +" vim: fdm=marker ts=2 sts=2 sw=2: diff --git a/nvim/init.vim b/nvim/init.vim new file mode 100644 index 0000000..f9d0e7f --- /dev/null +++ b/nvim/init.vim @@ -0,0 +1,243 @@ +" Set the leader key before plugin initialization. +let g:mapleader="\" + +" Make sure plugins cant use space as a keymapping. +nnoremap +xnoremap + +" +"General vim config--------------------- +" +set number relativenumber " Pretty line numbers +set mouse=a " I like the mouse +set clipboard=unnamedplus " Use system clipboard + +" Enable persistent undo so that undo history persists across vim sessions +set undofile +set undodir=~/.vim/undo + +" Nice tabs +set list lcs=tab:\|- +set tabstop=4 +set softtabstop=4 +set noexpandtab +set shiftwidth=4 +set smarttab + +" Colors---------------------------------- +syntax enable " Syntax highlighting +colorscheme dracula " Use the dracula colorscheme +set termguicolors " Enable full color support in terminal + +" vim-buffet +function! g:BuffetSetCustomColors() + hi! BuffetCurrentBuffer guibg=#2B899D guifg=#FFFFFF + hi! BuffetActiveBuffer guibg=#191A21 guifg=#8BE9FD + hi! BuffetBuffer guibg=#191A21 guifg=#FFFFFF + hi! BuffetTrunc guibg=#21222C guifg=#FFFFFF + hi! BuffetTab guibg=#7D53B9 guifg=#FFFFFF +endfunction +" +"Plugin Config---------------------------- +" +let g:NERDCreateDefaultMappings = 0 +let g:deoplete#enable_at_startup = 1 + +" Spaceline +let g:spaceline_seperate_style= 'arrow' +let g:spaceline_colorscheme = 'space' + +" vim-buffet +let g:buffet_tab_icon = "" +let g:buffet_powerline_separators = 1 +let g:buffet_tab_icon = "\uf00a" +let g:buffet_left_trunc_icon = "\uf0a8" +let g:buffet_right_trunc_icon = "\uf0a9" + +" vim-which-key +let g:which_key_map = {} +let g:which_key_map.1 = 'Select window 1' +let g:which_key_map.2 = 'Select window 2' +let g:which_key_map.3 = 'Select window 3' +let g:which_key_map.4 = 'Select window 4' +let g:which_key_map.5 = 'Select window 5' +let g:which_key_map.6 = 'Select window 6' +let g:which_key_map.7 = 'Select window 7' +let g:which_key_map.8 = 'Select window 8' +let g:which_key_map.9 = 'Select window 9' +let g:which_key_map.0 = 'Select window 10' +let g:which_key_map.c = 'Toggle comment' +let g:which_key_map.n = 'Open file tree' +let g:which_key_map.j = "Open any jump" +let g:which_key_map.w = "Close current tab" +let g:which_key_map.f = "Clap" +let g:which_key_map.r = "Toggle rainbow highlighting" +let g:which_key_map.g = {'name': "+grammarous"} +let g:which_key_map.g.c = "Check" +let g:which_key_map.g.r = "Reset" + +" any-jump +let g:any_jump_disable_default_keybindings = 1 + +" vim-markdown +let g:vim_markdown_folding_level = 1 +let g:vim_markdown_folding_style_pythonic = 1 +let g:vim_markdown_frontmatter = 1 +let g:vim_markdown_auto_insert_bullets = 1 +let g:vim_markdown_new_list_item_indent = 0 +let g:vim_markdown_conceal_code_blocks = 0 +let g:vim_markdown_conceal = 0 +let g:vim_markdown_strikethrough = 1 +let g:vim_markdown_edit_url_in = 'vsplit' +let g:vim_markdown_fenced_languages = [ + \ 'c++=cpp', + \ 'viml=vim', + \ 'bash=sh', + \ 'ini=dosini', + \ 'js=javascript', + \ 'json=javascript', + \ 'jsx=javascriptreact', + \ 'tsx=typescriptreact', + \ 'docker=Dockerfile', + \ 'makefile=make', + \ 'py=python' + \ ] + +" rainbow +let g:rainbow_active = 1 + +" vimtex +let g:tex_flavor = 'latex' +let g:vimtex_compiler_latexmk = { + \ 'build_dir' : 'build', + \ 'options' : [ + \ '-pdf', + \ '-shell-escape', + \ '-verbose', + \ '-file-line-error', + \ '-synctex=1', + \ '-interaction=nonstopmode', + \ ], + \} + +"dein Scripts----------------------------- +if &compatible + set nocompatible " Be iMproved +endif + +" Required: +set runtimepath+=/home/kalle/.cache/dein/repos/github.com/Shougo/dein.vim + +" Required: +if dein#load_state('/home/kalle/.local/share/dein') + call dein#begin('/home/kalle/.local/share/dein') + + " Let dein manage dein Required: + call dein#add('/home/kalle/.local/share/dein/repos/github.com/Shougo/dein.vim') + + " Add or remove your plugins here like this: + call dein#add('Shougo/neosnippet.vim') + call dein#add('Shougo/neosnippet-snippets') + call dein#add('Shougo/deoplete.nvim') + call dein#add('Shougo/neco-syntax') + call dein#add('tbodt/deoplete-tabnine', { 'build': './install.sh' }) + call dein#add('preservim/nerdcommenter') + call dein#add('ryanoasis/vim-devicons') + call dein#add('hardcoreplayers/spaceline.vim') + call dein#add('bagrat/vim-buffet') + call dein#add('liuchengxu/vim-which-key') + call dein#add('editorconfig/editorconfig-vim') + call dein#add('preservim/nerdtree') + call dein#add('pechorin/any-jump.vim') + call dein#add('liuchengxu/vim-clap') + call dein#add('rhysd/accelerated-jk') + call dein#add('t9md/vim-choosewin') + call dein#add('junegunn/vim-easy-align') + call dein#add('simnalamburt/vim-mundo') + call dein#add('plasticboy/vim-markdown') + call dein#add('luochen1990/rainbow') + call dein#add('rhysd/vim-grammarous') + call dein#add('dag/vim-fish') + call dein#add('lervag/vimtex') + call dein#add('calculuswhiz/vim-GAS-x86_64-highlighter') + + " Required: + call dein#end() + call dein#save_state() +endif + +" Required: +filetype plugin indent on +filetype plugin on +syntax enable + +" If you want to install not installed plugins on startup. +if dein#check_install() + call dein#install() +endif + +"End dein Scripts------------------------- + +call which_key#register('', "g:which_key_map") + +call deoplete#custom#var('omni', 'input_patterns', { + \ 'tex': g:vimtex#re#deoplete + \}) + +"Auto commands --------------------------- +au User VimtexEventInitPost call vimtex#compiler#start() +" +"Keymappings ----------------------------- +" +" General +nnoremap w :b#bd# + +" NERDCommenter +nnoremap c :call NERDComment("n", "Toggle") +xnoremap c :call NERDComment("x", "Toggle") + +" vim-buffet +nmap 1 BuffetSwitch(1) +nmap 2 BuffetSwitch(2) +nmap 3 BuffetSwitch(3) +nmap 4 BuffetSwitch(4) +nmap 5 BuffetSwitch(5) +nmap 6 BuffetSwitch(6) +nmap 7 BuffetSwitch(7) +nmap 8 BuffetSwitch(8) +nmap 9 BuffetSwitch(9) +nmap 0 BuffetSwitch(10) + +" vim-which-key +nnoremap :WhichKey '' + +" NERDTree +nnoremap n :NERDTreeToggle + +" any-jump +nnoremap j :AnyJump +xnoremap j :AnyJumpVisual + +" clap +nnoremap f :Clap + +" accelerated-jk +nmap j (accelerated_jk_gj) +nmap k (accelerated_jk_gk) + +" vim-choosewin +nmap - (choosewin) + +" vim-easy-align +xmap ga (EasyAlign) +nmap ga (EasyAlign) + +" vim-mundo" +nnoremap :MundoToggle + +" rainbow +nnoremap r :RainbowToggle + +" grammarous +nnoremap gc :GrammarousCheck +nnoremap gr :GrammarousReset diff --git a/setup.sh b/setup.sh new file mode 100755 index 0000000..567fee7 --- /dev/null +++ b/setup.sh @@ -0,0 +1,36 @@ +#!/bin/env bash +set -x + +cd $(dirname $0) + +DOTS_DIR=$(pwd) + +# Neovim +NVIM_DIR="$HOME/.config/nvim" + +# Check if the NVIM directory exists. If it does we skip this part of the script and inform the user. +if [ -d $NVIM_DIR ]; then + echo "[NVIM] Configuration directory exists. Skipping." +else + # Symlink the config. + ln -s $DOTS_DIR/nvim $NVIM_DIR + + # Install dein.vim + curl https://raw.githubusercontent.com/Shougo/dein.vim/master/bin/installer.sh > /tmp/dein_installer.sh + chmod +x /tmp/dein_installer.sh + /tmp/dein_installer.sh ~/.local/share/dein +fi + +# Fish +FISH_DIR="$HOME/.config/fish" + +# Check if the FISH directory exists. If it does we skip this part of the script and inform the user. +if [ -d $FISH_DIR ]; then + echo "[FISH] Configuration directory exists. Skipping." +else + # Symlink the config + ln -s $DOTS_DIR/fish $FISH_DIR + + # Install fisher plugins + fish -c "fisher add dracula/fish rafaelrinaldi/pure" +fi