feat(vscode): get vscode installed and configured

This commit is contained in:
Ade Attwood 2020-09-20 10:32:02 +01:00
parent 80239af169
commit 01d6024067
9 changed files with 731 additions and 0 deletions

View file

@ -22,4 +22,5 @@ node default {
include core::ssh
include core::tmux
include core::fonts
include core::vscode
}

View file

@ -0,0 +1,92 @@
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "capslock",
"command": "extension.vim_escape",
"when": "editorTextFocus && vim.active && !inDebugRepl"
},
{
"key": "f2",
"command": "workbench.action.tasks.runTask",
"args": "Build"
},
{
"key": "f3",
"command": "workbench.action.tasks.runTask",
"args": "Test"
},
{
"key": "f4",
"command": "workbench.action.tasks.runTask",
"args": "Test File"
},
{
"key": "ctrl+h",
"command": "workbench.action.focusNextGroup"
},
{
"key": "ctrl+k ctrl+right",
"command": "-workbench.action.focusNextGroup"
},
{
"key": "ctrl+l",
"command": "workbench.action.focusPreviousGroup"
},
{
"key": "ctrl+k ctrl+left",
"command": "-workbench.action.focusPreviousGroup"
},
{
"key": "ctrl+o",
"command": "workbench.action.toggleSidebarVisibility"
},
{
"key": "ctrl+b",
"command": "-workbench.action.toggleSidebarVisibility"
},
{
"key": "ctrl+k left",
"command": "workbench.action.moveActiveEditorGroupLeft"
},
{
"key": "ctrl+k left",
"command": "-workbench.action.moveActiveEditorGroupLeft"
},
{
"key": "ctrl+i",
"command": "workbench.action.quickOpenNavigatePreviousInEditorPicker",
"when": "inEditorsPicker && inQuickOpen"
},
{
"key": "ctrl+shift+tab",
"command": "-workbench.action.quickOpenNavigatePreviousInEditorPicker",
"when": "inEditorsPicker && inQuickOpen"
},
{
"key": "ctrl+i",
"command": "workbench.action.openPreviousRecentlyUsedEditorInGroup"
},
{
"key": "ctrl+shift+tab",
"command": "-workbench.action.openPreviousRecentlyUsedEditorInGroup"
},
{
"key": "ctrl+i",
"command": "workbench.action.openNextRecentlyUsedEditorInGroup"
},
{
"key": "ctrl+tab",
"command": "-workbench.action.openNextRecentlyUsedEditorInGroup"
},
{
"key": "ctrl+i",
"command": "workbench.action.quickOpenNavigateNextInEditorPicker",
"when": "inEditorsPicker && inQuickOpen"
},
{
"key": "ctrl+tab",
"command": "-workbench.action.quickOpenNavigateNextInEditorPicker",
"when": "inEditorsPicker && inQuickOpen"
}
]

View file

@ -0,0 +1,245 @@
{
"telemetry.enableTelemetry": false,
// Window
"window.zoomLevel": 1,
"window.menuBarVisibility": "default",
// Workbench
"workbench.sideBar.location": "left",
"workbench.iconTheme": null,
"workbench.activityBar.visible": true,
"workbench.statusBar.visible": true,
"workbench.colorTheme": "Base16 Dark Ocean",
"workbench.panel.location": "right",
// Editor
"editor.tabCompletion": true,
"editor.insertSpaces": true,
"editor.tabSize": 4,
"editor.fontSize": 14,
"editor.fontFamily": "'LigaFreeMono', Hasklig ,'JetBrains Mono', monospace, 'Droid Sans Fallback'",
"editor.minimap.enabled": false,
"editor.lineNumbers": "relative",
"editor.rulers": [
80,
120
],
"terminal.integrated.fontFamily": "'LigaFreeMono' ,monospace, 'Droid Sans Fallback'",
"terminal.integrated.fontSize": 14,
"php.suggest.basic": false,
"diffEditor.ignoreTrimWhitespace": false,
"files.trimTrailingWhitespace": true,
"vscode-neovim.neovimPath": "/usr/bin/nvim",
// Vim plugin
"vim.autoindent": true,
"vim.easymotionMarkerYOffset": 25,
"vim.hlsearch": true,
"vim.useCtrlKeys": true,
"vim.useSystemClipboard": true,
"vim.visualstar": true,
"vim.insertModeKeyBindings": [
{
"before": [
"j",
"j"
],
"after": [
"<Esc>"
]
}
],
"files.exclude": {
"**/.git": true,
"**/.vagrant": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true
},
"search.exclude": {
"**/node_modules": true,
"**/bower_components": true,
"**/vendor": true,
"**/vendor/revo": false,
"**/vendor/adeattwood": false,
"**/runtime": true
},
"git.enableSmartCommit": false,
"git.confirmSync": false,
"git.autofetch": false,
"phpcs.standard": "~/vscode/ruleset.xml",
"phpcs.showSources": true,
"cSpell.language": "en-GB",
"cSpell.userWords": [
"Analytics",
"Arobaze",
"Attwood",
"Battledown",
"CKEDITOR",
"Cest",
"Citu",
"Divs",
"Inflector",
"Init's",
"Metas",
"Pjax",
"Polyfill",
"Toggler",
"Unavailabilities",
"Vars",
"Winchcombe",
"aalert",
"adeattwood",
"admin",
"afterbegin",
"afterend",
"autoload",
"beforebegin",
"beforeend",
"behaviors",
"bootbox",
"canceled",
"cardless",
"cleanup",
"codeception",
"codesniffer",
"csrf",
"dont",
"dotfiles",
"edofre",
"endforeach",
"esac",
"filebrowser",
"fullcalendar",
"gitlab",
"httponly",
"inbox",
"incase",
"isdir",
"itemprop",
"jira",
"kartik",
"mkdir",
"multipart",
"nochex",
"nofollow",
"passphrase",
"paypal",
"phpunit",
"placeholder",
"rbac",
"reactstrap",
"readlink",
"revo",
"richtext",
"sagepay",
"sars",
"setuptools",
"sitemap",
"squizlabs",
"titleize",
"todos",
"ukmg",
"unclaim",
"webroot",
"yiisoft"
],
"extensions.ignoreRecommendations": false,
"gitProjectManager.baseProjectsFolders": [
"~/development",
"~/sites"
],
"gitProjectManager.storeRepositoriesBetweenSessions": true,
"gitProjectManager.ignoredFolders": [
"node-modules",
"vendor"
],
"gitlens.keymap": "alternate",
"gitlens.gitExplorer.files.layout": "tree",
"gitlens.codeLens.enabled": false,
"gitlens.historyExplorer.enabled": true,
"gitlens.advanced.messages": {
"suppressCommitHasNoPreviousCommitWarning": false,
"suppressCommitNotFoundWarning": false,
"suppressFileNotUnderSourceControlWarning": false,
"suppressGitVersionWarning": false,
"suppressLineUncommittedWarning": false,
"suppressNoRepositoryWarning": false,
"suppressResultsExplorerNotice": false,
"suppressShowKeyBindingsNotice": true,
"suppressUpdateNotice": true,
"suppressWelcomeNotice": true
},
"cSpell.enabledLanguageIds": [
"asciidoc",
"c",
"cpp",
"csharp",
"css",
"go",
"handlebars",
"html",
"jade",
"javascript",
"javascriptreact",
"json",
"latex",
"less",
"markdown",
"php",
"plaintext",
"pub",
"puppet",
"python",
"restructuredtext",
"rust",
"scss",
"shellscript",
"text",
"typescript",
"typescriptreact",
"yml"
],
"[php]": {
"editor.formatOnSave": false
},
"prettier.singleQuote": true,
"prettier.tabWidth": 4,
"files.associations": {
"Vagrantfile*": "ruby",
"*rc": "shellscript"
},
"go.formatTool": "goimports",
"editor.fontLigatures": true,
"cSpell.enableFiletypes": [
"diff",
"dockerfile",
"dotenv",
"erb",
"git-commit",
"helm",
"ini",
"makefile",
"mjml",
"puppetfile",
"ruby",
"toml",
"yaml"
],
"javascript.updateImportsOnFileMove.enabled": "never",
"dart.flutterSdkPath": "/home/ade/development/flutter",
"C_Cpp.clang_format_sortIncludes": true,
"cmake.configureArgs": [
"-DCMAKE_TOOLCHAIN_FILE=/home/ade/development/vcpkg/scripts/buildsystems/vcpkg.cmake"
],
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"vs-kubernetes": {
"vs-kubernetes.knownKubeconfigs": [
"/home/ade/.kube/zion-config.yaml"
],
"vs-kubernetes.kubeconfig": "/home/ade/.kube/zion-config.yaml"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}

View file

@ -0,0 +1,41 @@
{
"Php Tag": {
"prefix": "php",
"body": ["<?php ${1:code} ?>"],
"description": "Php Tag"
},
"Php Echo Tag": {
"prefix": "phpe",
"body": ["<?= ${1:code} ?>"],
"description": "Php echo tag"
},
"PHP if": {
"prefix": "phpif",
"body": [
"<?php if (${1:condition}) { ?>",
"\t${0:// Code ....}",
"<?php } ?>"
],
"description": ""
},
"PHP if else": {
"prefix": "phpife",
"body": [
"<?php if (${1:condition}) { ?>",
"\t${1: // Code....}",
"<?php else: ?>",
"\t${0:// Code ....}",
"<?php } ?>"
],
"description": ""
},
"PHP Foreach": {
"prefix": "phpfe",
"body": [
"<?php foreach (${1:variable} as ${2:key} => ${3:value}) { ?>",
"\t${0: // Code ....}",
"<?php } ?>"
],
"description": ""
}
}

View file

@ -0,0 +1,33 @@
{
"Create react functional component": {
"prefix": "rfc",
"body": ["export const ${1:Component} = ($2) => {", "\t$0", "};"]
},
"Create react class component": {
"prefix": "rc",
"body": [
"export class ${1:Component} extends React.Component {",
"",
"\tstatic propTypes = {",
"\t\t${2}",
"\t};",
"",
"\tconstructor(props) {",
"\t\tsuper(props);$3",
"\t}",
"",
"\trender() {",
"\t\treturn (",
"\t\t\t$0",
"\t\t);",
"\t}",
"",
"}"
]
},
"Jest Test": {
"prefix": "test",
"body": ["test('${1:Description}', () => {$0});"],
"description": "Create a jest test"
}
}

View file

@ -0,0 +1,226 @@
{
"Var Doc": {
"prefix": "var",
"body": ["/** @var ${1:var} ${2:type} ${0:comment} */"],
"description": "Renders a php var doc comment"
},
"Arrow": {
"prefix": "-",
"body": ["->$0"],
"description": "completes arraw"
},
"Equals": {
"prefix": "=",
"body": ["=>$0"],
"description": "completes equals"
},
"This": {
"prefix": "$",
"body": ["\\$this->${0:code}"],
"description": "php this"
},
"Array Item": {
"prefix": "ai",
"body": ["'${1:key}' => ${0:value},"],
"description": "Creates an array item"
},
"New": {
"prefix": "new",
"body": ["$${1:var} = new ${2:Class}($0);"]
},
"Public Function": {
"prefix": "pub",
"body": [
"public function ${1:name}(${2:$param})",
"{",
"\t${0://code......}",
"}"
],
"description": "Creates public function"
},
"Protected Function": {
"prefix": "pro",
"body": [
"protected function ${1:name}(${2:$param})",
"{",
"\t${0://code......}",
"}"
],
"description": "Creates protected function"
},
"Private Function": {
"prefix": "pri",
"body": [
"private function ${1:name}(${2:$param})",
"{",
"\t${0://code......}",
"}"
],
"description": "Creates private function"
},
"Public Static Function": {
"prefix": "pubs",
"body": [
"public static function ${1:name}(${2:$param})",
"{",
"\t${0://code......}",
"}"
],
"description": "Creates public static function"
},
"Protected Static Function": {
"prefix": "pros",
"body": [
"protected static function ${1:name}(${2:$param})",
"{",
"\t${0://code......}",
"}"
],
"description": "Creates protected static function"
},
"Private Static Function": {
"prefix": "pris",
"body": [
"private static function ${1:name}(${2:$param})",
"{",
"\t${0://code......}",
"}"
],
"description": "Creates private static function"
},
"Codeception unit test": {
"prefix": "cutest",
"body": [
"public function ${1:name}(UnitTester \\$I)",
"{",
"\t${0://code......}",
"}"
],
"description": "Codeception unit test"
},
"Codeception functional test": {
"prefix": "cftest",
"body": [
"public function ${1:name}(FunctionalTester \\$I)",
"{",
"\t${0://code......}",
"}"
],
"description": "Codeception functional test"
},
"Codeception acceptance test": {
"prefix": "catest",
"body": [
"public function ${1:name}(AcceptanceTester \\$I)",
"{",
"\t${0://code......}",
"}"
],
"description": "Codeception acceptance test"
},
"DD": {
"prefix": "dd",
"body": ["echo '<pre>' . var_dump($0) . '</pre>';die;"],
"description": "Dump die stright php"
},
"Dump": {
"prefix": "dump",
"body": ["dump(${0:var});"],
"description": "Dump a var"
},
"Dump Die": {
"prefix": "dumpd",
"body": ["dump(${0:var});die;"],
"description": "Dump a var"
},
"Dump Die Revo": {
"prefix": "rdd",
"body": ["\\revo\\Revo::dieVar(${0:var});"],
"description": "Revo die var"
},
"Yii Action": {
"prefix": "yii-action",
"body": [
"/**",
" * Undocumented action",
" *",
" * @return yii\\web\\View",
" */",
"public function action${1:name}(${2:$param})",
"{",
"\t${0://code......}",
"}"
],
"description": "Creates public function"
},
"Yii2 After Save": {
"prefix": "yii-after-save",
"body": [
" /**",
" * This method is called at the end of inserting or updating a record.",
" * ",
" * @param bool $insert Whether this method called while inserting or updating a record.",
" * @param array $changedAttributes The old values of attributes that had changed and were saved.",
" * ",
" * @return void",
" */",
" public function afterSave($insert, $changedAttributes)",
" {",
" return parent::afterSave();",
" }"
],
"description": "Yii2 after save funcion for a activerecord"
},
"Create Var Doc": {
"prefix": "var-doc",
"body": [
"echo '<pre>';",
"\\$_type = gettype(\\$this) == 'object' ? get_class(\\$this) : gettype(\\$this);",
"echo \"/** @var \\\\\\$this \\$_type */\\n\";",
"foreach(get_defined_vars() as \\$name => \\$var) {",
" if (substr(\\$name, 0, strlen('_')) !== '_' && \\$name !== 'this') {",
" if (is_array(\\$var) && isset(\\$var[0]) && gettype(\\$var[0]) == 'object') {",
" \\$type = get_class(\\$var[0]);",
" echo \"/** @var \\\\$\\$name {\\$type}[] */\\n\";",
" continue;",
" }",
" \\$type = gettype(\\$var) == 'object' ? get_class(\\$var) : gettype(\\$var);",
" echo \"/** @var \\\\$\\$name \\$type */\\n\";",
" }",
"}",
"echo \"</pre>\";",
"die;"
],
"description": "Creates a var doc from the defied vars"
},
"Create var doc for vscode": {
"prefix": "var-doc-code",
"body": [
"echo '<pre>';",
"echo '/**'.PHP_EOL;",
"echo ' *'.PHP_EOL;",
"\\$_type = gettype(\\$this) == 'object' ? get_class(\\$this) : gettype(\\$this);",
"echo \" * @var \\$_type \\\\\\$this\\n\";",
"foreach(get_defined_vars() as \\$name => \\$var) {",
" if (substr(\\$name, 0, strlen('_')) !== '_' && \\$name !== 'this') {",
" if (is_array(\\$var) && isset(\\$var[0]) && gettype(\\$var[0]) == 'object') {",
" \\$type = get_class(\\$var[0]);",
" echo \" * @var {\\$type}[] \\\\$\\$name\\n\";",
" continue;",
" }",
" \\$type = gettype(\\$var) == 'object' ? get_class(\\$var) : gettype(\\$var);",
" echo \" * @var \\$type \\\\$\\$name\\n\";",
" }",
"}",
"echo ' */'.PHP_EOL;",
"echo \"</pre>\";",
"die;"
],
"description": "Creates a var doc from the defied vars"
},
"Return Array": {
"prefix": "returna",
"body": ["return [", "\t${0}", "];"],
"description": ""
}
}

View file

@ -0,0 +1,45 @@
class core::vscode {
file { [
"${user_home}/.config/Code",
"${user_home}/.config/Code/User",
]:
ensure => 'directory',
}
vscode::extention { [
'adamwalzer.string-converter',
'andrsdc.base16-themes',
'bmewburn.vscode-intelephense-client',
'christian-kohler.path-intellisense',
'donjayamanne.githistory',
'eamodio.gitlens',
'ikappas.phpcs',
'jpogran.puppet-vscode',
'neilbrayfield.php-docblocker',
'ms-azuretools.vscode-docker',
'stkb.rewrap',
'streetsidesoftware.code-spell-checker',
'uriberman.colonizer',
'vscodevim.vim',
]: }
file { "${user_home}/.config/Code/User/settings.json":
ensure => 'link',
force => true,
target => find_file('core/vscode/settings.json'),
}
file { "${user_home}/.config/Code/User/keybindings.json":
ensure => 'link',
force => true,
target => find_file('core/vscode/keybindings.json'),
}
file { "${user_home}/.config/Code/User/snippets":
ensure => 'link',
force => true,
target => find_file('core/vscode/snippets'),
}
}

View file

@ -0,0 +1,7 @@
define vscode::extention {
exec { "code_install_${title}":
command => "code --install-extension ${title}",
path => '/usr/bin:/usr/local/bin:/usr/sbin:/bin',
provider => shell,
}
}

View file

@ -0,0 +1,41 @@
class vscode {
archive { '/tmp/microsoft.asc':
ensure => present,
source => 'https://packages.microsoft.com/keys/microsoft.asc',
}
exec { 'gpg --dearmor /tmp/microsoft.asc':
path => ['/usr/bin', '/usr/sbin',],
creates => '/tmp/microsoft.asc.gpg',
require => [
Archive['/tmp/microsoft.asc'],
]
}
file { '/etc/apt/trusted.gpg.d/microsoft.gpg':
ensure => present,
source => 'file:///tmp/microsoft.asc.gpg',
require => [
Exec['gpg --dearmor /tmp/microsoft.asc'],
]
}
apt::source { 'vscode':
comment => 'This is the official VSCode repository',
location => 'https://packages.microsoft.com/repos/vscode',
architecture => 'amd64',
release => 'stable',
repos => 'main',
include => {
'deb' => true,
},
}
package { 'code':
ensure => installed,
require => [
Apt::Source['vscode'],
],
}
}