NTBBloodbath / cheovim

Neovim configuration switcher written in Lua. Inspired by chemacs.
GNU General Public License v2.0
332 stars 14 forks source link

Convenience functions for getting path of current init.lua file? #13

Closed ElPiloto closed 1 year ago

ElPiloto commented 1 year ago

I typically have a keymapping to edit my init.lua file, but I find that doesn't work with cheovim. Does cheovim expose the currently loaded init.lua file somehow?

NTBBloodbath commented 1 year ago

Hey,

cheovim doesn't expose anything like that right now yet I'll make a small patch to expose current selected profile (and its init.lua path) soon.

In the meantime you could use something like this:

local loader = require("cheovim.loader")

-- Grab the selected profile from the profiles file
local selected_profile, _ = loader.get_profiles(vim.fn.stdpath("config") .. "/profiles.lua")
local current_init = selected_profile[1] .. "/init.lua"

Cheers

NTBBloodbath commented 1 year ago

Oops, didn't meant to close this until I push the patch, my apologies!

ElPiloto commented 1 year ago

Thank you, your snippet works well enough until that patch.

ElPiloto commented 1 year ago

After a closer look, I guess there's no need for a convenience function. Since cheovim manipulates vim.fn.stdpath to return the location of the loaded profile, I can get the location of the loaded config via that. Just need to change my keymapping, which should work both with and without cheovim.