Commit Briefs

8358793fd4 Benjamin Linskey

Fix restoration of original filename in Vim (btl/main)

Vim has built-in autocmds for filename suffixes such as .bak, .old, and .new that remove the trailing suffix from the file name and run file type detection with the resulting filename. The s:ft_vim() function in this plugin's ftdetect script receives that filename as an argument. Prior to this change, it would attempt to rename the file to the given filename after finishing its filetype detection work. As a result, a file named "foo.j2.old" would be renamed to "foo.j2". This change fixes the behavior by renaming the file to the original buffer name rather than the filename passed to the function.


b83bda57ed Benjamin Linskey

Merge branch 'btl/issue-4-bufname' into btl/main


592594b2be Benjamin Linskey

Ensure temporary file path is unique (btl/issue-4-bufname)

This fixes an error that occurred when the temporary filename used for filetype detection in Vim was identical to the name of another file already open in Vim. To prevent this from happening, a temporary directory is created and used as the prefix for the temporary filename.


4a678b53f9 Benjamin Linskey

Merge branch 'btl/issue-3-ftdetect' into btl/main


1ab4b34adb Benjamin Linskey

Don't reset ft after change to unrecognized suffix (btl/issue-3-ftdetect)

The ftdetect script handled file renames from a recognized compound file extension such as "foo.html.jinja" to an unrecognized extension such as "foo.xxxx.jinja" by resetting the filetype to "jinja." However, the logic used to implement this behavior conflicts with Vim's automatic filetype detection, causing files with certain compound file extensions to be set to the "jinja" filetype rather than the detected compound filetype. This commit fixes this by removing the filetype-reset logic, which both fixes this bug and brings the plugin's behavior closer to Vim's default handling of file renames. This bug occurs because Vim's built-in ftdetect logic, which runs before this plugin's ftdetect script, sometimes correctly identifies the filetype for files with a Jinja extension. For example, Vim will set the filetype to "apache" for a file named "httpd.conf.j2", and it will set the filetype to "sh" for a file named "foo.sh.j2" if it contains a /bin/sh shebang. When Vim correctly detected the filetype in the cases described above, l:previous_ft was set to that filetype in this plugin's ftdetect script. The script then proceeded to execute its own filetype detection logic, producing the same result. The script then compared l:previous_ft to the detected result and, finding them the same, erroneously treated this as a file renamed to an invalid compound type and reset the filetype to "jinja". The motivation for removing this logic altogether here rather than attempting to fix the logic is that Vim's default ftdetect behavior on file renames is less clever than the plugin was attempting to be. If you edit a new file in vim named "foo.sh", the filetype will be set to sh. If you then run ":saveas foo.c", the filetype will remain "sh" rather than being updated to "c". Since Vim doesn't attempt to execute ftdetect heuristics on file renames, it seems reasonable to imitate that behavior in this plugin.


677c930a18 Benjamin Linskey

Fix typo in readme (btl/readme-fix)


05373374a2 HiPhish

Silence file type detection in Neovim (master)


dacfd49e9f HiPhish

Merge branch 'syntax-on'


56feeed850 HiPhish

Update syntax test to be in line with upstream

There is a syntax file included upstream which should be taken as the canonical syntax highlighting.


7e8399c4c7 HiPhish

Add comments to `.submodules` file


950b01fae0 HiPhish

Fix file type detection for Neovim


cd939896b8 HiPhish

Hide Git submodules from plugin managers

I have renamed the `.gitmodules` file so Git no longer picks it up. Contributors have to create a symbolic link.


99afb6bf05 HiPhish

Update README

Mention all the supported extensions.


966cc763f3 HiPhish

Add `commentstring` setting for Jinja


f29c4abc60 HiPhish

Make the node bold


697c1d4f20 HiPhish

Make note in README more prominent


a56da59ed3 HiPhish

Add test for FQCN highlighting


5674eee5f2 HiPhish

Merge branch 'patch-1' into 'master'

fix: FQCN highlighting of Jinja2 filters See merge request HiPhish/jinja.vim!3


975e0eb900 Vadim A. Misbakh-Soloviov

fix: FQCN highlighting of Jinja2 filters

See: https://github.com/pearofducks/ansible-vim/commit/3329367d2e5f90d203c8d340c53fa83c60a1ad41 (and links to the issues there)


06fcfeeb20 HiPhish

Add `import` to keywords for Jinja detection


70c2d09857 HiPhish

Update test shims



81c0602f53 HiPhish

Silence file type detection



d112541c06 HiPhish

Add note about submodules to README