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

Enable tree-sitter for .zshrc and .bashrc #1460

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions helix-core/src/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,13 @@ impl Loader {
.and_then(|n| n.to_str())
.and_then(|file_name| self.language_config_ids_by_file_type.get(file_name))
.or_else(|| {
path.extension()
.and_then(|extension| extension.to_str())
// we can't use the `extension` methods here because it ignore
// empty file name with only an extension like `.bashrc`.
path.file_name()
.map(|file_name| file_name.to_str())
.flatten()
.map(|file_name| file_name.rsplit('.').next())
.flatten()
Comment on lines +311 to +317
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC currently .gitconfig already works since that is used for tree-sitter-git-config.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huum from what I see, no, it doesn’t work with git-config on master currently 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see highlights working on master for .gitmodules/.gitconfig (i.e. cargo run .gitmodules). That's not working for you?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to update your submodules?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not really good with submodules, is there a way to update my submodule more than that?
https://asciinema.org/a/tmOpnwQAFWhcWkJD3dFQJoIed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok, I think if you cargo clean -p helix-syntax after the submodule update and then cargo run ~/.gitconfig, that might do it. You can also add a --force on the end of that submodules command iirc, and that forces them to be checked out again at whatever revision git thinks they should be.

btw the animal emojis on your shell are awesome! 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I don't think this needs to be changed, file_name will return .bashrc so specifying ".bashrc" in TOML should be enough.

.and_then(|extension| self.language_config_ids_by_file_type.get(extension))
});

Expand Down
4 changes: 2 additions & 2 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ indent = { tab-width = 2, unit = " " }
name = "bash"
scope = "source.bash"
injection-regex = "bash"
file-types = ["sh", "bash"]
shebangs = ["sh", "bash", "dash"]
file-types = ["sh", "bash", "zsh", "bashrc", "zshrc"]
shebangs = ["sh", "bash", "dash", "zsh"]
roots = []
comment-token = "#"

Expand Down