Skip to content

Latest commit

 

History

History
146 lines (135 loc) · 11.5 KB

README.org

File metadata and controls

146 lines (135 loc) · 11.5 KB

lang/javascript

Table of Contents

Description

This module adds JavaScript and TypeScript support.

  • Code completion (tide)
  • REPL support (nodejs-repl)
  • Refactoring commands (js2-refactor)
  • Syntax checking (flycheck)
  • Browser code injection with skewer-mode
  • Coffeescript & JSX support
  • Jump-to-definitions and references support (xref)

Module Flags

  • +lsp Enables LangServer support for this module. You must have :tools lsp enabled for this to work, as well as the langserver (e.g. typescript-language-server) installed on your system.

Packages

Prerequisites

Many of this modules’ plugins require node and either npm or yarn installed.

MacOS

brew install node

Arch Linux

sudo pacman --needed --noconfirm -S nodejs npm

openSUSE

sudo zypper install nodejs npm

Troubleshooting

tide-sort-completions-by-kind isn’t respected

The :completion company module uses company-prescient to sort completion by frecency, which overrules specialized sorting provided by some company backends (like company-tide).

Appendix

Commands

JS2-mode

commandkey / ex commanddescription
+javascript/open-repl:replOpen the NodeJS REPL (or send the current selection to it)
+javascript/skewer-this-bufferSPC m SAttaches a browser to the current buffer

Tide

commandkey / ex commanddescription
tide-restart-serverSPC m RRestart tide server
tide-reformatSPC m fReformat region
tide-rename-symbolSPC m r sRename symbol at point
tide-organize-importsSPC m r o iOrganize imports

Refactoring (js2-refactor-mode)

commandkey / ex commanddescription
js2r-expand-node-at-pointSPC m r e eExpand bracketed list according to node type at point
js2r-contract-node-at-pointSPC m r c cContract bracketed list according to node type at point
js2r-extract-functionSPC m r e fExtracts the marked expressions out into a new named function.
js2r-extract-methodSPC m r e mExtracts the marked expressions out into a new named method in an object literal.
js2r-toggle-function-expression-and-declarationSPC m r t fToggle between function name() {} and var name = function ();
js2r-toggle-arrow-function-and-expressionSPC m r t aToggle between function expression to arrow function.
js2r-toggle-function-asyncSPC m r t sToggle between an async and a regular function.
js2r-introduce-parameterSPC m r i pChanges the marked expression to a parameter in a local function.
js2r-localize-parameterSPC m r l pChanges a parameter to a local var in a local function.
js2r-wrap-buffer-in-iifeSPC m r w iWraps the entire buffer in an immediately invoked function expression
js2r-inject-global-in-iifeSPC m r i gCreates a shortcut for a marked global by injecting it in the wrapping immediately invoked function expression
js2r-add-to-globals-annotationSPC m r a gCreates a *global * annotation if it is missing, and adds the var at point to it.
js2r-extract-varSPC m r e vTakes a marked expression and replaces it with a var.
js2r-extract-letSPC m r e lSimilar to extract-var but uses a let-statement.
js2r-extract-constSPC m r e cSimilar to extract-var but uses a const-statement.
js2r-inline-varSPC m r i vReplaces all instances of a variable with its initial value.
js2r-rename-varSPC m r r vRenames the variable on point and all occurrences in its lexical scope.
js2r-var-to-thisSPC m r v tChanges local var a to be this.a instead.
js2r-arguments-to-objectSPC m r a oReplaces arguments to a function call with an object literal of named arguments.
js2r-ternary-to-ifSPC m r 3 iConverts ternary operator to if-statement.
js2r-split-var-declarationSPC m r s vSplits a var with multiple vars declared, into several var statements.
js2r-split-stringSPC m r s sSplits a string.
js2r-string-to-templateSPC m r s tConverts a string into a template string.
js2r-unwrapSPC m r u wReplaces the parent statement with the selected region.
js2r-log-thisSPC m r l tAdds a console.log() statement for what is at point (or region). With a prefix argument, use JSON pretty-printing.
js2r-debug-thisSPC m r d tAdds a debug() statement for what is at point (or region).
js2r-forward-slurpSPC m r s lMoves the next statement into current function, if-statement, for-loop or while-loop.
js2r-forward-barfSPC m r b aMoves the last child out of current function, if-statement, for-loop or while-loop.
js2r-killSPC m r kKills to the end of the line, but does not cross semantic boundaries.

skewer-mode

general

commandkey / ex commanddescription
skewer-eval-last-expressionSPC m s EEvaluate last expression
skewer-eval-defunSPC m s eEvaluate function definition at point
skewer-load-bufferSPC m s fLoad buffer into REPL

css

commandkey / ex commanddescription
skewer-css-eval-current-declarationSPC m s eEvaluate declaration at point
skewer-css-eval-current-ruleSPC m s rEvaluate rule at point
skewer-css-eval-bufferSPC m s bEvaluate buffer
skewer-css-clear-allSPC m s cClear all rules

html

commandkey / ex commanddescription
skewer-html-eval-tagSPC m s eEvaluate tag at point

npm-mode

commandkey / ex commanddescription
npm-mode-npm-initSPC m n nInitialize npm project
npm-mode-npm-installSPC m n iInstall npm package
npm-mode-npm-install-saveSPC m n sInstall npm package and save to package.json
npm-mode-npm-install-save-devSPC m n dInstall npm package and save to package.json as a dev dependency
npm-mode-npm-uninstallSPC m n uUninstall npm package
npm-mode-npm-listSPC m n lList npm packages
npm-mode-npm-runSPC m n rRun npm task
npm-mode-visit-project-fileSPC m n vFind file in npm project