Skip to content

Conversation

@jparise
Copy link
Owner

@jparise jparise commented Aug 31, 2020

This builds upon the embedded syntax "magic" we perform in order to
identify and highlight GraphQL queries within JavaScript/TypeScript
template strings.

In order to enable GraphQL syntax-aware indentation within these
strings, we replace 'indentexpr' with our own function which calls
GetGraphQLIndent inside of a GraphQL syntax region and otherwise
defers to the indentation function provided by the filetype plugin.

To support loading indent/graphql.vim inside of other file types, it
no longer sets any buffer-local settings when b:did_indent is already
set. This means we use the "outer" JavaScript indentation settings for
the "inner" GraphQL region. In practice, this is probably only relevant
for 'indentkeys'; I haven't thought of a way to make that setting
syntax-aware, too, without also changing it for the JavaScript code.

This approach has been tested with all of the supported JavaScript and
TypeScript variants, but there still may be some lingering issues that I
haven't encountered yet.

Fixes #24, #54

This builds upon the embedded syntax "magic" we perform in order to
identify and highlight GraphQL queries within JavaScript/TypeScript
template strings.

In order to enable GraphQL syntax-aware indentation within these
strings, we replace `'indentexpr'` with our own function which calls
`GetGraphQLIndent` inside of a GraphQL syntax region and otherwise
defers to the indentation function provided by the filetype plugin.

To support loading `indent/graphql.vim` inside of other file types, it
no longer sets any buffer-local settings when `b:did_indent` is already
set. This means we use the "outer" JavaScript indentation settings for
the "inner" GraphQL region. In practice, this is probably only relevant
for `'indentkeys'`; I haven't thought of a way to make that setting
syntax-aware, too, without also changing it for the JavaScript code.

This approach has been tested with all of the supported JavaScript and
TypeScript variants, but there still may be some lingering issues that I
haven't encountered yet.
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 this pull request may close these issues.

Return not indenting properly

2 participants