Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to fix the parsing of .tex and .txt file extensions when parsing templates #55

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Chifiwang
Copy link

I was trying to create a template for some latex and noticed that it wouldn't parse. The other option of .tpl removed my lsp and syntax highlighting, so I wanted to see why it wouldn't parse

From what I saw, within the function temp.get_temp.list() the call to vim.filetype.match({ filename = name }) will not match .tex and .txt file extensions by design (see https://www.reddit.com/r/neovim/comments/1cb4kty/vimfiletypematch_returns_nil/) for why.

Because of this, templates in latex .tex, and also incidentally .txt files, will not parse requiring you to use .tpl files with a header comment of ;; tex to be read properly.

To fix this I reimplemented the functionality of vim.filetype.match and adjusted the code according to the new function's api.

If you have time feel free to review and adjust the code as needed or contact me if I made a mistake in understanding when adjusting the code.

Thank you for your time.

@Chifiwang Chifiwang marked this pull request as draft August 29, 2024 03:18
@Chifiwang Chifiwang marked this pull request as ready for review August 29, 2024 03:21
@Chifiwang
Copy link
Author

I noticed that when pasting multiple versions of the template into one file there was a nil exception so I added a guarding if statement to mitigate that. It looks as though the output is correct none the less

@glepnir
Copy link
Member

glepnir commented Aug 29, 2024

thanks I think we need a test here

@Chifiwang
Copy link
Author

No problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants