Skip to content

Improve config files and rtp handling #1920

Open
@MattSturgeon

Description

@MattSturgeon

@stasjok has an implementation here: stasjok/nixvim@optimize-rtp (commits) (last two commits), where the rtp is optimized as a "performance" option.

In the codebase I need to check wrapRc and if performance.optimizeRuntimePath is enabled. So it kind of strange to allow adding additional paths to rtp, but it works only if optimization is enabled and doesn't work otherwise...

So my thoughts are, if there is an interest in this feature, it shouldn't be performance options. Nixvim should do it by default with additional options to allow adding extra paths to rtp and packpath. It gives several benefits:

  1. nixvim will be pure by default (only paths managed by nixvim will be in rtp by default), but user always can add additional paths with options. Some plugins, like treesitter, can add the paths there automatically when nix parser management is disabled for example.
  2. filesPlugin should never be added as a plugin. This is wrong to begin with. That's because user files should always be first in rtp. When filesPlugins is in the mix with other plugins, overriding plugin files may not work (depending on sorting order).
  3. I think that there should be a default internal variable with a path to user files. By default it point to filesPlugin, but other modules (wrappers) can override it with it's own path (home-manager should set it to xdg config path that is perfectly known to it without using raw lua, like I did now, nixos can override it with etc directory with configs and so on). Final rtp is: configpath,plugins,nvimruntime,configafter.
  4. Potentially we can manage rtp partially with wrapper args, in that case we can even drop wrapRc completely and just place init.lua to filesPlugin. But this is debatable, maybe managing rtp paths as the first lines in init.lua is enough plus allow users to add paths with raw lua. Or it can mixed approach: user config path is added with command line args (so that the directory with init.lua is known to neovim), other paths are managed in init.lua.

In the end since all above as pretty large refactor and it should also change how things are managed right now, I put this task aside and decided to just change my lua code with a simple nix config in my config (in home-manager options I can get a static paths to my config files, to plugin path and to Nvim runtime, so no lua loops and matching needed, just plain vim.o.runtimepath assignment.

#1886 (comment)

Related issues:

  • We're conflating wrapRc with "isolating" the rtp - these are really separate issues.
    • wrapRc should just be about listing the init file in the wrapper args, using -u
    • Maybe we should always isolate the rtp instead of only doing it when wrapRc is enabled?
    • Is there ever a scenario where it makes sense to use nixvim with an impure config?
  • nixvim-print-init cannot show "extra files" content (i.e. filesPlugin)
  • modules/output: cleanup + refactoring #1889

Ping: @traxys @GaetanLepage

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions