82 lines
2.4 KiB
Text
82 lines
2.4 KiB
Text
# arrow keys for completions
|
|
|
|
declare-option -hidden str completions_status 'completions-off'
|
|
define-command -hidden completions-off fail
|
|
define-command -hidden completions-on nop
|
|
define-command -hidden completions-up nop
|
|
define-command -hidden completions-down fail
|
|
|
|
hook global InsertCompletionShow .* %{
|
|
set-option window completions_status 'completions-on'
|
|
}
|
|
|
|
hook global InsertCompletionHide .* %{
|
|
set-option window completions_status 'completions-off'
|
|
}
|
|
|
|
define-command -hidden assert-completions %{
|
|
%opt{completions_status}
|
|
}
|
|
|
|
# arg: "completions-up" or "completions-down"
|
|
define-command -hidden -params 1 move-or-complete %{
|
|
try %{
|
|
# completions are visible
|
|
%opt{completions_status}
|
|
try %{
|
|
# up
|
|
%arg{1}
|
|
execute-keys <c-p>
|
|
} catch %{
|
|
# down
|
|
execute-keys <c-n>
|
|
}
|
|
} catch %{
|
|
# completions are not visible
|
|
try %{
|
|
# up
|
|
%arg{1}
|
|
execute-keys <up>
|
|
} catch %{
|
|
execute-keys <down>
|
|
}
|
|
}
|
|
}
|
|
|
|
map global insert <down> '<a-;>: move-or-complete completions-down<ret>'
|
|
map global insert <up> '<a-;>: move-or-complete completions-up<ret>'
|
|
|
|
map global insert <c-m> <home>
|
|
map global insert <a-m> <home>
|
|
map global insert <c-i> <end>
|
|
map global insert <a-i> <end>
|
|
map global insert <a-e> "<a-semicolon>[p<a-semicolon><semicolon>"
|
|
map global insert <a-n> "<a-semicolon>]p<a-semicolon><semicolon>"
|
|
map global insert <a-s> "<a-semicolon>: write<ret>"
|
|
# indentation
|
|
map global insert <c-.> <a-semicolon><gt>
|
|
map global insert <a-.> <a-semicolon><gt>
|
|
map global insert <c-,> <a-semicolon><lt>
|
|
map global insert <a-,> <a-semicolon><lt>
|
|
|
|
# word movement (based version)
|
|
map global insert <c-b> <a-semicolon>b
|
|
map global insert <c-left> <a-semicolon>b
|
|
map global insert <c-w> <a-semicolon>w
|
|
map global insert <c-right> <a-semicolon>w
|
|
map global insert <c-l> <a-semicolon>e
|
|
map global insert <c-up> "<a-semicolon>[p<a-semicolon><semicolon>"
|
|
map global insert <c-down> "<a-semicolon>]p<a-semicolon><semicolon>"
|
|
|
|
define-command -hidden insert-char-no-hook %{
|
|
execute-keys '<a-;>\i'
|
|
hook -always -once window InsertChar .* %{
|
|
execute-keys '<esc>'
|
|
}
|
|
}
|
|
define-command -hidden insert-no-hook %{
|
|
execute-keys '<a-;>\i'
|
|
}
|
|
|
|
map global insert <a-/> '<a-;>: insert-char-no-hook<ret>'
|
|
map global insert <a-\> '<a-;>: insert-no-hook<ret>'
|