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

Comparison to efm-langserver #31

Open
nomasprime opened this issue Sep 7, 2020 · 2 comments · May be fixed by #91
Open

Comparison to efm-langserver #31

nomasprime opened this issue Sep 7, 2020 · 2 comments · May be fixed by #91

Comments

@nomasprime
Copy link

Says in the readme that this project was inspired by efm-langserver but there's no comparison. How is this project better/different?

@iamcco
Copy link
Owner

iamcco commented Sep 8, 2020

There are almost same features, the difference is how to config linter and formatter. The reason I create diagnostic-languageserver is that i want to use same config as coc.nvim instead of a new linters config like efm-langserver.

@terrortylor
Copy link

The following is an example of configuring both efm and dls via nvim-lspconfig:

EFM

  -- NOTE: an efm config file prevents error in log, only needs first line of: version:2
  local eslint = {
    lintCommand = "./node_modules/.bin/eslint -f unix --stdin --stdin-filename ${INPUT}",
    lintIgnoreExitCode = true,
    lintStdin = true
  }
  
  require "lspconfig".efm.setup {
    --cmd = {"efm-langserver", "-q"}, -- the `-q` prevents the  readng std in, printing stdout message
    init_options = {documentFormatting = true},
    filetypes = {"javascript", "typescript"},
    root_dir = function(fname)
      return util.root_pattern("tsconfig.json")(fname) or
      util.root_pattern(".eslintrc.js", ".git")(fname);
    end,
    init_options = {documentFormatting = true},
    settings = {
      rootMarkers = {".eslintrc.js", ".git/"},
      --logFile = "/home/alextylor/efm.log",
      --logLevel =  1,
      languages = {
        typescript = {eslint}
      }
    }
  }

DLS

  require'lspconfig'.diagnosticls.setup{
    filetypes = {"javascript", "typescript"},
    root_dir = function(fname)
      return util.root_pattern("tsconfig.json")(fname) or
      util.root_pattern(".eslintrc.js", ".git")(fname);
    end,
    init_options = {
      linters = {
        eslint = {
          command = "./node_modules/.bin/eslint",
          rootPatterns = {".eslintrc.js", ".git"},
          debounce = 100,
          args = {
            "--stdin",
            "--stdin-filename",
            "%filepath",
            "--format",
            "json"
          },
          sourceName = "eslint",
          parseJson = {
            errorsRoot = "[0].messages",
            line = "line",
            column = "column",
            endLine = "endLine",
            endColumn = "endColumn",
            message = "[eslint] ${message} [${ruleId}]",
            security = "severity"
          },
          securities = {
            [2] = "error",
            [1] = "warning"
          }
        },
      },
      filetypes = {
        javascript = "eslint",
        typescript = "eslint"
      }
    }
  }

Both tested and working, hope this is useful for comparisions

weakish added a commit to weakish/diagnostic-languageserver that referenced this issue Jan 26, 2024
weakish added a commit to weakish/diagnostic-languageserver that referenced this issue Jan 26, 2024
@weakish weakish linked a pull request Jan 26, 2024 that will close this issue
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 a pull request may close this issue.

3 participants