Code Monkey home page Code Monkey logo

Comments (7)

BrandonMathis avatar BrandonMathis commented on July 26, 2024

Correction, it seems that this is only an issue for arrow functions defined inside a jsClassBlock.

Screen Shot 2021-05-28 at 11 17 55 AM

from vim-javascript.

amadeus avatar amadeus commented on July 26, 2024

Yeah, this is definitely a known issue, but I haven't had time to dig into it. It's something to do with syntax priorities I think...

from vim-javascript.

BrandonMathis avatar BrandonMathis commented on July 26, 2024

True, I tried my hand @ fixing this a few times & the closest I managed to get is the following modification to the jsClassBlock (I just added @jsExpression to the contains)

-syntax region  jsClassBlock         contained matchgroup=jsClassBraces         start=/{/  end=/}/  contains=jsClassFuncName,jsClassMethodType,jsArrowFunction,jsArrowFuncArgs,jsComment,jsGenerator,jsDecorator,jsClassProperty,jsClassPropertyComputed,jsClassStringKey,jsAsyncKeyword,jsNoise extend fold
+syntax region  jsClassBlock         contained matchgroup=jsClassBraces         start=/{/  end=/}/  contains=@jsExpression,jsClassFuncName,jsClassMethodType,jsArrowFunction,jsArrowFuncArgs,jsComment,jsGenerator,jsDecorator,jsClassProperty,jsClassPropertyComputed,jsClassStringKey,jsAsyncKeyword,jsNoise extend fold

However, I then had to make this modification to the jsClassProperty so that the last line of a function doesn't get highlighted strangely (dropping the semicolon which usually terminates the last line of these js functions 😅)

-syntax match   jsClassProperty          contained /\<\K\k*\ze\s*[=;]/ skipwhite skipempty nextgroup=jsClassValue,jsFlowClassDef
+syntax match   jsClassProperty          contained /\<\K\k*\ze\s*[=]/ skipwhite skipempty nextgroup=jsClassValue,jsFlowClassDef

from vim-javascript.

amadeus avatar amadeus commented on July 26, 2024

It's been a bit since I've work on this, but pretty sure that change will then allow a whole slew of other stuff to exist within jsClassBlock which is not valid syntax

from vim-javascript.

BrandonMathis avatar BrandonMathis commented on July 26, 2024

My original solution was to create a new region called jsArrowFuncBlock what contains @jsAll or @jsExpression but I wasn't able to get a regex to properly match for me 😖

syntax region jsArrowFuncBlock contained matchgroup=jsFuncBraces start=/=>/ end=/;/ contains=@jsAll,jsBlock extend fold

Not even sure if the theory is correct either. Seems like I need to match everything from the beginning of a => & then until the ; denoting the end of a line (since you can't have multiple lines without wrapping the function body in { & })

from vim-javascript.

amadeus avatar amadeus commented on July 26, 2024

So I am 90% sure the issue is not actually related to any problem with our existing regexes for arrow functions, the issue is simply a priority issue. I think we just have to re-sort a few of the items to fix it

from vim-javascript.

BrandonMathis avatar BrandonMathis commented on July 26, 2024

Interesting.... I will try some re-ordering on my end and see if I can find the magic order that fixes this 😇

from vim-javascript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.