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

Simplify setup code #36

Open
creativenull opened this issue Aug 27, 2023 · 0 comments
Open

Simplify setup code #36

creativenull opened this issue Aug 27, 2023 · 0 comments

Comments

@creativenull
Copy link
Owner

Omit init() and setup() just like it was done in creativenull/efmls-configs-nvim#30.

The reason being that having two separate functions to have the user setup is not very friendly, the preference would be to keep setup code as minimal as possible, at the same time, provide more flexibility to the user if in case they might want to adjust some settings.

But since the API is different in diagnostic-languageserver compared to efm-langserver, I'm thinking of creating a wrapper to generate the LSP config and then have the user merge them on lspconfig.diagnosticls.setup().

New proposal example:

local eslint = require('diagnosticls-configs.linters.eslint')
local prettier = require('diagnosticls-configs.formatters.prettier')

local diagnosticls_config = require('diagnosticls-configs').create({
  javascript = {
    linters = { eslint },
    formatters = { prettier },
  },
  typescript = {
    linters = { eslint },
    formatters = { prettier },
  },
})

require('lspconfig').diagnosticls.setup(vim.tbl_extend('force', diagnosticls_config, {
  on_attach = on_attach,
  capabilities = capabilities,
})

For defaults:

local diagnosticls_config = require('diagnosticls-configs').defaults()

To add additional languages or to overrides defaults, just pass the same table structure as in create():

local diagnosticls_config = require('diagnosticls-configs').defaults({
  javascript = {
    linters = { eslint },
    formatters = { prettier },
  },
})
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

No branches or pull requests

1 participant