Skip to content

Document g:terminal_skip_key_init and simplify its usage #25

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

Open
wants to merge 1 commit into
base: master
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ tell vim to open `abc.txt`
- `g:terminal_list`: set to 0 to hide terminal buffer in the buffer list.
- `g:terminal_fixheight`: set to 1 to set `winfixheight` for the terminal window.
- `g:terminal_close`: set to 1 to close window if process finished.
- `g:terminal_skip_key_init`: set to 1 if you don't use the 'ALT' key and don't want this plugin to adjust options that recognises it.


## Remember
Expand Down
3 changes: 3 additions & 0 deletions doc/terminal_help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ Settings ~
- 'g:terminal_fixheight': set to 1 to set 'winfixheight' for the terminal
window.
- 'g:terminal_close': set to 1 to close window if process finished.
- 'g:terminal_skip_key_init': set to 1 if you don't use the 'ALT' key and
don't want this plugin to adjust options that recognises it.


===============================================================================
*terminal_help-remember*
Expand Down
12 changes: 5 additions & 7 deletions plugin/terminal_help.vim
Original file line number Diff line number Diff line change
Expand Up @@ -381,17 +381,17 @@ endfunc
"----------------------------------------------------------------------
" enable alt key in terminal vim
"----------------------------------------------------------------------
if has('nvim') == 0 && has('gui_running') == 0
if has('nvim') == 0
\ && has('gui_running') == 0
\ && get(g:, 'terminal_skip_key_init', 0) == 0
set ttimeout
if $TMUX != ''
set ttimeoutlen=35
elseif &ttimeoutlen > 80 || &ttimeoutlen <= 0
set ttimeoutlen=85
endif
function! s:meta_code(key)
if get(g:, 'terminal_skip_key_init', 0) == 0
exec "set <M-".a:key.">=\e".a:key
endif
exec "set <M-".a:key.">=\e".a:key
endfunc
for i in range(10)
call s:meta_code(nr2char(char2nr('0') + i))
Expand All @@ -407,9 +407,7 @@ if has('nvim') == 0 && has('gui_running') == 0
call s:meta_code(c)
endfor
function! s:key_escape(name, code)
if get(g:, 'terminal_skip_key_init', 0) == 0
exec "set ".a:name."=\e".a:code
endif
exec "set ".a:name."=\e".a:code
endfunc
call s:key_escape('<F1>', 'OP')
call s:key_escape('<F2>', 'OQ')
Expand Down