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

organize-imports fails when using ts-ls #3317

Closed
2 of 3 tasks
bolivier opened this issue Jan 13, 2022 · 1 comment
Closed
2 of 3 tasks

organize-imports fails when using ts-ls #3317

bolivier opened this issue Jan 13, 2022 · 1 comment
Labels

Comments

@bolivier
Copy link

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: M-x lsp-start-plain

Bug description

organize-imports doesn't work with ts-ls.

Steps to reproduce

run lsp-organize-imports

Expected behavior

Imports should be organized

Which Language Server did you use?

ts-ls

OS

MacOS

Error callstack

No response

Anything else?

The fix is to put

(lsp-make-interactive-code-action organize-imports "source.organizeImports.ts-ls")

In your config file. I think it'd be good to have it in the docs site somewhere. I'm happy to open a PR with that change.

@bolivier bolivier added the bug label Jan 13, 2022
@inscapist
Copy link

Overriding the organize-imports code action is going to affect non-typescript projects. My workaround is to create a new code action called organize-imports-ts, for example:

(after! lsp-mode
  ;; (setq lsp-clients-typescript-init-opts '(:importModuleSpecifierPreference "non-relative"))
  (lsp-make-interactive-code-action organize-imports-ts "source.organizeImports.ts-ls"))

calling this macro creates a new interactive function lsp-organize-imports-ts, which can be key-bound.

(map! :after lsp-mode
      (:map typescript-mode-map
       "C-c C-o" #'lsp-organize-imports-ts)
      ("C-c C-o" #'lsp-organize-imports))

NOTE: The example above is specific to doom emacs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants