tschuehly / spring-view-component

Server-side UI components with spring boot
MIT License
185 stars 10 forks source link

html layout - Namespace 'view' is not bound #22

Open landsman opened 5 months ago

landsman commented 5 months ago

Do you have a way how to enable Code completion/syntax highlight in IDE?

Screenshot 2024-05-03 at 15 38 51 Screenshot 2024-05-03 at 15 40 42

Active plugins:

landsman commented 5 months ago

From what I saw there is a need to write an IDE plugin to:

  1. learn IDE proprietary attribute view
  2. add syntax highlighting for view attribute values -> match them with fun names and allow us to click, navigate to fun definition
  3. get rid of thymeleaf html comments which currently provide "import", code completion

It would be interesting to get rid of plain strings and use Kotlin reflection for actions. With that it would be 100% type-safe and easy to work with (cmd + click to navigate).

tschuehly commented 5 months ago

@landsman Yes, we would need to create a custom IntelliJ plugin for Thymeleaf.

I'm currently thinking to depreceate view:action and replace it with a functional approach, in a larger application I did not think it was very useful. https://github.com/wimdeblauwe/htmx-spring-boot/issues/104

I think this is much better than the string solution with the annotation processor, as you can easily navigate between the definition and the usage. This has been very important in my experience. image

landsman commented 5 months ago

I see, yeah it would resolve this need for the plugin. Make sense.

landsman commented 4 months ago

Have you made up your mind? Are you going to release a new version? Can I help with updating the documentation or something?

tschuehly commented 4 months ago

I did not get around to it, but I still think it is a better approach. Creating an IntelliJ Plugin anyway would be still good for:

1. learn IDE proprietary attribute `view`

3. get rid of thymeleaf html comments which currently provide "import", code completion

Additionally defining ViewComponent Code templates: https://tschuehly.gitbook.io/server-side-spring-htmx-workshop#intellij-code-template

If you want to take a crack at an IntelliJ plugin that would be awesome.

Depreceating view:action would be a bigger rework, maybe I will have some time in June for that.

landsman commented 4 months ago

Yeah, I can take a look on the plugin.

tschuehly commented 4 months ago

Should I create a repo and add you as maintainer?

landsman commented 4 months ago

What about to do this as a module in this repository? It can be easier for the start I hope.

tschuehly commented 4 months ago

I've never developed a plugin so you can do that too if it's easier.

You can maybe take the jte plugin as example: https://github.com/casid/jte-intellij

wimdeblauwe commented 4 months ago

I created a small IntelliJ plugin. I recommend using the template https://github.com/JetBrains/intellij-platform-plugin-template This will configure everything you need to publish the plugin to the marketplace later.