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

Allow apps to force lang via code.language and add special cased files #1451

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

fidgetingbits
Copy link
Collaborator

This makes some tweaks to language modes:

  1. It adds a list of special-cased files that are mixed into the determination of the language, so you can return a language for things even if the file extension itself doesn't imply the language. The languages included aren't actually implemented in community, so I can keep the list empty if preferred, but I figured I'd keep it populated at first to give an example of why it's useful.
  2. Adds a command to show the currently forced language
  3. Remove language tags and instead utilize code.language #1256 semi-recently went the route of removing language-specific tags. This has the side effect (afaict) that an app that doesn't expose the file extension in its title can no longer force a language (previously it would just tag: user.<lang>). Given we removed the tags I assume we don't want them back, so this change goes a different route and adds an action that can be overridden to force a language. It's done in a way that the language being forced by an app will still be overridden by a user manually forcing a language with force <lang>. I've included an obsidian skeleton to demonstrate how to use it. Obsidian is a markdown editor that doesn't include file extensions in it's title. I took a look at search.talonvoice.com and see that some people are using tag.markdown (so are their community is not up to date, or they custom implemented tags again) and some others are re-implementing markdown commands. Since I tried to use this app recently, and I don't like forcing a language across my entire system and have to remember to clear it afterwards, I figured I should add a way to do it.

I'm open to other ways to do this if there is a better idea.

@auscompgeek
Copy link
Collaborator

I personally think an app that wants to force a language should override the code.language action.

@AndreasArvidsson
Copy link
Collaborator

I personally think an app that wants to force a language should override the code.language action.

Totally agree. If the problem is that forced language should take precedents over an application specific language then we just need to make the matcher of the forced context more specific. mode: all or something.

@fidgetingbits
Copy link
Collaborator Author

I personally think an app that wants to force a language should override the code.language action.

Hrm ya that makes sense, is simpler. I'll change it.

Will try the 'mode: all' thing as well, as ya I think we still want forced language to take precedence over overridden code.langauge

@fidgetingbits fidgetingbits marked this pull request as draft June 13, 2024 01:15
@AndreasArvidsson
Copy link
Collaborator

I will look into if we can make the forced override more specific and always win over application specific

nriley added a commit to nriley/talon_community that referenced this pull request Jun 22, 2024
Hopefully will be obsolete if we find a better solution (e.g. talonhub#1451).
@nriley
Copy link
Collaborator

nriley commented Jun 22, 2024

To be clear we tried mode: all and a couple other things in the community backlog session and couldn't get them to work.

A temporary workaround if you've already got code.language overrides is to do something like this:

nriley@b2d584a

but @AndreasArvidsson wasn't too excited about having to do that everywhere and neither am I…

@AndreasArvidsson
Copy link
Collaborator

It appears that the app context has a really high priority. For now I would probably recommend putting not tag: user.code_language_forced on the context where you override code.language

@nriley
Copy link
Collaborator

nriley commented Jun 23, 2024

Do you think creating another context for this is better than calling actions.next? :-) thought we were trying to avoid having to make changes every time you override code.language

@AndreasArvidsson
Copy link
Collaborator

AndreasArvidsson commented Jun 24, 2024

I guess both work I just prefer to actually use the Talon context for what it's made for. Just to be clear you put this not tag on the new context where you have your new code language override.

@nriley
Copy link
Collaborator

nriley commented Jul 27, 2024

I'm OK with the not tag solution! On the community backlog session apparently people are confused by actions.next...

@fidgetingbits fidgetingbits marked this pull request as ready for review August 13, 2024 07:45
@fidgetingbits
Copy link
Collaborator Author

Finally got time to circle back to this. I use the code.language override with a context that uses not forced language for obsidian, as suggested. I left in the filename special casing in language_modes.py.

Co-authored-by: David Vo <auscompgeek@users.noreply.github.com>
AndreasArvidsson pushed a commit that referenced this pull request Aug 24, 2024
Similar to #1451 this uses a context using not forced language to
override `code.language` and enable python lang features inside the
talon repl. It also makes the title matching more restricting, as this
currently matches on anything with repl in the name, and there are many
repls that aren't talon or python...

I also enable readline so that common navigation commands work inside.
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.

4 participants