Skip to content

Commit

Permalink
Merge branch 'master' into editable-postfix-templates
Browse files Browse the repository at this point in the history
  • Loading branch information
PHPirates committed Jun 9, 2024
2 parents 4f8e53a + aead4b4 commit d342485
Show file tree
Hide file tree
Showing 36 changed files with 347 additions and 141 deletions.
66 changes: 55 additions & 11 deletions .github/actions/insert-youtrack-link/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .github/actions/insert-youtrack-link/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"dependencies": {
"@actions/core": "^1.10.1",
"@actions/github": "^6.0.0",
"@octokit/rest": "^20.1.0"
"@octokit/rest": "^20.1.1"
}
}
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@

### Fixed

## [0.9.7-alpha.1] - 2024-06-06

### Added

* Support TeX Live docker image
* Formatter support for plain TeX \if-statements
* Index files from the TEXINPUTS variable, for autocompletion

## [0.9.6] - 2024-06-01

Welcome to TeXiFy IDEA 0.9.6! This release fixes an issue with the table insertion wizard, fixes pasting from a pdf file, and more.
Expand Down Expand Up @@ -358,7 +366,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.6...HEAD
[Unreleased]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.7-alpha.1...HEAD
[0.9.7-alpha.1]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.6...v0.9.7-alpha.1
[0.9.6]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.5...v0.9.6
[0.9.5]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.4...v0.9.5
[0.9.4]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.3...v0.9.4
Expand Down
6 changes: 6 additions & 0 deletions Writerside/topics/Run-configuration-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,12 @@ Custom output directories are supported.
* You have to login to GitHub to use the Docker image: get a github token from [https://github.com/settings/tokens,](https://github.com/settings/tokens,) save it somewhere secure and run `echo my_token | docker login https://docker.pkg.github.com -u myusername --password-stdin`
See [https://help.github.com/en/packages/using-github-packages-with-your-projects-ecosystem/configuring-docker-for-use-with-github-packages#authenticating-to-github-packages](https://help.github.com/en/packages/using-github-packages-with-your-projects-ecosystem/configuring-docker-for-use-with-github-packages#authenticating-to-github-packages) for more info.

### Dockerized TeX Live

Similar to the MiKTeX docker image, you can also use a texlive docker image if you have it installed.
By default, the official `texlive/texlive` image is used.
If you use IntelliJ, you can select a different image name by creating a LaTeX Docker SDK, see [Project configuration](Project-configuration.md#sdks).

### TeX Live from WSL

_Since b0.6.10_
Expand Down
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ plugins {
id("org.jetbrains.kotlinx.kover") version "0.8.0"

// Linting
id("org.jlleitschuh.gradle.ktlint") version "12.1.0"
id("org.jlleitschuh.gradle.ktlint") version "12.1.1"

// Vulnerability scanning
id("org.owasp.dependencycheck") version "9.2.0"
Expand Down Expand Up @@ -118,7 +118,7 @@ dependencies {
implementation("io.ktor:ktor-serialization-kotlinx-json:2.3.11")

// Comparing versions
implementation("org.apache.maven:maven-artifact:4.0.0-alpha-13")
implementation("org.apache.maven:maven-artifact:4.0.0-beta-3")

// LaTeX rendering for preview
implementation("org.scilab.forge:jlatexmath:1.0.7")
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pluginVersion = 0.9.6
pluginVersion = 0.9.7-alpha.1

# 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.*
Expand Down
2 changes: 1 addition & 1 deletion resources/META-INF/actions/actions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<!-- LaTeX Analyze menu -->
<action class="nl.hannahsten.texifyidea.action.analysis.WordCountAction" id="texify.analysis.WordCount"
text="_Word Count" description="Estimate the word count of the currently active .tex file and inclusions." icon="nl.hannahsten.texifyidea.TexifyIcons.WORD_COUNT">
<keyboard-shortcut first-keystroke="control alt W" keymap="$default"/>
<keyboard-shortcut first-keystroke="alt W" keymap="$default"/>
<override-text place="GoToAction" text="LaTeX _Word Count"/>
<!-- Prior to idea 213, the Code menu was called Analyze (but only in IntelliJ) -->
<add-to-group group-id="CodeMenu" anchor="last"/>
Expand Down
2 changes: 1 addition & 1 deletion scripts/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
beautifulsoup4==4.12.3
requests==2.32.0
requests==2.32.3
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.intellij.icons.AllIcons
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.PlatformDataKeys
import com.intellij.openapi.fileEditor.FileDocumentManager
import com.intellij.openapi.ui.DialogBuilder
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile
Expand Down Expand Up @@ -71,6 +72,8 @@ open class WordCountAction : AnAction() {
// Prefer texcount, I think it is slightly more accurate
val dialog = if (SystemEnvironment.isAvailable("texcount")) {
val root = psiFile.findRootFile().virtualFile
// Make sure the file is written to disk before running an external tool on it
FileDocumentManager.getInstance().apply { saveDocument(getDocument(root) ?: return@apply) }
val (output, exitCode) = runCommandWithExitCode("texcount", "-1", "-inc", "-sum", root.name, workingDirectory = File(root.parent.path))
if (exitCode == 0 && output?.toIntOrNull() != null) {
makeDialog(psiFile, output.toInt())
Expand Down
6 changes: 3 additions & 3 deletions src/nl/hannahsten/texifyidea/formatting/LatexBlock.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import nl.hannahsten.texifyidea.editor.typedhandlers.LatexEnterHandler
import nl.hannahsten.texifyidea.lang.commands.LatexCommand
import nl.hannahsten.texifyidea.psi.*
import nl.hannahsten.texifyidea.settings.codestyle.LatexCodeStyleSettings
import nl.hannahsten.texifyidea.util.parser.firstChildOfType
import nl.hannahsten.texifyidea.util.parser.firstParentOfType
import nl.hannahsten.texifyidea.util.magic.CommandMagic
import nl.hannahsten.texifyidea.util.magic.cmd
import nl.hannahsten.texifyidea.util.parser.firstChildOfType
import nl.hannahsten.texifyidea.util.parser.firstParentOfType
import java.lang.Integer.max

/**
Expand Down Expand Up @@ -158,7 +158,7 @@ class LatexBlock(
else -> shouldIndentEnvironments
}

if (shouldIndentEnvironment || myNode.elementType === LatexTypes.PSEUDOCODE_BLOCK_CONTENT ||
if (shouldIndentEnvironment || myNode.elementType === LatexTypes.PSEUDOCODE_BLOCK_CONTENT || myNode.elementType === LatexTypes.IF_BLOCK_CONTENT ||
// Fix for leading comments inside an environment, because somehow they are not placed inside environments.
// Note that this does not help to insert the indentation, but at least the indent is not removed
// when formatting.
Expand Down
10 changes: 7 additions & 3 deletions src/nl/hannahsten/texifyidea/formatting/LatexSpacingRules.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ package nl.hannahsten.texifyidea.formatting

import com.intellij.formatting.Spacing
import com.intellij.psi.codeStyle.CodeStyleSettings
import nl.hannahsten.texifyidea.grammar.LatexLanguage
import nl.hannahsten.texifyidea.formatting.spacingrules.leftTableSpaceAlign
import nl.hannahsten.texifyidea.formatting.spacingrules.rightTableSpaceAlign
import nl.hannahsten.texifyidea.grammar.LatexLanguage
import nl.hannahsten.texifyidea.psi.LatexCommands
import nl.hannahsten.texifyidea.psi.LatexTypes.*
import nl.hannahsten.texifyidea.settings.codestyle.LatexCodeStyleSettings
import nl.hannahsten.texifyidea.util.parser.firstChildOfType
import nl.hannahsten.texifyidea.util.parser.inDirectEnvironment
import nl.hannahsten.texifyidea.util.magic.CommandMagic
import nl.hannahsten.texifyidea.util.magic.EnvironmentMagic
import nl.hannahsten.texifyidea.util.parser.firstChildOfType
import nl.hannahsten.texifyidea.util.parser.inDirectEnvironment
import nl.hannahsten.texifyidea.util.parser.parentOfType
import java.util.*

Expand Down Expand Up @@ -49,6 +49,7 @@ fun createSpacingBuilder(settings: CodeStyleSettings): TexSpacingBuilder {
between(NORMAL_TEXT_WORD, NORMAL_TEXT_WORD).spaces(1)
before(ENVIRONMENT_CONTENT).lineBreakInCode()
before(PSEUDOCODE_BLOCK_CONTENT).lineBreakInCode()
before(IF_BLOCK_CONTENT).lineBreakInCode()
}

// Newline before certain algorithm pseudocode commands
Expand All @@ -75,6 +76,9 @@ fun createSpacingBuilder(settings: CodeStyleSettings): TexSpacingBuilder {
inPosition(parent = PSEUDOCODE_BLOCK, left = PSEUDOCODE_BLOCK_CONTENT, right = END_PSEUDOCODE_BLOCK).spacing(
Spacing.createSpacing(0, Int.MAX_VALUE, 1, latexCommonSettings.KEEP_LINE_BREAKS, latexCommonSettings.KEEP_BLANK_LINES_IN_CODE)
)
inPosition(parent = IF_BLOCK, left = IF_BLOCK_CONTENT, right = END_IF).spacing(
Spacing.createSpacing(0, Int.MAX_VALUE, 1, latexCommonSettings.KEEP_LINE_BREAKS, latexCommonSettings.KEEP_BLANK_LINES_IN_CODE)
)
}

custom {
Expand Down
15 changes: 11 additions & 4 deletions src/nl/hannahsten/texifyidea/grammar/Latex.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ latexFile ::= content
// Make sure that there is a root element with multiple children, for example for Grazie to allow ignoring certain types of no_math_content
content ::= no_math_content*

no_math_content ::= raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | commands | group | normal_text
// When updating this list, consider updating other _content lists
no_math_content ::= raw_text | magic_comment | comment | environment | pseudocode_block | if_block | math_environment | COMMAND_IFNEXTCHAR | commands | group | normal_text | END_IF

normal_text ::= (NORMAL_TEXT_WORD | STAR | AMPERSAND | QUOTATION_MARK | OPEN_ANGLE_BRACKET | CLOSE_ANGLE_BRACKET | OPEN_PAREN | CLOSE_PAREN | OPEN_BRACKET | CLOSE_BRACKET | PIPE | EXCLAMATION_MARK | BACKSLASH | EQUALS | COMMA | ANGLE_PARAM)+

Expand All @@ -75,6 +76,12 @@ pseudocode_block ::= BEGIN_PSEUDOCODE_BLOCK parameter* pseudocode_block_content?

pseudocode_block_content ::= no_math_content*

// Plain TeX \if...\fi, note that user defined ifs are not included so there may be unmatched \fi
if_block ::= START_IF if_block_content? (ELSE if_block_content?)* END_IF { pin=1 }

// no_math_content without end_if
if_block_content ::= (raw_text | magic_comment | comment | environment | pseudocode_block | if_block | math_environment | COMMAND_IFNEXTCHAR | commands | group | normal_text)*

commands ::= COMMAND_TOKEN STAR? parameter* {
pin=1
elementTypeClass="nl.hannahsten.texifyidea.index.stub.LatexCommandsStubElementType"
Expand Down Expand Up @@ -118,10 +125,10 @@ picture_param ::= OPEN_PAREN picture_param_content* CLOSE_PAREN { pin=3 }
// These are like content, but no brackets and with parameter_text instead of normal_text
// We have to separate optional and required parameter content, because required parameter content
// can contain mismatched brackets, but optional parameters not (then we wouldn't know what to match)
optional_param_content ::= raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | commands | group | OPEN_PAREN | CLOSE_PAREN | parameter_text | BACKSLASH | OPEN_ANGLE_BRACKET | CLOSE_ANGLE_BRACKET
required_param_content ::= raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | group | OPEN_PAREN | CLOSE_PAREN | parameter_text | COMMA | EQUALS | OPEN_BRACKET | CLOSE_BRACKET | BACKSLASH | OPEN_ANGLE_BRACKET | CLOSE_ANGLE_BRACKET
optional_param_content ::= raw_text | magic_comment | comment | environment | pseudocode_block | if_block | math_environment | COMMAND_IFNEXTCHAR | commands | group | OPEN_PAREN | CLOSE_PAREN | parameter_text | BACKSLASH | OPEN_ANGLE_BRACKET | CLOSE_ANGLE_BRACKET | END_IF
required_param_content ::= raw_text | magic_comment | comment | environment | pseudocode_block | if_block | math_environment | COMMAND_IFNEXTCHAR | group | OPEN_PAREN | CLOSE_PAREN | parameter_text | COMMA | EQUALS | OPEN_BRACKET | CLOSE_BRACKET | BACKSLASH | OPEN_ANGLE_BRACKET | CLOSE_ANGLE_BRACKET | END_IF
// Cannot contain ( or )
picture_param_content ::= raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | commands | group | parameter_text | BACKSLASH | COMMA | EQUALS | OPEN_BRACKET | CLOSE_BRACKET | OPEN_ANGLE_BRACKET | CLOSE_ANGLE_BRACKET
picture_param_content ::= raw_text | magic_comment | comment | environment | pseudocode_block | if_block | math_environment | COMMAND_IFNEXTCHAR | commands | group | parameter_text | BACKSLASH | COMMA | EQUALS | OPEN_BRACKET | CLOSE_BRACKET | OPEN_ANGLE_BRACKET | CLOSE_ANGLE_BRACKET | END_IF

strict_key_val_pair ::= key_val_key EQUALS key_val_value?

Expand Down
10 changes: 9 additions & 1 deletion src/nl/hannahsten/texifyidea/grammar/LatexLexer.flex
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ END_TOKEN="\\end"
COMMAND_IFNEXTCHAR=\\@ifnextchar.
COMMAND_TOKEN=\\([a-zA-Z@]+|.|\r)
COMMAND_TOKEN_LATEX3=\\([a-zA-Z@_:0-9]+|.|\r) // _ and : are only LaTeX3 syntax
LATEX3_ON=\\(ExplSyntaxOn|ProvidesExplPackage)
LATEX3_ON=\\(ExplSyntaxOn|ProvidesExplPackage|ProvidesExplClass|ProvidesExplFile)
LATEX3_OFF=\\ExplSyntaxOff
NEWENVIRONMENT=\\(re)?newenvironment
// BeforeBegin/AfterEnd are from etoolbox, and just happen to also have two parameters where the second can contain loose \begin or \end
Expand Down Expand Up @@ -125,6 +125,11 @@ BEGIN_PSEUDOCODE_BLOCK="\\For" | "\\ForAll" | "\\If" | "\\While" | "\\Repeat" |
MIDDLE_PSEUDOCODE_BLOCK="\\ElsIf" | "\\Else"
END_PSEUDOCODE_BLOCK="\\EndFor" | "\\EndIf" | "\\EndWhile" | "\\Until" | "\\EndLoop" | "\\EndFunction" | "\\EndProcedure"

// See TeX by Topic chapter 13
START_IFS=\\if | \\ifcat | \\ifx | \\ifcase | \\ifnum | \\ifodd | \\ifhmode | \\ifvmode | \\ifmmode | \\ifinner | \\ifdim | \\ifvoid | \\ifhbox | \\ifvbox | \\ifeof | \\iftrue | \\iffalse
ELSE=\\else
END_IFS=\\fi

%states INLINE_MATH INLINE_MATH_LATEX DISPLAY_MATH TEXT_INSIDE_INLINE_MATH NESTED_INLINE_MATH PARTIAL_DEFINITION
%states NEW_ENVIRONMENT_DEFINITION_NAME NEW_ENVIRONMENT_DEFINITION NEW_ENVIRONMENT_SKIP_BRACE NEW_ENVIRONMENT_DEFINITION_END NEW_DOCUMENT_ENV_DEFINITION_NAME NEW_DOCUMENT_ENV_DEFINITION_ARGS_SPEC NEW_COMMAND_DEFINITION_PARAM1 NEW_COMMAND_DEFINITION_PARAM2

Expand Down Expand Up @@ -524,6 +529,9 @@ END_PSEUDOCODE_BLOCK="\\EndFor" | "\\EndIf" | "\\EndWhile" | "\\Until" | "\\EndL
{ENDINPUT} { yypushState(OFF); return COMMAND_TOKEN; }
{BEGIN_TOKEN} { yypushState(POSSIBLE_VERBATIM_BEGIN); return BEGIN_TOKEN; }
{END_TOKEN} { return END_TOKEN; }
{START_IFS} { return START_IF; }
{ELSE} { return ELSE; }
{END_IFS} { return END_IF; }
{COMMAND_TOKEN} { return COMMAND_TOKEN; }
{COMMAND_IFNEXTCHAR} { return COMMAND_IFNEXTCHAR; }
{MAGIC_COMMENT_TOKEN} { return MAGIC_COMMENT_TOKEN; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class LatexParserDefinition : ParserDefinition {
val FILE: IStubFileElementType<*> = object : IStubFileElementType<LatexFileStub>(
"LatexStubFileElementType", Language.findInstance(LatexLanguage::class.java)
) {
override fun getStubVersion(): Int = 71
override fun getStubVersion(): Int = 72
}
}

Expand Down
Loading

0 comments on commit d342485

Please sign in to comment.