Skip to content

Use base &indentexpr for non-GraphQL indentation #66

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

Merged
merged 1 commit into from
Oct 4, 2020
Merged

Conversation

jparise
Copy link
Owner

@jparise jparise commented Oct 4, 2020

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

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).
@jparise
Copy link
Owner Author

jparise commented Oct 4, 2020

@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.

@jparise jparise merged commit 51c5b17 into master Oct 4, 2020
@jparise jparise deleted the indent-base branch October 4, 2020 18:26
@sheerun
Copy link

sheerun commented Oct 4, 2020

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
Copy link

sheerun commented Oct 4, 2020

Actually never mind, styled components does the same

@sheerun
Copy link

sheerun commented Oct 4, 2020

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

@jparise
Copy link
Owner Author

jparise commented Oct 4, 2020

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
Copy link
Owner Author

jparise commented Oct 4, 2020

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.

jparise referenced this pull request in sheerun/vim-polyglot Oct 4, 2020
@sheerun
Copy link

sheerun commented Oct 4, 2020

no idea, it just feels more correct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Breaks indentation if used with vim-jsx-pretty
2 participants