Skip to content

Add new "files.defaultLanguage" configuration setting#23220

Merged
bpasero merged 3 commits intomicrosoft:masterfrom
daviwil:default-language-config
Mar 27, 2017
Merged

Add new "files.defaultLanguage" configuration setting#23220
bpasero merged 3 commits intomicrosoft:masterfrom
daviwil:default-language-config

Conversation

@daviwil
Copy link
Contributor

@daviwil daviwil commented Mar 25, 2017

This change adds a new configuration setting that sets the default
language mode of new untitled files created with Ctrl+N
(workbench.action.files.newUntitledFile). This activates the user's
desired language mode when a new untitled file is created.

Fixes #8729.

@mention-bot
Copy link

@daviwil, thanks for your PR! By analyzing the history of the files in this pull request, we identified @bpasero and @egamma to be potential reviewers.

@daviwil
Copy link
Contributor Author

daviwil commented Mar 25, 2017

Happy to add or change anything you like!

@bpasero bpasero self-assigned this Mar 25, 2017
Copy link
Member

@bpasero bpasero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@daviwil Good start, some feedback provided 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to not add this to the action but actually to the place where untitled editors are being created. There can be other ways how untitled buffers open (e.g. from extensions) and I think a configured default language would also apply there.

I am thinking somewhere inside https://github.com/Microsoft/vscode/blob/master/src/vs/workbench/services/untitled/common/untitledEditorService.ts#L177 to use the configuration if the modeId parameter is undefined.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do have an extension running that provides intellisense inside settings. For this setting I would like to see the list of language Ids when the user wants to quickly select a known language. The place to add this is here: https://github.com/Microsoft/vscode/blob/master/extensions/configuration-editing/src/settingsDocumentHelper.ts#L26

This change adds a new configuration setting that sets the default
language mode of new untitled files created with Ctrl+N
(workbench.action.files.newUntitledFile).  This activates the user's
desired language mode when a new untitled file is created.

Fixes microsoft#8729.
@daviwil daviwil force-pushed the default-language-config branch from 39afece to dfa42af Compare March 26, 2017 18:05
@daviwil
Copy link
Contributor Author

daviwil commented Mar 26, 2017

Thanks Ben! Fixed the things you requested. Here's a GIF of the language mode IntelliSense:

fad29b7a-9d65-4414-b645-f9e3ce352cd6

Copy link
Member

@bpasero bpasero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Can we get a test for this into here?

return Promise.resolve([]);
}

private provideDefaultLanguageCompletionItems(location: Location, range: vscode.Range): vscode.ProviderResult<vscode.CompletionItem[]> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this method reused between the two clients calling vscode.languages.getLanguages here, it seems there is quite a bit of overlap

@daviwil
Copy link
Contributor Author

daviwil commented Mar 27, 2017

Hey Ben, I'm having a little trouble getting the modeId back out of the created untitled file in my unit tests. Take a look at this line:

0e19b7e#diff-f8147d00dccdef1240768b7b2812a1c9R145

Because no languages have been registered with the IModeService, model.getModeId() always returns plaintext at this point. It looks like IModeService isn't being mocked and I haven't found any examples of it being done elsewhere in the tests. Any recommendation on what I can do to make the model's mode validate correctly here?

@bpasero bpasero merged commit 1e99dc2 into microsoft:master Mar 27, 2017
@bpasero
Copy link
Member

bpasero commented Mar 27, 2017

@daviwil awesome, I took care of the tests via d5501a7

@bpasero bpasero added this to the March 2017 milestone Mar 27, 2017
@daviwil
Copy link
Contributor Author

daviwil commented Mar 27, 2017

Sweet, thanks a lot!

@APraestegaard
Copy link

Thank you for this nifty feature - really appreciated!

@daviwil daviwil deleted the default-language-config branch April 6, 2017 14:25
@ShalokShalom
Copy link

ShalokShalom commented Oct 11, 2017

Is there anything to do in order to get this IntelliSense working?

screenshot_20171011_142411

@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default language mode when new file opened

6 participants