Skip to content

Instantly share code, notes, and snippets.

@relax2code
Last active December 5, 2022 11:03
Show Gist options
  • Save relax2code/f2db79acfda81e03e8b9487681cdf7e9 to your computer and use it in GitHub Desktop.
Save relax2code/f2db79acfda81e03e8b9487681cdf7e9 to your computer and use it in GitHub Desktop.

Revisions

  1. relax2code revised this gist Dec 5, 2022. 1 changed file with 221 additions and 0 deletions.
    221 changes: 221 additions & 0 deletions vscode-snippets-elixir.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,221 @@
    {
    "lv_module": {
    "prefix": "lv",
    "body": [
    "defmodule LiveViewStudioWeb.${1}Live do",
    " use LiveViewStudioWeb, :live_view",
    "end"
    ],
    "description": "LiveView module"
    },
    "lc_module": {
    "prefix": "lc",
    "body": [
    "defmodule LiveViewStudioWeb.${1}Component do",
    " use LiveViewStudioWeb, :live_component",
    "end"
    ],
    "description": "LiveComponent module"
    },
    "lv_mount": {
    "prefix": "mount",
    "body": [
    "def mount(_params, _session, socket) do",
    " socket = assign(socket, ${1:key}: ${2:value})",
    " {:ok, socket}",
    "end"
    ],
    "description": "LiveView mount function"
    },
    "lv_rend": {
    "prefix": "rend",
    "body": [
    "def render(assigns) do",
    " ~L\"\"\"",
    " ${0}",
    " \"\"\"",
    "end"
    ],
    "description": "LiveView render function"
    },
    "lv_handle_event": {
    "prefix": "he",
    "body": [
    "def handle_event(${1:event}, _, socket) do",
    " socket = assign(socket, ${2:key}: ${3:value})",
    " {:noreply, socket}",
    "end"
    ],
    "description": "LiveView handle_event function"
    },
    "lv_handle_info": {
    "prefix": "hi",
    "body": [
    "def handle_info(${1:message}, socket) do",
    " socket = assign(socket, ${2:key}: ${3:value})",
    " {:noreply, socket}",
    "end"
    ],
    "description": "LiveView handle_info function"
    },
    "lv_handle_params": {
    "prefix": "hp",
    "body": [
    "def handle_params(params, _url, socket) do",
    " {:noreply, socket}",
    "end"
    ],
    "description": "LiveView handle_params function"
    },
    "lv_template": {
    "prefix": "lt",
    "body": [
    "~L\"\"\"",
    "${0}",
    "\"\"\""
    ],
    "description": "LiveView inline template"
    },
    "lv_test_module": {
    "prefix": "lvtest",
    "body": [
    "defmodule LiveViewStudioWeb.${1}Test do",
    " use LiveViewStudioWeb.ConnCase, async: true",
    "",
    " import Phoenix.LiveViewTest",
    "",
    " ${0}",
    "end"
    ],
    "description": "LiveView test module"
    },
    "lv_test": {
    "prefix": "test",
    "body": [
    "test \"${1:description}\", %{conn: conn} do",
    " {:ok, view, _html} = live(conn, \"${2:path}\")",
    " ${0}",
    "end"
    ],
    "description": "LiveView test"
    },
    "eex_datalist": {
    "prefix": "data",
    "body": [
    "<datalist id=\"${1}\">",
    " ${0}",
    "</datalist>",
    ""
    ],
    "description": "EEx datalist"
    },
    "eex_input": {
    "prefix": "input",
    "body": [
    "<input type=\"text\" name=\"${1}\" value=\"${2}\"",
    " placeholder=\"${3}\" />"
    ],
    "description": "EEx text input"
    },
    "eex_hidden_input": {
    "prefix": "hidden",
    "body": [
    "<input type=\"hidden\" name=\"${1}\" value=\"${2}\" />"
    ],
    "description": "EEx hidden input"
    },
    "eex_checkbox_input": {
    "prefix": "checkbox",
    "body": [
    "<input type=\"checkbox\" id=\"${1}\" name=\"${2}\" value=\"${3}\"/>"
    ],
    "description": "EEx checkbox input"
    },
    "eex_render_block": {
    "prefix": "et",
    "body": [
    "<%= $1 %>"
    ],
    "description": "<%= %> render block"
    },
    "eex_end_tag": {
    "prefix": "eend",
    "body": [
    "<% end %>$1"
    ],
    "description": "<% end %> end tag"
    },
    "for": {
    "prefix": "efor",
    "body": [
    "<%= for ${1:item} <- @$1s do %>",
    " $2",
    "<% end %>"
    ],
    "description": "EEx for"
    },
    "fori": {
    "prefix": "efori",
    "body": [
    "<%= for ${1:item} <- @$1s do %>",
    " $2",
    "<% end %>"
    ],
    "description": "EEx for comprehension with items"
    },
    "eex_ifa": {
    "prefix": "eifa",
    "body": [
    "<%= if $1, do: \"{$1}\" %>"
    ],
    "description": "EEx if for attribute"
    },
    "eex_if": {
    "prefix": "eif",
    "body": [
    "<%= if $1 do %>",
    " $2",
    "<% end %>"
    ],
    "description": "EEx if"
    },
    "eex_if_else": {
    "prefix": "eife",
    "body": [
    "<%= if $1 do %>",
    " $2",
    "<% else %>",
    " $3",
    "<% end %>"
    ],
    "description": "EEx if else"
    },
    "eex_else": {
    "prefix": "eelse",
    "body": [
    "<% else %>"
    ],
    "description": "EEx else"
    },
    "eex_cond": {
    "prefix": "econd",
    "body": [
    "<%= cond do %>",
    " <% $1 -> %>",
    " $2",
    " <% true -> %>",
    " $3",
    "<% end %>"
    ],
    "description": "EEx cond"
    },
    "eex_unless": {
    "prefix": "eunless",
    "body": [
    "<%= unless $1 do %>",
    " $2",
    "<% end %>"
    ],
    "description": "EEx unless"
    }
    }
  2. relax2code created this gist Dec 5, 2022.
    233 changes: 233 additions & 0 deletions vscode-keybindings.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,233 @@
    // Place your key bindings in this file to override the defaults
    [
    {
    "key": "shift+ctrl+e",
    "command": "actions.findWithSelection"
    },
    {
    "key": "ctrl+e",
    "command": "-actions.findWithSelection"
    },
    {
    "key": "ctrl+e",
    "command": "workbench.view.explorer"
    },
    {
    "key": "shift+ctrl+e",
    "command": "-workbench.view.explorer"
    },
    {
    "key": "r",
    "command": "renameFile",
    "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
    },
    {
    "key": "enter",
    "command": "-renameFile",
    "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
    },
    {
    "key": "j",
    "command": "list.focusDown",
    "when": "listFocus && !inputFocus"
    },
    {
    "key": "k",
    "command": "list.focusUp",
    "when": "listFocus && !inputFocus"
    },
    {
    "key": "ctrl+j",
    "command": "selectNextSuggestion",
    "when": "editorTextFocus && suggestWidgetMultipleSuggestions && suggestWidgetVisible"
    },
    {
    "key": "ctrl+k",
    "command": "selectPrevSuggestion",
    "when": "editorTextFocus && suggestWidgetMultipleSuggestions && suggestWidgetVisible"
    },
    {
    "key": "ctrl+j",
    "command": "workbench.action.quickOpenNavigateNext",
    "when": "inQuickOpen"
    },
    {
    "key": "tab",
    "command": "selectNextSuggestion",
    "when": "editorTextFocus && suggestWidgetMultipleSuggestions && suggestWidgetVisible"
    },
    {
    "key": "tab",
    "command": "workbench.action.quickOpenNavigateNext",
    "when": "inQuickOpen"
    },
    {
    "key": "shit+tab",
    "command": "selectPrevSuggestion",
    "when": "editorTextFocus && suggestWidgetMultipleSuggestions && suggestWidgetVisible"
    },
    {
    "key": "shift+tab",
    "command": "selectPrevSuggestion",
    "when": "editorTextFocus && suggestWidgetMultipleSuggestions && suggestWidgetVisible"
    },
    {
    "key": "shift+tab",
    "command": "workbench.action.quickOpenNavigatePrevious",
    "when": "inQuickOpen"
    },
    {
    "key": "ctrl+k",
    "command": "workbench.action.quickOpenNavigatePrevious",
    "when": "inQuickOpen"
    },
    {
    "key": "enter",
    "command": "list.select",
    "when": "explorerViewletVisible && filesExplorerFocus"
    },
    {
    "key": "l",
    "command": "list.select",
    "when": "!inputFocus"
    },
    {
    "key": "o",
    "command": "list.toggleExpand",
    "when": "!inputFocus"
    },
    {
    "key": "h",
    "command": "list.collapse",
    "when": "explorerViewletVisible && filesExplorerFocus && !inputFocus"
    },
    {
    "key": "d",
    "command": "deleteFile",
    "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceReadonly && !inputFocus"
    },
    {
    "key": "y",
    "command": "filesExplorer.copy",
    "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !inputFocus"
    },
    {
    "key": "x",
    "command": "filesExplorer.cut",
    "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !inputFocus"
    },
    {
    "key": "p",
    "command": "filesExplorer.paste",
    "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceReadonly && !inputFocus"
    },
    {
    "key": "v",
    "command": "explorer.openToSide",
    "when": "explorerViewletFocus && explorerViewletVisible && !inputFocus"
    },
    {
    "key": "a",
    "command": "explorer.newFile",
    "when": "filesExplorerFocus && !inputFocus"
    },
    {
    "key": "shift+a",
    "command": "explorer.newFolder",
    "when": "filesExplorerFocus && !inputFocus"
    },
    {
    "key": "shift+;",
    "command": "insertPrevSuggestion",
    "when": "hasOtherSuggestions && textInputFocus && textInputFocus && !inSnippetMode && !suggestWidgetVisible && config.editor.tabCompletion == 'on'"
    },
    {
    "key": "ctrl+l",
    "when": "sideBarFocus",
    "command": "workbench.action.focusActiveEditorGroup"
    },
    {
    "key": "ctrl+k",
    "command": "workbench.action.focusActiveEditorGroup",
    "when": "terminalFocus"
    },
    {
    "key": "ctrl+shift+t",
    "command": "workbench.action.terminal.focus",
    "when": "!terminalFocus"
    },
    {
    "key": "ctrl+j",
    "command": "-editor.action.insertLineAfter",
    "when": "editorTextFocus && neovim.ctrlKeysInsert && !neovim.recording && neovim.mode == 'insert'"
    },
    {
    "command": "vscode-neovim.compositeEscape1",
    "key": "j",
    "when": "neovim.mode == insert && editorTextFocus",
    "args": "j"
    },
    {
    "command": "vscode-neovim.compositeEscape2",
    "key": "k",
    "when": "neovim.mode == insert && editorTextFocus",
    "args": "k"
    },
    {
    "key": "alt+j",
    "command": "workbench.action.terminal.focus",
    "when": "!terminalFocus"
    },
    {
    "key": "ctrl+shift+t",
    "command": "workbench.action.togglePanel"
    },
    {
    "key": "ctrl+j",
    "command": "-workbench.action.togglePanel"
    },
    {
    "key": "shift+k",
    "command": "editor.action.showHover",
    "when": "editorTextFocus && !textInputFocus"
    },
    {
    "key": "ctrl+k ctrl+i",
    "command": "-editor.action.showHover",
    "when": "editorTextFocus"
    },
    {
    "key": "shift+tab",
    "command": "-acceptAlternativeSelectedSuggestion",
    "when": "suggestWidgetVisible && textInputFocus && textInputFocus"
    },
    {
    "key": "ctrl+f",
    "command": "-vscode-neovim.ctrl-f",
    "when": "editorTextFocus && neovim.ctrlKeysNormal && neovim.init && neovim.mode != 'insert'"
    },
    {
    "key": "shift+delete",
    "command": "-deleteFile",
    "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceReadonly && !inputFocus"
    },
    {
    "key": "ctrl+shift+k m",
    "command": "editor.action.deleteLines",
    "when": "textInputFocus && !editorReadonly"
    },
    {
    "key": "ctrl+shift+k",
    "command": "-editor.action.deleteLines",
    "when": "textInputFocus && !editorReadonly"
    },
    {
    "key": "ctrl+shift+m k",
    "command": "workbench.action.editor.changeLanguageMode"
    },
    {
    "key": "ctrl+k m",
    "command": "-workbench.action.editor.changeLanguageMode"
    }
    ]