Skip to content

Commit

Permalink
Add support for HGEDITOR similar to GIT_EDITOR
Browse files Browse the repository at this point in the history
  • Loading branch information
martintrojer authored and voldikss committed Apr 8, 2024
1 parent 64b1003 commit 4e28c8d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ Default: `['.project', '.git', '.hg', '.svn', '.root']`

Type `Boolean`. Whether to override `$GIT_EDITOR` in floaterm terminals so git commands can
open open an editor in the same neovim instance. See [git](#git) for details.
This flag also overrides `$HGEDITOR` for Mercurial.

Default: `v:true`

Expand Down
7 changes: 4 additions & 3 deletions autoload/floaterm/edita/neovim/editor.vim
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ function! floaterm#edita#neovim#editor#open(target, client)
call floaterm#util#open([{'filename': fnameescape(a:target)}], opener)
let mode = floaterm#edita#neovim#util#mode(a:client)
let b:edita = sockconnect(mode, a:client, { 'rpc': 1 })
if index([
let filename = expand('%:t')
if (index([
\ 'COMMIT_EDITMSG',
\ 'MERGE_MSG',
\ 'git-rebase-todo',
\ 'git-revise-todo',
\ 'addp-hunk-edit.diff'
\ ], expand('%:t')) > -1
\ 'addp-hunk-edit.diff',
\ ], filename) > -1) || (stridx(filename, 'commit.hg.txt') > -1)
setlocal bufhidden=wipe
augroup edita_buffer
autocmd! * <buffer>
Expand Down
7 changes: 4 additions & 3 deletions autoload/floaterm/edita/vim/editor.vim
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ function! floaterm#edita#vim#editor#open(target, bufnr)
let opener = floaterm#config#get(a:bufnr, 'opener', g:floaterm_opener)
call floaterm#util#open([{'filename': fnameescape(a:target)}], opener)
let b:edita = a:bufnr
if index([
let filename = expand('%:t')
if (index([
\ 'COMMIT_EDITMSG',
\ 'MERGE_MSG',
\ 'git-rebase-todo',
\ 'git-revise-todo',
\ 'addp-hunk-edit.diff'
\ ], expand('%:t')) > -1
\ 'addp-hunk-edit.diff',
\ ], filename) > -1) || (stridx(filename, 'commit.hg.txt') > -1)
setlocal bufhidden=wipe
augroup edita_buffer
autocmd! * <buffer>
Expand Down
1 change: 1 addition & 0 deletions autoload/floaterm/util.vim
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ function! floaterm#util#setenv() abort
let env.FLOATERM = editor
if g:floaterm_giteditor
let env.GIT_EDITOR = editor
let env.HGEDITOR = editor
endif
return env
endfunction
Expand Down

0 comments on commit 4e28c8d

Please sign in to comment.