local language_id_mapping = {
  bib = 'bibtex',
  pandoc = 'markdown',
  plaintex = 'tex',
  rnoweb = 'rsweave',
  rst = 'restructuredtext',
  tex = 'latex',
  text = 'plaintext',
}

local function get_language_id(_, filetype)
  return language_id_mapping[filetype] or filetype
end

return {
  cmd = { 'ltex-ls-plus' },
  filetypes = {
    'markdown',
    'pandoc',
    'latex',
    'text',
    'norg',
    'gitcommit',
    'jj',
    'jjdescription',
    'rst',
    'typst'
  },
  get_language_id = get_language_id,
  single_file_support = true,
  settings = {
    ltex = {
      language = "auto",
      diagnosticSeverity = "information",
      checkFrequency = "save",
      sentenceCacheSize = 2000,
      additionalRules = {
        enablePickyRules = true,
        motherTongue = "fr",
      },
      enabledRules = {
        en = { "EN_CONSISTENT_APOS" },
      },
      disabledRules = {
        fr = { "APOS_TYP", "FRENCH_WHITESPACE", "CHANGE", "ISSUE" },
        en = { "DASH_RULE", "TWO_HYPHENS", "CHANGE", "ISSUE", "CHECK",
          "ACTUALLY", "CONSISTENT" },
      },
      dictionary = {
        fr = { "CryptPad", "Chouhartem",
          -- field names
          "authors", "categories", "created", "updated", "title", "meta" },
        en = { "CryptPad", },
      }
    }
  }
}