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

set a buffer's language at runtime #1794

Closed
the-mikedavis opened this issue Mar 11, 2022 · 2 comments · Fixed by #1866
Closed

set a buffer's language at runtime #1794

the-mikedavis opened this issue Mar 11, 2022 · 2 comments · Fixed by #1866
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements E-good-first-issue Call for participation: Issues suitable for new contributors

Comments

@the-mikedavis
Copy link
Member

Currently a buffer's language is determined when opening the buffer by examining the filename, extension or contents. It would be useful to be able to pick a language at runtime, especially when editing a scratch buffer.

We should add an option to the :set typable command like :set language <language>, and possibly have autocomplete for available languages.

@the-mikedavis the-mikedavis added the C-enhancement Category: Improvements label Mar 11, 2022
@the-mikedavis the-mikedavis added the E-good-first-issue Call for participation: Issues suitable for new contributors label Mar 11, 2022
@the-mikedavis
Copy link
Member Author

Implementation-wise, this set_language2 function may be usable.

@kirawi kirawi added the A-helix-term Area: Helix term improvements label Mar 11, 2022
@the-mikedavis the-mikedavis changed the title :set a buffer's language set a buffer's language at runtime Mar 14, 2022
@the-mikedavis
Copy link
Member Author

I think it might make more sense for this to be a regular typable command instead of part of the :set typable command. :set is currently specific to editor config (whereas language lives on the document), and doesn't yet have autocomplete for available values. It should be fairly straightforward to add a typable command that calls a variant of set_language2 that chooses language by language_id.

zen3ger added a commit to zen3ger/helix that referenced this issue Mar 25, 2022
* Add set-language typable command to change the language of current buffer.
* Add completer for available language options.
zen3ger added a commit to zen3ger/helix that referenced this issue Mar 25, 2022
* Add set-language typable command to change the language of current buffer.
* Add completer for available language options.
archseer pushed a commit that referenced this issue Apr 5, 2022
* Add runtime language configuration (#1794)

* Add set-language typable command to change the language of current buffer.
* Add completer for available language options.

* Update set-language to refresh language server as well

* Add language id based config lookup on `syntax::Loader`.
* Add `Document::set_language3` to set programming language based on language
  id.
* Update `Editor::refresh_language_server` to try language detection only if
  language is not already set.

* Remove language detection from Editor::refresh_language_server

* Move document language detection to where the scratch buffer is saved.
* Rename Document::set_language3 to Document::set_language_by_language_id.

* Remove unnecessary clone in completers::language
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements E-good-first-issue Call for participation: Issues suitable for new contributors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants