jparise / vim-graphql

A Vim plugin that provides GraphQL file detection, syntax highlighting, and indentation.
MIT License
487 stars 25 forks source link

Use base &indentexpr for non-GraphQL indentation #66

Closed jparise closed 3 years ago

jparise commented 3 years ago

Stop assuming the name of the base JavaScript or TypeScript indentation function and instead store and use the buffer's existing &indentexpr for non-GraphQL lines.

This should produce more correct results when other plugins are also wrapping &indentexpr (such as vim-jsx-pretty and vim-styled-components).

Fixes #62

jparise commented 3 years ago

@sheerun I think this should address the issue you reported in #62.

I don't think I need a recursion guard here like the one used by vim-styled-components, but I may have missed a complex case that would require it.

sheerun commented 3 years ago

I guess you don't need it it with this implementation, but I suspect syntack is very slow... And this function will be called for each line in file

sheerun commented 3 years ago

Actually never mind, styled components does the same

sheerun commented 3 years ago

btw. maybe you could use synstack(a:lnum, a:cnum) instead of synstack(a:lnum, 1)?

jparise commented 3 years ago

btw. maybe you could use synstack(a:lnum, a:cnum) instead of synstack(a:lnum, 1)?

Do you have an example where that would make a difference? The GraphQL indentation implementation is essentially line-based, but if using the column number would make it more correct, I'd be fine changing it.

jparise commented 3 years ago

I guess you don't need it it with this implementation, but I suspect syntack is very slow... And this function will be called for each line in file

When I originally wrote that code, I looked for alternatives, but this approach seemed the only way to get build an accurate check. I'd love to use something faster, though.

sheerun commented 3 years ago

no idea, it just feels more correct