You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -190,3 +190,56 @@ For Nix contributors and maintainers:
190
190
191
191
[nix-flakes]: https://nixos.wiki/wiki/Flakes
192
192
193
+
## Development
194
+
195
+
### Loading the plugin
196
+
To be able to test our changes we need to tell our favourite plugin manager to load the plugin locally rather than clone it from GitHub. Below is a snippet on how to do it with `lazy.nvim`
197
+
198
+
```lua
199
+
{
200
+
--- The dir specified here is the absolute path to the sg.nvim repository
201
+
dir="~/code/path-to-sg-nvim-repo",
202
+
dependencies= { "nvim-lua/plenary.nvim" }
203
+
}
204
+
```
205
+
206
+
### Dynamically switch to loading the plugin from the repository
207
+
208
+
For ease for development it can be useful to automatically switch to loading the plugin from this repository if we enter this directory. We can do this by doing the following:
209
+
210
+
1. In your plugin manager configuration, create the following function
--- This is the configuration that lazy.nvim expects, but you can change it to whatever configuration your plugin manager expects
218
+
return {
219
+
"sourcegraph/sg.nvim",
220
+
dependencies= { "nvim-lua/plenary.nvim" },
221
+
}
222
+
end
223
+
end
224
+
```
225
+
2. Update your configuration - example (lazy.nvim):
226
+
227
+
```lua
228
+
require("lazy").setup({
229
+
"example/other-plugin",
230
+
load_sg(),
231
+
}
232
+
```
233
+
3. Finally, we need the `SG_NVIM_DEV` variable to exist in our environment as soon as we enter the repository. We can do that by using [direnv](https://direnv.net/) which automatically loads `.envrc` is it exists. Let's edit the present `.envrc`
234
+
235
+
```bash
236
+
export SG_NVIM_DEV="true"
237
+
# If nix-shell available, then nix is installed. We're going to use nix-direnv.
238
+
# for automatic devshell injection after opt-in `direnv allow`
239
+
ifcommand -v nix-shell &> /dev/null
240
+
then
241
+
use flake
242
+
fi
243
+
```
244
+
245
+
With the above changes, as soon as we enter this repository directory `direnv` will run `.envrc` which exports our `SG_NVIM_DEV` variable. Once we open Neovim and our plugins are loaded our `load_sg` function will get executed and see the `SG_NVIM_DEV` varialbe in the environment and rather load the `sg.nvim` plugin from the current working directory!
0 commit comments