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

Easy change split configuration with variable #163

Open
wants to merge 1 commit into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,15 @@ It takes 3 parameters:
- 'h', curent window is split horizontally, and magit is displayed in
new buffer
- 'c', magit is displayed in current buffer
user can control type of the split with variable
(see [g:magit_split_type](#gmagit_split_type))
* show_all_files: define how file diffs are shown by default for this session
(see [g:magit_default_show_all_files](#gmagit_default_show_all_files))
* foldlevel: set default magit buffer foldlevel for this session
(see [g:magit_default_fold_level](#gmagit_default_fold_level))

#### :Magit
Open magit buffer in a vertical split (see [details](magitshow_magit)).
Open magit buffer in a vertical split by default (see [details](magitshow_magit)).

#### :MagitOnly
Open magit buffer in current window (see [details](magitshow_magit)).
Expand Down Expand Up @@ -503,6 +505,12 @@ empty).
Default value is 0.
> let g:magit_auto_close=[01]

#### g:magit_split_type

When set to "h", magit will open in a horizontal split.
Default value is "v".
> let g:magit_split_type = [hv]

## Requirements

This part must be refined, I don't see any minimal version for git and vim, but for sure there should be one.
Expand Down
5 changes: 3 additions & 2 deletions plugin/magit.vim
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ let g:magit_show_magit_mapping = get(g:, 'magit_show_magit_mapping',

" user options
let g:magit_enabled = get(g:, 'magit_enabled', 1)
let g:magit_split_type = get(g:, 'magit_split_type', "v")
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)
let g:magit_default_fold_level = get(g:, 'magit_default_fold_level', 1)
Expand All @@ -41,7 +42,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_split_type)<cr>"

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

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

" }}}