lazy.nvim icon indicating copy to clipboard operation
lazy.nvim copied to clipboard

feature: language options in seperate files

Open sand4rt opened this issue 10 months ago • 2 comments

Did you check the docs?

  • [x] I have read all the lazy.nvim docs

Is your feature request related to a problem? Please describe.

Wanted to store my language config in seperate lua files and saw that lazy vim does something similar:

return {
  recommended = function()
    return LazyVim.extras.wants({
      ft = "rust",
      root = { "Cargo.toml", "rust-project.json" },
    })
  end,
  {
    "Saecki/crates.nvim",
    event = { "BufRead Cargo.toml" },
    opts = { },
  }
}

However the recommended and the LaztVim.extras.wants are not included lazy.vim

Describe the solution you'd like

Can this feature be moved to lazy.nvim?

Describe alternatives you've considered

I tried using ~/.config/nvim/after/ftplugin/{language}.lua as explained by TJ DeVries but this seems only for vim options, not for lazy plugins.

I have it working without the recommended property but i think im missing out on perf improvements, right?

Additional context

No response

sand4rt avatar Mar 07 '25 01:03 sand4rt

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Apr 21 '25 02:04 github-actions[bot]

Bump

sand4rt avatar Apr 21 '25 11:04 sand4rt

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar May 22 '25 02:05 github-actions[bot]

Bump

sand4rt avatar May 22 '25 09:05 sand4rt

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Jun 22 '25 02:06 github-actions[bot]

bump

sand4rt avatar Jun 22 '25 10:06 sand4rt

Hm... What is the feature? I have read the issue and I don't get why it is needed. I think more example or explanation are needed.

Are you trying to define file type-specific settings for each plugin?

Shougo avatar Jun 22 '25 10:06 Shougo

Are you trying to define file type-specific settings for each plugin?

Thanks for the reply. Yes, i was trying to implemt someting similar to LazyVim. rust.lua only seems to be loaded when the the filetype is rust and there is a cargo.toml and a rust-project.json in the root of the current working directory: https://github.com/LazyVim/LazyVim/blob/25abbf546d564dc484cf903804661ba12de45507/lua/lazyvim/plugins/extras/lang/rust.lua#L12-L17

sand4rt avatar Jun 22 '25 10:06 sand4rt

Can you tell me more about the specific plugin settings you're trying to achieve? It sounds like you might be misunderstanding LazyVim's "recommend" feature. It conditionally recommends plugin installations, which seems different from what you're describing.

Shougo avatar Jun 22 '25 11:06 Shougo

Sure. I wanted to organize my language-specific plugins into separate files, similar to how LazyVim does it: https://github.com/LazyVim/LazyVim/tree/main/lua/lazyvim/plugins/extras/lang

Ideally, I only want these plugins to be loaded when necessary. For example, the https://github.com/LazyVim/LazyVim/tree/main/lua/lazyvim/plugins/extras/lang/go.lua file should only be loaded when the following conditions are met:

ft = { "go", "gomod", "gowork", "gotmpl" },
root = { "go.work", "go.mod" },

This is what LazyVim.extras.wants handles right?

sand4rt avatar Jun 23 '25 16:06 sand4rt

If that's the case, how about separating your language-specific plugins into individual repositories for each language and loading them separately? As for loading plugins based on files in the root directory, since there is no such feature, I think it would be best to request only that feature from lazy.nvim.

Shougo avatar Jun 24 '25 01:06 Shougo

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Jul 30 '25 02:07 github-actions[bot]

This issue was closed because it has been stalled for 7 days with no activity.

github-actions[bot] avatar Aug 07 '25 02:08 github-actions[bot]