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

Ignore Files setting and --ignore-files in .streerc both have no effect #192

Open
chasestubblefield opened this issue Dec 18, 2022 · 4 comments

Comments

@chasestubblefield
Copy link

This may be due to a limitation of the language server itself, but I cannot get the extension to ignore files.

Assume I want to ignore checking and formatting for the file db/schema.rb in my Rails project. With the following .streerc file in the project root:

--ignore-files='db/schema.rb'

I can successfully have the CLI and Rake tasks ignore the file. However, the extension will always format the file, which is annoying because I like to use Format On Save. The language server does seem to pick up my other settings in .streerc, however.

Here's what I have tried. In each case I have restarted the language server. Also, it may be worth noting I am using a bundled syntax_tree.

  • Ignore Files set to db/schema.rb
  • Ignore Files set to schema.rb
  • Ignore Files set to **/schema.rb
  • Ignore Files set to '**/schema.rb' (quoted to avoid shell expansion)
  • Ignore Files set to /Users/chase/dev/my_project/db/schema.rb (Absolute path)

I expect the extension to do nothing when asked to format an ignored file either directly with the Command Pallete or with Format On Save.

If I need to dive into the language server and extension code to debug this, I will, because currently it's a bit annoying. I plan to generate a "TODO" list of files that fail stree check and adding them to my .streerc, so I can incrementally format my project.

@chasestubblefield chasestubblefield changed the title Ignore Files setting and --ignore-files in .streerc has no effect Ignore Files setting and --ignore-files in .streerc both have no effect Dec 18, 2022
@chasestubblefield
Copy link
Author

Seems like it is a limitation of the Language Server directly. It seems to ignore all command-line arguments (including from .streerc) except for print_width: https://github.com/ruby-syntax-tree/syntax_tree/blob/8fbcd1bc52e7e3f85bbf8d46cf93d0182a7a04ac/lib/syntax_tree/cli.rb#L504

@kddnewton
Copy link
Member

Which version of the plugin and which version of syntax tree are you running? This was fixed in a recent version.

@chasestubblefield
Copy link
Author

Gem version 5.0.1, extension version 0.5.1, which are both latest I believe. Just to be sure:

$ bundle info syntax_tree | head -n 1
  * syntax_tree (5.0.1)
$ code --list-extensions --show-versions | grep ruby-syntax-tree
[email protected]

Just to clarify, the gem CLI correctly ignores based on my .streerc:

$ bundle exec stree check db/schema.rb
All files matched expected format.

With the default extension settings however, opening db/schema.rb and saving (with Format on Save) still formats the file.

I tried using the setting "syntaxTree.ignoreFiles": "db/schema.rb", which restarted the LSP. Output channel shows:

Starting language server: bundle exec stree lsp --ignore-files=db/schema.rb

But I still get the same result when saving the file.

@matthewgapp
Copy link

matthewgapp commented Jan 26, 2023

I'm experiencing this also, fwiw. v0.5.1 of the extension and 5.3.0 of the gem. This appears to be an issue with the syntax_tree library's lsp implementation. It only accepts print width as an option.

https://github.com/ruby-syntax-tree/syntax_tree/blob/c497724afdd34ed00a4ac4804b1d26da973b4c95/lib/syntax_tree/cli.rb#L505

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

3 participants