-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for b:graphql_javascript_tags (#100)
This allows buffer-level JavaScript tag values, avoiding the need to modify the global namespace for more granular configurations. This also introduces graphql#var() as a convenience function to perform this kind of tiered variable look-up.
- Loading branch information
Showing
4 changed files
with
27 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,12 @@ | |
" Language: GraphQL | ||
" Maintainer: Jon Parise <[email protected]> | ||
|
||
" Look up the named variable in buffer scope and then in global scope. | ||
" Returns default if the named variable can't be found in either. | ||
function! graphql#var(name, default) abort | ||
return get(b:, a:name, get(g:, a:name, a:default)) | ||
endfunction | ||
|
||
function! graphql#has_syntax_group(group) abort | ||
try | ||
silent execute 'silent highlight ' . a:group | ||
|
@@ -31,5 +37,5 @@ function! graphql#has_syntax_group(group) abort | |
endfunction | ||
|
||
function! graphql#javascript_tags() abort | ||
return get(g:, 'graphql_javascript_tags', ['gql', 'graphql', 'Relay.QL']) | ||
return graphql#var('graphql_javascript_tags', ['gql', 'graphql', 'Relay.QL']) | ||
endfunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Before: | ||
let g:graphql_some_variable = 'abc' | ||
|
||
After: | ||
unlet! g:graphql_some_variable | ||
unlet! b:undefined_variable_name | ||
|
||
Execute(graphql#var should return global variables): | ||
AssertEqual 'abc', graphql#var('graphql_some_variable', '') | ||
|
||
Execute(graphql#var should return buffer overrides): | ||
let b:graphql_some_variable = 'def' | ||
|
||
AssertEqual 'def', graphql#var('graphql_some_variable', '') | ||
|
||
Execute(graphql#var should return default value for undefined variables): | ||
AssertEqual 'default', graphql#var('undefined_variable_name', 'default') |