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

Auto import with Dart LSP #1457

Closed
wwwdata opened this issue Jan 9, 2020 · 10 comments
Closed

Auto import with Dart LSP #1457

wwwdata opened this issue Jan 9, 2020 · 10 comments

Comments

@wwwdata
Copy link

wwwdata commented Jan 9, 2020

Result from CocInfo

## versions

vim version: NVIM v0.4.3
node version: v13.5.0
coc.nvim version: 0.0.74-db5ffd2ff0
term: tmux-256color
platform: darwin

Describe the bug

When using dart (flutter) with either directly configuring the LSP in CocConfig or with the coc-flutter plugin, I sometimes do not get completions to import classes from other files. The behavior is like the following:

  • When I am in a file, type the class name of another class in another file, it correctly shows up and suggests to import the file, so far so good.
  • But when that file is open in another vim buffer already, I do not get that suggestion to import the class from that file. It only works, if I then delete that buffer from vim again.
  • It also does not work when opening code actions, the action to automatically import the missing file then just doesn't show up.

Reproduce the bug

  • Use the coc-flutter plugin, or optionally directly configure the dart LSP like described in the WIKI:
  "languageserver": {
    "dart": {
      "command": "dart",
      "args": [
        " change this to the path of analysis_server
        "/usr/local/opt/dart/libexec/bin/snapshots/analysis_server.dart.snapshot",
        "--lsp"
      ],
      "filetypes": ["dart"],
      "disableDynamicRegister": true,
      "trace.server": "verbose"
    },
  }
  • Create two files with a class in it.
  • Restart vim and only open 1 file. Type the name of the other class -> It will suggest importing the other file
  • Remove that import again, open the other file that defines the import.
  • Go back to the first file, type the name of the other class -> it will not show up
  • Go back to the second file with the class, delete the buffer with :bdelete
  • Go back to the first file, type the name of the other class -> it will suggest importing again
@chemzqm
Copy link
Member

chemzqm commented Jan 10, 2020

Should be problem of your language server, you can checkout output https://github.com/neoclide/coc.nvim/wiki/Debug-language-server#using-output-channel

@chemzqm chemzqm closed this as completed Jan 10, 2020
@Kavantix
Copy link
Contributor

@wwwdata did you find a solution for this?

@wwwdata
Copy link
Author

wwwdata commented Mar 19, 2020

@Kavantix my workaround still is to close the open buffer of the file that I want to auto-import and then run the import again. So far it seems to be still broken in the latest releases of flutter/dart.

@chemzqm
Copy link
Member

chemzqm commented Mar 20, 2020

Looks like you have to save the file or use :CocRestart to make the language server work as expected.

@wwwdata
Copy link
Author

wwwdata commented Mar 20, 2020

no, it's not only for "new" files. Even if I just open vim, Coc starts and I have 2 open files. One where I want to add an import from the second file, it will sometimes not work properly. It really only depends on closing the open buffer of the second file, in order for it to show up as an auto-import suggestion in the first file.

@Kavantix
Copy link
Contributor

Exactly, opening two files disables the possibility to import from each other until I delete the buffer.
Thanks for the quick response!

Is there already an open ticket at the dart analysis server @wwwdata?

@arnaudelub
Copy link

i'm using vim inside tmux and indeed, each new file created won't be shown in the auto import, i have to exit vim to make the import available, this is quite annoying :(

@chemzqm
Copy link
Member

chemzqm commented Mar 25, 2020

Send your bug to repo of language server, we can't do anything.

@DenDos
Copy link

DenDos commented May 10, 2020

@wwwdata Not sure if it's your situation but I had the same issue and I solved this removing
set hid
from my .vimrc

After I removed this line autocompletion works fine

@wwwdata
Copy link
Author

wwwdata commented May 10, 2020

Hm, thanks for the tip but it still does not work. When I create a new file with a new widget. It is still not recognized... Only when I close that file can I import the new widget automatically in another one...

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

No branches or pull requests

5 participants