GithubHelp home page GithubHelp logo

Comments (5)

hdorgeval avatar hdorgeval commented on July 28, 2024 1

Hi @valentjn, thanks for your answer. Now I understand more.

For those who will land on this question/issue, here is the excerpt of the settings file that should be given to the --settings-file option (in my use case the input document is in french):

{
  "language": "fr",
  "dictionary": {
    "fr": [
      "Tehemten",
      "Akwan",
      "Rustem",
      "Touran",
      "Raksch",
      "farsangs",
      "Divs",
      // other words omitted for brevity
    ]
  },
  "hiddenFalsePositives": {
    "fr": [
      {
        "rule": "D_N",
        "sentence": "^\\QLorsqu'il fut revenu auprès de la source, méditant dans son âme guerrière de nouvelles luttes, le Div Akwan l'accosta de nouveau et lui dit :\\E$"
      },
      {
        "rule": "D_N",
        "sentence": "^\\QTehemten répondit aux paroles du Div par un mugissement de lion , détacha du crochet son lacet roulé, le lança et prit le Div au milieu du corps.\\E$"
      },
      // other rules omitted for brevity
    ]
  }
}

Basically, it is just a copy/paste of the files generated by the VSCode extension vscode-ltex under the .vscode folder.

I will provide soon in this discussion a node-js script that automatically create that settings files from the ones (ltex.dictionary.fr.txt, ltex.hiddenFalsePositives.fr.txt, settings.json) found in the .vscode folder

from ltex-ls.

valentjn avatar valentjn commented on July 28, 2024

There is an example in the docs under --settings-file.

You have to remove the ltex. prefixes to make it work (this stems from the configuration format the LSP mandates). Now that I think about it, you probably also have to unfold everything (that part is missing in the docs). So {"ltex.latex.commands": ...} becomes {"latex": {"commands": ...}}.

I see why this could confuse people, and it's a good idea to support both possibilities. Keep in mind, though, that VS Code is not the only editor LTEX LS supports; other editors might have different setting formats.

from ltex-ls.

hdorgeval avatar hdorgeval commented on July 28, 2024

Here is the script that builds the needed settings file from what has been generated by the VSCode extension (this sample code handles only french files):

  const ltexFrDictionaryFile = path.join(process.cwd(), '.vscode', 'ltex.dictionary.fr.txt');
  const frDictionary = readAllLinesInFile(ltexFrDictionaryFile).filter(
    (line) => line && line.length > 0,
  );

  const frFalsePositiveFile = path.join(
    process.cwd(),
    '.vscode',
    'ltex.hiddenFalsePositives.fr.txt',
  );
  const frFalsePositives = readAllLinesInFile(frFalsePositiveFile)
    .filter((line) => line && line.length > 0)
    .map((rawRule) => JSON.parse(rawRule));

  const frLtexLsSettings = {
    language: 'fr',
    dictionary: { fr: frDictionary },
    hiddenFalsePositives: { fr: frFalsePositives },
  };

  writeFileSync(
    path.join(process.cwd(), 'ltex-settings.fr.json'),
    JSON.stringify(frLtexLsSettings, null, 2),
  );

readAllLinesInFile:

export const readAllLinesInFile = (filePath: PathLike): string[] => {
  const lines = readFileSync(filePath, 'utf8').split(/\n|\r/);
  return lines;
};

from ltex-ls.

valentjn avatar valentjn commented on July 28, 2024

LTEX LS can now parse flattened JSON objects as well, with or without ltex. prefix. Look in the readme/CLI help for examples.

Note that the settings JSON of the screenshot in the description of this issue won't work though, because that's not valid JSON (has trailing commas). Only valid JSON is supported (no trailing commas, no comments).

from ltex-ls.

valentjn avatar valentjn commented on July 28, 2024

Feature released in 13.0.0.

from ltex-ls.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.