diff --git a/CHANGELOG.md b/CHANGELOG.md index 74f38eaa6..674866aa9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,12 +3,26 @@ ## [Unreleased] ### Added + +### Fixed + +## [0.9.10-alpha.3] - 2024-12-15 + +### Added + +* Add support for automatic language injection on the minted environment * Add support for DeclareGraphicsExtensions * Add inspection to warn about a missing reference for a glossary occurrence * Do not fold sections in a command definition * Include optional parameters in spellcheck, if it contains text +* Improve performance of finding files to be indexed +* Show formatted file path in file not found inspection quickfix name +* Automatically index bibliography files outside the project that are included by an absolute path +* Disable quotes inspection when TeX ligatures are disabled by fontspec +* Inspections can now be suppressed for any single line, or block of text ### Fixed + * Fix LaTeX files not showing up when choosing main file in run configuration * Fix various issues with the Grazie implementation, in particular default rules for Grazie Pro @@ -459,7 +473,8 @@ Thanks to @jojo2357 and @MisterDeenis for contributing to this release! * Fix some intention previews. ([#2796](https://github.com/Hannah-Sten/TeXiFy-IDEA/issues/2796)) * Other small bug fixes and improvements. ([#2776](https://github.com/Hannah-Sten/TeXiFy-IDEA/issues/2776), [#2774](https://github.com/Hannah-Sten/TeXiFy-IDEA/issues/2774), [#2765](https://github.com/Hannah-Sten/TeXiFy-IDEA/issues/2765)-[#2773](https://github.com/Hannah-Sten/TeXiFy-IDEA/issues/2773)) -[Unreleased]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.10-alpha.2...HEAD +[Unreleased]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.10-alpha.3...HEAD +[0.9.10-alpha.3]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.10-alpha.2...v0.9.10-alpha.3 [0.9.10-alpha.2]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.9...v0.9.10-alpha.2 [0.9.9]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.8...v0.9.9 [0.9.8]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.7...v0.9.8 diff --git a/gradle.properties b/gradle.properties index 4c8939784..9586f2e10 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -pluginVersion = 0.9.10-alpha.2 +pluginVersion = 0.9.10-alpha.3 # Info about build ranges: https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html # Note that an xyz branch corresponds to version 20xy.z and a since build of xyz.* diff --git a/src/nl/hannahsten/texifyidea/grammar/LatexLexer.flex b/src/nl/hannahsten/texifyidea/grammar/LatexLexer.flex index af76a5978..035ef11e0 100644 --- a/src/nl/hannahsten/texifyidea/grammar/LatexLexer.flex +++ b/src/nl/hannahsten/texifyidea/grammar/LatexLexer.flex @@ -38,9 +38,10 @@ import static nl.hannahsten.texifyidea.psi.LatexTypes.*; private int newCommandBracesNesting = 0; /** - * Also keep track of brackets of verbatim environment optional arguments. + * Also keep track of brackets of verbatim environment arguments. */ private int verbatimOptionalArgumentBracketsCount = 0; + private int verbatimRequiredArgumentBracketsCount = 0; /** * Keep track of braces in the PARTIAL_DEFINITION state. @@ -144,8 +145,8 @@ END_IFS=\\fi // States are exclusive to avoid matching expressions with an empty set of associated states, i.e. to avoid matching normal LaTeX expressions %xstates INLINE_VERBATIM_PLAIN_START INLINE_VERBATIM INLINE_VERBATIM_NORMAL_START -%states POSSIBLE_VERBATIM_BEGIN VERBATIM_OPTIONAL_ARG VERBATIM_START VERBATIM_END INLINE_VERBATIM_OPTIONAL_ARG -%xstates VERBATIM POSSIBLE_VERBATIM_OPTIONAL_ARG POSSIBLE_VERBATIM_END +%states POSSIBLE_VERBATIM_BEGIN VERBATIM_OPTIONAL_ARG VERBATIM_REQUIRED_ARG VERBATIM_START VERBATIM_END INLINE_VERBATIM_OPTIONAL_ARG +%xstates VERBATIM POSSIBLE_VERBATIM_ARG POSSIBLE_VERBATIM_END // algorithmic environment %states PSEUDOCODE POSSIBLE_PSEUDOCODE_END @@ -231,13 +232,14 @@ END_IFS=\\fi // Jump over the closing } of the \begin{verbatim} before starting verbatim state { - {CLOSE_BRACE} { yypopState(); yypushState(POSSIBLE_VERBATIM_OPTIONAL_ARG); return CLOSE_BRACE; } + {CLOSE_BRACE} { yypopState(); yypushState(POSSIBLE_VERBATIM_ARG); return CLOSE_BRACE; } } // Check if an optional argument is coming up // If you start a verbatim with an open bracket and don't close it, this won't work - { + { {OPEN_BRACKET} { verbatimOptionalArgumentBracketsCount = 1; yypopState(); yypushState(VERBATIM_OPTIONAL_ARG); return OPEN_BRACKET; } + {OPEN_BRACE} { verbatimRequiredArgumentBracketsCount = 1; yypopState(); yypushState(VERBATIM_REQUIRED_ARG); return OPEN_BRACE; } {WHITE_SPACE} { yypopState(); yypushState(VERBATIM); return com.intellij.psi.TokenType.WHITE_SPACE; } {ANY_CHAR} { yypopState(); yypushState(VERBATIM); return RAW_TEXT_TOKEN; } } @@ -248,11 +250,21 @@ END_IFS=\\fi {OPEN_BRACKET} { verbatimOptionalArgumentBracketsCount++; return OPEN_BRACKET; } {CLOSE_BRACKET} { verbatimOptionalArgumentBracketsCount--; - if (verbatimOptionalArgumentBracketsCount == 0) { yypopState(); yypushState(VERBATIM); } + // There can be a required arg coming + if (verbatimOptionalArgumentBracketsCount == 0) { yypopState(); yypushState(POSSIBLE_VERBATIM_ARG); } return CLOSE_BRACKET; } } + { + {OPEN_BRACE} { verbatimRequiredArgumentBracketsCount++; return OPEN_BRACE; } + {CLOSE_BRACE} { + verbatimRequiredArgumentBracketsCount--; + if (verbatimRequiredArgumentBracketsCount == 0) { yypopState(); yypushState(VERBATIM); } + return CLOSE_BRACE; + } +} + { // Also catch whitespace, see LatexParserUtil for more info {WHITE_SPACE} { return com.intellij.psi.TokenType.WHITE_SPACE; } diff --git a/src/nl/hannahsten/texifyidea/grammar/LatexParserDefinition.kt b/src/nl/hannahsten/texifyidea/grammar/LatexParserDefinition.kt index fa6c6c2f3..36122d828 100644 --- a/src/nl/hannahsten/texifyidea/grammar/LatexParserDefinition.kt +++ b/src/nl/hannahsten/texifyidea/grammar/LatexParserDefinition.kt @@ -48,7 +48,7 @@ class LatexParserDefinition : ParserDefinition { val FILE: IStubFileElementType<*> = object : IStubFileElementType( "LatexStubFileElementType", Language.findInstance(LatexLanguage::class.java) ) { - override fun getStubVersion(): Int = 77 + override fun getStubVersion(): Int = 78 } } diff --git a/src/nl/hannahsten/texifyidea/psi/LatexLanguageInjector.kt b/src/nl/hannahsten/texifyidea/psi/LatexLanguageInjector.kt index d582a6442..48cad906a 100644 --- a/src/nl/hannahsten/texifyidea/psi/LatexLanguageInjector.kt +++ b/src/nl/hannahsten/texifyidea/psi/LatexLanguageInjector.kt @@ -6,6 +6,7 @@ import com.intellij.openapi.util.TextRange import com.intellij.psi.InjectedLanguagePlaces import com.intellij.psi.LanguageInjector import com.intellij.psi.PsiLanguageInjectionHost +import nl.hannahsten.texifyidea.lang.DefaultEnvironment import nl.hannahsten.texifyidea.lang.magic.DefaultMagicKeys import nl.hannahsten.texifyidea.lang.magic.magicComment import nl.hannahsten.texifyidea.util.camelCase @@ -32,9 +33,12 @@ class LatexLanguageInjector : LanguageInjector { hasMagicCommentKey -> { magicComment.value(DefaultMagicKeys.INJECT_LANGUAGE) } - host.getEnvironmentName() == "lstlisting" -> { + host.getEnvironmentName() == DefaultEnvironment.LISTINGS.environmentName -> { host.beginCommand.getOptionalParameterMap().toStringMap().getOrDefault("language", null) } + host.getEnvironmentName() == DefaultEnvironment.MINTED.environmentName -> { + host.beginCommand.getRequiredParameters().getOrNull(1) + } host.getEnvironmentName() in EnvironmentMagic.languageInjections.keys -> { EnvironmentMagic.languageInjections[host.getEnvironmentName()] }