Skip to content

Lsp mode does not respect web mode indentation variables #2915

Closed
@vikigenius

Description

@vikigenius

Thank you for the bug report

  • I am using the latest version of lsp-mode related packages.
  • I checked FAQ and Troubleshooting sections
  • You may also try reproduce the issue using clean environment using the following command
emacs -q -l lsp-start-plain.el

where lsp-start-plain.el can be downloaded here.
Alternatively, it will be great if you can reproduce the issue using lsp-docker which provides the minimal configurations for lsp-mode and ships with most of the language servers.

Bug description

So I am using a custom derived more of web-mode to handle my .tsx files. This does not respect my indendation configurations.

For eg:

import {
  Stack,
} from '@chakra-ui/react';

In the above snippet if I try to add another import and use completion, it indents to 4 spaces instead of two. Even though according to normal indentation rules, I consistently use 2 spaces.

Steps to reproduce

  1. Set web-mode-code-indent-offset to 2
  2. Verify that standard indendation uses 2 spaces.
  3. Try to use completion when doing imports in .tsx files with web-mode.

Expected behavior

lsp-mode should respect web-mode indendation variables.

Which Language Server did you use?

ESLint and typescript-language-server

OS

Linux

Error callstack

No response

Anything else?

Adding the following advice in doom-emacs fixes the issue.

(defadvice! +lsp--fix-indent-width-in-web-mode-a (orig-fn mode)
  :around #'lsp--get-indent-width
  (if (provided-mode-derived-p mode 'web-mode)
      'tab-width
    (funcall orig-fn mode)))

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions