nix-community / nixvim

Configure Neovim with Nix! [maintainers=@GaetanLepage, @traxys, @mattsturgeon, @khaneliman]
https://nix-community.github.io/nixvim
MIT License
1.74k stars 266 forks source link

[Feature Request] `otter.activate()` automatically #2111

Closed henrispriet closed 1 month ago

henrispriet commented 2 months ago
Field Description
Plugin [otter.nvim](https://nix-community.github.io/nixvim/plugins/otter/index.html)
Nixpkgs unstable
Home Manager unstable

Description

I'm not sure whether this is really a bug. When enabling otter via nixvim, I expected that when I open up any of my nixvim config files with lua snippets in them, I would now automatically get all the lsp features in those snippets. According to otter.nvim, one has to activate otter per document.

I'm just going to set up an autocommand for my own config now to call require("otter").activate() for every file opened, but maybe the plugins.otter module could do this automatically? Or perhaps as an option (plugins.otter.auto_activate = true)?

Minimal, Reproducible Example (MRE)

programs.nixvim = {
  plugins.otter.enable = true;
  plugins.treesitter.enable = true;
  plugins.treesitter.settings.highlight.enable = true;
}
khaneliman commented 2 months ago

I have been meaning to use this plugin and forgot about it. But, I do see what you are talking about after adding it and trying it out. I wouldn't call it a bug, since it's the default behavior of the plugin and from the configuration used. But, now I am curious about what the proper way of auto loading it is. I'd assume we only want to load it with the lsp attach event handler...

MattSturgeon commented 2 months ago

I'd assume we only want to load it with the lsp attach event handler...

In addition to the on_attach callback, there's also the LspAttach autocmd event that we already use for registering lsp-plugin keybinds.