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

Support language aliases #73

Closed
resolritter opened this issue Jan 1, 2020 · 2 comments
Closed

Support language aliases #73

resolritter opened this issue Jan 1, 2020 · 2 comments
Assignees
Labels
feature New feature or request

Comments

@resolritter
Copy link

Is your feature request related to a problem? Please describe.

related to #72 - Ideally it would depend on the syntax of where the cursor is, not &filetype.

vim-doge currently matches the generator using &filetype. This is a problem for some languages because they sometimes vary in how the filetype is named, even though the generator they'd refer to is the same.

Describe the solution you'd like

You should be able to match arbitrary languages to arbitrary generators. Something like:

let g:doge_languages_to_generators = {
  \ 'typescript.tsx': 'typescript'
  ...
  \ }

Notice I'm using "languages" instead of "filetype" because, ideally, this would depend on the current block's syntax, not the filetype in general (as mentioned in #72).

Describe alternatives you've considered

There are no easy alternatives, as far as I'm aware.

Additional context

@kkoomen
Copy link
Owner

kkoomen commented Jan 1, 2020

Notice I'm using "languages" instead of "filetype" because, ideally, this would depend on the current block's syntax, not the filetype in general (as mentioned in #72).

This doesn't make sense, since block-based syntax is determined by filetype and not by "language".


I'll implement this since it's fixing a current issue at the same time. The future variable will be g:doge_filetype_aliases where as the key will be your main filetype and the value should be a list of 1 or more filetypes which will be aliases of the key. Example:

let g:doge_filetype_aliases = {
\  'javascript': ['javascript.jsx', 'javascript.tsx', 'typescript']
\}

If you use the above settings in the future and you open one of these filetypes: ['javascript.jsx', 'javascript.tsx', 'typescript'] then they will behave like you're opening a javascript filetype.


Since my TypeScript code is the same as my JavaScript I will already set ['javascript.jsx', 'javascript.tsx', 'typescript'] as an alias for javascript from the plugin itself, since I did want to support these filetypes already from the beginning but it wasn't that much priority.

kkoomen added a commit that referenced this issue Jan 1, 2020
@kkoomen kkoomen added the feature New feature or request label Jan 1, 2020
@kkoomen kkoomen self-assigned this Jan 1, 2020
@kkoomen
Copy link
Owner

kkoomen commented Jan 1, 2020

This feature has been merged and released in v2.2.0. See the g:doge_filetypes_aliases section in the README with what is supported by default.

Feel free to submit any new issues if you experience any unwanted behavior in the future. Thanks for your contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants