Git Product home page Git Product logo

antlers-idea's Introduction

Antlers Language Support

Build Version Downloads

This plugin adds support for Antlers, the templating language of Statamic, to IDEs based on the Intellij IDEA platform (IntelliJ IDEA and PhpStorm). New features are regularly announced in changelogs.

It supports:

  • Syntax highlighting and customizing the colors via settings
  • Creating of .antlers.html files via the new file action

This plugin is still alpha. New features will be added in future versions.

Installation

  • Using IDE built-in plugin system:

    Settings/Preferences > Plugins > Marketplace > Search for "antlers-idea" > Install Plugin

  • Manually:

    Download the latest release and install it manually using Settings/Preferences > Plugins > ⚙️ > Install plugin from disk...

Credits


Plugin based on the IntelliJ Platform Plugin Template.

antlers-idea's People

Contributors

actions-user avatar konafets avatar renovate-bot avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

brad-sf

antlers-idea's Issues

Exception in Plugin

Hey @Konafets

thank you for the hard work on this plugin. I know it is a lot of work and I appreciate it.

I wanted to let you know, that the last days PHPStorms crashes because of the plugin. Here is the stacktrace. Maybe it helps you. It happens when selecting some text parts in the code.

e.g. selecting the word „Marktführende“

    {{# Other / Extras #}}
    <section class="container space-y-6 px-6 lg:space-y-2 lg:px-12">
        {{# Manufacturers #}}
        <div class="gap-x-16 space-y-8 md:flex md:space-y-0">
            <div class="space-y-4 md:w-1/3">
                <h3 class="text-lg font-semibold">Marktführende Hersteller</h3>
                {{ partial:typography/paragraph :text="text" }}
            </div>
            <div class="flex-1">
                <div class="grid grid-cols-2 gap-2 md:grid-cols-3">
                    {{ manufacturers }}
                        <div class="border-4 border-gray-300 py-4">
                            <img
                                class="mx-auto"
                                src="{{ glide :src='url' height='80' filter='greyscale' }}"
                                alt=""
                            />
                        </div>
                    {{ /manufacturers }}
                </div>
            </div>
        </div>
        
       // some more code
  </section>

Here is the stacktrace:

java.lang.Throwable: Read access is allowed from inside read-action (or EDT) only (see com.intellij.openapi.application.Application.runReadAction())
Current thread: Thread[EncodingManagerImpl Document Pool[ApplicationImpl pooled thread 3],4,main] 1027375984 (EventQueue.isDispatchThread()=false)
SystemEventQueueThread: Thread[AWT-EventQueue-0,6,main] 1110023023
	at com.intellij.openapi.diagnostic.Logger.error(Logger.java:202)
	at com.intellij.openapi.application.impl.ApplicationImpl.assertReadAccessAllowed(ApplicationImpl.java:1004)
	at com.intellij.workspaceModel.core.fileIndex.impl.WorkspaceFileIndexDataImpl.ensureIsUpToDate(WorkspaceFileIndexDataImpl.kt:127)
	at com.intellij.workspaceModel.core.fileIndex.impl.WorkspaceFileIndexDataImpl.getFileInfo(WorkspaceFileIndexDataImpl.kt:70)
	at com.intellij.workspaceModel.core.fileIndex.impl.WorkspaceFileIndexImpl.getFileInfo(WorkspaceFileIndexImpl.kt:220)
	at com.intellij.workspaceModel.core.fileIndex.impl.WorkspaceFileIndexImpl.findFileSet(WorkspaceFileIndexImpl.kt:180)
	at com.intellij.workspaceModel.core.fileIndex.impl.WorkspaceFileIndexImpl.isInContent(WorkspaceFileIndexImpl.kt:73)
	at com.intellij.openapi.roots.impl.ProjectFileIndexImpl.isInContent(ProjectFileIndexImpl.java:314)
	at com.intellij.lang.PerFileMappingsBase.getNotInHierarchy(PerFileMappingsBase.java:144)
	at com.intellij.lang.PerFileMappingsBase.getMappingInner(PerFileMappingsBase.java:136)
	at com.intellij.lang.PerFileMappingsBase.getConfiguredMapping(PerFileMappingsBase.java:105)
	at com.intellij.psi.templateLanguages.TemplateDataLanguageMappings.getMapping(TemplateDataLanguageMappings.java:46)
	at de.arrobait.antlers.file.AntlersFileType$Companion.getAssociatedFileType(AntlersFileType.kt:30)
	at de.arrobait.antlers.file.AntlersFileType$Companion.access$getAssociatedFileType(AntlersFileType.kt:16)
	at de.arrobait.antlers.file.AntlersFileType.extractCharsetFromFileContent(AntlersFileType.kt:55)
	at com.intellij.openapi.fileTypes.CharsetUtil.extractCharsetFromFileContent(CharsetUtil.java:33)
	at com.intellij.openapi.fileEditor.impl.LoadTextUtil.charsetFromContentOrNull(LoadTextUtil.java:470)
	at com.intellij.openapi.vfs.encoding.EncodingManagerImpl.handleDocument(EncodingManagerImpl.java:131)
	at com.intellij.openapi.vfs.encoding.EncodingManagerImpl$DocumentEncodingDetectRequest.run(EncodingManagerImpl.java:203)
	at com.intellij.util.concurrency.BoundedTaskExecutor.doRun(BoundedTaskExecutor.java:248)
	at com.intellij.util.concurrency.BoundedTaskExecutor.access$200(BoundedTaskExecutor.java:28)
	at com.intellij.util.concurrency.BoundedTaskExecutor$1.executeFirstTaskAndHelpQueue(BoundedTaskExecutor.java:221)
	at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:227)
	at com.intellij.util.concurrency.BoundedTaskExecutor$1.run(BoundedTaskExecutor.java:210)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
	at java.base/java.lang.Thread.run(Thread.java:833)
	
Following exceptions happened soon after this one, most probably they are induced.

2023-04-27T13:58:37.291
java.lang.Throwable: Read access is allowed from inside read-action (or EDT) only (see com.intellij.openapi.application.Application.runReadAction())
Current thread: Thread[EncodingManagerImpl Document Pool[ApplicationImpl pooled thread 4],4,main] 1507409463 (EventQueue.isDispatchThread()=false)
SystemEventQueueThread: Thread[AWT-EventQueue-0,6,main] 1110023023
	at com.intellij.openapi.diagnostic.Logger.error(Logger.java:202)
	at com.intellij.openapi.application.impl.ApplicationImpl.assertReadAccessAllowed(ApplicationImpl.java:1004)
	at com.intellij.workspaceModel.core.fileIndex.impl.WorkspaceFileIndexDataImpl.ensureIsUpToDate(WorkspaceFileIndexDataImpl.kt:127)
	at com.intellij.workspaceModel.core.fileIndex.impl.WorkspaceFileIndexDataImpl.getFileInfo(WorkspaceFileIndexDataImpl.kt:70)
	at com.intellij.workspaceModel.core.fileIndex.impl.WorkspaceFileIndexImpl.getFileInfo(WorkspaceFileIndexImpl.kt:220)
	at com.intellij.workspaceModel.core.fileIndex.impl.WorkspaceFileIndexImpl.findFileSet(WorkspaceFileIndexImpl.kt:180)
	at com.intellij.workspaceModel.core.fileIndex.impl.WorkspaceFileIndexImpl.isInContent(WorkspaceFileIndexImpl.kt:73)
	at com.intellij.openapi.roots.impl.ProjectFileIndexImpl.isInContent(ProjectFileIndexImpl.java:314)
	at com.intellij.lang.PerFileMappingsBase.getNotInHierarchy(PerFileMappingsBase.java:144)
	at com.intellij.lang.PerFileMappingsBase.getMappingInner(PerFileMappingsBase.java:136)
	at com.intellij.lang.PerFileMappingsBase.getConfiguredMapping(PerFileMappingsBase.java:105)
	at com.intellij.psi.templateLanguages.TemplateDataLanguageMappings.getMapping(TemplateDataLanguageMappings.java:46)
	at de.arrobait.antlers.file.AntlersFileType$Companion.getAssociatedFileType(AntlersFileType.kt:30)
	at de.arrobait.antlers.file.AntlersFileType$Companion.access$getAssociatedFileType(AntlersFileType.kt:16)
	at de.arrobait.antlers.file.AntlersFileType.extractCharsetFromFileContent(AntlersFileType.kt:55)
	at com.intellij.openapi.fileTypes.CharsetUtil.extractCharsetFromFileContent(CharsetUtil.java:33)
	at com.intellij.openapi.fileEditor.impl.LoadTextUtil.charsetFromContentOrNull(LoadTextUtil.java:470)
	at com.intellij.openapi.vfs.encoding.EncodingManagerImpl.handleDocument(EncodingManagerImpl.java:131)
	at com.intellij.openapi.vfs.encoding.EncodingManagerImpl$DocumentEncodingDetectRequest.run(EncodingManagerImpl.java:203)
	at com.intellij.util.concurrency.BoundedTaskExecutor.doRun(BoundedTaskExecutor.java:248)
	at com.intellij.util.concurrency.BoundedTaskExecutor.access$200(BoundedTaskExecutor.java:28)
	at com.intellij.util.concurrency.BoundedTaskExecutor$1.executeFirstTaskAndHelpQueue(BoundedTaskExecutor.java:221)
	at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:227)
	at com.intellij.util.concurrency.BoundedTaskExecutor$1.run(BoundedTaskExecutor.java:210)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
	at java.base/java.lang.Thread.run(Thread.java:833)

Line breaks not handled gracefully

Great plugin, thanks for the work on it!

One UX issue I often hit is the way the Antlers tags are formatted. The biggest issues I hit are:

  • Subsequent tags ignore the line breaks I add, so they all run together
  • Long tags get line-breaks in the middle of them, and then the next tags follow right after

I've included some code below so you can get a sense of what I mean.

{{ nocache }} {{ collection from="training_log" status:is="published" limit="20"
    sort="date:desc" }}
<div class="flex {{ index === 0 ? 'col-span-3 row-span-3 sm:col-span-2 sm:row-span-2' : '' }}">
  <a class="group relative flex" href="{{ url }}">
    {{ if images }} {{ images limit="1" }} <img class="object-cover relative z-0" src="{{
    imagekit :src=" path" n="home_thumbnail" }}" alt=""/> {{ /images }} {{ /if }} {{ if
    index===0 }}
    <div
      class="pointer-events-none absolute bottom-0 right-0 z-20 bg-black bg-opacity-75 px-4 py-2 text-xs font-semibold text-cfhsv-blue group-hover:text-cfhsv-light-blue"
    >
      {{ title }}
    </div>
    {{ /if }}

    <div
      class="pointer-events-none absolute inset-0 z-10 bg-black opacity-20 transition-all duration-200 group-hover:opacity-0"
    ></div>
  </a>
</div>
{{ /collection }} {{ /nocache }}

This obviously isn't a breaking issue but visually it makes it tough to ensure my tags are configured and balanced correctly.

Thanks!

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • Update actions/upload-artifact action to v4
  • Update gradle/wrapper-validation-action action to v3
  • Update jtalk/url-health-check-action action to v4
  • Update plugin org.jetbrains.qodana to v2024
  • 🔐 Create all rate-limited PRs at once 🔐

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/build.yml
  • actions/checkout v3
  • gradle/wrapper-validation-action v1.0.5
  • actions/setup-java v3
  • actions/upload-artifact v3
  • actions/cache v3
  • actions/upload-artifact v3
  • JetBrains/qodana-action v2022.3.4
  • actions/upload-artifact v3
  • actions/checkout v3
.github/workflows/release.yml
  • actions/checkout v3
  • actions/setup-java v3
.github/workflows/run-ui-tests.yml
  • actions/checkout v3
  • actions/setup-java v3
  • jtalk/url-health-check-action v3
gradle
gradle.properties
  • junit:junit 4.13.2
  • org.junit.vintage:junit-vintage-engine 5.9.2
settings.gradle.kts
build.gradle.kts
  • org.jetbrains.kotlin.jvm 1.8.20
  • org.jetbrains.intellij 1.13.3
  • org.jetbrains.changelog 2.0.0
  • org.jetbrains.qodana 0.1.13
gradle-wrapper
gradle/wrapper/gradle-wrapper.properties
  • gradle 8.0.2

  • Check this box to trigger a request for Renovate to run again on this repository

Parse Antlers inside a parameter string value of another Antlers region.

Antlers support the concept of interpolated statements, which means, one can insert Antlers into a Antlers node:

{{ items = {collection:products sort="rating:desc" limit="5"} }}

While this already works, I discovered a special case, where an Antlers switch statement is inserted into the string value of a class attribute:

{{ svg
    :src="type"
    alt=""
    aria-hidden="true"
    class="
        h-5 w-5 fill-current motion-safe:transition-colors
        { switch(
            (type == 'success') => 'text-green-800',
            (type == 'notice') => 'text-yellow-800',
            (type == 'error') => 'text-red-800',
            () => 'text-gray-800'
        )}
    "
}}

Error in switch statement

Describe the bug
A clear and concise description of what the bug is.

OS:

  • Mac
  • Linux
  • Windows

Jetbrains Product:

  • PhpStorm
  • IntelliJ

IDE Version:

  • [2023.3.2]

Plugin Version:

  • [0.0.6]

To Reproduce
Steps to reproduce the behavior:

  1. Install Peak
  2. Open file resources/views/page_builder/_link_blocks.antlers.html
  3. See two errors in switch: One at the comma in the line before default case and one in the default case

Expected behavior
No errors

Screenshots
2023-08-03_17-34-51

Latest version of phpstorm slowed down by this plugin

Describe the bug
A clear and concise description of what the bug is.

OS:

  • [ X ] Mac
  • Linux
  • Windows

Jetbrains Product:

  • [X ] PhpStorm
  • IntelliJ

IDE Version:

  • [late 2023 versions to 2024.1.1]

Plugin Version:

  • [e.g. 0.0.6]

To Reproduce
Steps to reproduce the behavior:

  1. Copy paste, make comments or do anything code related in an antler file

Expected behavior
Smooth fast response

Additional context
The IDE is super slow and takes over 30 seconds just to copy paste code or comment a line

Brackets are not correctly added when nested.

When the Antlers plugin is enabled, the code formatting, indenting and brackets as you type is not working correctly.

PhpStorm version
PhpStorm 2022.2.1 Preview
Build #PS-222.3739.28, built on August 5, 2022
(using EAP for the UI Preview program)

Video of issue
https://www.awesomescreenshot.com/video/10406461?key=5c7ca37705ea5526a79c6935abb8a3c0

Interesting notes:

  1. First use of {{ appears to work correctly - it creates the correct double closing
  2. Use a div, then try {{ and you only get one } - expected }}
  3. Outside (and after) the div, try {{ and you get three }}} closing brackets

I see there is already issue #19 regarding indentation too - was able to confirm incorrect indentation.

Reformat adding spaces

Describe the bug
When using the reformat option it's adding spaces around group_by options and others.

OS:

  • Mac
  • Linux
  • Windows

Jetbrains Product:

  • PhpStorm
  • IntelliJ

IDE Version:
2023.1.4

Plugin Version:
0.0.6

To Reproduce
Steps to reproduce the behavior:

  1. Write antlers code that uses group_by
  2. Have PHPStorm reformat

Expected behavior
Expected spaces not to show up

Screenshots
image

Additional context
Link to Discord thread

Plugin confuses regular .HTML files

It seems like the plugin currently confuses PhpStorm if you have the plugin enabled and try to edit a regular .HTML file.
Code highlighting and executing the comment shortcut do not function correctly.

Plugin disabled
Scherm­afbeelding 2023-02-27 om 09 51 34

Plugin enabled
Scherm­afbeelding 2023-02-27 om 09 50 49

I don't know how this plugin exactly works, but maybe the file extension pattern is incorrect?
This has been tested using a scratch file on PhpStorm 2022.2.4 with plugin version 0.0.5.

Indentation support

Adding a line break in a tag should format the code according to the indentation config.
image

Issue using antlers file type:
image

Expectation using html file type:
image

Also, 'delete' should bring me immediately to the end of the previous line, instead it only deletes a space/tab character

Error with double colons in partial

Describe the bug
A clear and concise description of what the bug is.

OS:

  • Mac
  • Linux
  • Windows

Jetbrains Product:

  • PhpStorm
  • IntelliJ

IDE Version:

  • [2023.3.2]

Plugin Version:

  • [e.g. 0.0.6]

To Reproduce

  1. Install Peak
  2. Go to layout.antlers.html
  3. See an error at line 14 with code {{ partial:statamic-peak-seo::snippets/seo }}

Expected behavior
See no error

Screenshots
2023-08-03_15-47-37

IDE Error

Plugin: 0.0.6
PhpStorm: 2023.1.1

I get an IDE error from time to time, i haven't figured out which project / file cashes the plugin yet.

Thanks for your great work - we have been waiting for PhpStorm antlers support so long :)

Here is the trace:

java.lang.Throwable: Read access is allowed from inside read-action (or EDT) only (see com.intellij.openapi.application.Application.runReadAction())
Current thread: Thread[EncodingManagerImpl Document Pool,4,main] 414988783 (EventQueue.isDispatchThread()=false)
SystemEventQueueThread: Thread[AWT-EventQueue-0,6,main] 1512743941
	at com.intellij.openapi.diagnostic.Logger.error(Logger.java:202)
	at com.intellij.openapi.application.impl.ApplicationImpl.assertReadAccessAllowed(ApplicationImpl.java:1004)
	at com.intellij.workspaceModel.core.fileIndex.impl.WorkspaceFileIndexDataImpl.ensureIsUpToDate(WorkspaceFileIndexDataImpl.kt:127)
	at com.intellij.workspaceModel.core.fileIndex.impl.WorkspaceFileIndexDataImpl.getFileInfo(WorkspaceFileIndexDataImpl.kt:70)
	at com.intellij.workspaceModel.core.fileIndex.impl.WorkspaceFileIndexImpl.getFileInfo(WorkspaceFileIndexImpl.kt:220)
	at com.intellij.workspaceModel.core.fileIndex.impl.WorkspaceFileIndexImpl.findFileSet(WorkspaceFileIndexImpl.kt:180)
	at com.intellij.workspaceModel.core.fileIndex.impl.WorkspaceFileIndexImpl.isInContent(WorkspaceFileIndexImpl.kt:73)
	at com.intellij.openapi.roots.impl.ProjectFileIndexImpl.isInContent(ProjectFileIndexImpl.java:314)
	at com.intellij.lang.PerFileMappingsBase.getNotInHierarchy(PerFileMappingsBase.java:144)
	at com.intellij.lang.PerFileMappingsBase.getMappingInner(PerFileMappingsBase.java:136)
	at com.intellij.lang.PerFileMappingsBase.getConfiguredMapping(PerFileMappingsBase.java:105)
	at com.intellij.psi.templateLanguages.TemplateDataLanguageMappings.getMapping(TemplateDataLanguageMappings.java:46)
	at de.arrobait.antlers.file.AntlersFileType$Companion.getAssociatedFileType(AntlersFileType.kt:30)
	at de.arrobait.antlers.file.AntlersFileType$Companion.access$getAssociatedFileType(AntlersFileType.kt:16)
	at de.arrobait.antlers.file.AntlersFileType.extractCharsetFromFileContent(AntlersFileType.kt:55)
	at com.intellij.openapi.fileTypes.CharsetUtil.extractCharsetFromFileContent(CharsetUtil.java:33)
	at com.intellij.openapi.fileEditor.impl.LoadTextUtil.charsetFromContentOrNull(LoadTextUtil.java:470)
	at com.intellij.openapi.vfs.encoding.EncodingManagerImpl.handleDocument(EncodingManagerImpl.java:131)
	at com.intellij.openapi.vfs.encoding.EncodingManagerImpl$DocumentEncodingDetectRequest.run(EncodingManagerImpl.java:203)
	at com.intellij.util.concurrency.BoundedTaskExecutor.doRun(BoundedTaskExecutor.java:248)
	at com.intellij.util.concurrency.BoundedTaskExecutor.access$200(BoundedTaskExecutor.java:28)
	at com.intellij.util.concurrency.BoundedTaskExecutor$1.executeFirstTaskAndHelpQueue(BoundedTaskExecutor.java:221)
	at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:227)
	at com.intellij.util.concurrency.BoundedTaskExecutor$1.run(BoundedTaskExecutor.java:210)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
	at java.base/java.lang.Thread.run(Thread.java:833)

Reformat code indents the code badly

Hi, when I use the reformat code function in .antlers.html file, it reformats my code badly. I'm not sure what causes this behaviour because I think it was working for me fine before. Could you please help me navigate this issue?

I tried on both the latest released version 0.0.4 and the latest main.

Before reformat:
image

After reformat:
image

Space in variables pair leads to error

In the following antlers snippet the formatter in v.0.0.5 changes {{ /cells }} to {{ / cells }} which throws a parsing error (runtime parser):

<tr>
  {{ cells }}
    {{ if first && first_column_headers }}
      <th class="border-b border-black bg-black px-3 py-3 text-left font-anton uppercase tracking-wider text-white xl:px-6">
        {{ value }}
      </th>
    {{ else }}
      <td class="border-b border-black px-3 py-3 text-black xl:px-6">{{ value }}</td>
    {{ /if }}
  {{ /cells }}
</tr>

Error: [ANTLR_131]: Unpaired closing tag.

Parse and format "extended" comments aka Template IDE hints

A normal comment looks like {{# This is a comment #}} and this works so far. However, "Template IDE hints" are getting used more often for example in the Peak codebase. This concept originated from the Antlers Toolbox https://antlers.dev/docs/template-ide-hints. For now this plugin should be able to lex and parse them correctly to provide proper formatting.

{{#
    @name The template name.
    @desc A human-friendly description for your awesome template.
#}}

PHP in Antlers incorrect highlight

Describe the bug
If you add some PHP into an antlers.html file the highlight is incorrect.
It's misleading because you feel you have some issue but the file works correctly.

OS:

  • Mac
  • Linux
  • Windows

Jetbrains Product:

  • PhpStorm
  • IntelliJ

IDE Version:

  • [PS-232.10227.13]

Plugin Version:

  • [0.0.6]

To Reproduce
Go to https://statamic.dev/antlers#syntax

Copy the example code
<a href="{{$ route('account.register') $}}">Register for a new account</a>

Expected behavior
Should keep the correct highlight as if we are using variables {{ variable }}

Screenshots
-- with variables --
Screenshot 2023-11-24 at 10 41 43 pm

-- with php --
Screenshot 2023-11-24 at 10 41 13 pm

Support for scopes in the grammar

Hey! Let me start out by saying that you've done an awesome job! I started building a similar plugin before but never finished it since it was a lot of work. Believe me when I say I know how much effort you've put into this 😄.

Nevertheless, adding a feature request: support for scopes in the grammar. Here's an example of the default template in Peak where it's used in the wild.

example

Highlighting in .antlers.php files?

Hi Stefano,

I just renamed an .antlers.html file to .antlers.php to use native PHP inside – and the magic Antlers highlighting is gone. :-(

Would it be possible to highlight those files as well, combined with normal PHP syntax highlighting?

Best, Jens Olaf

Do not add spaces around parameter assignment

Formatter adds spaces around assignment operator like {{ foo = [1, 2, 3] }} but also around the assignment of parameter values:

{{ svg src = "hamburger" class = "w-full" }}
          ^ ^                 ^ ^ 

Wrong indentation at newline on enter on HTML

Describe the bug
A clear and concise description of what the bug is.

OS:

  • Mac
  • Linux
  • Windows

Jetbrains Product:

  • PhpStorm
  • IntelliJ

IDE Version:

  • latest

Plugin Version:

  • 0.0.6

To Reproduce

2024-02-11_17-09-57.mp4

Performance Issues

The last days I have very bad performance issues when activating the plugin. They are so bad, that every typing or moving with keys has lags of 2-3secs or more.

I love the plugin, but under this circumstances I can not use it. After deactivating the plugin the performance issues are gone.

Formatter overrules Prettier

Issue

I'm using John Kosters Antlers Prettier formatter (https://github.com/Stillat/vscode-antlers-language-server/tree/main/formatcli/prettier-plugin-antlers) instead of the one provided by the plugin. In PhpStorm it's possible to define Prettier as formatter on Reformat Code action which uses Prettier instead of the PhpStorm formatter. The issue is that the bundled formatter in the Antlers IDEA seems not to respect that checkbox. The issue is gone when disabling the plugin.

It would be nice if the plugin would respect that setting or the formatting capabilities could be deactivated via settings.

Reproduction

  1. Install prettier and prettier-plugin-antlers (npm install -D prettier prettier-plugin-antlers)
  2. Create a .prettierrc file in the project root
{
    "singleQuote": true,
    "trailingComma": "all",
    "printWidth": 140,
    "tabWidth": 16,
    "endOfLine": "lf",
    "plugins": [
        "./node_modules/prettier-plugin-antlers/"
    ],
    "overrides": [
        {
            "files": "*.antlers.html",
            "options": {
                "parser": "antlers",
                "singleQuote": false
            }
        }
    ]
}
  1. Set Prettier as default formatter
    3.1. Go to Settings > Languages & Frameworks > JavaScript > Prettier
    3.2. Add {**/*,*}.{js,ts,jsx,tsx,antlers.html,vue,blade.php,css} for Run for files:
    3.3. Check the On 'Reformat Code' action

Bildschirm­foto 2023-03-15 um 11 12 42

  1. Format the following code via Code > Reformat Code
<main id="content">{{ page_builder }} {{ partial src="blocks/{type}" }} {{ /page_builder }}</main>
  1. Notice that the code does not have the heavy indentation (which should be caused by "tabWidth": 16, in .prettierrc
  2. Reinsert the code above, right click and perform "Reformat with Prettier"
  3. The code should now have the heavy indentation

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.