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

Deletes comments in Ruby files #335

Open
coaxial opened this issue Oct 25, 2022 · 3 comments
Open

Deletes comments in Ruby files #335

coaxial opened this issue Oct 25, 2022 · 3 comments

Comments

@coaxial
Copy link

coaxial commented Oct 25, 2022

Do you want to request a feature or report a bug? A bug

What is the current/expected behavior? current: deletes comments. Expected: leave comments alone

What version of vim-prettier are you using - (output of :PrettierVersion) ? 1.0.0-beta

What version of prettier are you using - (output of :PrettierCliVersion) ? 2.3.1

What is your prettier executable path - (output of :PrettierCliPath) ? ~/.vim/plugged/vim-prettier/node_modules/.bin/prettier

Did this work in previous versions of vim-prettier and/or prettier ? I don't know

With let g:prettier#autoformat=1, create a new buffer and set ft=ruby. Saving this buffer:

# My comment

puts 'hello'

Will modify it to:

puts 'hello'

My config file:

Plug 'prettier/vim-prettier', { 'do': 'npm install'  }
let g:prettier#autoformat = 1
let g:prettier#autoformat_config_present = 0
let g:prettier#autoformat_require_pragma = 0
let g:prettier#exec_cmd_async = 1
let g:prettier#quickfix_enabled = 0

For those affected, a temporary fix in your .vimrc:

autocmd BufRead,BufNewFile  *.rb let g:prettier#autoformat = 0
@alexstan67
Copy link

alexstan67 commented Nov 7, 2022

Hi same problem for me... Comments disappearing as well as shebang line
#! /usr/bin/env ruby

@marcosmcz
Copy link

marcosmcz commented Mar 13, 2023

I have the same issue :(

My solution was to use Neovims null-ls.nvim package for ruby.

@victorsptt
Copy link
Contributor

What version of the @prettier/plugin-ruby npm package are you using?

There is a bug in versions of the @prettier/plugin-ruby npm package lower than 1.0 that removes comments from some parts of the code.

You can try updating your version of the @prettier/plugin-ruby to >=1.0.0 <4.0.0 and see if it solves the error.

npm install --save-dev @prettier/plugin-ruby@">=1.0.0 <4.0.0"

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