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

Detect .bb and .clj_kondo file extension as Clojure #42

Merged
merged 3 commits into from
Nov 15, 2024

Conversation

russtoku
Copy link
Contributor

This should resolve issue #38.

I ran the Clojure program to update the syntax files but nothing was changed except the comment about the version of Java using with Clojure. I did have to make the update-project! function not private to run the function as specified in contributiting guidelines.

I didn't test the browsefilter because I don't use Windows or GTK.

I ran lein test and got:

Ran 7 tests containing 272 assertions.
0 failures, 0 errors.

I installed my changes as a plugin for Vim 9.0.2142 on macOS Sequoia 15.0.1 on Apple Silicon (M3 2024 Macbook air). Editing files with extension .bb and .clj_kondo are detected as clojure files. The same is true with Neovim 0.10.2.

I did notice that in a file without a filename extension but a shebang line, the filetype isn't set to clojure.

Another thing that I noticed is that .bb is a recognized as a bitbake filetype so the associated .vim scripts are loaded as reported by :scriptnames. I'm not sure if that affects the syntax highlighting and/or indent as I'm not quite up-to-speed with Clojure syntax.

russtoku and others added 3 commits November 8, 2024 18:37
Since BitBake already claimed the `.bb` file extension before Babashka,
we cannot override it in upstream Vim, hence we register an optional
`after` ftdetect plugin for various unofficial Clojure file extensions.

I'm not a fan of using `after` for this, so I may change it at a later
date.
@axvr
Copy link
Member

axvr commented Nov 15, 2024

Thank you!

Another thing that I noticed is that .bb is a recognized as a bitbake filetype so the associated .vim scripts are loaded as reported by :scriptnames. I'm not sure if that affects the syntax highlighting and/or indent as I'm not quite up-to-speed with Clojure syntax.

Ah yes, sorry I forgot about that. That explains the note I had on my local machine about maybe making this an optional toggle.

I've pushed a small update to this PR to move detection of unofficial Clojure file extensions to an "after" ftdetect file. Reasoning for this is that we cannot override detection of BitBake files in upstream Vim (and Neovim) but can do it if the user installs this plugin directly. (I may change how this mechanism works in future as I'm still not particularly happy with this workaround.)

Regarding if it matters that the BitBake syntax and indent files being loaded before the Clojure files matters, it doesn't. We override all those options. Unfortunately there's no easy way to prevent it either, especially not in Neovim (since they've replaced many Vimscript files with Lua ones).

I did notice that in a file without a filename extension but a shebang line, the filetype isn't set to clojure.

Yes this is because there is a dedicated file in Vim which handles those. I'll update that when I next merge these changes upstream, but due to the BitBake clash I'll need to make sure it won't impact anything else first.


I also noticed that we weren't including an XML option in the GVim file browse option, so I've included that too in this PR.

@axvr
Copy link
Member

axvr commented Nov 15, 2024

I'll merge this now and make a note to update the README to mention how to enable/disable Babashka (and other unofficial Clj) file type detection (and that it requires this plugin to be installed).

I'll also make a note to check and maybe update shebang detection for Babashka in upstream Vim.

@axvr axvr merged commit 128ccd4 into clojure-vim:master Nov 15, 2024
2 checks passed
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

Successfully merging this pull request may close these issues.

2 participants