Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose config for other devs to make integrations with your plugin? #167

Closed
pocco81 opened this issue Apr 25, 2021 · 4 comments
Closed

Expose config for other devs to make integrations with your plugin? #167

pocco81 opened this issue Apr 25, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@pocco81
Copy link

pocco81 commented Apr 25, 2021

Is your feature request related to a problem? Please describe.
I'm working on an integration for my plugin with yours. For the integration, I need to check the state of some stuff your plug-in can do (e.g. config.sings, config.numhl, config.linehl)

Describe the solution you'd like
Simply expose the instance of Config named config from here by returning it. In this way I can access each on of its fields (like this one) to determine the state of each one of the elements/features your plugin provides.

Describe alternatives you've considered
The solution above is pretty simple a self explanatory. However, you can also create a new table (e.g. state) and add all the variables the variables as keys and their values as values, and in the end, return it.

Additional context
Need this for an integration. In the end it'll be possible for me to simply access each field. For instance:

local signcolumn = require("gitsigns.M.config").signcolumn
@lewis6991
Copy link
Owner

Sorry for taking a while to reply.

I'd like to expose the config, I've just been struggling to think how to do this nicely. Ideally I'd to expose it as require('gitsigns.config'), but that modules needs to expose other functions too.

For the meantime we can expose it as require('gitsigns')._config (API unstable). Would that be ok?

@pocco81
Copy link
Author

pocco81 commented May 1, 2021

Hello again. Yes, it would be nice to have it exposed as a field for now, which is the simplest solution. However, having _config as its own module would be better.

I haven't played around with it much because I just saw your message, but I can confirm that this API call is working:

local gs = require("gitsigns")
local gs_config = gs._get_config()

cmd("echo 'GS signcolumn = "..tostring(gs_config.signcolumn).."'")

Congrats! I'll update you if something isn't working as it should.

@pocco81
Copy link
Author

pocco81 commented May 1, 2021

Unrelated to the issue but... this was for an integration between your plugin and mine. You can go and check it out if you want!

@lewis6991
Copy link
Owner

@pocco81 btw there's now a stable way of getting the config:

local gs_config = require('gitsigns.config').config

I plan to remove _get_config() soon just to be warned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants