Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML attributes misaligned on different lines #1288

Closed
sphakka opened this issue Nov 23, 2023 · 3 comments
Closed

HTML attributes misaligned on different lines #1288

sphakka opened this issue Nov 23, 2023 · 3 comments

Comments

@sphakka
Copy link

sphakka commented Nov 23, 2023

Maybe I'm missing something about lineup args, etc. I have these in my .emacs:

(add-to-list 'web-mode-indentation-params '("lineup-args" . nil))
(add-to-list 'web-mode-indentation-params '("lineup-calls" . nil))
(add-to-list 'web-mode-indentation-params '("lineup-concats" . nil))
(add-to-list 'web-mode-indentation-params '("lineup-ternary" . nil))

Still, with plain HTML, I can't manage to stop attrs to (mis)align on different lines. This is what happens:

  1. Write a first line, then (| is the cursor) hit enter: the cursor is correctly indented by one tab:
    <div class="foobar" 
        |
  2. Keep writing on the next line:
    <div class="foobar" 
        id="quux"|
  3. As soon as enter is hit, the second line gets misaligned like this:
    <div class="foobar" 
               id="quux"

That's, ahem... ugly! How to prevent it?

BTW, even when lineup alignment is desired, IMO, it would be nicer to have attributes on multiple lines to get aligned (whenever possible -- I guess it might be really complicated!) at the = sign:

<div class="foobar" 
        id="quux"
@fxbois
Copy link
Owner

fxbois commented Nov 24, 2023

try with an empty .emacs

@sphakka
Copy link
Author

sphakka commented Nov 24, 2023

After much head scratching, here comes the bug. It has nothing to do with lineup settings and it happens with minimal .emacs:

(require 'web-mode)

(setq-default tab-width 4)

(add-hook
 'web-mode-hook
 (lambda ()
   (setq indent-tabs-mode t)
   (web-mode-use-tabs)
   ))

The culprit is (web-mode-use-tabs) -- removing it, brings back the expected behavior.

@fxbois
Copy link
Owner

fxbois commented Nov 24, 2023

There is issues with tab alignment. Would be happy to review a patch.

@fxbois fxbois closed this as completed Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants