Skip to content
This repository has been archived by the owner on Dec 11, 2023. It is now read-only.

Integration with Coc? #8

Open
yatesco opened this issue Sep 29, 2021 · 15 comments
Open

Integration with Coc? #8

yatesco opened this issue Sep 29, 2021 · 15 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@yatesco
Copy link

yatesco commented Sep 29, 2021

Hi there - this looks great. Does it only integrate with the native LSP? If I run code actions from Coc I get a bunch but if I run CodeActionMenu without changing the cursor I get "No code actions available!"

image

image

@weilbith
Copy link
Owner

I'm sorry to say, but this does not support CoC. I have 0 experience with CoC. How easy is it to ask CoC for code actions at the current cursor location? 🤔
So I could add the feature that it tries both, the native LSP clients and CoC (if available).

@yatesco
Copy link
Author

yatesco commented Sep 29, 2021

No problem at all :-). I have no idea either, I was just wondering if it was already done. I could add this to my never-ending list of TODOs but... :-(.

I'm converting over to native LSP anyway, I just need to make Telescope as fast as FZF to complete the switch .

@yatesco yatesco closed this as completed Sep 29, 2021
@weilbith
Copy link
Owner

Haha okay. Let's see if more users want this. I don't need it, but it looks like it is fairly easy to add. Depending on how easy CoC is to use. Though I would rather not like to add CoC to my local setup to test it. So I appreciate if someone would open a PR 😬

@TxHawks
Copy link

TxHawks commented Oct 1, 2021

It would be really great if this plugin could support CoC as a source. It should be be pretty easy to get a code action from CoC. There's a <Plug> mapping for it, which is mapped to :<C-u>call CocActionAsync('codeAction', 'cursor') here

@xiyaowong
Copy link
Contributor

Hey guys, check this https://github.com/xiyaowong/coc-code-action-menu

@TxHawks @yatesco

@TxHawks
Copy link

TxHawks commented Oct 2, 2021

@xiyaowong Thanks!

@weilbith Would you be open to integrating @xiyaowong's work into this repo? Seems like a shame to keep two different plugins that are likely to get out of sync at some point

@weilbith
Copy link
Owner

weilbith commented Oct 2, 2021

I'm honestly confused about @xiyaowong. Why isn't he just doing this in a feature branch and open a PR for it. Just discussing the solution together. That's usually how open source projects work. Yes therefore you have to fork the repo. But why rename it, don't open a PR and advertise it?
I was going to check how I can integrate CoC here best. The idea of this plugin should be independent from where the data comes from. Though I have no experience with CoC and honestly don't like its approach too much. But I thought with the help of you guys we can do it together.

PS: @xiyaowong if your intention was to first have others test it and you planned to open a PR soon, you can ignore the above. I'm just confused right now. 🤷🏻‍♂️

@weilbith weilbith reopened this Oct 2, 2021
@weilbith weilbith added help wanted Extra attention is needed enhancement New feature or request labels Oct 2, 2021
@xiyaowong
Copy link
Contributor

I am very happy to contribute, it requires adding a settings feature, so it may modify many codes, I also see you have a pr about new feature , I'm waiting for your work to be merged, then reorganize them

@weilbith
Copy link
Owner

weilbith commented Oct 3, 2021

I am very happy to contribute, it requires adding a settings feature, so it may modify many codes, I also see you have a pr about new feature , I'm waiting for your work to be merged, then reorganize them

Thanks for replying. 😊
I checked the commits on your branch to get a feeling how if works. Due to the recent work here (especially with the current open PR) there will be tons of conflicts. Anyway you are right, adding this feature will require some "bigger" changes to maintain a good architecture. I plan to work on this tonight and start to refactor this. In theory it should be possible to add then any kind of LSP client implementation, not only native and CoC.

@weilbith
Copy link
Owner

weilbith commented Oct 3, 2021

It would be very helpful if someone could tell me if CoC it's client implementation sets the capability to resolve actions. And if so, if it does resolve them automatically when requesting the actions. Though this is kinda against the idea of resolvable actions but "necessary" for this plugin to preview as much metadata as possible.
Would be good to know for a few design decisions I have to make.

@SirWrexes
Copy link

SirWrexes commented Sep 5, 2022

Hey there, I'm not sure if this is the right thread, but I've been struggling to make @xiyaowong's plugin work.

Is it even possible using Plug ? -- I dont really feel like changing my whole plugin management env' to packer just for this, honestly.

I can't seem to understand when/where/how I'm supposed to make the menu require the plugin, since its README says "in code-action-menu's config" and code-action-menu's README basically says "there is no actual config file yet"

This is how they're installed for now, and reading Plug's docs there is no real dependency management, which seems to be an issue in how I should get the CoC extension to work... 🤔
image
I also have a ~/.vim/after/ftplugin/code-action-menu-menu.lua containing a single line: require 'coc-code-action-menu' even though I'm pretty sure this line is actually something to be executed in the packer installation chain.

@xiyaowong
Copy link
Contributor

xiyaowong commented Sep 5, 2022

try Plug 'weilbith/nvim-code-action-menu', {'do': 'lua require"coc-code-action-menu"'}

@SirWrexes
Copy link

That didn't work.
The do option is only to perform certain commands after install/upgrade so I tried fully reinstalling and it didn't work either.

@xiyaowong
Copy link
Contributor

That didn't work. The do option is only to perform certain commands after install/upgrade so I tried fully reinstalling and it didn't work either.

put lua require"coc-code-action-menu" to the last line in your config

@SirWrexes
Copy link

SirWrexes commented Sep 7, 2022

I had no idea you could run Lua right inside .vim files. o.o
Anyway, doing that broke everything and CoC with it BUT...

Despite my abysmal knowledge of Lua, I found a way to require the module only if it exists.
I've then tried it with and without coc-code-action-menu and calling <Plug>(coc-codeaction) with my prefered keystroke did in fact show me CoC's menu when coc-code-action-menu was not installed, and then the custom menu when I reinstalled it.

Here's what I did, I added this line before the return in code_action_menu.lua:l134:

local _hasCCAM, _ccam = pcall(require, "coc-code-action-menu")

Simple and works.

Now I have other issues, apparently the pop-up window blends into what's behind it, I see characters from under the window appear inside it.
image
Do you guys think it's a side effect of the way I've loaded the plugin ?

I'm also having the issues described in #52 but they're not for this thread.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants