this post was submitted on 12 Dec 2024
7 points (88.9% liked)

Neovim

2226 readers
1 users here now

founded 2 years ago
MODERATORS
7
submitted 1 month ago* (last edited 1 month ago) by [email protected] to c/neovim
 

I need some advice how to handle project-specific plugin configuration for Neovim. My paid software gig involves work for several different client projects which are basically structured like this:

~/work-clientA
  - repoA1
  - repoA2
~/work-clientB
  - repoB1
  - repoB2
~/work-clientC
...

I manage the different environments using direnv.

What I struggle with is overriding/extending the config for Neovim plugins for each environment.

let's say for example clientA uses a self-hosted GitLab instance which requires me to override the lazy.nvim config for some Git-related plugins. How could I achieve this?

I looked into exrc. afaict this would require duplicating any client-specific configuration for each new repository. Instead what I would like is something like ~/work-clientA/init.lua which would then be sourced automatically for each project (repo) inside work-clientA.

top 2 comments
sorted by: hot top controversial new old
[–] [email protected] 2 points 3 weeks ago* (last edited 3 weeks ago) (1 children)

what about using exrc (with like a .nvim.lua file inside the repos) with the content of

dofile(“../init.lua”)
-- maybe more repo specific config here

and then say ~/work-clientA/init.lua with all client specific changes there.

this would still require creating two separate files but the client setup will be the same for all client repos, and additionally you can add repo specific changes.

[–] [email protected] 1 points 3 weeks ago

that's a great idea!