Skip to content

Instantly share code, notes, and snippets.

@mkuchak
Last active June 11, 2024 21:50
Show Gist options
  • Save mkuchak/cea5c4b7029de0361e9092bc040527d6 to your computer and use it in GitHub Desktop.
Save mkuchak/cea5c4b7029de0361e9092bc040527d6 to your computer and use it in GitHub Desktop.
Backup of VSCode settings
/*
* Ctrl+Shift+P > snippets > Preferences: Configure User Snippets (or add global)
* clean.code-snippets.json
*/
{
"Clean Architecture Controller": {
"prefix": "cleanController",
"body": [
"import { Request, Response } from 'express'",
"",
"class ${TM_FILENAME_BASE/(.)/${1:/capitalize}/} {",
" async handle (request: Request, response: Response): Promise<Response> {",
" const data = {",
" ...request.body,$1",
" ...request.params,",
" ...request.query,",
" ...request.headers,",
" ...request.cookies,",
" }",
"",
" const payload = {}",
"",
" return response.status(200).json(payload)",
" }",
"}",
"",
"export { ${TM_FILENAME_BASE/(.)/${1:/capitalize}/} }",
""
],
"description": "Clean Architecture Controller"
},
"Clean Architecture Use Case": {
"prefix": "cleanUseCase",
"body": [
"interface IRequest {}",
"",
"class ${TM_FILENAME_BASE/(.)/${1:/capitalize}/} {",
" constructor () {}",
"",
" async execute (data: IRequest): Promise<void> {",
" $1",
" }",
"}",
"",
"export { ${TM_FILENAME_BASE/(.)/${1:/capitalize}/} }",
""
],
"description": "Clean Architecture Use Case"
},
"Clean Architecture Repository": {
"prefix": "cleanRepository",
"body": [
"class ${TM_FILENAME_BASE/(.)/${1:/capitalize}/} implements I${TM_FILENAME_BASE/([A-Z]*[a-z]*$)//g}Repository {",
" constructor () {}",
"",
" async create (${TM_FILENAME_BASE/(.*)[A-Z][a-z]*/${1:/downcase}/}: ICreate${TM_FILENAME_BASE/([A-Z]*[a-z]*$)//g}DTO): Promise<number> {",
" $0",
" }",
"",
" // async findById (id: number): Promise<${TM_FILENAME_BASE/([A-Z]*[a-z]*$)//g}> {}",
"}",
"",
"export { ${TM_FILENAME_BASE/(.)/${1:/capitalize}/} }",
""
],
"description": "Clean Architecture Repository"
}
}
# To export the Visual Studio Code extension list, run
code --list-extensions | xargs -L 1 echo code --install-extension
# To install, just open or copy and paste to run on terminal
code --install-extension adpyke.vscode-sql-formatter &&
code --install-extension anseki.vscode-color &&
code --install-extension BeardedBear.beardedicons &&
code --install-extension BeardedBear.beardedtheme &&
code --install-extension bradlc.vscode-tailwindcss &&
code --install-extension ChakrounAnas.turbo-console-log &&
code --install-extension christian-kohler.npm-intellisense &&
code --install-extension christian-kohler.path-intellisense &&
code --install-extension clinyong.vscode-css-modules &&
code --install-extension csstools.postcss &&
code --install-extension dannyconnell.split-html-attributes &&
code --install-extension dbaeumer.vscode-eslint &&
code --install-extension DominicVonk.parameter-hints &&
code --install-extension donjayamanne.githistory &&
code --install-extension dzhavat.bracket-pair-toggler &&
code --install-extension eamodio.gitlens &&
code --install-extension EditorConfig.EditorConfig &&
code --install-extension esbenp.prettier-vscode &&
code --install-extension formulahendry.auto-close-tag &&
code --install-extension formulahendry.auto-rename-tag &&
code --install-extension foxundermoon.shell-format &&
code --install-extension GitHub.copilot &&
code --install-extension GitHub.copilot-chat &&
code --install-extension golang.go &&
code --install-extension GraphQL.vscode-graphql &&
code --install-extension GraphQL.vscode-graphql-execution &&
code --install-extension GraphQL.vscode-graphql-syntax &&
code --install-extension Gruntfuggly.todo-tree &&
code --install-extension humao.rest-client &&
code --install-extension Ionic.ionic &&
code --install-extension jrebocho.vscode-random &&
code --install-extension kamikillerto.vscode-colorize &&
code --install-extension kettanaito.nako &&
code --install-extension lokalise.i18n-ally &&
code --install-extension MarkThomasMiller.sorcerer &&
code --install-extension MaxvanderSchee.web-accessibility &&
code --install-extension mechatroner.rainbow-csv &&
code --install-extension meganrogge.template-string-converter &&
code --install-extension mikestead.dotenv &&
code --install-extension mintlify.document &&
code --install-extension moshfeu.compare-folders &&
code --install-extension ms-azuretools.vscode-docker &&
code --install-extension ms-python.python &&
code --install-extension ms-python.vscode-pylance &&
code --install-extension ms-vscode-remote.remote-containers &&
code --install-extension ms-vscode-remote.remote-ssh &&
code --install-extension ms-vscode-remote.remote-ssh-edit &&
code --install-extension ms-vscode-remote.remote-wsl &&
code --install-extension ms-vscode.remote-explorer &&
code --install-extension ms-vscode.vscode-typescript-next &&
code --install-extension mtxr.sqltools &&
code --install-extension natqe.reload &&
code --install-extension naumovs.color-highlight &&
code --install-extension octref.vetur &&
code --install-extension patbenatar.advanced-new-file &&
code --install-extension pepri.subtitles-editor &&
code --install-extension PKief.material-icon-theme &&
code --install-extension planbcoding.vscode-react-refactor &&
code --install-extension plex.vscode-protolint &&
code --install-extension Prisma.prisma &&
code --install-extension rangav.vscode-thunder-client &&
code --install-extension ritwickdey.LiveServer &&
code --install-extension RobertOstermann.inline-parameters-extended &&
code --install-extension rubberduck.rubberduck-vscode &&
code --install-extension ryuta46.multi-command &&
code --install-extension silvenon.mdx &&
code --install-extension steoates.autoimport &&
code --install-extension streetsidesoftware.code-spell-checker &&
code --install-extension streetsidesoftware.code-spell-checker-portuguese-brazilian &&
code --install-extension styled-components.vscode-styled-components &&
code --install-extension tamasfe.even-better-toml &&
code --install-extension vadistic.mdx-inline &&
code --install-extension Vue.volar &&
code --install-extension WallabyJs.console-ninja &&
code --install-extension wix.vscode-import-cost &&
code --install-extension YoavBls.pretty-ts-errors &&
code --install-extension yzhang.markdown-all-in-one &&
code --install-extension zxh404.vscode-proto3
/*
* Ctrl+Shift+P > shortcuts
* Preferences: Open Keyboard Shortcuts (JSON)
*/
[
// Move the cursor and select between CamelCase words
{
"key": "alt+right",
"command": "cursorWordPartRight",
"when": "editorTextFocus"
},
{
"key": "alt+left",
"command": "cursorWordPartLeft",
"when": "editorTextFocus"
},
{
"key": "alt+shift+right",
"command": "cursorWordPartRightSelect",
"when": "editorTextFocus"
},
{
"key": "alt+shift+left",
"command": "cursorWordPartLeftSelect",
"when": "editorTextFocus"
},
// Delete the rest of the word forward or backward
{
"key": "alt+delete",
"command": "deleteWordRight",
"when": "textInputFocus && !editorReadonly"
},
{
"key": "alt+backspace",
"command": "deleteWordLeft",
"when": "textInputFocus && !editorReadonly"
},
// Reverse the order of the lines
{
"key": "ctrl+shift+up",
"command": "editor.action.moveLinesUpAction",
"when": "editorTextFocus"
},
{
"key": "ctrl+shift+down",
"command": "editor.action.moveLinesDownAction",
"when": "editorTextFocus"
},
// Search for sentences equal to the current selection
{
"key": "ctrl+shift+d",
"command": "editor.action.addSelectionToNextFindMatch",
"when": "editorFocus"
},
// Duplicate current line with just one shortcut
{
"key": "ctrl+d",
"command": "editor.action.copyLinesDownAction",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+d",
"command": "-editor.action.addSelectionToNextFindMatch",
"when": "editorFocus"
},
{
"key": "shift+alt+up",
"command": "-editor.action.copyLinesUpAction",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "shift+alt+down",
"command": "-editor.action.copyLinesDownAction",
"when": "editorTextFocus && !editorReadonly"
},
// Change the programming language of the current file
{
"key": "ctrl+j",
"command": "workbench.action.editor.changeLanguageMode",
"when": "textInputFocus && !editorReadonly"
},
{
"key": "ctrl+j",
"command": "-workbench.action.togglePanel"
},
// Select up and down, vertically
{
"key": "ctrl+alt+down",
"command": "cursorColumnSelectDown",
"when": "textInputFocus"
},
{
"key": "ctrl+alt+up",
"command": "cursorColumnSelectUp",
"when": "textInputFocus"
},
// Create a block comment in the selected part like /* some selected part */
{
"key": "ctrl+shift+/",
"command": "editor.action.blockComment",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+shift+;",
"command": "editor.action.blockComment",
"when": "editorTextFocus && !editorReadonly"
},
// Comment on selected lines
{
"key": "ctrl+/",
"command": "editor.action.commentLine",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+;",
"command": "editor.action.commentLine",
"when": "editorTextFocus && !editorReadonly"
},
// Delete the line without copying to the clipboard
{
"key": "ctrl+shift+x",
"command": "editor.action.deleteLines",
"when": "textInputFocus && !editorReadonly"
},
{
"key": "ctrl+shift+k",
"command": "-editor.action.deleteLines",
"when": "textInputFocus && !editorReadonly"
},
// Move the current tab to the right or to the left
{
"key": "ctrl+alt+right",
"command": "workbench.action.moveEditorRightInGroup",
"when": "editorTextFocus"
},
{
"key": "alt+right",
"command": "-workbench.action.terminal.focusNextPane",
"when": "terminalFocus"
},
{
"key": "ctrl+alt+left",
"command": "workbench.action.moveEditorLeftInGroup",
"when": "editorTextFocus"
},
{
"key": "alt+left",
"command": "-workbench.action.terminal.focusPreviousPane",
"when": "terminalFocus"
},
// Move the tab to a different screen split, whether left, right, up, or down
{
"key": "ctrl+shift+alt+up",
"command": "workbench.action.moveEditorToAboveGroup",
"when": "editorTextFocus"
},
{
"key": "ctrl+shift+alt+down",
"command": "workbench.action.moveEditorToBelowGroup",
"when": "editorTextFocus"
},
{
"key": "ctrl+shift+alt+left",
"command": "workbench.action.moveEditorToLeftGroup",
"when": "editorTextFocus"
},
{
"key": "ctrl+shift+alt+right",
"command": "workbench.action.moveEditorToRightGroup",
"when": "editorTextFocus"
},
// Create a new file (install patbenatar.advanced-new-file extension)
{
"key": "ctrl+n",
"command": "extension.advancedNewFile"
},
{
"key": "ctrl+alt+n",
"command": "-extension.advancedNewFile"
},
{
"key": "ctrl+n",
"command": "-workbench.action.files.newUntitledFile"
},
// Create a new empty tab
{
"key": "ctrl+t",
"command": "workbench.action.files.newUntitledFile"
},
{
"key": "ctrl+t",
"command": "-workbench.action.showAllSymbols"
},
// Go to the previous or next tab (similar to browsers)
{
"key": "ctrl+tab",
"command": "workbench.action.nextEditor"
},
{
"key": "ctrl+shift+tab",
"command": "workbench.action.previousEditor"
},
// Switch between tabs (similar to using Alt+Tab in Windows)
{
"key": "alt+q",
"command": "workbench.action.quickOpenPreviousRecentlyUsedEditor"
},
{
"key": "alt+q",
"command": "workbench.action.quickOpenNavigateNextInEditorPicker",
"when": "inEditorsPicker && inQuickOpen"
},
{
"key": "alt+shift+q",
"command": "workbench.action.quickOpenLeastRecentlyUsedEditor"
},
{
"key": "alt+shift+q",
"command": "workbench.action.quickOpenNavigatePreviousInEditorPicker",
"when": "inEditorsPicker && inQuickOpen"
},
// Toggle to hide and show the left and bottom sidebar
{
"key": "shift+alt+b",
"command": "workbench.action.toggleStatusbarVisibility"
},
{
"key": "ctrl+shift+b",
"command": "workbench.action.toggleActivityBarVisibility"
},
{
"key": "ctrl+shift+b",
"command": "-workbench.action.tasks.build"
},
{
"key": "ctrl+alt+b",
"command": "workbench.action.tasks.build"
},
// Open, hide, minimize and maximize the terminal
{
"key": "ctrl+shift+enter",
"command": "workbench.action.toggleMaximizedPanel"
},
{
"key": "shift+enter",
"command": "workbench.action.terminal.toggleTerminal"
},
{
"key": "shift+enter",
"command": "workbench.action.focusActiveEditorGroup",
"when": "terminalFocus"
},
{
"key": "ctrl+enter",
"command": "workbench.action.togglePanel"
},
{
"key": "ctrl+enter",
"command": "-github.copilot.generate",
"when": "editorTextFocus"
},
// Close terminal if selected
{
"key": "ctrl+shift+d",
"command": "workbench.action.terminal.split",
"when": "terminalFocus"
},
{
"key": "ctrl+shift+d",
"command": "-workbench.view.debug"
},
// Move the terminal left, down and right
{
"key": "ctrl+alt+d",
"command": "workbench.action.positionPanelRight"
},
{
"key": "ctrl+alt+s",
"command": "workbench.action.positionPanelBottom"
},
{
"key": "ctrl+alt+a",
"command": "workbench.action.positionPanelLeft"
},
// Open a recent Workspace
{
"key": "ctrl+shift+o",
"command": "workbench.action.openRecent"
},
{
"key": "ctrl+shift+o",
"command": "-workbench.action.gotoSymbol"
},
{
"key": "ctrl+r",
"command": "-workbench.action.openRecent"
},
// Trigger GitHub Copilot suggestions
{
"key": "ctrl+shift+c",
"command": "github.copilot.generate",
"when": "editorTextFocus"
},
// Enable or disable GitHub Copilot
{
"key": "alt+shift+c",
"command": "github.copilot.toggleCopilot"
},
// Write documentation for the selected function or class
{
"key": "ctrl+alt+oem_period",
"command": "docs.write",
"when": "editorTextFocus && config.docwriter.hotkey.windows == 'Ctrl + .' && editorLangId =~ /typescript|javascript|python|php|java|c|cpp|csharp|dart|ruby|go|rust/"
},
{
"key": "ctrl+oem_period",
"command": "-docs.write",
"when": "editorTextFocus && config.docwriter.hotkey.windows == 'Ctrl + .' && editorLangId =~ /typescript|javascript|python|php|java|c|cpp|csharp|dart|ruby|go|rust/"
},
// Toggle the match case when performing a search
{
"key": "alt+c",
"command": "toggleFindCaseSensitive",
"when": "editorTextFocus"
},
{
"key": "alt+c c",
"command": "-extension.colorHelper.convert",
"when": "editorTextFocus"
},
{
"key": "alt+c p",
"command": "-extension.colorHelper.pick",
"when": "editorTextFocus"
},
//Compresses folder expansion
{
"key": "alt+shift+e",
"command": "workbench.files.action.collapseExplorerFolders"
},
// Reveal file explorer
{
"key": "ctrl+shift+e",
"command": "remote-wsl.revealInExplorer",
"when": "editorTextFocus && remoteName == 'wsl'"
},
// Switch between the file explorer and the file picker
{
"key": "alt+e",
"command": "workbench.view.explorer",
"when": "viewContainer.workbench.view.explorer.enabled"
},
{
"key": "alt+e",
"command": "workbench.action.quickOpenNavigatePreviousInFilePicker",
"when": "inFilesPicker && inQuickOpen"
},
{
"key": "ctrl+shift+e",
"command": "-workbench.view.explorer",
"when": "viewContainer.workbench.view.explorer.enabled"
},
{
"key": "ctrl+shift+e",
"command": "-workbench.action.quickOpenNavigatePreviousInFilePicker",
"when": "inFilesPicker && inQuickOpen"
},
// Restart TypeScript and ESLint server (install ryuta46.multi-command extension)
{
"key": "ctrl+shift+r",
"command": "extension.multiCommand.execute",
"interval": 100,
"args": {
"sequence": ["typescript.restartTsServer", "eslint.restart"]
}
},
// Format the file with the standard formatter (Prettier, for example) and then with ESLint
{
"key": "shift+alt+f",
"command": "extension.multiCommand.execute",
"interval": 100,
"args": {
"sequence": ["editor.action.formatDocument", "eslint.executeAutofix"]
},
"when": "editorTextFocus && !editorReadonly && !inCompositeEditor"
},
// Format file with ESLint
// {
// "key": "shift+alt+d",
// "command": "eslint.executeAutofix",
// "when": "editorTextFocus && !editorReadonly && !inCompositeEditor"
// },
// Format file with standard formatter
// {
// "key": "shift+alt+f",
// "command": "editor.action.formatDocument",
// "when": "editorHasDocumentFormattingProvider && editorTextFocus && !editorReadonly && !inCompositeEditor"
// },
// Add required imports
{
"key": "shift+alt+a",
"command": "editor.action.sourceAction",
"args": {
"kind": "source.addMissingImports",
"apply": "first"
}
},
// Remove unnecessary imports and organize them
{
"key": "shift+alt+s",
"command": "extension.multiCommand.execute",
"interval": 10,
"args": {
"sequence": [
"typescript.removeUnusedImports",
"editor.action.organizeImports",
"typescript.organizeImports",
"typescript.sortImports"
]
},
"when": "editorTextFocus && !editorReadonly && !inCompositeEditor"
},
// Toggle to display function parameter names (install DominicVonk.parameter-hints extension)
{
"key": "alt+shift+p",
"command": "parameterHints.toggle"
},
// Break HTML tag into multiple lines (install dannyconnell.split-html-attributes extension)
{
"key": "shift+alt+x",
"command": "extension.splitHTMLAttributes",
"when": "editorTextFocus && !editorReadonly && !inCompositeEditor"
},
// Add or remove selected lines to the Git staging area
{
"key": "shift+alt+a",
"command": "git.stageSelectedRanges",
"when": "isInDiffEditor"
},
{
"key": "shift+alt+s",
"command": "git.unstageSelectedRanges",
"when": "isInDiffEditor"
},
// Toggle between continuous lines or line breaks at the limit of horizontal scrolling
{
"key": "shift+alt+z",
"command": "editor.action.toggleWordWrap",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "alt+z",
"command": "-editor.action.toggleWordWrap",
"when": "editorTextFocus && !editorReadonly"
},
// Attach a new remote container to VSCode
{
"key": "alt+a",
"command": "remote-containers.attachToRunningContainer"
},
// Expand or collapse block of code where the cursor is located
{
"key": "ctrl+shift+]",
"command": "editor.fold",
"when": "editorTextFocus && foldingEnabled"
},
{
"key": "ctrl+shift+\\",
"command": "editor.unfold",
"when": "editorTextFocus && foldingEnabled"
},
// Save file without formatting
{
"key": "ctrl+shift+s",
"command": "workbench.action.files.saveWithoutFormatting"
},
{
"key": "ctrl+shift+s",
"command": "-workbench.action.files.saveAs"
},
// Remove Markdown extension incompatibility with GitHub Copilot if installed
{
"key": "tab",
"command": "-markdown.extension.onTabKey",
"when": "editorTextFocus && !editorReadonly && !editorTabMovesFocus && !hasOtherSuggestions && !hasSnippetCompletions && !inSnippetMode && !suggestWidgetVisible && editorLangId == 'markdown'"
},
// Disable default Alt+Number commands
{
"key": "alt+1",
"command": "-workbench.action.openEditorAtIndex1"
},
{
"key": "alt+2",
"command": "-workbench.action.openEditorAtIndex2"
},
{
"key": "alt+3",
"command": "-workbench.action.openEditorAtIndex3"
},
{
"key": "alt+4",
"command": "-workbench.action.openEditorAtIndex4"
},
{
"key": "alt+5",
"command": "-workbench.action.openEditorAtIndex5"
},
{
"key": "alt+6",
"command": "-workbench.action.openEditorAtIndex6"
},
{
"key": "alt+7",
"command": "-workbench.action.openEditorAtIndex7"
},
{
"key": "alt+8",
"command": "-workbench.action.openEditorAtIndex8"
},
{
"key": "alt+9",
"command": "-workbench.action.openEditorAtIndex9"
},
// Customize Alt+Number commands and apply toggle for them
{
"key": "alt+1",
"command": "workbench.view.explorer"
},
{
"key": "alt+1",
"command": "workbench.action.toggleSidebarVisibility",
"when": "activeViewlet == 'workbench.view.explorer'"
},
{
"key": "alt+2",
"command": "workbench.view.scm"
},
{
"key": "alt+2",
"command": "workbench.action.toggleSidebarVisibility",
"when": "activeViewlet == 'workbench.view.scm'"
},
{
"key": "alt+3",
"command": "workbench.view.extensions"
},
{
"key": "alt+3",
"command": "workbench.action.toggleSidebarVisibility",
"when": "activeViewlet == 'workbench.view.extensions'"
},
{
"key": "alt+4",
"command": "workbench.view.search"
},
{
"key": "alt+4",
"command": "workbench.action.toggleSidebarVisibility",
"when": "activeViewlet == 'workbench.view.search'"
},
{
"key": "alt+5",
"command": "workbench.view.extension.rubberduck"
},
{
"key": "alt+5",
"command": "workbench.action.toggleSidebarVisibility",
"when": "activeViewlet == 'workbench.view.extension.rubberduck'"
},
{
"key": "alt+6",
"command": "workbench.view.debug"
},
{
"key": "alt+6",
"command": "workbench.action.toggleSidebarVisibility",
"when": "activeViewlet == 'workbench.view.debug'"
},
{
"key": "alt+7",
"command": "workbench.view.extension.dockerView"
},
{
"key": "alt+7",
"command": "workbench.action.toggleSidebarVisibility",
"when": "activeViewlet == 'workbench.view.extension.dockerView'"
},
{
"key": "alt+8",
"command": "workbench.view.remote"
},
{
"key": "alt+8",
"command": "workbench.action.toggleSidebarVisibility",
"when": "activeViewlet == 'workbench.view.remote'"
},
{
"key": "alt+9",
"command": "workbench.view.extension.gitlens"
},
{
"key": "alt+9",
"command": "workbench.action.toggleSidebarVisibility",
"when": "activeViewlet == 'workbench.view.extension.gitlens'"
}
]
/*
* Ctrl+Shift+P > snippets > Preferences: Configure User Snippets
* next.code-snippets.json
*/
{
"clsx": {
"prefix": "xx",
"body": ["className={clsx(", "'$0',", "'',", ")}"],
"description": "Join classnames: clsx library"
},
"className": {
"prefix": "cc",
"body": ["className=\"$0\""],
"description": "React className"
},
"style": {
"prefix": "ww",
"body": ["style={tw`$0`}"],
"description": "React Native style"
},
"tailwind": {
"prefix": "ss",
"body": ["style={tw(\"$0\")}"],
"description": "React Native style"
},
"Next.js Component": {
"prefix": "nextComponent",
"body": [
"export function ${1:${TM_FILENAME_BASE}} () {",
" return (",
" <>",
" <h1>${2:${TM_FILENAME_BASE}}</h1>",
" </>",
" )",
"}",
""
],
"description": "Next.js Component"
},
"Next.js Page": {
"prefix": "nextPage",
"body": [
"export default function ${1:${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/}} () {",
" return (",
" <>",
" <h1>${2:${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/}}</h1>",
" </>",
" )",
"}",
""
],
"description": "Next.js Page"
},
"Next.js Server Page": {
"prefix": "nextServer",
"body": [
"import type { GetServerSideProps } from 'next'",
"",
"export default function ${1:${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/}} ({ cookies }: any) {",
" return (",
" <>",
" <pre>{JSON.stringify(cookies, null, 2)}$0</pre>",
" </>",
" )",
"}",
"",
"export const getServerSideProps: GetServerSideProps = async ({",
" params,",
" req,",
" query",
"}) => {",
" // const { slug, id } = params",
" // const { page, perPage } = query",
"",
" const { cookies } = req // { token, refreshToken } = req.cookies",
" return {",
" // notFound: true,",
" props: { cookies }",
" }",
"}",
""
],
"description": "Next.js Server Page"
},
"Next.js Static Page": {
"prefix": "nextStatic",
"body": [
"import type { GetStaticPaths, GetStaticProps } from 'next'",
"import { ParsedUrlQuery } from 'querystring'",
"",
"export default function ${1:${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/}} ({ id, currentHour }: any) {",
" return (",
" <>",
" <h1>Page ID: {id}</h1>",
" <h2>Current hour: {currentHour}$0</h2>",
" </>",
" )",
"}",
"",
"export const getStaticPaths: GetStaticPaths = async () => {",
" return {",
" paths: [",
" // { params: { id: '1' } },",
" // { params: { id: '2' } },",
" // { params: { id: '3' } }",
" ],",
" // fallback: false // false pre-rendered just the paths and the rest is never showed",
" // fallback: true // true forces paths to be pre-rendered and the rest is generated on demand",
" fallback: 'blocking' // blocking does not need to have paths because all paths are generated on demand",
" }",
"}",
"",
"export const getStaticProps: GetStaticProps = async ({ params }) => {",
" const { id } = params as ParsedUrlQuery",
" const currentHour = new Date().toLocaleTimeString('en-US', {",
" hour: '2-digit',",
" minute: '2-digit',",
" second: '2-digit',",
" hour12: false",
" })",
"",
" return {",
" // notFound: true,",
" // redirect: {",
" // destination: '/',",
" // permanent: false",
" // },",
" props: { id, currentHour },",
" revalidate: 60 * 1 // 1 minute",
" }",
"}",
""
],
"description": "Next.js Static Page"
},
"Next.js API": {
"prefix": "nextAPI",
"body": [
"import type { NextApiRequest, NextApiResponse } from 'next'",
"",
"type ResponseData = any;",
"",
"export default async function ${1:${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/}} (",
" req: NextApiRequest,",
" res: NextApiResponse<ResponseData>",
") {",
" const { id, page } = req.query // /5?page=20",
" const { method, url, cookies } = req",
"",
" // res.setHeader('Cache-Control', 's-maxage=30, stale-while-revalidate') // cache for 30 seconds",
"",
" res.status(200).json({",
" message: '${2:Hello, API!}',",
" id, // 5",
" page, // 20",
" method,",
" url,",
" cookies,",
" headers: req.headers",
" })",
" // res.status(500).send({ error: 'failed to fetch data' })",
" // res.redirect(307, '/')",
"}",
""
],
"description": "Next.js API"
},
"Next.js Context": {
"prefix": "nextContext",
"body": [
"import { createContext, PropsWithChildren, useContext } from 'react'",
"",
"interface ${TM_FILENAME_BASE}Props {${1:",
" // doSomething(): Promise<void>;",
" // isTrue: boolean;",
" // info: Info | undefined;",
"}}",
"",
"export const ${TM_FILENAME_BASE} = createContext({} as ${TM_FILENAME_BASE}Props)",
"",
"export function ${TM_FILENAME_BASE/([A-Z]*[a-z]*$)//g}Provider({ children }: PropsWithChildren) {${2:",
" // const [info, setInfo] = useState<Info>()",
" // const [isTrue, setIsTrue] = useState(false)",
" // const doSomething = async () => {}",
" $0",
"",
" return (",
" <${TM_FILENAME_BASE}.Provider value={{${3: /* doSomething, isTrue, info */ }}}>",
" {children}",
" </${TM_FILENAME_BASE}.Provider>",
" )",
"}",
"",
"export function use${TM_FILENAME_BASE/([A-Z]*[a-z]*$)//g}() {",
" return useContext(${TM_FILENAME_BASE})",
"}",
""
],
"description": "Next.js Context"
}
}
/*
* Ctrl+Shift+P > settings
* Preferences: Open Settings (JSON)
*/
{
// Style and Theme
"workbench.colorTheme": "Sorcerer",
"workbench.iconTheme": "material-icon-theme",
"editor.fontFamily": "Rec Mono Casual, Codelia Ligatures", // https://drive.google.com/file/d/1wgKy3QuYQOGDZZj5S12Ryt84yeJee2JC https://drive.google.com/file/d/1iwEhhk3l8VEa3H3zLtYaMF526NSTn_wR
"editor.fontSize": 14,
"editor.lineHeight": 19,
"editor.fontWeight": "400",
"editor.fontLigatures": true,
"editor.rulers": [80, 120],
"editor.renderLineHighlight": "all",
"editor.cursorBlinking": "smooth",
"editor.semanticHighlighting.enabled": false,
"editor.scrollbar.vertical": "auto",
"editor.scrollbar.horizontal": "auto",
"window.titleBarStyle": "custom",
// Custom Style
"apc.electron": {
"titleBarStyle": "hiddenInset",
"frame": false
},
"apc.header": {
"height": 36
},
"apc.listRow": {
"height": 22
},
"apc.font.family": "Inter", // https://fonts.google.com/specimen/Inter
"apc.stylesheet": {
// ".titlebar-center": "display: none !important",
".title-label > h2": "display: none",
".editor-actions": "display: none"
},
"workbench.colorCustomizations": {
"[Sorcerer]": {
"titleBar.activeBackground": "#0e141a",
"titleBar.activeForeground": "#d1d6df",
"titleBar.inactiveBackground": "#0e141abd",
"titleBar.inactiveForeground": "#d1d6dfbd"
},
"parameterHints.hintBackground": "#25374a50",
"parameterHints.hintForeground": "#6e7d9a",
"titleBar.activeBackground": "#2596be",
"titleBar.activeForeground": "#ffffff",
"titleBar.inactiveBackground": "#004a72",
"titleBar.inactiveForeground": "#639db2"
},
// Behavior
"editor.mouseWheelZoom": true,
"explorer.compactFolders": false,
"explorer.confirmDragAndDrop": false,
"explorer.confirmDelete": false,
"security.workspace.trust.untrustedFiles": "open",
"workbench.editor.enablePreview": false,
"editor.lightbulb.enabled": "off",
"editor.insertSpaces": true,
"editor.tabSize": 2,
// Languages Behavior
"typescript.preferences.importModuleSpecifier": "non-relative",
"typescript.updateImportsOnFileMove.enabled": "always",
"typescript.suggest.autoImports": true,
"javascript.preferences.importModuleSpecifier": "non-relative",
"javascript.updateImportsOnFileMove.enabled": "always",
"javascript.suggest.autoImports": true,
// Formatting
"prettier.printWidth": 80, // esbenp.prettier-vscode
"cSpell.language": "en,pt,pt_BR", // streetsidesoftware.code-spell-checker
"splitHTMLAttributes.closingBracketOnNewLine": true, // dannyconnell.split-html-attributes
"scss.lint.unknownAtRules": "ignore",
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[scss]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
// Organization
// "explorer.sortOrder": "foldersNestsFiles",
// "explorer.fileNesting.enabled": true,
// "explorer.fileNesting.patterns": {
// "package.json": "package-lock*, pnpm-lock*, bun.lockb, nest*",
// "docker*": ".docker*",
// "nest*": "nest*",
// "vite*": "vite*",
// "tsconfig*": "tsconfig*,",
// "prettier*": "prettier*",
// ".eslint*": ".eslint*",
// "tailwind.config*": "tailwind.config*, postcss.config*",
// ".env*": ".env*"
// },
"console-ninja.featureSet": "Community",
"symbols.hidesExplorerArrows": false,
"editor.minimap.enabled": false,
"workbench.editor.labelFormat": "short",
"workbench.startupEditor": "newUntitledFile",
"window.commandCenter": false,
"workbench.layoutControl.enabled": false,
"parameterHints.enabled": false,
"workbench.activityBar.location": "hidden",
"terminal.integrated.env.linux": {},
"terminal.integrated.env.windows": {},
"github.copilot.enable": {
"*": true,
"plaintext": false,
"markdown": true,
"scminput": false
},
"[markdown]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"prisma.showPrismaDataPlatformNotification": false,
"github.copilot.editor.enableAutoCompletions": true,
"window.customTitleBarVisibility": "auto"
}
/*
* Ctrl+Shift+P > snippets > vue.json
* Preferences: Configure User Snippets
* ~/.config/Code/User/snippets/vue.json
*/
{
"Vue template": {
"prefix": "vue",
"body": [
"<template>",
" $0",
"</template>"
"",
"<script>",
"// import { onBeforeMount, onMounted, computed, ref, reactive } from 'vue'",
"",
"export default {",
" setup() {",
" ",
" ",
" return {",
" ",
" }",
" }",
"}",
"</script>",
"",
"<style lang=\"scss\" scoped>",
"",
"</style>",
],
"description": "Vue template"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment