Commits


Fix restoration of original filename in Vim 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.


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


Ensure temporary file path is unique 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.


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


Don't reset ft after change to unrecognized suffix 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.


Fix typo in readme


Silence file type detection in Neovim


Merge branch 'syntax-on'


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.


Add comments to `.submodules` file


Fix file type detection for Neovim


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.


Update README Mention all the supported extensions.


Add `commentstring` setting for Jinja


Make the node bold


Make note in README more prominent


Add test for FQCN highlighting


Merge branch 'patch-1' into 'master' fix: FQCN highlighting of Jinja2 filters See merge request HiPhish/jinja.vim!3


fix: FQCN highlighting of Jinja2 filters See: https://github.com/pearofducks/ansible-vim/commit/3329367d2e5f90d203c8d340c53fa83c60a1ad41 (and links to the issues there)


Add `import` to keywords for Jinja detection


Update test shims


fix(ftdetect): escape filenames to avoid failure on special chars (fix #3)


Silence file type detection


Do not use Neovim functions in filetype detection


Add note about submodules to README