-
Notifications
You must be signed in to change notification settings - Fork 25
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
Are we managed to get organize import and auto import working #16
Comments
Great to hear that. Would it be possible if you paste your io log as well. I'm curious about what the server replied to us. |
No additional settings. I am using pyright 1.1.64. I think I know what's the problem. If the module name or keyword was not input in the buffer, it won't be listed in the completion list. The issue needs lsp-mode core to take a look. |
I'm not sure if this is lsp-mode core problem or not because based on the io log, the suggestion was not sent by the server.
|
@yyoncho can u pls take a look at the issue about auto import and organize imports? @f279801 The commit 2d0e3eb seems just removing organize-imports on saving. I tried in VSCode, the command works manually. |
Organize import in lsp protocol is code action. If the server supports it we will call it. |
I'm having the same behavior and the workaround works for me. Also, organize imports doesn't work for me either. It returns the same |
It works with vscode but doesn't with lsp-mode. Wired. |
Can someone provide client/server log from vscode? |
@seagle0128 would you mind to help with this request? I don't use vscode. |
I tried a several times but failed to get the verbose logs in vscode 😭️ |
Can someone point me to vscode client? Seems like the server has code action |
|
So, generally it should work either via this:
Or by doing something like:
|
@yyoncho I supposed it should work, but still got error: Please advise? |
I suspect that the first problem is actually an expected behavior and opened a question to pyright here: Let's wait for their answer. |
So it's confirmed that it's an expected behavior. |
Anyone else still receiving |
@padraic-mcatee According to microsoft/pyright#967, it's as designed in pyright. |
@seagle0128 I also get |
pyright.organizeimports command has be invoked like that: I checked that |
@seagle0128 cannot we import after typing via something like code action? |
Since pyright will not support code action, if we still use pyright, is there any other package we can use for code action? For example type |
@ardrabczyk I see that this works for me as well. |
@seagle0128, any comments on @ardrabczyk 's note above that even though |
@indigoviolet What's the behavior of pyright extension of VSCode? Can you confirm if there are same? |
Seems like to me that it behaves exactly the same way in VsCode, and the only way to get imports in a sane way is by adding an import alias or importing a module directly. e.g. Works import django.urls as urls
urls.include(... # this will autocomplete Does not work from django.urls import include
include( ... # This will not, and it will also complain that it is an unknown symbol) Edit: I also just noticed that if you have something like this: include( ... # This will not, and it will also complain that it is an unknown symbol) and you delete the |
If the behaviors are same, it seems like an issue of the server side. |
That seems to be the case to me - I think the only way to fix this is to get the pyright server to fix it. |
@ardrabczyk thanks for your workaround, it works great! I overrode the default (defun mpereira/lsp-pyright-buffer-file-organize-imports ()
(interactive)
(lsp-send-execute-command "pyright.organizeimports"
(vector (concat "file://" (buffer-file-name)))))
(use-package lsp-pyright
:after lsp-mode
:hook ((python-mode-hook . (lambda ()
(general-define-key
:keymaps '(local)
:states '(normal visual)
"gn" #'mpereira/lsp-pyright-buffer-file-organize-imports))))
:init
(require 'lsp-pyright)) |
Just a question on if we are able to get organize import and auto import working?
If we are then would you mind to give me a hint.
s = socket.socket()
lsp-organize-imports
, it also does not help.LSP :: source.organizeImports action not available
The text was updated successfully, but these errors were encountered: