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

import completion not working in neovim #1

Closed
om-tat-sat opened this issue Jul 21, 2022 · 16 comments
Closed

import completion not working in neovim #1

om-tat-sat opened this issue Jul 21, 2022 · 16 comments

Comments

@om-tat-sat
Copy link

Hi,
I installed the coc-cairo extension using :CocInstall coc-cairo in Neovim. I could not get the completions for import definitions.

In VSCode, the completions work partially. from a.b import c - In vscode, completions work after typing out the module names fully - from a.b

Could you please help?

Warm Regards,

@om-tat-sat
Copy link
Author

This extension pulls [email protected]. The latest version is 0.0.25. How can I get the extension use the latest version of cairo-ls?

Thanks.

@kevinhalliday
Copy link
Owner

@om-tat-sat thanks for flagging this. The original issue with imports is an issue with an older version of cairo-ls. So yes, this extension should use the latest.

I'll bump the dependency and publish a new release now. And I'll work on a better approach to managing cairo-ls versions.

@kevinhalliday
Copy link
Owner

It seems the latest version of cairo-ls is not yet on npm. I've opened an issue here ericglau/cairo-ls#39

@ericglau
Copy link

@om-tat-sat It should work if you add the example VIM configuration to your ~/.vimrc file. I've updated the steps in these instructions.

After you've added that to ~/.vimrc, press Control Space to trigger the completion.

Example:
Screen Shot 2022-07-22 at 2 14 41 PM

@amanusk
Copy link

amanusk commented Jul 22, 2022

No dice for me either, only seem to work with the method of installing and editing the coc-settings configuration..

The completion menu pops up without any need for a trigger

@kevinhalliday
Copy link
Owner

kevinhalliday commented Jul 22, 2022

Okay I think I'm experiencing the same issue - I'll describe it here.

Given we point to the cairo-ls via config in coc-settings.json to the right virtual environment, I have completions working after the from keyword

image

Completions do not work in the middle of a module name. There is a related issue on cairo-ls here ericglau/cairo-ls#32. So from some.<complete me> would not work.

The issue with this package is that completions do not work after the import keyword, but they should. Completions like from some.module import <complete me>. I believe that works in the vscode plugin - @om-tat-sat is that right?

Hope this is the same issue you all are experiencing. I'll look into it.

@om-tat-sat
Copy link
Author

Thanks for checking and your reply.
I'm using Neovim. I installed the plugin using :CoCInstall. The only setting I did in coc-settings.json was to point to the correct activate file using cairols.nileVenvCommand and cairols.venvCommand config options.

I have the below setting to trigger completion on pressing Ctrl-Space, and to set the syntax for cairo files.

inoremap <silent><expr> <c-space> coc#refresh()                                                     
vim.api.nvim_command('au BufNewFile,BufRead *.cairo set filetype=cairo')                            

Inside Neovim, the completions after from works after a few attempts. But, after the import keyword, it never worked for me too in Neovim. I see errors like this (checked it with :ConInfo).

   19 2022-07-22T20:57:39.235 ERROR (pid:1602545) [server] - uncaughtException Error: Header must provide a Content-Length property.
   20     at AS.onData (/home/<myusername>/.cache/nvim/pack/packer/start/coc.nvim/build/index.js:36:14451)
   21     at Socket.<anonymous> (/home/<myusername>/.cache/nvim/pack/packer/start/coc.nvim/build/index.js:36:14181)
   22     at Socket.emit (node:events:513:28)                                                             
   23     at addChunk (node:internal/streams/readable:324:12)                                             
   24     at readableAddChunk (node:internal/streams/readable:297:9)                                      
   25     at Readable.push (node:internal/streams/readable:234:10)                                        
   26     at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)                                 

In vscode, the completions after the import keyword worked for me earlier today, but it doesn't now. Am I missing some settings?

@kevinhalliday
Copy link
Owner

Nope. You're settings are good. I'm getting the same error. I'll look into it. Won't have much time this weekend though.

Also if you wanna try debugging, you can fork this repo, uninstall coc-cairo, and add this to your init.vim

set runtimepath^=/path/to/forked/coc-cairo

Then you can just mess around locally and see what gives.

@om-tat-sat
Copy link
Author

I tried that earlier today. Also, instead of picking the cairo-ls from the npmjs server, I pointed the dependency to a local clone of cairo-ls, and somehow built it and got the out files for that repo. I still see the same issue.

Searching for this error online doesn't help much. I have no knowledge of Nodejs.

Have a nice weekend. Would be great if you are able to look into it sometime next week.

Thanks.

@kevinhalliday
Copy link
Owner

@om-tat-sat turns out the v0.0.7 cairo-ls on npm is the latest version. see here ericglau/cairo-ls#39. the v0.0.25 package is the vscode exentsion, not the language server

@kevinhalliday
Copy link
Owner

kevinhalliday commented Jul 25, 2022

This should be fixed in v0.0.3. v0.0.3 also adds the commands nile.compile, nile.compile.all, nile.clean, and pytest - which were configured as callable but not implemented in v0.0.2. Here's the PR if you're interested.

I just tried it out and it seems to be working so closing this issue. Thanks all for your input

If it doesn't work we can reopen

@om-tat-sat
Copy link
Author

Thanks a lot for fixing this. I tried it now and it works perfectly fine. Thanks again.

@amanusk
Copy link

amanusk commented Jul 30, 2022

I am still stuck with the same issue. Not getting completion for libs

image

Is there anything I need to do post installation?

@om-tat-sat
Copy link
Author

I tried this in a new virtualenv, and it worked for me.
Did you try uninstalling and installing the coc-cairo?

@ericglau
Copy link

@amanusk Does completion work after from? There is a bug where it doesn't work in the middle of a module name.

My suggested post-installation steps are here.

If you see compile error highlighting, then your virtualenv is working fine:
Screen Shot 2022-07-30 at 10 54 42 AM

@amanusk
Copy link

amanusk commented Jul 30, 2022

Thanks @ericglau.

I indeed get compilation errors and I do get completion after import, but not after from

image

With your previous instructions, all that works + I get completion after from and in the middle of a module name

image

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

4 participants