Skip to content

Commit

Permalink
install: multiple configs aliases and shell selector
Browse files Browse the repository at this point in the history
  • Loading branch information
practicalli-johnny committed Jun 17, 2024
1 parent e2eadd2 commit 29a7f1e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 23 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
53 changes: 32 additions & 21 deletions docs/install/multiple-configurations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
```


Expand All @@ -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
}
```

8 changes: 6 additions & 2 deletions docs/install/neovim.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 29a7f1e

Please sign in to comment.