Skip to content

[vim] Fix command already exists on opening multiple mir buffers #82410

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

Merged
merged 1 commit into from
Feb 28, 2024

Conversation

Sisyph
Copy link
Contributor

@Sisyph Sisyph commented Feb 20, 2024

When using the vim syntax for mir, an error occurs in nvim (unknown if it affects the original vim) when opening multiple .mir buffers. Add '!' when defining HiLink to redefine the command instead of giving an error. Only the changes to mir.vim and llvm.vim are required to fix the error, but from similarity making the change in all the syntax files seems prudent.

To reproduce:
Open an .mir file, for example llvm/test/Codegen/X86/expand-post-ra-pseudo.mir
Open another mir file from within nvim, for example peephole.mir

Error detected while processing function 335[30]..<SNR>43_callback[25]..function 335[30]..<SNR>43_callback:                                                                                                                      
line   23:                                                                                                                                                                                                                       
Vim(command):E174: Command already exists: add ! to replace it: HiLink hi def link <args>   

@Sisyph
Copy link
Contributor Author

Sisyph commented Feb 28, 2024

Ping!

@frasercrmck
Copy link
Contributor

Thanks for the PR! Sorry for the delay.

It took me a bit of fiddling to reproduce the error. I had only the llvm.vim and tablegen.vim files copied to my local nvim config, and I didn't see any issue. When I copied over the mir.vim files I started seeing the issue you report. It does seem like plain vim also shows the same problem.

I noticed I wasn't seeing the same issue when opening a tablegen file, so I poked around for a bit. I think the problem with MIR is because it doesn't have delcommand HiLink. If I add that command to mir.vim, the problem also goes away. What do you think about that fix instead?

@Sisyph
Copy link
Contributor Author

Sisyph commented Feb 28, 2024

I think the problem with MIR is because it doesn't have delcommand HiLink. If I add that command to mir.vim, the problem also goes away. What do you think about that fix instead?

That makes sense and sounds like a good fix. It worked for me too. Probably better than this one since it is unlikely users would want to call HiLink. Do you want to put that change up, or should I update this one?

When using the vim syntax for mir, an error occurs in nvim  when opening
multiple .mir buffers. delcommand HiLink in the mir syntax file to avoid
the issue.
@Sisyph
Copy link
Contributor Author

Sisyph commented Feb 28, 2024

@frasercrmck I updated this PR with your fix instead. Thanks.

Copy link
Contributor

@frasercrmck frasercrmck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@Sisyph Sisyph merged commit caca8d3 into llvm:main Feb 28, 2024
mylai-mtk pushed a commit to mylai-mtk/llvm-project that referenced this pull request Jul 12, 2024
…m#82410)

When using the vim syntax for mir, an error occurs in nvim  when opening
multiple .mir buffers. delcommand HiLink in the mir syntax file to avoid
the issue.

To reproduce:
Open an .mir file, for example
llvm/test/Codegen/X86/expand-post-ra-pseudo.mir
Open another mir file from within nvim, for example peephole.mir
```
Error detected while processing function 335[30]..<SNR>43_callback[25]..function 335[30]..<SNR>43_callback:                                                                                                                      
line   23:                                                                                                                                                                                                                       
Vim(command):E174: Command already exists: add ! to replace it: HiLink hi def link <args>   
```
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