mirror of
https://github.com/sheerun/vim-polyglot.git
synced 2025-11-11 13:03:50 -05:00
Update
This commit is contained in:
@@ -23,25 +23,24 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'graphql') == -1
|
|||||||
" Language: GraphQL
|
" Language: GraphQL
|
||||||
" Maintainer: Jon Parise <jon@indelible.org>
|
" Maintainer: Jon Parise <jon@indelible.org>
|
||||||
|
|
||||||
runtime! indent/graphql.vim
|
if exists('*GetJavascriptGraphQLIndent') && !empty(&indentexpr)
|
||||||
|
|
||||||
" Don't redefine our function and also require the standard Javascript indent
|
|
||||||
" function to exist.
|
|
||||||
if exists('*GetJavascriptGraphQLIndent') || !exists('*GetJavascriptIndent')
|
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
runtime! indent/graphql.vim
|
||||||
|
|
||||||
" Set the indentexpr with our own version that will call GetGraphQLIndent when
|
" Set the indentexpr with our own version that will call GetGraphQLIndent when
|
||||||
" we're inside of a GraphQL string and otherwise defer to GetJavascriptIndent.
|
" we're inside of a GraphQL string and otherwise defer to the base function.
|
||||||
|
let b:indentexpr_base = &indentexpr
|
||||||
setlocal indentexpr=GetJavascriptGraphQLIndent()
|
setlocal indentexpr=GetJavascriptGraphQLIndent()
|
||||||
|
|
||||||
function GetJavascriptGraphQLIndent()
|
function GetJavascriptGraphQLIndent()
|
||||||
let l:stack = map(synstack(v:lnum, 1), "synIDattr(v:val,'name')")
|
let l:stack = map(synstack(v:lnum, 1), "synIDattr(v:val, 'name')")
|
||||||
if !empty(l:stack) && l:stack[0] ==# 'graphqlTemplateString'
|
if get(l:stack, 0) ==# 'graphqlTemplateString'
|
||||||
return GetGraphQLIndent()
|
return GetGraphQLIndent()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
return GetJavascriptIndent()
|
return eval(b:indentexpr_base)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -23,25 +23,24 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'graphql') == -1
|
|||||||
" Language: GraphQL
|
" Language: GraphQL
|
||||||
" Maintainer: Jon Parise <jon@indelible.org>
|
" Maintainer: Jon Parise <jon@indelible.org>
|
||||||
|
|
||||||
runtime! indent/graphql.vim
|
if exists('*GetTypescriptGraphQLIndent') && !empty(&indentexpr)
|
||||||
|
|
||||||
" Don't redefine our function and also require the standard Typescript indent
|
|
||||||
" function to exist.
|
|
||||||
if exists('*GetTypescriptGraphQLIndent') || !exists('*GetTypescriptIndent')
|
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
runtime! indent/graphql.vim
|
||||||
|
|
||||||
" Set the indentexpr with our own version that will call GetGraphQLIndent when
|
" Set the indentexpr with our own version that will call GetGraphQLIndent when
|
||||||
" we're inside of a GraphQL string and otherwise defer to GetTypescriptIndent.
|
" we're inside of a GraphQL string and otherwise defer to the base function.
|
||||||
|
let b:indentexpr_base = &indentexpr
|
||||||
setlocal indentexpr=GetTypescriptGraphQLIndent()
|
setlocal indentexpr=GetTypescriptGraphQLIndent()
|
||||||
|
|
||||||
function GetTypescriptGraphQLIndent()
|
function GetTypescriptGraphQLIndent()
|
||||||
let l:stack = map(synstack(v:lnum, 1), "synIDattr(v:val,'name')")
|
let l:stack = map(synstack(v:lnum, 1), "synIDattr(v:val, 'name')")
|
||||||
if !empty(l:stack) && l:stack[0] ==# 'graphqlTemplateString'
|
if get(l:stack, 0) ==# 'graphqlTemplateString'
|
||||||
return GetGraphQLIndent()
|
return GetGraphQLIndent()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
return GetTypescriptIndent()
|
return eval(b:indentexpr_base)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|||||||
Reference in New Issue
Block a user