praem90 / nvim-phpcsf

A simple nvim plugin wrapper for both phpcs and phpcbf.
https://praem90.github.io/nvim-phpcsf/
13 stars 3 forks source link

phpcbf not working #1

Closed gabrielbidula closed 3 years ago

gabrielbidula commented 3 years ago

First of all, good job on making this plugin, really handy.

I am trying to figure why phpcbf is not working on neovim, follows a screenshot with the error.

Screenshot 2021-06-16 at 23 20 05

On the terminal, phpcbf works with no issue.

Screenshot 2021-06-16 at 23 23 03

This is my neovim config.

Screenshot 2021-06-16 at 23 24 20

Thanks

praem90 commented 3 years ago

run the below nvim cmd on a php buffer and make sure the phpcbf was executed.

:lua require'phpcs'.cbf()

gabrielbidula commented 3 years ago

Yes, I tried but it doesn't do anything, not even display an error, can we debug it somehow?

praem90 commented 3 years ago

I've an option to disable phpcbf. Make sure the g.disable_cbf option is not set or set it to zero as below

:let g:disable_cbf=0

gabrielbidula commented 3 years ago

But I do want it enabled, didn't get it. I dont see any output when running :lua require'phpcs'.cbf()

praem90 commented 3 years ago

Added two new helper to read the stdout and stderr

:lua require'phpcs'.get_last_stdout()
:lua require'phpcs'.get_last_stderr()
gabrielbidula commented 3 years ago

Good, so I can see this output when I run :lua require'phpcs'.cs()

STDIN:23:25: error - Parentheses must be used when instantiating a new class
STDIN:34:27: error - Parentheses must be used when instantiating a new class

Press ENTER or type command to continue

But no stdout or stderr for :lua require'phpcs'.cbf() , weird. It seems it is not even running.

praem90 commented 3 years ago

after :lua require'phpcs'.cbf(),

gabrielbidula commented 3 years ago

Yes, I did it before, as I said, there is not output for both commands, it works when the command is:lua require'phpcs'.get_last_stdout() although. Something is missing with the cbf command.

gabrielbidula commented 3 years ago

@praem90 Another detail, after adding the autocmd calls to my init.vim I get the below error. It shows this handle error whenever I open a buffer or save it.

Screenshot 2021-06-26 at 16 54 25
praem90 commented 3 years ago

Thanks for reporting. It will be fixed ASAP

praem90 commented 3 years ago

Made some fixes and improvements. You can get the latest one. Hope no more bugs :grin:

gabrielbidula commented 3 years ago

@praem90 Okay thanks! I just updated and now I cannot see the errors being displayed on the buffer in any case as before ie: opening, editing, or saving the file. I am able to see the output being created via the command :lua require'phpcs'.get_last_stdout() as you can see in the print below. Do we need a different setup on init.vim?

Screenshot 2021-07-02 at 23 33 03
praem90 commented 3 years ago

Yes, You may have to enable on your vim config.

You can see that there is no space to display diagnostic errors/warnings on the left to the line numbers as like as seen in the previous screenshots.

gabrielbidula commented 3 years ago

Hi @praem90 , I didnt touch my setup on, still has the same config.

    autocmd!
    autocmd BufWritePost,BufReadPost,InsertLeave *.php :lua require'phpcs'.cs()
    autocmd BufWritePost *.php :lua require'phpcs'.cbf()
augroup END

let g:nvim_phpcs_config_phpcs_path = '/Users/gabriel/.composer/vendor/bin/phpcs'
let g:nvim_phpcs_config_phpcbf_path = '/Users/gabriel/.composer/vendor/bin/phpcbf'
let g:nvim_phpcs_config_phpcs_standard = 'PSR12'

I didn't get what you mean by there is no space as it is the same setup as the other images, the only thing is that I do not see the diagnostic in line but on require'phpcs'.get_last_stdout(). On top of that, I am able to see in-line diagnostics for errors that are not coming from phpcsf ie: inteliphense, so I would assume something changed here.

gabrielbidula commented 3 years ago

FYI @praem90

Still, I am not able to make it work.

praem90 commented 3 years ago

@gabrielbidula I have fixed an issue. Please checkout the latest code and try again.