diff --git a/src/nl/hannahsten/texifyidea/editor/folding/LatexCodeFoldingOptionsProvider.kt b/src/nl/hannahsten/texifyidea/editor/folding/LatexCodeFoldingOptionsProvider.kt index d2bb1b320..849ede96e 100644 --- a/src/nl/hannahsten/texifyidea/editor/folding/LatexCodeFoldingOptionsProvider.kt +++ b/src/nl/hannahsten/texifyidea/editor/folding/LatexCodeFoldingOptionsProvider.kt @@ -12,6 +12,12 @@ class LatexCodeFoldingOptionsProvider : CodeFoldingOptionsProvider, BeanConfigur val settings = instance if (settings != null) { checkBox("Package imports", settings::collapseImports) + checkBox("Environments", settings::foldEnvironments) + checkBox("Escaped symbols", settings::foldEscapedSymbols) + checkBox("Footnotes", settings::foldFootnotes) + checkBox("Math symbols", settings::foldMathSymbols) + checkBox("Sections", settings::foldSections) + checkBox("Symbols", settings::foldSymbols) } } } \ No newline at end of file diff --git a/src/nl/hannahsten/texifyidea/editor/folding/LatexCodeFoldingSettings.kt b/src/nl/hannahsten/texifyidea/editor/folding/LatexCodeFoldingSettings.kt index c52c78fc1..ed430cd97 100644 --- a/src/nl/hannahsten/texifyidea/editor/folding/LatexCodeFoldingSettings.kt +++ b/src/nl/hannahsten/texifyidea/editor/folding/LatexCodeFoldingSettings.kt @@ -14,7 +14,13 @@ import com.intellij.util.xmlb.XmlSerializerUtil @State(name = "LatexCodeFoldingSettings", storages = [Storage("editor.xml")]) class LatexCodeFoldingSettings : PersistentStateComponent { - var collapseImports: Boolean = true + var collapseImports = true + var foldEnvironments = false + var foldEscapedSymbols = true + var foldFootnotes = true + var foldMathSymbols = true + var foldSections = false + var foldSymbols = true override fun getState() = this diff --git a/src/nl/hannahsten/texifyidea/editor/folding/LatexEnvironmentFoldingBuilder.kt b/src/nl/hannahsten/texifyidea/editor/folding/LatexEnvironmentFoldingBuilder.kt index 8c5a9caaa..90b96f330 100644 --- a/src/nl/hannahsten/texifyidea/editor/folding/LatexEnvironmentFoldingBuilder.kt +++ b/src/nl/hannahsten/texifyidea/editor/folding/LatexEnvironmentFoldingBuilder.kt @@ -20,7 +20,7 @@ import nl.hannahsten.texifyidea.util.parser.endOffset */ class LatexEnvironmentFoldingBuilder : FoldingBuilderEx(), DumbAware { - override fun isCollapsedByDefault(node: ASTNode) = false + override fun isCollapsedByDefault(node: ASTNode) = LatexCodeFoldingSettings.getInstance().foldEnvironments override fun getPlaceholderText(node: ASTNode) = "..." diff --git a/src/nl/hannahsten/texifyidea/editor/folding/LatexEscapedSymbolFoldingBuilder.kt b/src/nl/hannahsten/texifyidea/editor/folding/LatexEscapedSymbolFoldingBuilder.kt index ea5ded398..ac5d24b0c 100644 --- a/src/nl/hannahsten/texifyidea/editor/folding/LatexEscapedSymbolFoldingBuilder.kt +++ b/src/nl/hannahsten/texifyidea/editor/folding/LatexEscapedSymbolFoldingBuilder.kt @@ -14,7 +14,7 @@ import nl.hannahsten.texifyidea.util.files.commandsInFile */ class LatexEscapedSymbolFoldingBuilder : FoldingBuilderEx(), DumbAware { - override fun isCollapsedByDefault(node: ASTNode) = true + override fun isCollapsedByDefault(node: ASTNode) = LatexCodeFoldingSettings.getInstance().foldEscapedSymbols override fun getPlaceholderText(node: ASTNode): String? = null diff --git a/src/nl/hannahsten/texifyidea/editor/folding/LatexFootnoteFoldingBuilder.kt b/src/nl/hannahsten/texifyidea/editor/folding/LatexFootnoteFoldingBuilder.kt index d7561a23c..c016ef8bb 100644 --- a/src/nl/hannahsten/texifyidea/editor/folding/LatexFootnoteFoldingBuilder.kt +++ b/src/nl/hannahsten/texifyidea/editor/folding/LatexFootnoteFoldingBuilder.kt @@ -11,9 +11,9 @@ import com.intellij.refactoring.suggested.endOffset import com.intellij.refactoring.suggested.startOffset import nl.hannahsten.texifyidea.psi.LatexCommands import nl.hannahsten.texifyidea.psi.LatexRequiredParam +import nl.hannahsten.texifyidea.util.magic.CommandMagic.foldableFootnotes import nl.hannahsten.texifyidea.util.parser.childrenOfType import nl.hannahsten.texifyidea.util.parser.firstChildOfType -import nl.hannahsten.texifyidea.util.magic.CommandMagic.foldableFootnotes /** * Adds folding regions for LaTeX environments. @@ -24,7 +24,7 @@ import nl.hannahsten.texifyidea.util.magic.CommandMagic.foldableFootnotes */ class LatexFootnoteFoldingBuilder : FoldingBuilderEx(), DumbAware { - override fun isCollapsedByDefault(node: ASTNode) = true + override fun isCollapsedByDefault(node: ASTNode) = LatexCodeFoldingSettings.getInstance().foldFootnotes override fun getPlaceholderText(node: ASTNode): String { val parsedText = node.text.substring(1).trim() diff --git a/src/nl/hannahsten/texifyidea/editor/folding/LatexMathSymbolFoldingBuilder.kt b/src/nl/hannahsten/texifyidea/editor/folding/LatexMathSymbolFoldingBuilder.kt index e1ecb3e01..d5085f5d0 100644 --- a/src/nl/hannahsten/texifyidea/editor/folding/LatexMathSymbolFoldingBuilder.kt +++ b/src/nl/hannahsten/texifyidea/editor/folding/LatexMathSymbolFoldingBuilder.kt @@ -37,7 +37,7 @@ class LatexMathSymbolFoldingBuilder : FoldingBuilderEx(), DumbAware { return descriptors.toTypedArray() } - override fun isCollapsedByDefault(node: ASTNode) = true + override fun isCollapsedByDefault(node: ASTNode) = LatexCodeFoldingSettings.getInstance().foldMathSymbols override fun getPlaceholderText(node: ASTNode): String? = null } diff --git a/src/nl/hannahsten/texifyidea/editor/folding/LatexSectionFoldingBuilder.kt b/src/nl/hannahsten/texifyidea/editor/folding/LatexSectionFoldingBuilder.kt index 5e3adbe2f..0faa43f9f 100644 --- a/src/nl/hannahsten/texifyidea/editor/folding/LatexSectionFoldingBuilder.kt +++ b/src/nl/hannahsten/texifyidea/editor/folding/LatexSectionFoldingBuilder.kt @@ -24,7 +24,7 @@ open class LatexSectionFoldingBuilder : FoldingBuilderEx() { private val sectionCommandNames = CommandMagic.sectioningCommands.map { it.command } private val sectionCommands = sectionCommandNames.map { "\\$it" }.toTypedArray() - override fun isCollapsedByDefault(node: ASTNode) = false + override fun isCollapsedByDefault(node: ASTNode) = LatexCodeFoldingSettings.getInstance().foldSections override fun getPlaceholderText(node: ASTNode) = node.text + "..." diff --git a/src/nl/hannahsten/texifyidea/editor/folding/LatexSymbolFoldingBuilder.kt b/src/nl/hannahsten/texifyidea/editor/folding/LatexSymbolFoldingBuilder.kt index a7354e5d3..15f863779 100644 --- a/src/nl/hannahsten/texifyidea/editor/folding/LatexSymbolFoldingBuilder.kt +++ b/src/nl/hannahsten/texifyidea/editor/folding/LatexSymbolFoldingBuilder.kt @@ -20,7 +20,7 @@ import nl.hannahsten.texifyidea.util.toTextRange */ class LatexSymbolFoldingBuilder : FoldingBuilderEx(), DumbAware { - override fun isCollapsedByDefault(node: ASTNode) = true + override fun isCollapsedByDefault(node: ASTNode) = LatexCodeFoldingSettings.getInstance().foldSymbols override fun getPlaceholderText(node: ASTNode): String? = null