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

How to configure efm? #388

Open
RudolfVonKrugstein opened this issue Apr 2, 2024 · 1 comment
Open

How to configure efm? #388

RudolfVonKrugstein opened this issue Apr 2, 2024 · 1 comment

Comments

@RudolfVonKrugstein
Copy link

Hi,

I am trying to configure efm to use markdown-lint and pandoc in markdown. Following this https://github.com/VonHeikemen/lsp-zero.nvim/blob/efm-client/doc/md/api-reference.md#efmtoolsopts I did:

-- setup efm
local efm_opts = lsp_zero.efm.tools({ -- this is line 201, from the error below
  {
    name = "markdown-lint",
    lintCommand = "markdownlint -s",
    lintStdin = true,
    lintFormats = {
      "%f:%l %m",
      "%f:%l:%c %m",
      "%f: %l: %m",
    },
    languages = { "markdown" },
  },
  {
    name = "markdown-pandoc",
    formatCommand = "pandoc -f markdown -t gfm -sp --tab-stop=2",
    languages = { "markdown" },
  },
})
require("lspconfig").efm.setup(efm_opts)

But when running this, I get:

Error detected while processing /home/nathan/dotfiles/nvim/init.lua:
E5113: Error while calling lua chunk: /home/nathan/dotfiles/nvim/init.lua:201: attempt to index field 'efm' (a nil value)
stack traceback:
        /home/nathan/dotfiles/nvim/init.lua:201: in main chunk

Why? What shall I do different?

Thanks!

@VonHeikemen
Copy link
Owner

VonHeikemen commented Apr 2, 2024

That feature was never merged in any release branch. So you have to add all the relevant options to lspconfig manually.

I would do something like this.

local efm_tools = {
  pandoc = {
    formatCommand = "pandoc -f markdown -t gfm -sp --tab-stop=2",
  },
  markdownlint = {
    lintCommand = "markdownlint -s",
    lintStdin = true,
    lintFormats = {
      "%f:%l %m",
      "%f:%l:%c %m",
      "%f: %l: %m",
    },
  }
}

require('lspconfig').efm.setup({
  init_options = {
    -- enable the options that your tools support
    documentFormatting = true,
    documentRangeFormatting = false,
    hover = false,
    documentSymbol = false,
    completion = false,
    codeAction = false
  },
  settings = {
    rootMarkers = {'.git/'},
    -- here you configure the tools per language
    languages = {
      markdown = {
        efm_tools.pandoc,
        efm_tools.markdownlint,
      },
    }
  },
  -- list of file types where the language server will be active
  filetypes = {
    'markdown',
  },
})

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

2 participants