From 75c5ea7ea2aa3b778d3b8580202228e6c90c2353 Mon Sep 17 00:00:00 2001 From: Thomas Schouten Date: Wed, 27 Nov 2024 11:13:31 +0100 Subject: [PATCH 1/5] Add support for \includesvg --- CHANGELOG.md | 1 + .../completion/pathcompletion/LatexGraphicsPathProvider.kt | 5 +++-- src/nl/hannahsten/texifyidea/lang/LatexPackage.kt | 1 + .../texifyidea/lang/commands/LatexGenericRegularCommand.kt | 3 +++ src/nl/hannahsten/texifyidea/reference/InputFileReference.kt | 3 ++- src/nl/hannahsten/texifyidea/util/magic/CommandMagic.kt | 2 ++ 6 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a3da820f..03b356d22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## [Unreleased] ### Added +* Add support for \includesvg ### Fixed * Fix basic case of false positive of duplicate label inspection when user defined \if commands are used diff --git a/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexGraphicsPathProvider.kt b/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexGraphicsPathProvider.kt index 1af487424..f4c4a78b5 100644 --- a/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexGraphicsPathProvider.kt +++ b/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexGraphicsPathProvider.kt @@ -7,6 +7,7 @@ import nl.hannahsten.texifyidea.lang.commands.LatexGenericRegularCommand import nl.hannahsten.texifyidea.psi.LatexCommands import nl.hannahsten.texifyidea.psi.LatexNormalText import nl.hannahsten.texifyidea.util.files.* +import nl.hannahsten.texifyidea.util.magic.CommandMagic import nl.hannahsten.texifyidea.util.magic.cmd import nl.hannahsten.texifyidea.util.parser.childrenOfType import java.io.File @@ -33,7 +34,7 @@ class LatexGraphicsPathProvider : LatexPathProviderBase() { */ fun getGraphicsPathsInFileSet(file: PsiFile): List { val graphicsPaths = mutableListOf() - val graphicsPathCommands = file.commandsInFileSet().filter { it.name == LatexGenericRegularCommand.GRAPHICSPATH.cmd } + val graphicsPathCommands = file.commandsInFileSet().filter { CommandMagic.graphicPathsCommands.map { it.cmd }.contains(it.name) } // Is a graphicspath defined? if (graphicsPathCommands.isNotEmpty()) { @@ -95,7 +96,7 @@ class LatexGraphicsPathProvider : LatexPathProviderBase() { * Get all the graphics paths defined by one \graphicspaths command. */ private fun LatexCommands.getGraphicsPaths(): List { - if (name != LatexGenericRegularCommand.GRAPHICSPATH.cmd) return emptyList() + if (!CommandMagic.graphicPathsCommands.map { it.cmd }.contains(name)) return emptyList() return parameterList.firstNotNullOfOrNull { it.requiredParam } // Each graphics path is in a group. ?.childrenOfType(LatexNormalText::class) diff --git a/src/nl/hannahsten/texifyidea/lang/LatexPackage.kt b/src/nl/hannahsten/texifyidea/lang/LatexPackage.kt index 84e559102..5b46f172f 100644 --- a/src/nl/hannahsten/texifyidea/lang/LatexPackage.kt +++ b/src/nl/hannahsten/texifyidea/lang/LatexPackage.kt @@ -83,6 +83,7 @@ open class LatexPackage @JvmOverloads constructor( val SPLITINDEX = LatexPackage("splitindex") val STMARYRD = LatexPackage("stmaryrd") val SUBFILES = LatexPackage("subfiles") + val SVG = LatexPackage("svg") val TABULARRAY = LatexPackage("tabularray") val TCOLORBOX = LatexPackage("tcolorbox") val TEXTCOMP = LatexPackage("textcomp") diff --git a/src/nl/hannahsten/texifyidea/lang/commands/LatexGenericRegularCommand.kt b/src/nl/hannahsten/texifyidea/lang/commands/LatexGenericRegularCommand.kt index e7b156501..2b2461886 100644 --- a/src/nl/hannahsten/texifyidea/lang/commands/LatexGenericRegularCommand.kt +++ b/src/nl/hannahsten/texifyidea/lang/commands/LatexGenericRegularCommand.kt @@ -11,6 +11,7 @@ import nl.hannahsten.texifyidea.lang.LatexPackage.Companion.GLOSSARIES import nl.hannahsten.texifyidea.lang.LatexPackage.Companion.GRAPHICX import nl.hannahsten.texifyidea.lang.LatexPackage.Companion.MATHTOOLS import nl.hannahsten.texifyidea.lang.LatexPackage.Companion.NTHEOREM +import nl.hannahsten.texifyidea.lang.LatexPackage.Companion.SVG import nl.hannahsten.texifyidea.lang.LatexPackage.Companion.TEXTCOMP import nl.hannahsten.texifyidea.lang.LatexPackage.Companion.ULEM import nl.hannahsten.texifyidea.lang.LatexPackage.Companion.VARIOREF @@ -147,6 +148,7 @@ enum class LatexGenericRegularCommand( INPUTMINTED("inputminted", "language".asRequired(Argument.Type.MINTED_FUNTIME_LAND), RequiredFileArgument("sourcefile", true, false, ""), dependency = LatexPackage.MINTED), INCLUDEGRAPHICS("includegraphics", "key-val-list".asOptional(), RequiredPicturePathArgument("imagefile", isAbsolutePathSupported = true, commaSeparatesArguments = false, FileMagic.graphicFileExtensions, supportsAnyExtension = false), dependency = GRAPHICX), INCLUDEONLY("includeonly", RequiredFileArgument("sourcefile", false, true, "tex")), + INCLUDESVG("includesvg", "options".asOptional(), RequiredPicturePathArgument("svg file", isAbsolutePathSupported = true, commaSeparatesArguments = false, extension = listOf("svg"), supportsAnyExtension = false), dependency = SVG), INDEXNAME("indexname", "name".asRequired()), INDEXSPACE("indexspace"), INDEX("intex", "entry".asRequired()), @@ -303,6 +305,7 @@ enum class LatexGenericRegularCommand( SUBSUBSECTION_STAR("subsubsection*", "title".asRequired(Argument.Type.TEXT)), SUBSUBSECTIONMARK("subsubsectionmark", "code".asRequired()), SUPPRESSFLOATS("suppressfloats", "placement".asOptional()), + SVGPATH("svgpath", RequiredFolderArgument("foldername"), dependency = SVG), SYMBOL("symbol", "n".asRequired()), TABCOLSEP("tabcolsep"), TABLENAME("tablename", "name".asRequired(Argument.Type.TEXT)), diff --git a/src/nl/hannahsten/texifyidea/reference/InputFileReference.kt b/src/nl/hannahsten/texifyidea/reference/InputFileReference.kt index d63fd907f..090b00ee8 100644 --- a/src/nl/hannahsten/texifyidea/reference/InputFileReference.kt +++ b/src/nl/hannahsten/texifyidea/reference/InputFileReference.kt @@ -148,7 +148,8 @@ class InputFileReference( // Try graphicspaths if (targetFile == null) { // If we are not building the fileset, we can make use of it - if (!isBuildingFileset && element.containingFile.includedPackages().contains(LatexGenericRegularCommand.GRAPHICSPATH.dependency)) { + val includedPackages = element.containingFile.includedPackages() + if (!isBuildingFileset && CommandMagic.graphicPathsCommands.any { includedPackages.contains(it.dependency) }) { // Add the graphics paths to the search paths searchPaths.addAll(LatexGraphicsPathProvider().getGraphicsPathsInFileSet(element.containingFile)) } diff --git a/src/nl/hannahsten/texifyidea/util/magic/CommandMagic.kt b/src/nl/hannahsten/texifyidea/util/magic/CommandMagic.kt index e8cbb0f42..357dda39e 100644 --- a/src/nl/hannahsten/texifyidea/util/magic/CommandMagic.kt +++ b/src/nl/hannahsten/texifyidea/util/magic/CommandMagic.kt @@ -378,6 +378,8 @@ object CommandMagic { "\\DeclareDocumentEnvironment" ) + val graphicPathsCommands = listOf(GRAPHICSPATH, SVGPATH) + /** * Commands that should not have the given file extensions. */ From efad3c1fdcbe2b8dc9a6e67e26017c1441b2de5d Mon Sep 17 00:00:00 2001 From: Thomas Schouten Date: Wed, 27 Nov 2024 17:24:34 +0100 Subject: [PATCH 2/5] Remove incorrect path formatting for create file quickfix --- .../completion/pathcompletion/LatexGraphicsPathProvider.kt | 1 - .../latex/probablebugs/LatexFileNotFoundInspection.kt | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexGraphicsPathProvider.kt b/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexGraphicsPathProvider.kt index f4c4a78b5..212efc1de 100644 --- a/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexGraphicsPathProvider.kt +++ b/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexGraphicsPathProvider.kt @@ -3,7 +3,6 @@ package nl.hannahsten.texifyidea.completion.pathcompletion import com.intellij.openapi.vfs.VirtualFile import com.intellij.psi.PsiFile import nl.hannahsten.texifyidea.index.LatexIncludesIndex -import nl.hannahsten.texifyidea.lang.commands.LatexGenericRegularCommand import nl.hannahsten.texifyidea.psi.LatexCommands import nl.hannahsten.texifyidea.psi.LatexNormalText import nl.hannahsten.texifyidea.util.files.* diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/probablebugs/LatexFileNotFoundInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/probablebugs/LatexFileNotFoundInspection.kt index 4bc0b9e01..b1fc1a839 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/probablebugs/LatexFileNotFoundInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/probablebugs/LatexFileNotFoundInspection.kt @@ -115,7 +115,7 @@ open class LatexFileNotFoundInspection : TexifyInspectionBase() { // Display a dialog to ask for the location and name of the new file. // By default, all inclusion paths are relative to the main file - val newFilePath = CreateFileDialog(root, filePath.replace("$root/", "").formatAsFilePath()) + val newFilePath = CreateFileDialog(root, filePath.replace("$root/", "")) .newFileFullPath ?: return runWriteAction { From f246e28a16e769acec2c6a6b5c5d5fbbf2080ed5 Mon Sep 17 00:00:00 2001 From: Thomas Schouten Date: Thu, 28 Nov 2024 07:53:56 +0100 Subject: [PATCH 3/5] Formatting --- .../completion/pathcompletion/LatexGraphicsPathProvider.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexGraphicsPathProvider.kt b/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexGraphicsPathProvider.kt index 212efc1de..b872d53e9 100644 --- a/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexGraphicsPathProvider.kt +++ b/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexGraphicsPathProvider.kt @@ -33,7 +33,7 @@ class LatexGraphicsPathProvider : LatexPathProviderBase() { */ fun getGraphicsPathsInFileSet(file: PsiFile): List { val graphicsPaths = mutableListOf() - val graphicsPathCommands = file.commandsInFileSet().filter { CommandMagic.graphicPathsCommands.map { it.cmd }.contains(it.name) } + val graphicsPathCommands = file.commandsInFileSet().filter { command -> CommandMagic.graphicPathsCommands.map { it.cmd }.contains(command.name) } // Is a graphicspath defined? if (graphicsPathCommands.isNotEmpty()) { From 708d3e4ef3b2564a1bb2b054b6361d8ffdf50812 Mon Sep 17 00:00:00 2001 From: Thomas Schouten Date: Thu, 28 Nov 2024 08:19:17 +0100 Subject: [PATCH 4/5] 0.9.9-alpha.8 --- CHANGELOG.md | 38 +++++++++++++++++++++++++++++++++++++- gradle.properties | 2 +- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03b356d22..892832dbb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,11 +3,45 @@ ## [Unreleased] ### Added + +### Fixed + +## [0.9.9-alpha.8] - 2024-11-28 + +### Added + * Add support for \includesvg +* Support references in \subfix command +* Provide autocompletion for all relevant directories when using subfiles +* Do not format existing directories in the given path in the file creation quickfix dialog +* Disable Evince inverse search on Windows to avoid a UI freeze on opening a second project +* Use xdg-mime to choose a default pdf viewer in the run configuration template +* Don't insert the right brace when in front of text +* Add DeclareMathSymbol to indexed command definitions in installed packages +* Add support for TEXMFHOME for reference resolving +* Add diffcoeff and upgreek packages to autocompletion, by @Toseflo +* Improve reference resolving when using subfiles +* Add setting to disable auto-import of bibtex entries from remote libraries ### Fixed + * Fix basic case of false positive of duplicate label inspection when user defined \if commands are used * Fix a parse error when using \else with a user defined \if-command +* Fix relative path conversion in graphics insertion wizard by resolving relative to the root file +* Fix exception #3763 +* Fix 'missing import' false positive in subfiles +* Don't override the file icon for .txt files, by @Steve-Li-1998 +* Fix exceptions #3754 and #3326 +* Fix exceptions in structure view when command parameters are missing +* Improve error report submitter for long stacktraces +* Fix a parser issue with bidirectional arrow in TikZ +* Fix default Docker image name when running Dockerized TeX Live without a project SDK +* Always use content roots to resolve references +* Fix 'package not found' error when using texlive-full on Windows, and improve running of system commands, by @tristankretzer +* Fix rename of files when using subfiles +* Fix incorrect 'package already included' warning for the subfiles package +* Fix exception #3557 if using bibtex structure view when bibtex file type is reassignd to plain text +* Avoid referencing obsolete psifiles, fix exception #3635 ## [0.9.9-alpha.7] - 2024-11-24 @@ -26,6 +60,7 @@ * Add setting to disable auto-import of bibtex entries from remote libraries ### Fixed + * Fix relative path conversion in graphics insertion wizard by resolving relative to the root file * Fix exception #3763 * Fix 'missing import' false positive in subfiles @@ -520,7 +555,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.9-alpha.7...HEAD +[Unreleased]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.9-alpha.8...HEAD +[0.9.9-alpha.8]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.9-alpha.7...v0.9.9-alpha.8 [0.9.9-alpha.7]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.9-alpha.6...v0.9.9-alpha.7 [0.9.9-alpha.6]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.9-alpha.4...v0.9.9-alpha.6 [0.9.9-alpha.4]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.9-alpha.3...v0.9.9-alpha.4 diff --git a/gradle.properties b/gradle.properties index e1150a553..665ee2133 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -pluginVersion = 0.9.9-alpha.7 +pluginVersion = 0.9.9-alpha.8 # 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.* From 38f7a586580181dbc3562d19089e722d61c15f80 Mon Sep 17 00:00:00 2001 From: Thomas Schouten Date: Thu, 28 Nov 2024 08:48:05 +0100 Subject: [PATCH 5/5] Avoid infinite loop in input reference --- .../texifyidea/reference/InputFileReference.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/nl/hannahsten/texifyidea/reference/InputFileReference.kt b/src/nl/hannahsten/texifyidea/reference/InputFileReference.kt index 090b00ee8..3866b0888 100644 --- a/src/nl/hannahsten/texifyidea/reference/InputFileReference.kt +++ b/src/nl/hannahsten/texifyidea/reference/InputFileReference.kt @@ -148,10 +148,12 @@ class InputFileReference( // Try graphicspaths if (targetFile == null) { // If we are not building the fileset, we can make use of it - val includedPackages = element.containingFile.includedPackages() - if (!isBuildingFileset && CommandMagic.graphicPathsCommands.any { includedPackages.contains(it.dependency) }) { - // Add the graphics paths to the search paths - searchPaths.addAll(LatexGraphicsPathProvider().getGraphicsPathsInFileSet(element.containingFile)) + if (!isBuildingFileset) { + val includedPackages = element.containingFile.includedPackages() + if (CommandMagic.graphicPathsCommands.any { includedPackages.contains(it.dependency) }) { + // Add the graphics paths to the search paths + searchPaths.addAll(LatexGraphicsPathProvider().getGraphicsPathsInFileSet(element.containingFile)) + } } for (searchPath in searchPaths) { val path = if (!searchPath.endsWith("/")) "$searchPath/" else searchPath