-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
Make --settings-file
compatible with flattened JSON like VS Code's settings.json
#91
Comments
There is an example in the docs under You have to remove the 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. |
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 {
"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 I will provide soon in this discussion a node-js script that automatically create that settings files from the ones ( |
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),
);
export const readAllLinesInFile = (filePath: PathLike): string[] => {
const lines = readFileSync(filePath, 'utf8').split(/\n|\r/);
return lines;
}; |
LTEX LS can now parse flattened JSON objects as well, with or without 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). |
--settings-file
compatible with flattened JSON like VS Code's settings.json
Feature released in 13.0.0. |
Hi @valentjn, I just tried the new option
--input-documents
and it works great. Thank you so much for providing this feature!Nonetheless, It is not clear how to use this new option with the
--settings-file
option.My use case is that I would like to re-use the workspace settings files that have been generated in VSCode:
It would be great if you could give some help.
Thanks.
The text was updated successfully, but these errors were encountered: