-
-
Notifications
You must be signed in to change notification settings - Fork 836
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
feat!(previewer): replace plenary.filetype with vim.filetype.match #2529
feat!(previewer): replace plenary.filetype with vim.filetype.match #2529
Conversation
9fd5ff4
to
3bc13c4
Compare
That's right, modeline is not part of the automatic filetype detection; this is an independent codepath (for manually setting the filetype independent of automatic detection). |
a02303a
to
2ff4559
Compare
okay, i think everything still works. doing docs a little bit later. @fdschmidt93 can you review the changes in buffer_previewer.lua? because you've written parts of it. thanks :) i probably gonna run it a couple of days before merging. problem right now is that we cant really drop filetype support from plenary. https://sourcegraph.com/search?q=context%3Aglobal+plenary.filetype&patternType=standard&sm=1&groupBy=repo but we can work towards that, deprecating it, making a release, .... |
2ff4559
to
239550b
Compare
Happy to have a look! As a heads up, planning to get to it Saturday morning. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran the {filesize, timeout}_hooks and filesize_limit and everything worked as intended.
Diff also lgtm :)
thanks for reviewing, then i'll try to get this done (and merged) by this evening |
239550b
to
28f33e5
Compare
(On a related note: It's a big job, but it would be worth making a dedicated effort to remove the dependency on plenary as much as possible. The Neovim standard library is much more extensive these days than it was when telescope was first written: there's |
yeah i thought about that as well, plenary is huge and there is a lot of stuff obsolete and its impossible to remove stuff from it. Like there is still async_v1 code in that repo and so on. We probably will keep plenary for busted but yeah that would be the long term goal (to get rid of plenary). Although i am not sure how we can get rid of plenary.log, plenary.popup, plenary.strings (we had that one here and upstreamed it to plenary) and we still have a couple of plenary.job So yeah maybe the goal is to go to tag plenary and then start removing stuff. I'll make an "tracking issue" (here in telescope) |
28f33e5
to
abe3027
Compare
abe3027
to
c225433
Compare
Marked as a breaking change because it could affects ppls config, in this case |
I just noticed a regression: previewing (I'm using VimTeX, which registers as a ftplugin for these, and includes its own ftdetect -- maybe that interferes? |
Similar for Both of these require looking at contents to disambiguate. Maybe that's the issue here? |
yep can reproduce, :| lets see if i can fix it |
tex files arent being recognized even with full buffer as content input, thats a problem ... |
Is there a feature missing in vim.filetype? |
currently skimming source code, one thing to notice is that there is not tex extension, only latex, using header are a little bit difficult because its defined by a function, and those function, as far as i can see, always need to content already in the buffer to determine the ft, so passing content wouldn't resolve the issue, we could do the ft detect after we've written the lines to a buffer, but that would be a hack because we already read the lines |
If that were the case, Neovim couldn't detect
Yeah, I can see how that's an issue. But not detecting filetypes at all is not acceptable, I feel. Maybe do a first pass with only the file name, and if that fails a second pass with the read lines, and if that fails a third pass (which should rarely be needed) with the full file contents? |
at least its missing in |
you need to also check |
i can make it work if i pass the bufnr and give the bufnr a name, or if i pass additionally the filename i can not make it work if i pass the content + filename. if i see that correctly the content is ever really used for shebangs and a couple of patterns
i know, i think i have a pretty good understanding now how it works. also my bad i found the |
I have a fix for it, but i wanna come back the the implementation ^^ meaning i think i can make the combination of filename + contents work |
That may be one of the (very few) combinations that is indeed missing, and probably should be added (in Neovim) if so.
That is correct. |
CC @clason
this would drop usage of
plenary.filetype
still left todo
seems like vim.filetype match doesnt have support for modeline so we still do that manually
:lua print(vim.filetype.match({ contents = { " vim:tw=78:ts=8:ft=help:norl:" } }))