Closed mxstbr closed 6 years ago
Hi Max, every JS file? Yes, probably. 😑
The way this plugin works is by checking, whether something is required/imported from a supported API by searching for a specific regular expression on every javascript file. The default memory is 1000 bytes and the error message basically indicates, that the search has to keep more than 1000 bytes in memory to check, whether this is the case.
I will have to tweak the regular expression to be not as inclusive but at the same time inclusive enough to not let all the edge case import/require statements fall off.
Currently it checks for (assume libraries
is the list of supported library names):
import(.|\n)*from.*[libraries]
or
require(.|\n)*'[libraries]
Or it's an unmatched parenthesis thing? Like in this similar issue on vim-markdown. I have to check, thanks for the notification. 😊
I feel like assuming that any styled.div
call with a tagged template literal likely has styles after it is fine, why do we check for imports?
I thought checking for imports is the smallest common denominator.
The plugin does not specifically highlights CSS rules in tagged template literals, but CSS rules in all template strings, if the import statement is present.
But now that you mention it, maybe it makes more sense to only inject CSS rules into tagged template literals? But then again, how to know whether it's only API-conform tagged template literals?
I think there's just three cases where they should be highlighted as CSS:
styled.x`
`
styled(X)`
`
Comp.extend`
`
What about css
, injectGlobal
, etc.?
There already was a discussion about whether to whitelist the tagged templates and I wasn't really convinced. (See #21.)
Do you have a lot of plugins and/or give an example file, that displays the maxmempattern
errors? So I can better test? Also what's your environment? Vim Version, OS, etc.
@mxstbr If you are still interested in this issue, I discussed a complete rewrite of this plugin in this comment on #21.
I hope that a complete rewrite will mitigate this memory pattern issue.
Update: Please see whether #30 helps you with this error.
nvim --version
NVIM v0.2.2
I also run into this error when running various commands on a non-styled component .js file.
Next week I'll probably merge #30 after fixing some long-standing issues. Hopefully this should fix this for good for now.
I just solved this issue by adding:
set maxmempattern = 2000000
to my vimrc.
In my case the symptom was inserting a '[' char on a long markdown file (~4K lines).
Found the solution here:
https://www.zhihu.com/question/60367881
You can also check :help maxmempattern
Getting this error when opening any (?) JS file:
These files don't even contain any styled components!