@@ -73,6 +73,8 @@ std::shared_ptr<vscode::InitializeResult> LanguageService::OnInitialize(std::sha
7373 result->capabilities .textDocumentSync .change = vscode::TextDocumentSyncKind::Incremental;
7474 result->capabilities .textDocumentSync .openClose = true ;
7575
76+ LanguageClient::GetInstance ().SetVscodeSettings (param->initializationOptions .vscodeConfig );
77+
7678 result->capabilities .codeActionProvider = true ;
7779 result->capabilities .executeCommandProvider .commands = {
7880 " emmylua.reformat.me" ,
@@ -341,6 +343,11 @@ std::shared_ptr<vscode::CodeActionResult> LanguageService::OnCodeAction(std::sha
341343 auto filePath = url::UrlToFilePath (uri);
342344 auto codeActionResult = std::make_shared<vscode::CodeActionResult>();
343345
346+ if (!LanguageClient::GetInstance ().GetSettings ().autoImport )
347+ {
348+ return codeActionResult;
349+ }
350+
344351 if (LanguageClient::GetInstance ().GetService <CodeFormatService>()->IsDiagnosticRange (filePath, range))
345352 {
346353 auto & action = codeActionResult->actions .emplace_back ();
@@ -493,13 +500,19 @@ std::shared_ptr<vscode::Serializable> LanguageService::OnDidChangeWatchedFiles(
493500
494501std::shared_ptr<vscode::CompletionList> LanguageService::OnCompletion (std::shared_ptr<vscode::CompletionParams> param)
495502{
503+ auto list = std::make_shared<vscode::CompletionList>();
504+
505+ if (!LanguageClient::GetInstance ().GetSettings ().autoImport )
506+ {
507+ return list;
508+ }
509+
496510 auto uri = param->textDocument .uri ;
497511
498512 auto parser = LanguageClient::GetInstance ().GetFileParser (uri);
499513
500514 auto options = LanguageClient::GetInstance ().GetOptions (uri);
501515
502- auto list = std::make_shared<vscode::CompletionList>();
503516 list->isIncomplete = true ;
504517 list->items = LanguageClient::GetInstance ().GetService <CompletionService>()->GetCompletions (
505518 param->textDocument .uri , param->position , parser, options);
0 commit comments