-
-
Notifications
You must be signed in to change notification settings - Fork 913
Lsp mode does not respect web mode indentation variables #2915
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
Comments
@vikigenius Can you try (setf (alist-get 'web-mode lsp--formatting-indent-alist) 'web-mode-code-indent-offset) There is no |
So it does work in my specific case since I am using web mode for typescript mostly. But web-mode provides multiple indentation variables
I am not really sure how to handle that nicely. I will probably no longer be using web-mode for tsx once emacs-typescript/typescript.el#4 gets resolved. But meanwhile I will use the suggestion you provided since that works out ok for me. If you have any better ideas on handling the multiple indentation variables that web-mode provides I can provide a more generic PR. |
What we can do is allow providing a matcher function in the indent alist. Marking as closed since the issue has a workarround. If you want to extend lsp-mode to support matcher function feel free to provide a PR. |
tab 押下時は web-mode-code-indent-offset 等の設定で動いていたが indent-region ではそれと違う値(4)でインデントされていて indent-region を使えずにいた emacs-lsp/lsp-mode#2915 (comment) を参考に lsp--formatting-indent-aliat に web-mode の設定を追加することで 良い感じにインデントできるように調整した
tab 押下時は web-mode-code-indent-offset 等の設定で動いていたが indent-region ではそれと違う値(4)でインデントされていて indent-region を使えずにいた emacs-lsp/lsp-mode#2915 (comment) を参考に lsp--formatting-indent-aliat に web-mode の設定を追加することで 良い感じにインデントできるように調整した
Hi @yyoncho,
I didn't go for the matcher function that you suggested. I decided to go this way becuase it makes the configuration easier as you don't have to create a custom function but you can just map a file extention (a string) to a variable. If you don't like this approach then I can try to implement the matcher function. I think this is a really common problem as LSP and web-mode are typical packages used by devs, so please tell me what you think so that we can reach a solution, thank you! |
Thank you for the bug report
lsp-mode
related packages.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:
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
web-mode-code-indent-offset
to 2.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.
The text was updated successfully, but these errors were encountered: