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

Add custom digraph support #984

Merged
merged 17 commits into from
Sep 5, 2024
Merged

Conversation

citizenmatt
Copy link
Member

@citizenmatt citizenmatt commented Sep 4, 2024

I found an old, unfinished branch and brought it up to date 😄

This PR will add support for adding custom digraph using the :digraphs command interactively or in ~/.ideavimrc, such as :digraphs (0 9450 for the character (VIM-3623). It also updates the output of the :digraphs command to match Vim, and adds headers when called with :digraphs!. And it updates the list of digraphs to match Vim's current set, adding a number of missing digraphs such as oo for "bullet", =e for "euro" and so on.

Finally, the output panel now includes the width of the editor gutter when calculating the approximate number of columns it's got to display text.

Vim only use the `~` prefix if the encoding is "latin1". We can just treat it as though the encoding is Unicode, and match the other places we format printable characters. Note that for Vim, if `'display'` contains "uhex", then all unprintable characters are shown in hex, including control characters (`^C`, etc.). IdeaVim does not support the `'display'` option.
Not sure why IdeaVim has used hex. Vim appears to have used decimal for at least 20 years.
List is based on Vim's documentation, although not all digraphs are documented. Additional digraphs are added based on the output of `:digraphs`. These additional digraphs include some digraphs that produce the same character, so the code is updated to handle duplicates, with the same ordering/priority as Vim.

Extra digraphs include the Euro symbol (`=e` and `Eu`), quadruple prime (`4'`) and bullet (`oo`), amongst others.

Also removes a number of non-standard digraphs. The symbols generated don't match the descriptions. The code appears to be private use, so are not reliable. Once custom digraphs are implemented, they can be easily added back in `~/.ideavimrc`
@AlexPl292
Copy link
Member

Yay, this is a sweet set of changes!

By the way, have you used any automation to find the missing digraphs? I remember I noticed such a problem already and thought about making a test that compares our digraph list with the one from Vim. However, for the moment, I think this might be a bit complicated to implement and maintain. We can probably just make a yearly review of the digraph set. Is there some simple way to manually compare our digraph set with the one from Vim?

@AlexPl292 AlexPl292 merged commit 34fe09c into JetBrains:master Sep 5, 2024
4 checks passed
@citizenmatt
Copy link
Member Author

Semi-automated. I copied the digraphs from the docs, ran an awk script on them, pasted it into the code and checked the git diffs. This doesn't quite work, because there are additional digraphs for Vim 5.x compatibility. So the git diff has to be handled manually. (The awk command is in the comments for the digraph list)

Fortunately, it's incredibly rare for Vim to add new digraphs - I think they've added 10 in the last 20 years!

@citizenmatt citizenmatt deleted the feature/digraphs branch September 5, 2024 18:32
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.

2 participants