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

Properly set ft=gitcommit when opening editor #518

Closed
savchenko opened this issue Feb 17, 2021 · 7 comments · Fixed by #733
Closed

Properly set ft=gitcommit when opening editor #518

savchenko opened this issue Feb 17, 2021 · 7 comments · Fixed by #733
Milestone

Comments

@savchenko
Copy link

Is your feature request related to a problem? Please describe.
When user opens an editor to redact the commit message, it does not pass the filetype.

Describe the solution you'd like
Pass set ft=gitcommit to vim when editing commit message.

Describe alternatives you've considered
Set filetype manually on each edit.

Additional context
This can be done via -c flag, e.g.:

nvim -c ":set ft=gitcommit" -- /path/to/commit
@savchenko
Copy link
Author

This might be partially related to #517.

@extrawurst
Copy link
Owner

This might be partially related to #517.

I don't see what it has to do with #517 - one is about which file to open and this one is about how to open it in nvim - what am I missing?

@savchenko
Copy link
Author

@extrawurst ,
hunch
they both refer to the "open editor" so might be handled within the same logical module.

@extrawurst extrawurst added this to the v0.12 milestone Feb 24, 2021
@extrawurst
Copy link
Owner

extrawurst commented Feb 24, 2021

@savchenko can you tell me more about this, I am not a vim user. is that something git does when opening the editor for a commit msg? can you point me to some documentation?

also how would this behave if the user configures its EDITOR to be something else?

@extrawurst extrawurst removed this from the v0.12 milestone Feb 24, 2021
@savchenko
Copy link
Author

savchenko commented Feb 24, 2021

Editor for git can be set separately:

export EDITOR="nvim"
export GIT_EDITOR="nvim -u $HOME/.config/nvim/init.vim"

also how would this behave if the user configures its EDITOR to be something else?

I would imagine that gitui simply uses whatever is defined in user's EDITOR and GIT_EDITOR environment variables preferring the latter one, same as git does. If none are present — fallback to vi/nano/ed.

is that something git does when opening the editor for a commit msg?

When editing git commit message, vim detects .git/COMMIT_EDITMSG and sets filetype=gitcommit which results in a nice highlighting, proper wrap and so on:

image

@MagicDuck
Copy link

@extrawurst I think the problem might just be the file name. When committing through gitui, it sets the file name to gitui/COMMITMSG_EDITOR. Using the name that @savchenko mentions above .git/COMMIT_EDITMSG should allow it to work correctly in theory. Actually, even gitui/COMMIT_EDITMSG should work according to this: https://github.com/neovim/neovim/blob/0a653f7ab98dfc05bf0532b9f81bc19377031900/runtime/filetype.vim#L646.

@extrawurst
Copy link
Owner

@extrawurst I think the problem might just be the file name. When committing through gitui, it sets the file name to gitui/COMMITMSG_EDITOR. Using the name that @savchenko mentions above .git/COMMIT_EDITMSG should allow it to work correctly in theory. Actually, even gitui/COMMIT_EDITMSG should work according to this: https://github.com/neovim/neovim/blob/0a653f7ab98dfc05bf0532b9f81bc19377031900/runtime/filetype.vim#L646.

thanks for the hint, I think #733 fixes this now

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 a pull request may close this issue.

3 participants