Micron Document
exrc foolishness

I like having a T383838.exrc file in some of my repositories. But I started embedding my Neovim configuration in my Nix configuration. This means that when I run T383838nvim at the console it really does T383838nvim -u some-file-in-the-nix-store. And that's fine, it works like it should because when I build my system it puts the configuration bits in that file in the nix store that gets referenced via T383838nvim -u. Except, that's where the problem lies, too. If you use the T383838-u option to Neovim, you cannot make use of a T383838.exrc file. That file will be ignored. Despite that it may exist and it may have been marked as trusted and runnable.

So to get around this, I wrote some messy Lua code. For reference, until I started using Neovim a few years back, I hadn't touched Lua since making dumb little mods for World of Warcraft in the aughties. So here's what I came up with:

T282828
Tff7b72local Te6edf3cwd Tff7b72= Te6edf3vimTb4b4b4.Te6edf3fnTb4b4b4.Td2a8ffgetcwdTb4b4b4(Tff7b72-T79c0ff1Tb4b4b4, Tff7b72-T79c0ff1Tb4b4b4)
Tff7b72if Tffa657string.findTb4b4b4(Te6edf3cwdTb4b4b4, Ta5d6ff"Ta5d6ff/messyTa5d6ff"Tb4b4b4) Tff7b72then
T8b949e-- project specific settings for my project
Te6edf3vimTb4b4b4.Td2a8ffcmdTb4b4b4(Ta5d6ff"Ta5d6ffsource Ta5d6ff" Tff7b72.. Tffa657os.getenvTb4b4b4(Ta5d6ff"Ta5d6ffHOMETa5d6ff"Tb4b4b4) Tff7b72.. Ta5d6ff"Ta5d6ff/messy/.exrcTa5d6ff"Tb4b4b4)
Tff7b72end


This goes in my T383838.config/nvim/init.lua file. And if the file I'm editing happens to be in my T383838messy notes repository, then Neovim will run the source command on the T383838.exrc file there.

I did this to restore my note specific project settings, from which I feel the most important settings are the following:

T282828
autocmd Tffa657BufWritePost *.mu execute Ta5d6ff'!git add % && git commit -m "autosaved %" && python resources/faster.py'
Tff7b72if hasTb4b4b4(Ta5d6ff"autocmd"Tb4b4b4)
augroup templates
autocmd Tffa657BufNewFile *.mu T79c0ff0r resources/template
augroup END
Tff7b72endif


The first line is auto commit to git on save for all markdown files and call my python script that deals with links and tags for files that might get published. The bit that follows makes it expand my markdown template into any newly created markdown file in the project. I have aliases for creating new files from the console that look like this:

T282828
Tffa657alias Te6edf3newnoteTff7b72=Ta5d6ff'(cd ~/messy ; "${EDITOR}" notes/$(date 'Tffea00\'Ta5d6ff'+%Y-%m-%d-%H-%M-%S'Tffea00\'Ta5d6ff').mu)'


The end result is that if I close the note without saving, no new file is created, but if I do make a note, it conforms to my template.

I need to make the Lua stuff a little more flexible and portable though, so it can slurp up other trusted T383838.exrc files, but I think I might end up finding some existing exrc plugin just so I'm not reinventing the wheel so much.

Tags: nixos, nvim

Tags
Navigation



created: 2025-01-23

(re)generated: 2026-07-17