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

bug when used with classnames package #1

Open
kyle-mccarthy opened this issue May 26, 2021 · 5 comments
Open

bug when used with classnames package #1

kyle-mccarthy opened this issue May 26, 2021 · 5 comments

Comments

@kyle-mccarthy
Copy link

I have a typescript file that contains a react component and one of HTML elements uses the classnames utility to manage the element's classNames property. When trying to save the component + headwind.nvim resorts the classnames, it outputs invalid JSX. (see gif)

2021-05-26 10 29 11

BTW thanks for this plugin! All the existing headwind integrations are outdated and don't work with Tailwind 2 or JIT.

@kyle-mccarthy
Copy link
Author

It does look like using treesitter fixes the issue; however, I haven't been using treesitter because it causes some problems that are unrelated to your plugin.

Would any of the regexes mentioned in this PR help?

@steelsojka
Copy link
Owner

I used the wrong github account for those replies.... here they are for context.

I'll try out this scenario... are you using treesitter integration? This scenario is a little tricky using the pattern approach...
I would highly recommend using the treesitter setting instead of using the pattern approach. This scenario is hard to target using lua patterns. I will add steps on how to use treesitter. If you already are using treesitter and have the parser installed, you just need to enable the treesiter flag during setup.

@kyle-mccarthy Treesitter is just a parser. It won't cause you any problems to have the parser installed. You don't have to use the any highlighting or any other plugins that use treesitter. You just need the parser for your language installed.

I think the problem here is how it calculates the range to replace... the new line is messing it up.

@kyle-mccarthy
Copy link
Author

Is there a new line? I think that it just wraps currently without inserting a line break.

Also to preface this, I know this isn't the right place for me get treesitter assistance but I want to explain why I haven't enabled it. My main problems with treesitter are errors when editing a file with a language (like vim) that doesn't have a parser, also, for some unknown reason, saving a file takes longer with treesitter enabled, and saving a file intermittently triggers an error and writes Error detected while processing BufWritePre Autocommands for '*'.

I haven't had the time to debug the errors further though, but since treesitter didn't exactly work out of the box I haven't been using it.

@steelsojka
Copy link
Owner

@kyle-mccarthy You don't have to enable any highlighting module for treesitter. You can just install the parser and this plugin will use it. Treesitter does nothing on it's own. It's just an api for plugins to use. I recommend just installing the nvim-treesitter plugin and installing the parser for javascript (or typescript). You don't even need to setup the nvim-treesitter plugin. It's purely just for compiling the parser.

@steelsojka
Copy link
Owner

Also, I think it's treating the function call as a class and that's why it's messing it up.

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

No branches or pull requests

2 participants