# `launch-editor-nvim`

something you can set as `$LAUNCH_EDITOR` for
[`launch-editor`](https://github.com/yyx990803/launch-editor) to open a file in
an existing `nvim` process

uses artificial intelligence to choose the best neovim process to open the file
in, based on the current working directory of neovim and the path of the file to
open

based on
<https://theosteiner.de/open-neovim-from-your-browser-integrating-nvim-with-sveltes-inspector>
and some discussion in the comment section under that blog post. thanks
everyone!

## installation

```sh
cargo install --locked launch-editor-nvim
```

then just set `$LAUNCH_EDITOR` (e.g., in `~/.zshenv`):

```zsh
export LAUNCH_EDITOR=launch-editor-nvim
```

## platform support

|    platform    | tested | should work |
| :------------: | :----: | :---------: |
|     macOS      |  yeah  |    yeah     |
| any other unix |   no   |    yeah     |
|    windows     |   no   |     no      |

## frequently asked questions

### why did you write in rust what should really be a shell script

because its fun and also i wanted to be able to `cargo install` it anywhere

### how does the artificial intelligence decide which neovim process to target?

1. the current working directory of the neovim process must be an ancestor of
   the file to open
2. the process with the closest ancestor "wins"

### does it really use artificial intelligence?

it makes use of somewhat arbitrary heuristics to take a decision for you. it
also helps you be more productive, so it's like a sort of "copilot" i guess. it
also involves a lot of `if` statements, enough to be called an ai-enabled app

### this isn't artificial intelligence

this isn't a question

## infrequently asked questions

### should i play outer wilds

no, you _MUST_ (see [RFC 2119](https://www.rfc-editor.org/info/rfc2119))
