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

Project Organizer: Add option/ability to set filetype of header files? #1121

Closed
xiota opened this issue Oct 17, 2021 · 3 comments · Fixed by #1122
Closed

Project Organizer: Add option/ability to set filetype of header files? #1121

xiota opened this issue Oct 17, 2021 · 3 comments · Fixed by #1122

Comments

@xiota
Copy link
Contributor

xiota commented Oct 17, 2021

@techee

I opened a similar issue at geany/#2946. I was informed that the feature might be a better fit with one of the project-related plugins. Since the Project Organizer already has some file extension-related settings, setting filetype for ambiguous header files may be within its scope.

The issue is that .h files are ambiguous with respect to C and C++. Identifying the right type most visibly affects syntax highlighting. But it may also affect whether class structures and other symbols are correctly identified.

  1. Many header files have corresponding source files. When a pair is found, the header type can be changed if needed.

  2. Projects may have sufficient information about file locations to find related files in separate directories?

  3. If pairing files is too troublesome, or wasteful of cpu cycles, whichever language predominates the project could be used.

  4. The project organizer could have a setting that identifies the main project language. Ambiguous header files could then be set accordingly.

What do you think? Any other ideas?

@xiota xiota changed the title Project Organizer: Add option/ability to set filetype of opened files. Project Organizer: Add option/ability to set filetype of header files? Oct 18, 2021
@xiota xiota closed this as completed Oct 25, 2021
@techee
Copy link
Member

techee commented Oct 25, 2021

Yeah, I think (1) should be doable quite easily. There would always be a problem if there is both some_file.cpp, some_file.c and some_file.h in the project to detect to which of the source files the header belongs (different projects use different directory structures and there's no easy way to tell which file belongs to which) but these cases should be exceptions.

I don't remember the Geany API exactly and implementing this feature would require that Geany allows plugins to specify the filetype that should be used to open the files but I believe there is such a function.

I'll have a look at this when I have time - should be quite easy to implement.

@elextr
Copy link
Member

elextr commented Oct 25, 2021

but I believe there is such a function.

document_set_filetype()

@xiota
Copy link
Contributor Author

xiota commented Oct 26, 2021

@techee Thanks for your response. I opened a PR that implements this feature. #1122

It first looks for files in the same directory. It should be rare for there to be a .h and .c and .c[cxp]+ in the same directory. If there isn't a match, it looks in the rest of the project. It's adapted from the header/source switching code, so any problems with setting filetypes would also affect switching files.

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 a pull request may close this issue.

3 participants