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

Set init_options for each language #164

Open
guilhermehubner opened this issue Sep 8, 2021 · 0 comments
Open

Set init_options for each language #164

guilhermehubner opened this issue Sep 8, 2021 · 0 comments

Comments

@guilhermehubner
Copy link

Hello, I am using efm-langserver with nvim-lspconfig, this is my configuration:

local prettier = {
  formatCommand = 'prettier'
}

local golangcilint = {
  lintCommand = "golangci-lint run",
  lintSource = "golanci-lint",
}

lsp.efm.setup{
  init_options = {documentFormatting = true},
  root_dir = vim.loop.cwd,
  settings = {
    rootMarkers = {".git/"},
    languages = {
        go                     = {golangcilint},
        typescript      = {prettier},
    }
  }
}

As you can see, for golang I am using efm only for lint, the rest I do using gopls; There is a problem though, for typescript I am using prettier for formating, so I need to set init_options = {documentFormatting = true} and I have a format command set on save. For typescript it is ok, but for go, I have 2 server which offer documentFormating, so everytime I save a document I need to select the LSP I want to use for formatting. In this case my EFM don't format for Go so it is useless and inconvenient. I wonder if it is possible to do something like:

local prettier = {
  formatCommand = 'prettier'
  init_options = {documentFormatting = true}, -- SET HERE
}

local golangcilint = {
  lintCommand = "golangci-lint run",
  lintSource = "golanci-lint",
  init_options = {documentFormatting = false}, -- SET HERE
}

lsp.efm.setup{
  root_dir = vim.loop.cwd,
  settings = {
    rootMarkers = {".git/"},
    languages = {
        go                     = {golangcilint},
        typescript      = {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