Skip to content

Commit

Permalink
Merge pull request #205 from fbouchez/dev/display-option
Browse files Browse the repository at this point in the history
Display option to modify how the magit window is shown
  • Loading branch information
jreybert committed Mar 28, 2024
2 parents 06afe48 + 09935b3 commit fc7eda9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,15 @@ example to your vimrc.

User can define in its prefered vimrc some options.

#### g:magit_show_magit_display
Choose display setup for magit (default: 'v')
Possible values:
'v': vertical split
'h': horizontal split
'c': current buffer
> let g:magit_show_magit_display='v'

#### g:magit_enabled

To enable or disable vimagit plugin.
Expand Down
18 changes: 15 additions & 3 deletions doc/vimagit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ MAPPINGS *vimagit-mappings*
For each mapping, user can redefine the behavior with its own mapping. Each
variable is described below as *vimagit-g:magit_nameofmapping_mapping*

For example, to redefine the <leader>M mapping, user should add this line in
its |vimrc|:
let g:magit_show_magit_mapping='m'
For example, to redefine the <leader>M mapping to <leader>g, add this line in
your |vimrc|:
let g:magit_show_magit_mapping='<leader>g'

Mapping update *vimagit-mapping-update*
--------------
Expand All @@ -179,6 +179,10 @@ Since vimagit 1.7, jump mappings have changed:
Jump next hunk : N -> <C-n>
Jump prev hunk : P -> <C-p>

(Previous behaviour can be restored by redefining the following variables:
let g:magit_jump_next_hunk='N'
let g:magit_jump_prev_hunk='P')

Global mappings
---------------
Following mappings are broadly set, and are applied in all vim buffers.
Expand Down Expand Up @@ -450,6 +454,14 @@ example to your vimrc.

User can define in its prefered |vimrc| some options.

*vimagit-g:magit_show_magit_display*
Choose display setup for magit (default: 'v')
Possible values:
'v': vertical split
'h': horizontal split
'c': current buffer
let g:magit_show_magit_display='v'

*vimagit-g:magit_enabled*
To enable or disable vimagit plugin.
Default value is 1.
Expand Down
6 changes: 4 additions & 2 deletions plugin/magit.vim
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ execute 'source ' . g:vimagit_path . '/../common/magit_common.vim'
let g:magit_show_magit_mapping = get(g:, 'magit_show_magit_mapping', '<leader>M' )

" user options
" default display: vertical split.
let g:magit_show_magit_display = get(g:, 'magit_show_magit_display', 'v')
let g:magit_enabled = get(g:, 'magit_enabled', 1)
let g:magit_show_help = get(g:, 'magit_show_help', 0)
let g:magit_default_show_all_files = get(g:, 'magit_default_show_all_files', 1)
Expand All @@ -48,7 +50,7 @@ let g:magit_warning_max_lines = get(g:, 'magit_warning_max_lines',

let g:magit_git_cmd = get(g:, 'magit_git_cmd' , "git")

execute "nnoremap <silent> " . g:magit_show_magit_mapping . " :call magit#show_magit('v')<cr>"
execute "nnoremap <silent> " . g:magit_show_magit_mapping . " :call magit#show_magit('" . g:magit_show_magit_display . "')<cr>"

if (g:magit_refresh_gutter == 1 || g:magit_refresh_gitgutter == 1)
autocmd User VimagitUpdateFile
Expand Down Expand Up @@ -1409,7 +1411,7 @@ function! magit#get_current_mode()
endif
endfunction

command! Magit call magit#show_magit('v')
command! Magit call magit#show_magit(g:magit_show_magit_display)
command! MagitOnly call magit#show_magit('c')

" }}}

0 comments on commit fc7eda9

Please sign in to comment.