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

Allow a default config to be used #2

Merged
merged 5 commits into from
Jul 7, 2021

Conversation

academo
Copy link
Contributor

@academo academo commented Jul 4, 2021

This PR's adds a default config to the plugin and an option to enable it when you init.

The default config is meant to ease the setup of diagnostics and formatting for the same standard files that are supported by the plugin.

To avoid breaking any configuration from people using the plugin, the default configuration is opt-in.

To enable this default configuration a new parameter can be passed to the init function

require'diagnosticls-nvim'.init {default_config = true}

This will internally set all the linters and formatters.

A user could change or disable specific linters or formatters by passing custom config. E.g. If eslint would like to be used to fix JS files instead of prettier, an user could write this:

require'diagnosticls-nvim'.init {default_config = true}

require'diagnosticls-nvim'.setup {
    ['javascript'] = {
		linter = require 'diagnosticls-nvim.linters.eslint',
        formatter = require 'diagnosticls-nvim.formatters.eslint'
    },
    
}

note that in the previous snippet the linter is also passed. If not passed the linter will be empty: the default config containing linter and formatter as keys will be overwritten by a new table containing only formatter.

This PR also adds an additional option: format.

The idea is, if some use wants to use the default_config for linting for not for formatting, they could pass this to the init and the plugin will not set any formatter (not even the ones passed on the setup function).

This is useful for users that'd like to use this plugin only for linting with the default config.

Note: I applied lua-format to the init.lua file.

@creativenull
Copy link
Owner

Hey, thanks for the PR 🙂

I'll take a look at it during this week and see if it's good or if it needs some improvements

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@academo
Copy link
Contributor Author

academo commented Jul 7, 2021

@creativenull any comment on the PR other than code formatting/style?

@creativenull
Copy link
Owner

creativenull commented Jul 7, 2021

From what I see the code looks good to add default configs to the init() function, I've also tested it out and it seems to work. I also feel like the format key option should also be a different PR but it's fine to keep it here.

Let me add an editorconfig and lua format rules to the project and let you know when ready for you to make the formatting changes. In the meantime, you can move the eslint formatter config to a different PR.

@academo
Copy link
Contributor Author

academo commented Jul 7, 2021

Great! I'll move eslint fixer to another PR.

could you please ping me when you have the editorconfig? thanks!

@academo academo changed the title Allow a default config to be used and add eslint formatter Allow a default config to be used Jul 7, 2021
@creativenull
Copy link
Owner

creativenull commented Jul 7, 2021

@academo I've added a editorconfig and lua-format rules to the repo. But I can fix those formatting issue myself and go ahead and approve this if you're good

Added in #5

@academo
Copy link
Contributor Author

academo commented Jul 7, 2021

@creativenull go for it! thanks

@creativenull creativenull merged commit 719a6c8 into creativenull:main Jul 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants