Since Angular 17, the new Control Flow Syntax is not valid HTML. This PR adds a new filetype detection for the HTML templates of Angular.
It first checks the filename. The Angular convention is to use *.component.html for the template. However, this is not mandatory.
If the filename does not match, it will check the contents of the file if it contains:
@if, @for, @switch, @defer*ngIf, *ngFor, *ngSwitch, *ngTemplateOutletng-template or ng-contentThis enables the Angular LSP to attach only to htmlangular filetypes, as well as language parsers, such as tree-sitter.
I've added a simple ft test, but only on filename. I'd like to add a testcase to check the contents of the file, but I do not know how. Tips are welcome.
https://github.com/vim/vim/pull/15190
(3 files)
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
@clason commented on this pull request.
In runtime/ftplugin/htmlangular.vim:
> @@ -0,0 +1,13 @@ +" Vim filetype plugin file +" Language: Angular HTML Template +" Maintainer: Dennis van den Berg <den...@vdberg.dev> +" Last Change: 2024 Jul 8 + +" Only use this filetype plugin when no other was loaded. +if exists("b:did_ftplugin") + finish +endif + +" Use HTML and Angular template ftplugins +runtime! ftplugin/html.vim +runtime! ftplugin/htmlangular.vim⬇️ Suggested change
-runtime! ftplugin/htmlangular.vim
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
@dlvandenberg pushed 1 commit.
—
View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
@dlvandenberg commented on this pull request.
In runtime/ftplugin/htmlangular.vim:
> @@ -0,0 +1,13 @@ +" Vim filetype plugin file +" Language: Angular HTML Template +" Maintainer: Dennis van den Berg <den...@vdberg.dev> +" Last Change: 2024 Jul 8 + +" Only use this filetype plugin when no other was loaded. +if exists("b:did_ftplugin") + finish +endif + +" Use HTML and Angular template ftplugins +runtime! ftplugin/html.vim +runtime! ftplugin/htmlangular.vim
No, not sure what to put in such a file.. angular.vim
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Thanks. One thing I noticed is the *\(ngIf\|ngFor\|ngSwitch\|ngTemplateOutlet\)\|ng-template\|ng-content\|{{.*}}
Let me backslah-escape the * while merging, it's clearer I think.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
I've added a simple ft test, but only on filename. I'd like to add a testcase to check the contents of the file, but I do not know how. Tips are welcome.
Nevermind, I'll add a test while merging.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
As mentioned in #13594 (comment) detecting angular files by filename is not desired. I think this is still the case.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
@zeertzjq commented on this pull request.
In runtime/ftplugin/htmlangular.vim:
> @@ -0,0 +1,12 @@ +" Vim filetype plugin file +" Language: Angular HTML Template +" Maintainer: Dennis van den Berg <den...@vdberg.dev> +" Last Change: 2024 Jul 8 + +" Only use this filetype plugin when no other was loaded. +if exists("b:did_ftplugin") + finish +endif + +" Use HTML and Angular template ftplugins
This comment seems wrong now, as it only uses HTML ftplugin.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Okay, we can revert looking at the filename and just make it inspect the file, when doing so, we can also fix the comment. @dlvandenberg is that fine for you?
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
Okay, we can revert looking at the filename and just make it inspect the file, when doing so, we can also fix the comment. @dlvandenberg is that fine for you?
Yeah, sure.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()