NTBBloodbath / cheovim

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

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

Closed ElPiloto closed 2 years ago

ElPiloto commented 2 years 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 2 years 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 2 years ago

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

ElPiloto commented 2 years ago

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

ElPiloto commented 2 years 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.