Skip to content

Latest commit

 

History

History
167 lines (141 loc) · 12.6 KB

README.org

File metadata and controls

167 lines (141 loc) · 12.6 KB

:lang javascript

Description

This module adds JavaScript and TypeScript support to Doom Emacs.

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

Maintainers

  • @elken
  • @hlissner
  • @iyefrat

Become a maintainer?

Module flags

+lsp
Enable LSP support for js2-mode, rjsx-mode, JS in web-mode, and typescript-mode. Requires doom-module::tools lsp and a langserver (supports ts-ls and deno-ls).
+tree-sitter
Leverages tree-sitter for better syntax highlighting and structural text editing. Requires doom-module::tools tree-sitter.

Packages

  • doom-package:js2-refactor
  • doom-package:nodejs-repl
  • doom-package:npm-mode
  • doom-package:rjsx-mode
  • doom-package:skewer-mode (DEPRECATED)
  • doom-package:tide
  • doom-package:typescript-mode
  • doom-package:xref-js2 if doom-module::tools lookup

Hacks

󱌣 This module’s hacks haven’t been documented yet. Document them?

Changelog

This module does not have a changelog yet.

Installation

Enable this module in your doom! block.

This module requires NodeJS and one of NPM or Yarn in your $PATH.

  • MacOS: $ brew install node
  • Arch Linux: $ pacman --needed --noconfirm -S nodejs npm
  • openSUSE: $ zypper install nodejs npm

Formatter

Formatting is handled using the doom-module::editor format module via prettier.

Usage

󱌣 This module’s usage documentation is incomplete. Complete it?

rjsx-mode is used for all javascript buffers.

Commands

rjsx-mode

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

Tide

commandkey / ex commanddescription
tide-restart-server<localleader> RRestart tide server
tide-reformat<localleader> fReformat region
tide-rename-symbol<localleader> r r sRename symbol at point
tide-organize-imports<localleader> r o iOrganize imports

Refactoring (js2-refactor-mode)

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

skewer-mode

general

commandkey / ex commanddescription
skewer-eval-last-expression<localleader> s EEvaluate last expression
skewer-eval-defun<localleader> s eEvaluate function definition at point
skewer-load-buffer<localleader> s fLoad buffer into REPL

css

commandkey / ex commanddescription
skewer-css-eval-current-declaration<localleader> s eEvaluate declaration at point
skewer-css-eval-current-rule<localleader> s rEvaluate rule at point
skewer-css-eval-buffer<localleader> s bEvaluate buffer
skewer-css-clear-all<localleader> s cClear all rules

html

commandkey / ex commanddescription
skewer-html-eval-tag<localleader> s eEvaluate tag at point

npm-mode

commandkey / ex commanddescription
npm-mode-npm-init<localleader> n nInitialize npm project
npm-mode-npm-install<localleader> n iInstall npm package
npm-mode-npm-install-save<localleader> n sInstall npm package and save to package.json
npm-mode-npm-install-save-dev<localleader> n dInstall npm package and save to package.json as a dev dependency
npm-mode-npm-uninstall<localleader> n uUninstall npm package
npm-mode-npm-list<localleader> n lList npm packages
npm-mode-npm-run<localleader> n rRun npm task
npm-mode-visit-project-file<localleader> n vFind file in npm project

Configuration

󱌣 This module has no configuration documentation yet. Write some?

Troubleshooting

There are no known problems with this module. Report one?

Frequently asked questions

This module has no FAQs yet. Ask one?

Appendix

󱌣 This module has no appendix yet. Write one?