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

Blows up with CSS Grid Layout #36

Open
jdsutherland opened this issue Aug 13, 2020 · 8 comments · Fixed by #40
Open

Blows up with CSS Grid Layout #36

jdsutherland opened this issue Aug 13, 2020 · 8 comments · Fixed by #40

Comments

@jdsutherland
Copy link
Contributor

jdsutherland commented Aug 13, 2020

When the CSS file contains named grid lines, the following stack trace occurs:

/Users/j/.config/nvim/plugged/bracey.vim/server/cssfile.js:15
        var rules = this.parsed.stylesheet.rules;
                                ^

TypeError: Cannot read property 'stylesheet' of undefined
    at CssFile.selectorFromPosition (/Users/j/.config/nvim/plugged/bracey.vim/server/cssfile.js:15:26)
    at Server.handleEditorCommand (/Users/j/.config/nvim/plugged/bracey.vim/server/server.js:187:28)
    at Server.parseEditorRequest (/Users/j/.config/nvim/plugged/bracey.vim/server/server.js:97:7)
    at IncomingMessage.<anonymous> (/Users/j/.config/nvim/plugged/bracey.vim/server/server.js:65:9)
    at IncomingMessage.emit (events.js:314:20)
    at endReadableNT (_stream_readable.js:1244:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)

named grid line syntax:

grid-template-columns: [main-start] 1fr [content-start] 1fr [content-end] 1fr [main-end];

It looks like this is probably a bug with the css parser dependency:

this.parsed = cssparser.parse(source);

@jdsutherland jdsutherland changed the title Breaks CSS file contains named grid lines Blows up when CSS file contains named grid lines Aug 13, 2020
@jdsutherland
Copy link
Contributor Author

jdsutherland commented Aug 15, 2020

Looking at this a bit more, I'm not sure exactly what is causing it to blow up but it seems very likely related to grid; I suspect the css parser hasn't been updated to support it.

@jdsutherland jdsutherland changed the title Blows up when CSS file contains named grid lines Blows up with CSS Grid Layout Aug 15, 2020
@mirsella
Copy link

i don't know if this is included in "named grid line" but this make it blow up too :

:root {
  --primary: #F7CCCC;
  --second: #F12B6B;
  /* etc */ 
}

i hope it can be fixed soon :)

@mirsella
Copy link

mirsella commented Aug 18, 2020

I tried to put my statement in an <style> element directly in the index.html and it works, but not in the .css.
I'll put it here while I'm using Bracey and deleting it after.

@jdsutherland
Copy link
Contributor Author

jdsutherland commented Aug 18, 2020

@mirsella your issue isn't related to grid but what both probably have in common is that they're newer CSS additions. It looks like bracey and the css parser library were mostly built prior to 2015, so it's not surprising that new CSS features are causing issues.

One way to fix the issue might be to swap out the current css parser (looks dead) for https://github.com/postcss/postcss.

@mirsella
Copy link

i've found this project which will replace bracey for me. can even be install as vim module with Plug etc pretty easily.

I know you deleted it from your comments, but what the live reloading feature modern framework have ? like vuejs reactjs etc can have live reload which reload the whole html file so with support for CSS js etc ?

@jdsutherland
Copy link
Contributor Author

jdsutherland commented Sep 6, 2020

@mirsella I replaced the css parser with postcss. postcss supports CSS3+ features that the old css parser didn't. There is an additional issue, however; csslint is used to detect errors and it doesn't support some newer features, notably CSS3 variables. So even though postcss works, csslint causes bracey to show false positives.

csslint is dead and isn't likely to be updated (see CSSLint/csslint#720).
stylelint might be an alternative–I briefly tried swapping it out but couldn't get it working. My workaround is to just remove csslint and avoid having bracey display errors–I'm using CoC with CSS LS, so it's redundant.

You can try using the branch postcss-and-remove-csslint at https://github.com/jdsutherland/bracey.vim if interested. If you do check it out, let me know if you have any issues.

@mirsella
Copy link

mirsella commented Sep 6, 2020

waw gg. when you mentioned that it was the css parser not up to date, I tried to fork it with another one but didn't understand the code. the logic was overwhelming, I'll go look our fork :)
I'm using live-server now, but thanks.

@turbio
Copy link
Owner

turbio commented Sep 18, 2020

reopening, since linting also needs to be fixed to handle modern css.

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 a pull request may close this issue.

3 participants