Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [javascript]

for the use (typically editing) of JavaScript code in Emacs.

Filter by
Sorted by
Tagged with
0 votes
0 answers
16 views

How can I load a specific language server for a particular file extension?

I'm using emacs29 on linux. At present, if I load a file with the extension '.tsx', and then do 'M-x lsp-mode' I get an error: 'Symbol’s value as variable is void: lsp-ada-project-file' I assume that ...
3 votes
1 answer
66 views

Switch Cases's code block doesn't get indented in JavaScript mode

I'm having trouble with the indentation of the cases's code-blocks in my switch statements it looks like this: switch(var) { case "case1": case's code line 1; case's code line 2; ...
0 votes
1 answer
11 views

In js2-mode, how can I insert another star after creating a new line in comment?

For example, | is the location of the cursor. /* * This is a comment| */ Now I type Enter. I would prefer the screen becomes: /* * This is a comment * | */ But in reality it is /* * This is a ...
0 votes
1 answer
125 views

Add a watch statement in Indium?

Is it possible to add a watch statement in Indium like you can in the node debugging utility? from Debugger | Node.js v9.10.1 Documentation: It is possible to watch expression and variable values ...
1 vote
1 answer
216 views

set js-indent-level from .eslintrc?

when I edit javascript, I'm usually actually editing someone else's code. Is there a way to dynamically set the value of js-indent-level from a .eslintrc file?
0 votes
1 answer
837 views

Javascript mode mixes tabs and spaces for indent

My javascript mode indents with a mix of tabs and spaces. I'm ok with the mix if spaces are used for cosmetic alignment, but this is just wrong: First level of indentation is spaces, second is tab, ...
0 votes
1 answer
35 views

Is Javascript supported by `flyspell-prog-mode`?

Which programming languages are supported by flyspell-prog-mode? Is Javascript? I can get flyspell-prog-mode to spellcheck comments on Python buffers, but it doesn't seem to work on Javascript buffers....
0 votes
2 answers
849 views

How to correctly configure Flow backend for LSP mode?

I'm using spacemacs @develop (branch). I can't use lsp and lsp-ui. In vscode everything works (using flow lsp mode). With company-flow I can also make it working. When opening a .js file with // @...
0 votes
2 answers
826 views

Enable JSX folding in web-mode

I'm using web-mode to edit jsx files and I'm wondering what minor-mode can I use to add folding support. Is there anything out there that works? Thanks
0 votes
1 answer
33 views

Disable code autocompletion in JS files

For some reason, my Emacs started autocompleting code. I have noticed this in both web-mode and rjsx-mode. For example, if I type <button></ it will autocomplete it to <button></...
1 vote
1 answer
98 views

Is it possible to do conditional formatting on an org-table?

Here is an example of a table to format, the first row represents how often a task is done per year, the first column represents how long a task takes in seconds |-------+------------+-----------+---...
0 votes
2 answers
2k views

Configuring Flycheck to use a local ESLint

I was trying to get emacs to point to a version of eslint that isn't installed globally (but located in the node_modules of the directory one level up), so I followed this: Flycheck with file relative ...
20 votes
6 answers
11k views

How to edit jsx (react) files in emacs?

I've use js2-mode but it don't indent html in javascript properly. I've found this repo https://github.com/jsx/jsx-mode.el but it's not for react, it's for some other jsx. What do you use for editing ...
5 votes
2 answers
325 views

Commenting out some JSX code section with Emacs 27 js-mode

When I comment out (M-x comment-dwim) some section of JSX code with the new js-mode in Emacs 27, it gives: // <Grid rows={rows} columns={columns}> // <Table /> // <TableHeaderRow /&...
0 votes
1 answer
48 views

Tide mode: how do I get it to stop running tide-format-before-save?

I'm at my utter wit's end with this hell-plugin lmao. I've tried (remove-hook 'before-save-hook 'tide-format-before-save t), and it doesn't work. How do I remove tide-format-before-save from the ...
1 vote
1 answer
58 views

How to proper install and configure js2-mode via use-package declaration?

I am trying to install this package called js2-mode. This is part of my effort to follow this tutorial. Package documentation and tutorial are using classic installation via package-install as follows:...
1 vote
0 answers
14 views

What is the correct way to make js2-next-error available when using js2-mode as major mode?

I'm using js2-mode. It provides js2-next-error, but apparently only when using js2-minor-mode and not when using js2-mode as a major mode. This is clear from the code in js2-mode.el (in version ...
0 votes
1 answer
789 views

Javascript LSP mode in Emacs (using typescript-language-server) uses inconsistent indentation between files

On the first file I created, I had tabs set to 4 spaces and wasn't using the LSP yet. Then I enabled the LSP, and on all subsequently created files tabs are 2 spaces, yet on the original file, it ...
4 votes
4 answers
2k views

Emacs Javascript basic code completion

I try to set proper completions/suggestions for Javascript. There is no problem with ES6+ and Typescript types and defined variables but most of the time I work with vanilla JS in browser context, so ...
2 votes
3 answers
955 views

Emacs can't find Node when Node was installed using NVM (again)

My question is similar to this question. I've installed node via nvm. (executable-find "node") returns .nvm/versions/node/v15.11.0/bin/node. Entering node on eshell drops me into a node ...
0 votes
1 answer
74 views

How can I font-lock JavaScript code?

I find the default syntax highlighting for JavaScript and TypeScript to be lacking slightly. For example, s there a package equivalent to vim-polyglot for Emacs? I have tried Emacs tree-sitter but it ...
3 votes
3 answers
867 views

Stop javascript-mode from lining up function parameters after newline

Using javascript-mode, functions are indented like this: console.log('Example', var1, var2); test('Example2', var1, var2); I'd like to change this so that ...
1 vote
1 answer
680 views

ELDoc and company-tern are not working properly in JS2-mode (.js buffer in node) and Javascript, in Emacs

In my Emacs configuration for JavaScript/ JS2-mode, specifically .js buffer in node: (1) company-tern and ELDoc are NOT working properly. For eg. when I type 'console.l', 'log' does not pop up, ...
2 votes
1 answer
372 views

Cannot add general block header arguments in org mode

While I'm learning javascript following a book, I Like to take notes with org-mode. I use Indium and followed this instructions to handle it working It works well, and I get my work done, interacting ...
1 vote
1 answer
189 views

Emacs hangs when saving new file with prettier-mode enabled

I'm editing JavaScript files quite a bit and I have prettier installed and prettier-mode and when I load files and make changes it runs, changes the layout and saves them as expected. However, if I ...
0 votes
1 answer
360 views

How can I run JavaScript in a browser console?

I am looking for a way to stream data, using Emacs, which is accessible through an API that requires the submission of JavaScript code to a browser console: https://developer.tdameritrade.com/content/...
4 votes
0 answers
577 views

How to use dap-mode with TypeScript?

https://github.com/emacs-lsp/dap-mode provides DAP debugging for various languages (along the same lines as LSP does for completion, formatting, etc). How can I use that to debug programs written in ...
1 vote
0 answers
292 views

How to configure emacs for use with yarn 3?

The yarn package manager suggests a snippet of elisp to use: Create a .dir-locals.el with the following content to enable Flycheck and LSP support and make sure LSP is loaded after local variables ...
4 votes
1 answer
878 views

Evaluate JavaScript source block in org-mode

If I attempt to evaluate a JavaScript source block then I have to return a value to get a result. For example: #+begin_src js return 1 + 2; #+end_src #+RESULTS: : 3 That's a bit unusual. I guess ...
1 vote
0 answers
49 views

Emacs freezes on javascript mode if I enter a newline after a dot character

Cursor is on the dot, I press newline, emacs hangs. This happens often to me I kill emacs and restart it. I come to this situation to break long lines at function calls at dot character. situation('...
1 vote
0 answers
378 views

dap-mode for nodejs with nodemon

After 5 hours of googling and trying out different configurations i give up. How do i setup dap-mode for debugging nodejs with nodemon so that the debugger restarts when nodemon restarts? Non-solution ...
0 votes
0 answers
114 views

Uncommenting not working on Javascript file

I am trying to use the block un-comment command C-x C-; but I am getting the error message "Can't find the comment end". I am writing Javascript code in an .html file. The block comment ...
1 vote
1 answer
237 views

How do I make emacs indent relative to the beginning of the previous line?

Here's how emacs indents e.g. Python code: a = myfun(b, c) I'd like it to be this way: a = myfun(b, c) Reasoning? If I later replace myfun with myfunction, in the first case it becomes:...
2 votes
0 answers
79 views

How to move by defun without moving up a level?

I am attempting to navigate methods in a file. Typically these are javascript or python files, which have a classes at the "top level", which in turn have methods nested within those ...
1 vote
1 answer
945 views

automatic prettier for python code? (as in javascript)

https://github.com/prettier/prettier-emacs does formatting for javascript wonder if there's an equivalent for python code?
0 votes
0 answers
84 views

What doesn't my JavaScript layer automatically automatically format my JavaScript files?

When I open a JavaScript file, the file appears as plain text. When I activate javascript-mode in more (SPC SPC) on a .js file, then the file is correctly formatted. I have the layer installed with ...
0 votes
1 answer
86 views

Need help with JavaScript `{` indentation

I'd need some guidance with adjusting my indentation settings for js-mode (JavaScript). It should basically look like C/C++'s Stroustrup mode. Most of it works as expected, however there are some ...
0 votes
2 answers
706 views

Emacs acting strangely with indentation

So I've recently come back to working with emacs again I mostly write JavaScript in particular React these days and I'm noticing some strange behaviour when trying to indent my code. it seems the ...
1 vote
2 answers
179 views

Setup find-file-at-point to treat tilde as project root

A JavaScript project is setup with webpack path resolver like this: resolve: { alias: { '~': path.resolve(cwd, 'src') } }, This has the effect that a line in c:/...
1 vote
0 answers
2k views

Emacs configure lsp-mode / lsp-ui

I work mainly with javascript and typescript. And I have enabled lsp-mode in Doom Emacs. But I am not very happy about the descriptions and information shown to me on hover. It is not very useful and ...
0 votes
0 answers
732 views

How to set up Emacs Tide to use auto-complete for completion instead of company-mode?

I installed Tide in Emacs, and found it is pretty useful for writing JavaScript code. But one thing is that Tide has built-in support for company-mode to do completions. Since I am an auto-complete ...
3 votes
1 answer
158 views

customize js2-mode switch indentation

This is pretty simple but it's thwarting me: this is how a switch statement indents in js2-mode switch(letterGrade){ case "A+": value = 100 ; break; case "A": value = 97 ; break; ...
2 votes
1 answer
433 views

How to generate and display tags in treemacs (for JavaScript)?

I'd like to generate a set of tags and then view them in Treemacs, ideally whenever I open a file that I can generate tags for. The docs for Treemacs' tag view say: Treemacs is able to display ...
1 vote
1 answer
224 views

How to display js2-mode warnings

I am running Emacs 26.1 on Ubuntu 16.4. I am writing Javascript using js2-mode. When the linter underlines a line of code, I want to know what error or warning it has detected. For example, in this ...
13 votes
1 answer
4k views

How to get org-babel source block working with ES6-7?

I'm having difficulty getting org-babel to evaluate this block of code with emacs v24.5 node v5.0.0 babel-node v.6.6.5 #+BEGIN_SRC js :cmd "babel-node" let arr = [1, 2]; let [x, y] = ...
1 vote
0 answers
62 views

tide-mode in org-edit-src-code

I want to activate tide-mode when using Javascript soruce code blocks, following this it works well with indium: https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-js.html But I want to use ...
2 votes
2 answers
882 views

How to show all functions in a javascript file?

How to show all functions in a js file? I am using js2, but any solution will do. Additional info: I am expecting an occur style buffer. This can persist and be edited if necessary. Or searched. This ...
1 vote
1 answer
635 views

Unable to Set Javascript Indent on Spacemacs

I have a vanilla Spacemacs setup, and in my .spacemacs file, the dotspacemacs/user-config definition I have added (setq js2-basic-offset 2) which should be sufficient to set the indent length as 2. I ...
0 votes
0 answers
171 views

Web-beautify JS code on Windows (js-beautify for unminimifying)

I'm trying to un-minimify JS code on Windows. I've installed web-beautify from MELPA. I also installed Node.js for Windows, which is a dependency of this package. I then ran npm -g install js-beautify ...
1 vote
1 answer
935 views

ES6 imports auto suggestion

I'm new to emacs and trying to setup emacs for ES6/React developement. I would like to have auto suggestions for es6 imports like lodash similar to vscode (as shown in screenshot). Is there a way to ...