Skip to content

feat: document abbreviations #3023

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

Closed
wants to merge 4 commits into from

Conversation

lazytanuki
Copy link
Contributor

Peek 2022-07-10 00-26

This feature introduces four new typed commands to handle vim-like abbreviations:

  • insert-abbreviation (alias abbr): adds a new abbreviation, or overwrites an existing one (with completion, local to current document only)

  • delete-abbreviation (alias rabbr): removes an abbreviation (with completion)

  • load-abbreviations-from-file (alias labbr): loads abbreviations from a file. Each line is an abbreviation, for instance:

    nvm nevermind
    brb be right back
    
  • write-abbreviations-to-file (alias wabbr): writes to file with the same format as above

I have tested and solved edge cases (beginning of the file, of a line, etc), but would be happy to have someone test this.

Closes #1471.

@archseer
Copy link
Member

Rather than special files, can we make this static and a part of the current toml config? In the future this can be more scriptable then

@lazytanuki
Copy link
Contributor Author

Rather than special files, can we make this static and a part of the current toml config? In the future this can be more scriptable then

I think we could have both ! I could add editor-wide abbreviations sourced from the configuration file, but I'd like to keep the ability to load from file because sometimes you have abbreviations specific to one document but don't want them all the time, you just want to reload them until you finish the document and then get rid of them.

@EpocSquadron
Copy link
Contributor

How does this relate to #2852 ? They seem to be the same thing with sightly different angles of attack to me. Also wondering how both intersect with the idea of snippets.

@lazytanuki
Copy link
Contributor Author

lazytanuki commented Jul 10, 2022

How does this relate to #2852 ? They seem to be the same thing with sightly different angles of attack to me. Also wondering how both intersect with the idea of snippets.

This was not made with #2852 in mind at all, but I guess people could use abbreviations to be able to insert digraphs. I'm French, so I wouldn't be able to help a lot with that as I don't really know how one uses digraphs.

Snippets are different, they're closer to the LSP aspect of the editor and they are not something one can define "on-the-fly", unlike abbreviations.

I've implemented static abbreviations in the TOML config file, which are available editor-wide.

@kirawi kirawi added A-helix-term Area: Helix term improvements S-waiting-on-review Status: Awaiting review from a maintainer. labels Sep 13, 2022
@lazytanuki
Copy link
Contributor Author

I just rebased this on the current master. Been using it since July without any issue, would someone care to review ?
Thanks !

@lazytanuki
Copy link
Contributor Author

Rebased on master.

@lazytanuki
Copy link
Contributor Author

Rebased and resolved conflicts. Any hope for a review ?
Thanks !

@lazytanuki
Copy link
Contributor Author

Rebased on master.

@lazytanuki
Copy link
Contributor Author

Rebased on master.

@lazytanuki lazytanuki mentioned this pull request Dec 16, 2022
@lazytanuki
Copy link
Contributor Author

Following a discussion on Matrix with @pascalkuthe, we came to the conclusion that abbreviations should be implemented as special snippets that trigger instantaneously. It would also require to implement a command to define them on-the-fly.
We'll have to wait for the snippet engine (for anyone wondering about it, there's a snippet branch where it is currently being developed).
For the impatient: feel free to merge this PR into you own custom forks until we have this in the snippet engine.

Closing.

@lazytanuki lazytanuki closed this Dec 16, 2022
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 S-waiting-on-review Status: Awaiting review from a maintainer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Abbreviation
4 participants