firenvim
firenvim copied to clipboard
Explore Lua metatables to provide less verbose configuration
While thinking about #1403, I realized that there might be a way to provide shorthands to the firenvim configuration object without polluting the global scope (e.g. require"firenvim".gc
to access g:firenvim_config["globalConfig"]
). This will be longer that the fc[...]
shorthand used at the moment, but the benefit of having copy-pastable, context-free configuration snippets might outweigh the cost? Cherry on top, we could make the metatable typecheck the configuration options using the types defined here, and warn the user when they're doing something wrong.
require"firenvim".gc
--or
local gc = require("firenvim").globalConfig
-- meta table methods could give some nice ergonomics
-- arg1: pattern
-- arg2: priority, default 1
-- arg3: table { takeover, selector, etc }
gc:add([[.*]], 0, { takeover = "once", selector = 'textarea, div[role="textbox"]' })
gc:add([[https://gitter\.im]], 1, { takeover = "never" })