UNPKG

@citedrive/codemirror-lang-bibtex

Version:

BibTeX language support for CodeMirror

51 lines (45 loc) 3.38 kB
import { LRLanguage, LanguageSupport } from '@codemirror/language'; import * as _codemirror_state from '@codemirror/state'; /** BibTeX Language configuration with [syntax highlighting](https://codemirror.net/6/docs/ref/#language.syntaxHighlighting), [folding](https://codemirror.net/6/docs/ref/#language.foldNodeProp), and [indentation](https://codemirror.net/6/docs/ref/#language.indentNodeProp). */ declare const bibtexLanguage: LRLanguage; /** BibLaTeX Language configuration as a [dialect](https://lezer.codemirror.net/docs/ref/#lr.ParserConfig.dialect) of [BibTeX](https://codemirror.net/6/docs/ref/#lang-bibtex.bibtexLanguage). */ declare const biblatexLanguage: LRLanguage; /** [BibTeX](https://codemirror.net/6/docs/ref/#lang-bibtex.bibtexLanguage) language support with [BibLaTeX](https://codemirror.net/6/docs/ref/#lang-bibtex.biblatexLanguage) dialect support, autocompletion [configuration](https://codemirror.net/6/docs/ref/#lang-bibtex.bibtexCompletion), and [snippets](https://codemirror.net/6/docs/ref/#autocomplete.snippet) for both BibTeX and BibLaTeX that are suggested based on the editor [context](https://codemirror.net/6/docs/ref/#autocomplete.CompletionContext). There are configuration options for the following: - **BibTeX** vs **BibLaTeX** language support: - default: `biblatex: false` - defaults to BibTeX - **Snippet Smart-Suggestion:** - default: `smartSuggest: true` - The smart-suggestion feature only suggests snippets for bibliography `entries` (i.e. `@article = {...}`) when the user *is not* currently editing an entry and only suggests snippets for bibliography `fields` (i.e. `author = {Donald Knuth}`) when the user *is* currently editing an entry. - **Opinionated Snippets**: - default: `snippetRecs: true` - Snippets have been scaffolded as per the current [BibTeX](https://ctan.org/ctan-ann/id/mailman.3109.1292253131.2307.ctan-ann@dante.de)/[BibLaTeX](https://ctan.org/ctan-ann/id/mailman.404.1656879977.32352.ctan-ann@ctan.org) specs. The snippet [render config](https://codemirror.net/6/docs/ref/#autocomplete.CompletionSection), exclusion of certain snippets, and entry snippets' suggestion of recommendation/optional fields are done in an [opinionated](https://www.citedrive.com/en/blog/codemirror-bibtex-plugin) manner ([suggestions](https://github.com/citedrive/codemirror-lang-bibtex/issues) are welcome!). - **Syntax Linting**: - default: `syntaxLinter: true` - Invalid BibTeX (and BibLaTeX) syntax is underlined in red and a warning is issued, thanks to [bibtex-tidy](https://github.com/flamingtempura/bibtex-tidy). - **Custom Keywords**: - default: `keywords: []` - Users can specify custom keywords/values that will be auto-suggested when within a `FieldValue` syntax node. */ declare function bibtex(config?: { biblatex?: boolean; smartSuggest?: boolean; snippetRecs?: boolean; syntaxLinter?: boolean; keywords?: readonly string[]; }): LanguageSupport; /** BibTeX autocompletion [configuration](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion^config). */ declare const bibtexCompletion: _codemirror_state.Extension; /** BibTeX [syntax linter](https://codemirror.net/6/docs/ref/#lint.Diagnostic). */ declare const bibtexLinter: _codemirror_state.Extension; export { biblatexLanguage, bibtex, bibtexCompletion, bibtexLanguage, bibtexLinter };