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

CMakeLists.txt considered Plain Text file even with NeoCMake extension installed #20291

Open
1 task done
k0tran opened this issue Nov 6, 2024 · 7 comments · May be fixed by #25420
Open
1 task done

CMakeLists.txt considered Plain Text file even with NeoCMake extension installed #20291

k0tran opened this issue Nov 6, 2024 · 7 comments · May be fixed by #25420
Labels
bug [core label] c C programming language support language An umbrella label for all programming languages syntax behaviors regression A bug that was introduced in a recent release

Comments

@k0tran
Copy link
Contributor

k0tran commented Nov 6, 2024

Check for existing issues

  • Completed

Describe the bug / provide steps to reproduce it

Extracted from #5102 (comment)

Basically when you open CMakeLists.txt Zed automatically chooses Plain Text format.
CMakeLists.txt is already added to config.toml:
https://github.com/k0tran/zed_neocmake/blob/master/languages/cmake/config.toml#L3

Problem appeared about 3 weeks ago (everything worked before - k0tran/zed_neocmake#5)

Environment

My machine specs here, but I don't think this is related.

Zed: v0.158.1 (Zed)
OS: Linux Wayland altlinux 20240122
Memory: 15.3 GiB
Architecture: x86_64
GPU: Intel(R) Graphics (ADL GT2) || Intel open-source Mesa driver || Mesa 24.2.6

If applicable, add mockups / screenshots to help explain present your vision of the feature

I think this has to do something with this

"Plain Text": ["txt"],

Which may overwrite extension config.toml

If applicable, attach your Zed.log file to this issue.

Zed.log

@k0tran k0tran added admin read bug [core label] labels Nov 6, 2024
@k0tran k0tran mentioned this issue Nov 6, 2024
1 task
@k0tran
Copy link
Contributor Author

k0tran commented Nov 6, 2024

So I added this line to "file_types" section in Zed settings: "CMake": ["CMakeLists.txt"],
And it worked. I suppose the fix is to add this to Zed default settings.

I could make a PR, but first I would like to know if I should add "cmake" to "CMake" file_type like this "Cmake": ["CMakeLists.txt", "cmake"]. It seems unnecessary but could be nice

@SomeoneToIgnore

This comment was marked as outdated.

@JosephTLyons JosephTLyons added potential extension Functionality that could be implemented as an extension (consider moving to community extensions) language An umbrella label for all programming languages syntax behaviors c C programming language support and removed triage labels Nov 10, 2024
@k0tran
Copy link
Contributor Author

k0tran commented Nov 18, 2024

This fixed issue for me

diff --git a/assets/settings/default.json b/assets/settings/default.json
index a59e115901..49cd414b66 100644
--- a/assets/settings/default.json
+++ b/assets/settings/default.json
@@ -843,6 +843,7 @@
   // }
   //
   "file_types": {
+    "CMake": ["CMakeLists.txt", "cmake"],
     "Plain Text": ["txt"],
     "JSON": ["flake.lock"],
     "JSONC": [

@k0tran
Copy link
Contributor Author

k0tran commented Nov 18, 2024

Also added this to my fork. If everything is fine I'm ready to open PR https://github.com/k0tran/zed/tree/main

@notpeter
Copy link
Member

notpeter commented Nov 26, 2024

I think I likely broke this in:

Relevant lines from default.json with the "txt" line:

  "file_types": {
    "Plain Text": ["txt"],
    "JSONC": ["**/.zed/**/*.json", "**/zed/**/*.json", "**/Zed/**/*.json", "**/.vscode/**/*.json"],
    "Shell Script": [".env.*"]
  },

Currently here is the order of file_type overrides: (top wins)

  • ~/.zed/settings.json
  • zed default.json (bundled)
  • config.toml in extension/built-in languages

As we don't ship default.json settings Languages provided by 3rd party extensions, for the moment you'll have to manually add this to your settings:

"file_types": {
    "CMake": [
      "CMakeLists.txt"
    ]
}

The longer term fix is perhaps to populate the Plain Text language with txt as an extension instead of using default.json, but this may require some work.

My apologies for breaking this.

@notpeter notpeter added regression A bug that was introduced in a recent release and removed potential extension Functionality that could be implemented as an extension (consider moving to community extensions) labels Nov 26, 2024
@regisx001
Copy link

there is another issue with the with Cmake extension.
when changing manually to the cmake filetype. and write some cmake command (add_executable or something in the CMakeLists.txt file) it seem to remove the added file and reset it to the previous state .

@notpeter
Copy link
Member

notpeter commented Dec 4, 2024

@regisx001 Please file that upstream on k0tran/zed_neocmake

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug [core label] c C programming language support language An umbrella label for all programming languages syntax behaviors regression A bug that was introduced in a recent release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants