@@ -16,9 +16,8 @@ permissions and limitations under the License.
1616
1717import * as path from 'path' ;
1818import * as fs from 'fs' ;
19- import { workspace , ExtensionContext , ConfigurationTarget , window , WebviewPanel , Uri , commands , ViewColumn , window as VsCodeWindow } from 'vscode' ;
19+ import { workspace , ExtensionContext , window , WebviewPanel , Uri , commands , ViewColumn , window as VsCodeWindow } from 'vscode' ;
2020import { LanguageClient , LanguageClientOptions , ServerOptions , TransportKind } from 'vscode-languageclient/node' ;
21- import { registerYamlSchemaSupport } from './yaml-support/yaml-schema' ;
2221
2322let previews : { [ index : string ] : WebviewPanel } = { } ;
2423let languageClient : LanguageClient ;
@@ -41,58 +40,20 @@ export async function activate(context: ExtensionContext) {
4140 let clientOptions : LanguageClientOptions = {
4241 // Register the server for plain text documents
4342 documentSelector : [
44- { scheme : 'file' , language : 'yaml' } ,
45- { scheme : 'file' , language : 'json' }
43+ { scheme : 'file' , language : 'yaml' } ,
44+ { scheme : 'file' , language : 'json' } ,
4645 ] ,
4746 synchronize : {
4847 // Synchronize the setting section 'languageServerExample' to the server
4948 configurationSection : 'cfnLint' ,
5049 // Notify the server about file changes to '.clientrc files contain in the workspace
51- fileEvents : workspace . createFileSystemWatcher ( '**/.clientrc' )
50+ fileEvents : [
51+ workspace . createFileSystemWatcher ( '**/.clientrc' ) ,
52+ workspace . createFileSystemWatcher ( '**/*.?(e)y?(a)ml' ) ,
53+ ]
5254 }
5355 } ;
5456
55- let enableAutocomplete : boolean = workspace . getConfiguration ( ) . get ( 'cfnLint.enableAutocomplete' ) ;
56- if ( enableAutocomplete ) {
57- let currentTags : Array < string > = workspace . getConfiguration ( ) . get ( 'yaml.customTags' ) ;
58- let cloudFormationTags = [
59- "!And" ,
60- "!And sequence" ,
61- "!If" ,
62- "!If sequence" ,
63- "!Not" ,
64- "!Not sequence" ,
65- "!Equals" ,
66- "!Equals sequence" ,
67- "!Or" ,
68- "!Or sequence" ,
69- "!FindInMap" ,
70- "!FindInMap sequence" ,
71- "!Base64" ,
72- "!Join" ,
73- "!Join sequence" ,
74- "!Cidr" ,
75- "!Ref" ,
76- "!Sub" ,
77- "!Sub sequence" ,
78- "!GetAtt" ,
79- "!GetAZs" ,
80- "!ImportValue" ,
81- "!ImportValue sequence" ,
82- "!Select" ,
83- "!Select sequence" ,
84- "!Split" ,
85- "!Split sequence"
86- ] ;
87- let updateTags = currentTags . concat ( cloudFormationTags . filter ( ( item ) => currentTags . indexOf ( item ) < 0 ) ) ;
88-
89- workspace . getConfiguration ( ) . update ( 'yaml.customTags' , updateTags , ConfigurationTarget . Global ) ;
90-
91- yamlLangaugeServerValidation ( ) ;
92-
93- registerYamlSchemaSupport ( ) ;
94- }
95-
9657 // Create the language client and start the client.
9758 languageClient = new LanguageClient ( 'cfnLint' , 'CloudFormation linter Language Server' , serverOptions , clientOptions ) ;
9859 await languageClient . start ( ) ;
@@ -181,30 +142,6 @@ function getPreviewContent(content: String): string {
181142` ;
182143}
183144
184- export async function yamlLangaugeServerValidation ( ) : Promise < void > {
185- let validateYaml : boolean = workspace . getConfiguration ( ) . get ( 'yaml.validate' ) ;
186- let cfnValidateYamlInspect = workspace . getConfiguration ( ) . inspect ( 'cfnLint.validateUsingJsonSchema' ) ;
187- let cfnValidateYaml : boolean = workspace . getConfiguration ( ) . get ( 'cfnLint.validateUsingJsonSchema' ) ;
188-
189- if ( validateYaml ) {
190- if ( cfnValidateYamlInspect . globalValue === null || cfnValidateYamlInspect . workspaceFolderValue === null || cfnValidateYamlInspect . workspaceValue === null ) {
191- let selection : string = await window
192- . showInformationMessage ( 'The installed Red Hat YAML extension is also configured to validate YAML templates. This may result in duplicate lint errors with cfn-lint. Disabling the YAML extensions validation will disable it completely. Would you like to only use cfn-lint to lint CloudFormation templates?' ,
193- ...[ 'yes' , 'no' ] ) ;
194- if ( selection === 'yes' ) {
195- workspace . getConfiguration ( ) . update ( 'cfnLint.validateUsingJsonSchema' , false , ConfigurationTarget . Global ) ;
196- } else if ( selection === 'no' ) {
197- workspace . getConfiguration ( ) . update ( 'cfnLint.validateUsingJsonSchema' , true , ConfigurationTarget . Global ) ;
198- cfnValidateYaml = true ;
199- }
200-
201- }
202- if ( cfnValidateYaml === false ) {
203- workspace . getConfiguration ( ) . update ( 'yaml.validate' , false , ConfigurationTarget . Global ) ;
204- }
205- }
206- }
207-
208145export function deactivate ( ) : Thenable < void > | undefined {
209146 if ( ! languageClient ) {
210147 return undefined ;
0 commit comments