]> git.ipfire.org Git - thirdparty/vim.git/commit
patch 9.1.0551: filetype: htmlangular files are not properly detected v9.1.0551
authorDennis van den Berg <dennis.vandenberg@nedap.com>
Tue, 9 Jul 2024 17:25:33 +0000 (19:25 +0200)
committerChristian Brabandt <cb@256bit.org>
Tue, 9 Jul 2024 17:44:32 +0000 (19:44 +0200)
commit1ad194c0dfd82ca1e7a1b6f2fca89a487794158d
tree3431b55230a375caeacbfbef397ee60cf9e640e3
parent4a7a4a3675b6ad90a525524ba4684925df212325
patch 9.1.0551: filetype: htmlangular files are not properly detected

Problem:  filetype: htmlangular files are not properly detected
Solution: Use the new htmlangular filetype for angular files, because
          since angular v17, those are no longer valid HTML files.
          (Dennis van den Berg)

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:

  - One of the Control-Flow blocks: @if, @for, @switch, @defer
  - A structural directive: *ngIf, *ngFor, *ngSwitch, *ngTemplateOutlet
  - Builtin Angular elements: ng-template or ng-content
  - String interpolation: {{ something }}

This enables the Angular LSP to attach only to htmlangular filetypes, as
well as language parsers, such as tree-sitter.

closes: #15190

Signed-off-by: Dennis van den Berg <dennis.vandenberg@nedap.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/autoload/dist/ft.vim
runtime/ftplugin/htmlangular.vim [new file with mode: 0644]
src/testdir/test_filetype.vim
src/version.c