This commit is contained in:
Kenneth Auchenberg 2017-08-24 05:55:48 -07:00
Родитель 4dce97f40f
Коммит 3f8fce4361
11 изменённых файлов: 411 добавлений и 288 удалений

291
.gitignore поставляемый
Просмотреть файл

@ -1,288 +1,3 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
**/Properties/launchSettings.json
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Typescript v1 declaration files
typings/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
out
node_modules
.DS_Store

16
.vscode/launch.json поставляемый Normal file
Просмотреть файл

@ -0,0 +1,16 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceRoot}"
],
"stopOnEntry": false,
"sourceMaps": true
}
]
}

26
.vscode/tasks.json поставляемый Normal file
Просмотреть файл

@ -0,0 +1,26 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "npm",
"isShellCommand": true,
"showOutput": "always",
"suppressTaskName": true,
"tasks": [
{
"taskName": "install",
"args": ["install"]
},
{
"taskName": "update",
"args": ["update"]
},
{
"taskName": "test",
"args": ["run", "test"]
},
{
"taskName": "prelaunchTask"
}
]
}

1
CHANGELOG.md Normal file
Просмотреть файл

@ -0,0 +1 @@
## 1.0.0 - Initial.

72
README.md Normal file
Просмотреть файл

@ -0,0 +1,72 @@
# Sublime Text Keymap for VS Code
This extension ports the most popular Sublime Text keyboard shortcuts to Visual Studio Code. After installing the extension and restarting VS Code your favorite keyboard shortcuts from Sublime Text are now available.
## Changes Introduced in Version 3.0
- Multi cursor editing changed from <kbd>alt</kbd> + click to <kbd>ctrl</kbd> (or <kbd>cmd</kbd>) + click.
- Enable format on paste.
- Change snippet suggestions to be at the top of the completion list.
All of these features make VS Code more "Sublime Text like." The changes to your User Settings file are as followed.
```javascript
// Controls whether the prompt will show
"sublimeTextKeymap.promptV3Features": true,
// Changes the multi cursor mouse binding
"editor.multiCursorModifier": "ctrlCmd",
// Specifies the location of snippets in the suggestion widget
"editor.snippetSuggestions": "top",
// Controls whether format on paste is on or off
"editor.formatOnPaste": true
```
>**Tip:** If you want to see the prompt again simply change `sublimeTextKeymap.promptV3Features` to `false` and restart VS Code.
## What keyboard shortcuts are included?
You can see all the keyboard shortcuts in the extension's contribution list.
![extension contributions](https://raw.githubusercontent.com/Microsoft/vscode-sublime-keybindings/master/contributions_list.png)
## Why don't all Sublime Text commands work?
VS Code has not implemented all features. Head on over to this [GitHub issue](https://github.com/Microsoft/vscode/issues/3776) and let the VS Code team know what you'd like to see.
You can install an extension for many of these features:
* [Expand Selection To Scope](https://marketplace.visualstudio.com/items?itemName=vittorioromeo.expand-selection-to-scope)
* [FontSize Shortcuts](https://marketplace.visualstudio.com/items?itemName=peterjuras.fontsize-shortcuts)
* [change case](https://marketplace.visualstudio.com/items?itemName=wmaurer.change-case)
* [expand-region](https://marketplace.visualstudio.com/items?itemName=letrieu.expand-region)
* [transpose](https://marketplace.visualstudio.com/items?itemName=v4run.transpose)
* [Close HTML/XML tag](https://marketplace.visualstudio.com/items?itemName=Compulim.compulim-vscode-closetag)
## How do I contribute a keyboard shortcut?
We may have missed a keyboard shortcut. If we did please help us out! It is very easy to make a PR.
1. Head over to our [GitHub repository](https://github.com/Microsoft/vscode-sublime-keybindings).
2. Open the [`package.json` file](https://github.com/Microsoft/vscode-sublime-keybindings/blob/master/package.json).
3. Add a JSON object to [`contributes.keybindings`](https://github.com/Microsoft/vscode-sublime-keybindings/blob/master/package.json#L25) as seen below.
4. Open a pull request.
```json
{
"mac": "<keyboard shortcut for mac>",
"linux": "<keyboard shortcut for linux",
"win": "<keyboard shortcut for windows",
"key": "<default keyboard shortcut>",
"command": "<name of the command in VS Code"
}
```
You can read more about how to contribute keybindings in extensions in the [official documentation](http://code.visualstudio.com/docs/extensionAPI/extension-points#_contributeskeybindings).
## License
[MIT](license.txt)

86
extension.js Normal file
Просмотреть файл

@ -0,0 +1,86 @@
const vscode = require('vscode')
const showInformationMessage = vscode.window.showInformationMessage
const Importer = require('./importer')
class Extension {
constructor() {
this.importer = new Importer()
this.messages = {
yes: 'Yes',
no: 'No',
userSettings: 'Do you want to import your User Settings from Sublime Text?',
projectSettings: 'Do you want to import your Project Settings from Sublime Text?',
snippets: 'Do you want to import your Snippets from Sublime?',
finished: 'Import finished. We found',
skipped: 'Import skipped.'
}
}
start() {
var jobs = []
Promise.all([
showInformationMessage(this.messages.userSettings, this.messages.yes, this.messages.no),
showInformationMessage(this.messages.projectSettings, this.messages.yes, this.messages.no),
showInformationMessage(this.messages.snippets, this.messages.yes, this.messages.no)
]).then((data) => {
let user = data[0]
let project = data[1]
let snippets = data[2]
if (user === this.messages.yes) {
jobs.push(this.importer.importGlobalsettings())
}
if (project === this.messages.yes) {
jobs.push(this.importer.importProjectsettings())
}
if (snippets === this.messages.yes) {
jobs.push(this.importer.importSnippets())
}
if(jobs.length) {
Promise.all(jobs).then((stats) => {
let snippestStats = stats.find((s) => s.type == 'snippets')
let globalStats = stats.find((s) => s.type == 'global')
let projectStats = stats.find((s) => s.type == 'project')
var text = [this.messages.finished]
if(snippestStats) {
text.push(`${snippestStats.count} snippets,`)
}
if(globalStats) {
text.push(`${globalStats.count} Global settings,`)
}
if(projectStats) {
text.push(`${projectStats.count} Project settings`)
}
showInformationMessage(text.join(' '))
})
} else {
showInformationMessage(this.messages.skipped)
}
})
}
}
const activate = (context) => {
var cmd = vscode.commands.registerCommand('extension.importFromSublime', function (e) {
new Extension().start()
})
context.subscriptions.push(cmd)
}
module.exports = {
activate
};

Двоичные данные
icon.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.7 KiB

71
importer.js Normal file
Просмотреть файл

@ -0,0 +1,71 @@
const fs = require('fs')
const vscode = require('vscode')
var rjson = require('relaxed-json');
function updateSettings(editorConfig, settings) {
settings.forEach((setting) => {
editorConfig.update(setting.name, setting.value, isGlobalConfigValue)
});
}
class Setting {
constructor(name, value) {
this.name = name
this.value = value
}
}
const versionThreeSettings = [
new Setting('multiCursorModifier', 'ctrlCmd'),
new Setting('snippetSuggestions', 'top'),
new Setting('formatOnPaste', true)
];
class Importer {
constructor() {
}
importSnippets() {
console.log('importSnippets')
return Promise.resolve({
type: 'snippets',
count: 1
})
}
importGlobalsettings() {
console.log('importGlobalsettings')
var path = '/Users/auchenberg/Library/Application Support/Sublime Text 3/Packages/User/Preferences.sublime-settings'
return new Promise((resolve, reject) => {
fs.readFile(path, (err, data) => {
if (err) {
reject(err)
} else {
var json = rjson.parse(data.toString())
console.log(json)
resolve({
type: 'global',
count: 33
})
}
})
})
}
importProjectsettings() {
console.log('importProjectsettings')
return Promise.resolve({
type: 'project',
count: 3
})
}
}
module.exports = Importer;

17
license.txt Normal file
Просмотреть файл

@ -0,0 +1,17 @@
Copyright (c) Microsoft Corporation
All rights reserved.
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

70
package-lock.json сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,70 @@
{
"name": "vscode-sublime-importer",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"ansi-regex": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8="
},
"ansi-styles": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz",
"integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4="
},
"chalk": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
"integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
"requires": {
"ansi-styles": "2.2.1",
"escape-string-regexp": "1.0.5",
"has-ansi": "2.0.0",
"strip-ansi": "3.0.1",
"supports-color": "2.0.0"
}
},
"commander": {
"version": "2.11.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz",
"integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ=="
},
"escape-string-regexp": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ="
},
"has-ansi": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz",
"integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=",
"requires": {
"ansi-regex": "2.1.1"
}
},
"relaxed-json": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/relaxed-json/-/relaxed-json-1.0.1.tgz",
"integrity": "sha1-fI1KovCVcEzQIOMugJm8rhA/C9Q=",
"requires": {
"chalk": "1.1.3",
"commander": "2.11.0"
}
},
"strip-ansi": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
"requires": {
"ansi-regex": "2.1.1"
}
},
"supports-color": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz",
"integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc="
}
}
}

49
package.json Normal file
Просмотреть файл

@ -0,0 +1,49 @@
{
"name": "vscode-sublime-importer",
"displayName": "Import Sublime Text settings to VS Code",
"description": "Import Sublime Text settings to VS Code.",
"version": "1.0.0",
"publisher": "ms-vscode",
"engines": {
"vscode": "^1.6.0"
},
"categories": [
"import"
],
"keywords": [
"Importer",
"Sublime Text"
],
"activationEvents": [
"*",
"onCommand:extension.importFromSublime"
],
"contributes": {
"commands": [
{
"command": "extension.importFromSublime",
"title": "Import Sublime Text settings"
}
]
},
"main": "./extension",
"preview": false,
"icon": "icon.png",
"repository": {
"type": "git",
"url": "https://github.com/Microsoft/vscode-sublime-importer.git"
},
"bugs": {
"url": "https://github.com/Microsoft/vscode-sublime-importer/issues"
},
"scripts": {
"postinstall": "node ./node_modules/vscode/bin/install"
},
"devDependencies": {
"vscode": "^1.0.3",
"typescript": "^2.0.3"
},
"dependencies": {
"relaxed-json": "^1.0.1"
}
}