marlonfan / coc-phpls

🐭 php language server for coc.nvim
MIT License
212 stars 16 forks source link

Docblock does not work. #81

Open alalfakawma opened 3 years ago

alalfakawma commented 3 years ago

Describe the bug Docblock does not work. Typing /** should trigger it, but does not show anything. I have bought intelephense premium too.

To Reproduce Steps to reproduce the behavior: Type in a function, go 1 line above the function, type /**, you won't get a snippet list.

Expected behavior I should see a snippet that is waiting to be completed by pressing the completion mapping.

Screenshots https://i.imgur.com/0los5vH.png

Additional context

versions

vim version: NVIM v0.4.4 node version: v14.12.0 coc.nvim version: 0.0.79-3e5fbe3a93 coc.nvim directory: /home/aseem/.vim/plugged/coc.nvim term: xterm-256color platform: linux

Log of coc.nvim

2020-11-05T20:20:00.860 INFO (pid:622078) [plugin] - coc.nvim 0.0.79-3e5fbe3a93 initialized with node: v14.12.0 after 464ms 2020-11-05T20:20:01.981 INFO (pid:622078) [watchman] - watchman watching project: /home/aseem/Code/Projects/test 2020-11-05T20:20:05.578 INFO (pid:622078) [coc-phpls] - intelephense module (builtin) is ready to be started 2020-11-05T20:20:05.619 INFO (pid:622078) [language-client-index] - phpls started with 622671 2020-11-05T20:20:05.898 INFO (pid:622078) [language-client-index] - tailwindCSS started with 622851 2020-11-05T20:20:09.175 INFO (pid:622078) [completion-complete] - Results from: file 2020-11-05T20:20:10.790 ERROR (pid:622078) [languages] - Complete "phpls-1" error: TypeError: Cannot read property 'hasOwnProperty' of null at /home/aseem/.config/coc/extensions/node_modules/coc-phpls/lib/index.js:97:29 at async Object.doComplete (/home/aseem/.vim/plugged/coc.nvim/build/index.js:71822:30) 2020-11-05T20:20:12.022 INFO (pid:622078) [willSaveHandler] - Will save cost: 62 2020-11-05T20:20:13.012 INFO (pid:622078) [completion-complete] - Results from: file 2020-11-05T20:20:13.412 ERROR (pid:622078) [languages] - Complete "phpls-1" error: TypeError: Cannot read property 'hasOwnProperty' of null at /home/aseem/.config/coc/extensions/node_modules/coc-phpls/lib/index.js:97:29 at async Object.doComplete (/home/aseem/.vim/plugged/coc.nvim/build/index.js:71822:30) 2020-11-05T20:21:11.877 INFO (pid:622078) [willSaveHandler] - Will save cost: 63

d0nth4x commented 3 years ago

Same situation here. Any solutions?

alalfakawma commented 3 years ago

Not yet. Looks like this extension is not maintained anymore. But i'm still using it.

EDIT: Looks like it is still maintained. My bad on assuming.

d0nth4x commented 3 years ago

I solved this problem by disabling fixer provided by 'dense-analysis/ale'. Now I use 'stephpy/vim-php-cs-fixer' with @PhpCsFixer rule and it works! @alalfakawma can you check your plugins and confirm this solution?

EDIT: Proper coc/ale config

alalfakawma commented 3 years ago

I solved this problem by disabling fixer provided by 'dense-analysis/ale'. Now I use 'stephpy/vim-php-cs-fixer' with @PhpCsFixer rule and it works! @alalfakawma can you check your plugins and confirm this solution?

EDIT: Proper coc/ale config

I'm not using the lint plugins you mentioned, so I cannot confirm this.

d0nth4x commented 3 years ago

After few days I have same problem as before my fix. I have one solution for that: clear cache rm -rf ~/.config/coc/extensions/coc-phpls-data

yaegassy commented 3 years ago

@alalfakawma /** is displayed by VSCode's snippet feature.

The intelephense language server does not return completion suggestions for /**, so it may not be easy for coc-phpls to handle this.

There is another way to go about doc comment.

You can use the CodeAction feature to support doc comment.

See: https://github.com/marlonfan/coc-phpls/issues/38#issuecomment-660704805

alalfakawma commented 3 years ago

@alalfakawma /** is displayed by VSCode's snippet feature.

The intelephense language server does not return completion suggestions for /**, so it may not be easy for coc-phpls to handle this.

There is another way to go about doc comment.

You can use the CodeAction feature to support doc comment.

See: https://github.com/marlonfan/coc-phpls/issues/38#issuecomment-660704805

I mean. It does work sometimes, that's the thing that's bothering me. Sometimes when I create a random php file and create a class, it suddenly works, but adds unnecessary lines in the doc. Meaning, it is capable of working, and there has to be a solution to make it work consistently.

alalfakawma commented 3 years ago

After few days I have same problem as before my fix. I have one solution for that: clear cache rm -rf ~/.config/coc/extensions/coc-phpls-data

Will try this and get back with the result.

yaegassy commented 3 years ago

I mean. It does work sometimes, that's the thing that's bothering me. Sometimes when I create a random php file and create a class, it suddenly works, but adds unnecessary lines in the doc. Meaning, it is capable of working, and there has to be a solution to make it work consistently.

Do you have any coc extensions installed, such as coc-snippets, or Vim plugins, such as ultisnips?

Is there any chance that those snippet feature are working?

If you can find a reproducible procedure, I may be able to help you with something.

alalfakawma commented 3 years ago

I mean. It does work sometimes, that's the thing that's bothering me. Sometimes when I create a random php file and create a class, it suddenly works, but adds unnecessary lines in the doc. Meaning, it is capable of working, and there has to be a solution to make it work consistently.

Do you have any coc extensions installed, such as coc-snippets, or Vim plugins, such as ultisnips?

Is there any chance that those snippet feature are working?

If you can find a reproducible procedure, I may be able to help you with something.

Yeah I do have coc-snippets enabled, and they do work. Everything is working except the docblock, I can go to references, go to implementations, etc. As you can see in the logs above, I kept an eye on CocInfo to get the logs and this is the line that keeps popping up whenever it doesn't try to autocomplete the docblock for me -

2020-11-05T20:20:10.790 ERROR (pid:622078) [languages] - Complete "phpls-1" error: TypeError: Cannot read property 'hasOwnProperty' of null
at /home/aseem/.config/coc/extensions/node_modules/coc-phpls/lib/index.js:97:29
at async Object.doComplete (/home/aseem/.vim/plugged/coc.nvim/build/index.js:71822:30)

I have gone into the file and checked on the line but I'm not too familiar with what it is trying to do, so did not try to poke my head into it too much.

yaegassy commented 3 years ago

@alalfakawma Unfortunately, it's probably just a log of coc-phpls' lack of null handling, and has nothing to do with the /** docblock.

However, I have found a way to complement the docblock.

/**|*/ (| is the position of the cursor.)

I found out that if I do the completion with this |, I get a candidate.

intelephense-ls-snippets

Code

<?php

/**|*/
function check(string $hoge)
{
}
alalfakawma commented 3 years ago

@alalfakawma Unfortunately, it's probably just a log of coc-phpls' lack of null handling, and has nothing to do with the /** docblock.

However, I have found a way to complement the docblock.

/**|*/ (| is the position of the cursor.)

I found out that if I do the completion with this |, I get a candidate.

intelephense-ls-snippets

Code

<?php

/**|*/
function check(string $hoge)
{
}

Oh alright. I will try it out as soon as I get to my PC. I've never tried what you have suggested. And will report if it works or not.

alalfakawma commented 3 years ago

I can confirm this does work. I will just create my own snippet that creates a /*|*/, and moves the cursor where the | is. I know it's not the perfect solution, but it should do for now. But I really hope this can get fixed somehow. @yaegassy Thank you for your time mate. @d0nth4x you should try this out.