Comments (7)
Correction, it seems that this is only an issue for arrow functions defined inside a jsClassBlock
.
from vim-javascript.
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.
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.
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.
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.
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.
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)
- Function declaration's closing bracket highlighted as error HOT 1
- Broken javascript indentation inside <script> tags in html HOT 1
- redrawtime exceeded syntax highlighting disabled
- Code incorrectly highlighted in nested braces
- Class method with Implicit Return and String Literal Kills Formatting
- [Flow] Nested Generic Types break syntax highlighting HOT 1
- JSDoc @example highlighting only works if the example is right next to the comment `*`
- Is it possible to have concealing on typescript? HOT 1
- Highlight breaking when there is a -- inside template literals HOT 1
- Priority issues with jsGlobals
- Support class static initialization blocks HOT 1
- Destruct nested array HOT 4
- Arrow function name doesn't have same highlight as regular function name HOT 1
- Number in snake case are not highlighted
- Incomplete support for jsdoc3 namepaths on @typedef
- Detect embedded typescript as javascript in vue component HOT 1
- customize color scheme doesn't work HOT 1
- Class with static initialization block highlighting issue
- indentation issue
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vim-javascript.