| Summary: | Should use shebang to decide which language the file is | ||
|---|---|---|---|
| Product: | [Applications] kdevelop | Reporter: | Salvo "LtWorf" Tomaselli <tiposchi> |
| Component: | All editors | Assignee: | kdevelop-bugs-null |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | mail, mail |
| Priority: | NOR | ||
| Version First Reported In: | 5.2.3 | ||
| Target Milestone: | --- | ||
| Platform: | Other | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
|
Description
Salvo "LtWorf" Tomaselli
2018-07-05 09:56:54 UTC
Can you not set a proper mime type for the files in your system's mime database? $ file /tmp/pythonscript /tmp/pythonscript: Python script, ASCII text executable $ file --mime /tmp/pythonscript /tmp/pythonscript: text/x-python; charset=us-ascii What is there to set? I did some brief testing on my Arch system with KDev* master, using a file named `no_suffix` having the contents
```
#!/usr/bin/env python3
print("Hello, world!")
```
Mime tools detect it:
$ file --mime no_suffix
no_suffix: text/x-python; charset=us-ascii
$ kmimetypefinder5 no_suffix
text/x-python3
KWrite *doesn't* detect it - the default ksyntaxhighlighting and indentation are 'None' and 'Normal' respectively. Both of these work fine if explicitly enabled.
Using KDevelop, it *does* get assigned to and recognised by kdev-python - there are tooltips, semantic highlighting etc. - but the ktexteditor highlighting/indenter still aren't used by default.
KDevelop uses either the default text-file icon or a '[?]' icon in the Projects/Filesystem toolviews, open-files menu etc., not the Python icon.
Changing the shebang to `... python or `... python2` fixes the ksyntaxhighlighting detection in KWrite (but not KDevelop). With `...python3`, the detected mimetype is 'text/x-python3'; ksyntaxhighlighting doesn't understand `<sub-class-of type='text/x-python'/>` in the mime database and it's not listed explicitly in python.xml I don't yet understand why KDevelop behaves differently. This has been fixed at some point. KDevelop and other KTextEditor-based applications now detect such files. |