From 29a7f1e20b418fb524101d3fed47134bc32c6d09 Mon Sep 17 00:00:00 2001 From: Practicalli Engineering Date: Tue, 18 Jun 2024 00:08:25 +0100 Subject: [PATCH] install: multiple configs aliases and shell selector --- CHANGELOG.md | 1 + docs/install/multiple-configurations.md | 53 +++++++++++++++---------- docs/install/neovim.md | 8 +++- 3 files changed, 39 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5667efe9..6ae16bc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ - intro: use practial.li/writing-tips link - install: use practial.li/clojure/install link - reference: practicalli configuration moved into reference +- install: multiple configs aliases and shell selector ## 2023-07-11 diff --git a/docs/install/multiple-configurations.md b/docs/install/multiple-configurations.md index dd7d7fc8..79153448 100644 --- a/docs/install/multiple-configurations.md +++ b/docs/install/multiple-configurations.md @@ -13,10 +13,10 @@ The configuration directory name is used to save local `share`, `state` and `cac ??? INFO "Community Configuration Projects" + * [kickstart.nvim](https://github.com/nvim-lua/kickstart.nvim) a highly documented starter configuration to effectively build your own + * [LazyVim](https://www.lazyvim.org/) lazy & mason configuration * [Magit Kit](https://github.com/Olical/magic-kit) fennel configuration from the author of Conjure * [cajus-nvim](https://github.com/rafaeldelboni/cajus-nvim) inspiration for practicalli/neovim-config-redux - * [LazyVim](https://www.lazyvim.org/) lazy & mason configuration - * [NvChad](https://github.com/NvChad/NvChad) polished UI with Lazy optomisations ## Configure shell alias @@ -27,9 +27,9 @@ Add alias to `.bashrc` for Bash shell or `.zshrc` for Zsh !!! EXAMPLE "Define Shell Aliases to run each configuration" ```shell - alias astro="NVIM_APPNAME=astronvim nvim" - alias lazy="NVIM_APPNAME=lazyvim nvim" - alias practicalli="NVIM_APPNAME=neovim-config nvim" + alias astro="NVIM_APPNAME=nvim-astro nvim" + alias lazy="NVIM_APPNAME=nvim-lazyvim nvim" + alias cajus="NVIM_APPNAME=nvim-cajus nvim" ``` @@ -53,21 +53,32 @@ Source the `.config/shell-aliases` file from within `.bashrc` or `.zshrc` fi ``` -## Zsh Terminal config selector - -Optionalliy define a terminal UI selection to choose a configuration if using zsh. - -!!! EXAMPLE "Z Shell nvim-selector script" - ```zsh title=".local/bin/nvim-selector" - function nvim-selector() { - items=("astronvim" "practicalli" "lazyvim") - config=$(printf "%s\n" "${items[@]}" | fzf --prompt=" Neovim Config  " --height=~50% --layout=reverse --border --exit-0) - if [[ -z $config ]]; then - echo "Nothing selected" - return 0 - elif [[ $config == "default" ]]; then - config="" - fi - NVIM_APPNAME=$config nvim $@ +## Neovim config selector + +Create a shell function to popup a menu with the list of available Neovim configurations, defined in `~/.config` where the configuration directories are prefixed with `nvim-`, e.g. `~/.config/nvim-astro/` + +![Neovim Config Fuzy Selector](https://github.com/practicalli/graphic-design/blob/live/editors/neovim/screenshots/neovim-config-selector-fuzzy-find-config-list-dark.png?raw=true){loading=lazy} + +!!! EXAMPLE "Neovim Config Fuzzy Finder" + + ```shell title=".local/bin/nvim-fuzy-find" + nvim-fuzy-find() { + # All config paths are prefixed with ~/.config/nvim- + local config=$(fdfind --max-depth 1 --glob 'nvim-*' ~/.config | fzf --prompt="Neovim Configs > " --height=15% --layout=reverse --border --exit-0) + + [[ -z $config ]] && echo "No config selected, Neovim not starting" && return + + # Open Neovim with selected config + NVIM_APPNAME=$(basename $config) nvim $@ + } + ``` + +??? EXAMPLE "Neovim Config simple Selector" + Add the Neovim config directory names from `~/.config/` + ```shell title=".local/bin/nvim-selector" + nvim-selector() { + select config in nvim-astro nvim-astronvim-template nvim-lazyvim nvim-kickstart + do NVIM_APPNAME=nvim-$config nvim $@; break; done } ``` + diff --git a/docs/install/neovim.md b/docs/install/neovim.md index 8d90c195..f4e9d321 100644 --- a/docs/install/neovim.md +++ b/docs/install/neovim.md @@ -202,14 +202,18 @@ Clone the [Practicalli Astro](https://github.com/practicalli/astro) config or cr ??? HINT "Multiple Neovim Configurations" Clone the configuration to a unique name within `~/.config` directory. + ```shell + git clone https://github.com/practicalli/astro.git ~/.config/nvim-astro + ``` + Set the `NVIM_APPNAME` environment variable to the configuration directory name under `~/.config` e.g. Run Neovim using the configuration in `~/.config/astro` ```shell - export NVIM_APPNAME=astro nvim + export NVIM_APPNAME=nvim-astro nvim ``` - [:fontawesome-solid-book-open: Configure shell alias](multiple-configurations/#configure-shell-alias){target=_blank} to simplify the command to run a specific configuration. + [:fontawesome-solid-book-open: Configure shell alias and selectors](multiple-configurations/#configure-shell-alias){target=_blank} to simplify the command to run a specific configuration. ??? INFO "AstroNvim Template" [:fontawesome-brands-github: AstroNvim template repository](https://github.com/AstroNvim/template) provide a general configuration for Neovim.