neovim / neovim

Vim-fork focused on extensibility and usability
https://neovim.io
Other
83.16k stars 5.69k forks source link

Ctrl/Shift + function keys mappings do not work #7384

Closed antoinemadec closed 5 years ago

antoinemadec commented 7 years ago

Steps to reproduce using nvim -u vimrc_test.txt

Minimal vimrc to reproduce the issue: vimrc_test.txt In normal mode, press F5, then Ctrl+F5, then Shift+F5.

Actual behaviour

F5 echos "FOO" Ctrl+F5 mapping does not work Shift+F5 mapping does not work

Expected behaviour

F5 echos "FOO" Ctrl+F5 echos "BAR" Shift+F5 echos "HELLO"

It seems Ctrl/Shift + function keys mappings do not work in neovim. I tried to bisect to the cause of regression, but it seems this issue has been present from at least v0.1.7

Cheers, Antoine

teto commented 7 years ago

"xterm-256color" is not good for "GNOME Terminal 3.18.3" thought it won't solve this.

Have you tried with neovim-qt ? the problem most likely lies with the terminal though I've no solution to offer but others might.

justinmk commented 7 years ago

see also https://github.com/neovim/neovim/issues/5795

@antoinemadec thanks for bisecting, this is a known issue. Most likely we need to send extra info to libtermkey in tui/input.c.

nateozem commented 7 years ago

I found the issue. It's because there is a mismatch data between the mapped command and input buffer.

The reason <f5> works because the data from input_buffer->read_ptr matches to the value from a field called m_keys. This field came from one of the elements inside maphash.

However, when <c-f5> is pressed, there wouldn't be a match because input_buffer->read_ptr contains the data value of 0x80466a (length of 3) and the element, from maphash that suppose to be matched with, has a different value of 0x80fc04806b35 (length of 6) from m_keys field.

I don't know if this is libtermkey issue or the key mapping needs to be updated.

Please let me know which direction to take.

nateozem commented 7 years ago

To note: input_buffer->read_ptr is set when input_enqueue() is called. The function, that contains the logic for matching, is from vgetorpeek().

nateozem commented 7 years ago

From my last inspection, it might not be a bug, but a problem with the keyboard configuration from the terminal emulator itself. My terminal is set in a way that the following works for me:

nmap <F17> :echo "HELLO"<CR>
nmap <F29> :echo "BAR"<CR>

Have you tried mapping to <F17> or <F29>? Any of them not work? As mention from #5795, try executing $ showkey -a to see what the key value comes back with?

antoinemadec commented 7 years ago

@nateozem , here are the answers to your questions:

showkey -a: F5 ^[[15~ 27 0033 0x1b 91 0133 0x5b 49 0061 0x31 53 0065 0x35 126 0176 0x7e Ctrl+F5 ^[[15;5~ 27 0033 0x1b 91 0133 0x5b 49 0061 0x31 53 0065 0x35 59 0073 0x3b 53 0065 0x35 126 0176 0x7e Shift+F5 ^[[15;2~ 27 0033 0x1b 91 0133 0x5b 49 0061 0x31 53 0065 0x35 59 0073 0x3b 50 0062 0x32 126 0176 0x7e

map on F17 and F29: F17 mapping catches Shift+F5 F29 mapping catches Ctrl+F5

If it is not a bug from neovim:

  1. what should I change on my side ?
  2. how come vim is working fine when neovim is not ?
nateozem commented 7 years ago
  1. I'm don't know how to change the key value for gnome terminal. With iterm2, it has the ability add (or change) the keys in the preference settings. To make it work with <c-f5> & <s-f5>, I had to changed the key values as follows: ^F5 to send as \E[>15;5~ and <Shift>F5 to send as \E[>15;2~ If you can see, there is a small difference and that difference is by adding > character. You may see the values I used is from xterm+pcf3.
  2. My guess for the reason why vim works, they are probably transforming the value that comes from pressing the function + modifier keys into one kind of value. Or they probably mapped the keys like so :nmap <f29> <c-f5>.

It's a good question and I'll try to confirm this.

antoinemadec commented 7 years ago

@nateozem thanks for your response and support. However what you propose sounds like a workaround. I was more expecting to have to change $TERM or something like that.

Here are my questions:

  1. To be clear, do you mean that gnome terminal, terminator (my every day terminal) and iterm2 don't handle <c-func_keys> & <s-func_keys> properly ?
  2. If so, do you know a terminal that handles it properly ?

I know very little about key values and how they are generated but those are very mainstream terminals. Besides, the fact that Vim works fine makes me even more skeptical when you say that the issue does not come from Neovim. But once again, I know very little about those things.

Cheers!

nateozem commented 7 years ago

I was going to write something elegant, but I'll try to answer as best as I can.

iterm2 and gnome-terminal are working properly. neovim is also working properly. There is just a misunderstanding of the expectation of what the keycodes suppose to be within terminal emulator (that includes me).

I have tested vim and my assumption is correct. vim wouldn't work if I change the keycodes to the values I have mentioned. I tried changing gnome-terminal keycodes for testing, but there aren't no easy way (maybe none at all). So I tested "Konsole" application instead and able to change the keycodes. Then, I tested neovim under the same condition and tested vim to verify my assumption.

To conclude, I don't know if "proper" is the right way of looking at this issue. I'd suggest the focus to be on "simplicity" and "clearness". I would agree, from my finding, it's not the case. To answer the last question, I don't know if there are any terminal emulator that handles it properly.

Sorry I don't have a definitive answer. I'd think someone more knowledgeable than me would weigh in.

nateozem commented 7 years ago

clarification: @antoinemadec, from what you have said. I think terminfo (relation to $TERM) is more of a guide, if I'm not mistaken. Applications can comply or don't. With $TERM, it tells the application, "Hey, I'm this type of terminal and I can only do these things, so please don't try to throw any curve balls that I can not catch." So gnome-terminal, iterm2, or Konsole are the like computers, and the applications are ls, cp, vim, and nvim. (please correct me if inexact)


possible resolution: To think openly, here is my idea to resolve the issue. When nvim starts up and depending on what is set to $TERM, it should map to the correct keycode (Let me explain). For example, my $TERM is set to xterm-256color, so I'll in turn use xterm+pcf2 fragment. When I pressed the ctrl+f5 in nvim with $TERM set to xterm-256color, nvim would receive the value of \E[15;5~ (<f29>) and notice the type of $TERM. It sees xterm-256color and then decides to transform (or map) \E[15;5~ to \E[>15;5~ (<c-f5>) and then it can correctly map to the right command and execute it. This also applies vice versa if $TERM uses the xterm+pcf3 fragment. I would implement this, but it would be a waste of time if my understanding is incorrect.


questions: (to anyone) Beg the question, If implemented as describe above and set a mapping to a command for <f29> key, what would happen to this mapping? would the mapping be ignore?

This issue may could a problem with libtermkey library? I just don't know which.

I think the focus question should be, "From nvim set of keys, should <modkey-fn[1-12]> equal to <fnXX+12> and vice versa?". It's an interesting question and I don't know if someone has already pointed this out.


If anything I mention is incorrect (which probably is), please let me know.

antoinemadec commented 6 years ago

@justinmk @nateozem do you have any news about this issue? Could we mimic Vim behavior regarding modkey-fn[1-12]?

ngortheone commented 5 years ago

I have this issue on 0.3.7 I am willing to assist with debugging this

justinmk commented 5 years ago

https://github.com/neovim/neovim/issues/9780 has a good discussion showing how to debug key input. It was later resolved by these PRs, which may provide hints: https://github.com/neovim/neovim/pull/9810 https://github.com/neovim/neovim/pull/9793 .

ngortheone commented 5 years ago

I did some investigation and here are the facts that I have established so far.

nnoremap ^[[1;2Q :echo 'foobar'<CR> Mapping keycode directly to action also does not work

I hope this will help to narrow down the search.

@justinmk I tried reading issues that you mentioned but I got confused even more. I am not a C developer and my knowledge of neovim codebase/architecture is close to zero so I am not sure what exactly needs to be done in terms of actual debugging. Unfortunately I don't have enough time to dive and learn everything. As I understand - the actual debugging of the issue consists of tracing a received keypress through a number of relevant functions to determine where it gets screwed. I could probably do more with a little bit of hand holding.

ngortheone commented 5 years ago

@justinmk I was able to get a bit more info. By setting breakpoint in tui/input.c:tk_getkeys() I was able to inspect the key when I pressed <S-F2>

key = {TermKeyKey} 
 type = {TermKeyType} TERMKEY_TYPE_FUNCTION
 code = {union {...}} 
  codepoint = {long} 140557099728910
  number = {int} 14

And also by pressing keys in insert mode I got this: S-F2 is recognized as <F14> C-F2 is recognized as <F26> A-F2 - not recognized ,but A-F1 is recognized as <F37> (keymap.c goes only up to F37)

Any ideas?

ngortheone commented 5 years ago

It looks like the value ^[[1;2Q gets recognized by tk_getkey

static void tk_getkeys(TermInput *input, bool force)
{
  TermKeyKey key;
  TermKeyResult result;

  while ((result = tk_getkey(input->tk, &key, force)) == TERMKEY_RES_KEY) {
...

And tk_getkey goes into libtermkey

static TermKeyResult tk_getkey(TermKey *tk, TermKeyKey *key, bool force)
{
  return force ? termkey_getkey_force(tk, key) : termkey_getkey(tk, key);
}
blueyed commented 5 years ago

@ngortheone JFI (as reply to asking on IRC): I see <F14> with kitty, <S-F2> with urxvt (but I have special things with regard to making it behave more like xterm with the latter). Used <c-v> in insert mode to test it. In zsh I see ^[[1;2Q with kitty, and ^[[12;2~ with urxvt. Reminded me of this commit: https://github.com/neovim/libvterm/commit/a6293a0 - maybe that's a good starting point?

ngortheone commented 5 years ago

if I configure my terminal to emit ^[[12;2~on Shift-F2 then nvim recognizes it as S-F2

ngortheone commented 5 years ago

Is this a terminal problem or nvim/libterm problem?

justinmk commented 5 years ago

Is this a terminal problem or nvim/libterm problem?

With Nvim 0.3.0+ you can see terminal debugging info when the 'verbose' level is >=3 (see :help 'verbose'). Try this:

nvim -V3log
:q

Then the file named log will have a --- Terminal info --- section. Please post that section.

(Note: invoke :q manually, so that the builtin UI has a chance to start up. Don't add -c "q" in the command-line args.)

ngortheone commented 5 years ago

@justinmk terminal info as you requested (this is alacritty terminal)

--- Terminal info --- {{{
&term: xterm-256color
Description: xterm with 256 colors
Aliases: xterm-256color
Boolean capabilities:
  auto_left_margin          bw         = false
  auto_right_margin         am         = true
  no_esc_ctlc               xsb        = false
  ceol_standout_glitch      xhp        = false
  eat_newline_glitch        xenl       = true
  erase_overstrike          eo         = false
  generic_type              gn         = false
  hard_copy                 hc         = false
  has_meta_key              km         = true
  has_status_line           hs         = false
  insert_null_glitch        in         = false
  memory_above              da         = false
  memory_below              db         = false
  move_insert_mode          mir        = true
  move_standout_mode        msgr       = true
  over_strike               os         = false
  status_line_esc_ok        eslok      = false
  dest_tabs_magic_smso      xt         = false
  tilde_glitch              hz         = false
  transparent_underline     ul         = false
  xon_xoff                  xon        = false
  needs_xon_xoff            nxon       = false
  prtr_silent               mc5i       = true
  hard_cursor               chts       = false
  non_rev_rmcup             nrrmc      = false
  no_pad_char               npc        = true
  non_dest_scroll_region    ndscr      = false
  can_change                ccc        = true
  back_color_erase          bce        = true
  hue_lightness_saturation  hls        = false
  col_addr_glitch           xhpa       = false
  cr_cancels_micro_mode     crxm       = false
  has_print_wheel           daisy      = false
  row_addr_glitch           xvpa       = false
  semi_auto_right_margin    sam        = false
  cpi_changes_res           cpix       = false
  lpi_changes_res           lpix       = false
  backspaces_with_bs        OTbs       = true
  crt_no_scrolling          OTns       = false
  no_correctly_working_cr   OTnc       = false
  gnu_has_meta_key          OTMT       = false
  linefeed_is_newline       OTNL       = false
  has_hardware_tabs         OTpt       = false
  return_does_clr_eol       OTxr       = false
Numeric capabilities:
  columns                   cols       = 80
  init_tabs                 it         = 8
  lines                     lines      = 24
  lines_of_memory           lm         = -1
  magic_cookie_glitch       xmc        = -1
  padding_baud_rate         pb         = -1
  virtual_terminal          vt         = -1
  width_status_line         wsl        = -1
  num_labels                nlab       = -1
  label_height              lh         = -1
  label_width               lw         = -1
  max_attributes            ma         = -1
  maximum_windows           wnum       = -1
  max_colors                colors     = 256
  max_pairs                 pairs      = 65536
  no_color_video            ncv        = -1
  buffer_capacity           bufsz      = -1
  dot_vert_spacing          spinv      = -1
  dot_horz_spacing          spinh      = -1
  max_micro_address         maddr      = -1
  max_micro_jump            mjump      = -1
  micro_col_size            mcs        = -1
  micro_line_size           mls        = -1
  number_of_pins            npins      = -1
  output_res_char           orc        = -1
  output_res_line           orl        = -1
  output_res_horz_inch      orhi       = -1
  output_res_vert_inch      orvi       = -1
  print_rate                cps        = -1
  wide_char_size            widcs      = -1
  buttons                   btns       = -1
  bit_image_entwining       bitwin     = -1
  bit_image_type            bitype     = -1
  magic_cookie_glitch_ul    OTug       = -1
  carriage_return_delay     OTdC       = -1
  new_line_delay            OTdN       = -1
  backspace_delay           OTdB       = -1
  horizontal_tab_delay      OTdT       = -1
  number_of_function_keys   OTkn       = -1
String capabilities:
  back_tab                  cbt        = <Esc>[Z
  bell                      bel        = <C-G>
  carriage_return           cr         = <CR>
  change_scroll_region      csr        = <Esc>[%i%p1%d;%p2%dr
  clear_all_tabs            tbc        = <Esc>[3g
  clear_screen              clear      = <Esc>[H<Esc>[2J
  clr_eol                   el         = <Esc>[K
  clr_eos                   ed         = <Esc>[J
  column_address            hpa        = <Esc>[%i%p1%dG
  cursor_address            cup        = <Esc>[%i%p1%d;%p2%dH
  cursor_down               cud1       = <NL>
  cursor_home               home       = <Esc>[H
  cursor_invisible          civis      = <Esc>[?25l
  cursor_left               cub1       = <C-H>
  cursor_normal             cnorm      = <Esc>[?25h
  cursor_right              cuf1       = <Esc>[C
  cursor_up                 cuu1       = <Esc>[A
  cursor_visible            cvvis      = <Esc>[?12;25h
  delete_character          dch1       = <Esc>[P
  delete_line               dl1        = <Esc>[M
  enter_alt_charset_mode    smacs      = <Esc>(0
  enter_blink_mode          blink      = <Esc>[5m
  enter_bold_mode           bold       = <Esc>[1m
  enter_ca_mode             smcup      = <Esc>[?1049h<Esc>[22;0;0t
  enter_dim_mode            dim        = <Esc>[2m
  enter_insert_mode         smir       = <Esc>[4h
  enter_secure_mode         invis      = <Esc>[8m
  enter_reverse_mode        rev        = <Esc>[7m
  enter_standout_mode       smso       = <Esc>[7m
  enter_underline_mode      smul       = <Esc>[4m
  erase_chars               ech        = <Esc>[%p1%dX
  exit_alt_charset_mode     rmacs      = <Esc>(B
  exit_attribute_mode       sgr0       = <Esc>(B<Esc>[m
  exit_ca_mode              rmcup      = <Esc>[?1049l<Esc>[23;0;0t
  exit_insert_mode          rmir       = <Esc>[4l
  exit_standout_mode        rmso       = <Esc>[27m
  exit_underline_mode       rmul       = <Esc>[24m
  flash_screen              flash      = <Esc>[?5h$<100/><Esc>[?5l
  from_status_line          fsl        = <C-G>
  init_2string              is2        = <Esc>[!p<Esc>[?3;4l<Esc>[4l<Esc>>
  insert_line               il1        = <Esc>[L
  key_backspace             kbs        = <C-H>
  key_dc                    kdch1      = <Esc>[3~
  key_down                  kcud1      = <Esc>OB
  key_f1                    kf1        = <Esc>OP
  key_f10                   kf10       = <Esc>[21~
  key_f2                    kf2        = <Esc>OQ
  key_f3                    kf3        = <Esc>OR
  key_f4                    kf4        = <Esc>OS
  key_f5                    kf5        = <Esc>[15~
  key_f6                    kf6        = <Esc>[17~
  key_f7                    kf7        = <Esc>[18~
  key_f8                    kf8        = <Esc>[19~
  key_f9                    kf9        = <Esc>[20~
  key_home                  khome      = <Esc>OH
  key_ic                    kich1      = <Esc>[2~
  key_left                  kcub1      = <Esc>OD
  key_npage                 knp        = <Esc>[6~
  key_ppage                 kpp        = <Esc>[5~
  key_right                 kcuf1      = <Esc>OC
  key_sf                    kind       = <Esc>[1;2B
  key_sr                    kri        = <Esc>[1;2A
  key_up                    kcuu1      = <Esc>OA
  keypad_local              rmkx       = <Esc>[?1l<Esc>>
  keypad_xmit               smkx       = <Esc>[?1h<Esc>=
  meta_off                  rmm        = <Esc>[?1034l
  meta_on                   smm        = <Esc>[?1034h
  parm_dch                  dch        = <Esc>[%p1%dP
  parm_delete_line          dl         = <Esc>[%p1%dM
  parm_down_cursor          cud        = <Esc>[%p1%dB
  parm_ich                  ich        = <Esc>[%p1%d@
  parm_index                indn       = <Esc>[%p1%dS
  parm_insert_line          il         = <Esc>[%p1%dL
  parm_left_cursor          cub        = <Esc>[%p1%dD
  parm_right_cursor         cuf        = <Esc>[%p1%dC
  parm_rindex               rin        = <Esc>[%p1%dT
  parm_up_cursor            cuu        = <Esc>[%p1%dA
  print_screen              mc0        = <Esc>[i
  prtr_off                  mc4        = <Esc>[4i
  prtr_on                   mc5        = <Esc>[5i
  repeat_char               rep        = %p1%c<Esc>[%p2%{1}%-%db
  reset_1string             rs1        = <Esc>c<Esc>]104<C-G>
  reset_2string             rs2        = <Esc>[!p<Esc>[?3;4l<Esc>[4l<Esc>>
  restore_cursor            rc         = <Esc>8
  row_address               vpa        = <Esc>[%i%p1%dd
  save_cursor               sc         = <Esc>7
  scroll_forward            ind        = <NL>
  scroll_reverse            ri         = <Esc>M
  set_attributes            sgr        = %?%p9%t<Esc>(0%e<Esc>(B%;<Esc>[0%?%p6%t;1%;%?%p5%t;2%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m
  set_tab                   hts        = <Esc>H
  tab                       ht         = <Tab>
  to_status_line            tsl        = <Esc>]0;
  key_b2                    kb2        = <Esc>OE
  acs_chars                 acsc       = ``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~
  key_btab                  kcbt       = <Esc>[Z
  enter_am_mode             smam       = <Esc>[?7h
  exit_am_mode              rmam       = <Esc>[?7l
  key_end                   kend       = <Esc>OF
  key_enter                 kent       = <Esc>OM
  key_sdc                   kDC        = <Esc>[3;2~
  key_send                  kEND       = <Esc>[1;2F
  key_shome                 kHOM       = <Esc>[1;2H
  key_sic                   kIC        = <Esc>[2;2~
  key_sleft                 kLFT       = <Esc>[1;2D
  key_snext                 kNXT       = <Esc>[6;2~
  key_sprevious             kPRV       = <Esc>[5;2~
  key_sright                kRIT       = <Esc>[1;2C
  key_f11                   kf11       = <Esc>[23~
  key_f12                   kf12       = <Esc>[24~
  key_f13                   kf13       = <Esc>[1;2P
  key_f14                   kf14       = <Esc>[1;2Q
  key_f15                   kf15       = <Esc>[1;2R
  key_f16                   kf16       = <Esc>[1;2S
  key_f17                   kf17       = <Esc>[15;2~
  key_f18                   kf18       = <Esc>[17;2~
  key_f19                   kf19       = <Esc>[18;2~
  key_f20                   kf20       = <Esc>[19;2~
  key_f21                   kf21       = <Esc>[20;2~
  key_f22                   kf22       = <Esc>[21;2~
  key_f23                   kf23       = <Esc>[23;2~
  key_f24                   kf24       = <Esc>[24;2~
  key_f25                   kf25       = <Esc>[1;5P
  key_f26                   kf26       = <Esc>[1;5Q
  key_f27                   kf27       = <Esc>[1;5R
  key_f28                   kf28       = <Esc>[1;5S
  key_f29                   kf29       = <Esc>[15;5~
  key_f30                   kf30       = <Esc>[17;5~
  key_f31                   kf31       = <Esc>[18;5~
  key_f32                   kf32       = <Esc>[19;5~
  key_f33                   kf33       = <Esc>[20;5~
  key_f34                   kf34       = <Esc>[21;5~
  key_f35                   kf35       = <Esc>[23;5~
  key_f36                   kf36       = <Esc>[24;5~
  key_f37                   kf37       = <Esc>[1;6P
  key_f38                   kf38       = <Esc>[1;6Q
  key_f39                   kf39       = <Esc>[1;6R
  key_f40                   kf40       = <Esc>[1;6S
  key_f41                   kf41       = <Esc>[15;6~
  key_f42                   kf42       = <Esc>[17;6~
  key_f43                   kf43       = <Esc>[18;6~
  key_f44                   kf44       = <Esc>[19;6~
  key_f45                   kf45       = <Esc>[20;6~
  key_f46                   kf46       = <Esc>[21;6~
  key_f47                   kf47       = <Esc>[23;6~
  key_f48                   kf48       = <Esc>[24;6~
  key_f49                   kf49       = <Esc>[1;3P
  key_f50                   kf50       = <Esc>[1;3Q
  key_f51                   kf51       = <Esc>[1;3R
  key_f52                   kf52       = <Esc>[1;3S
  key_f53                   kf53       = <Esc>[15;3~
  key_f54                   kf54       = <Esc>[17;3~
  key_f55                   kf55       = <Esc>[18;3~
  key_f56                   kf56       = <Esc>[19;3~
  key_f57                   kf57       = <Esc>[20;3~
  key_f58                   kf58       = <Esc>[21;3~
  key_f59                   kf59       = <Esc>[23;3~
  key_f60                   kf60       = <Esc>[24;3~
  key_f61                   kf61       = <Esc>[1;4P
  key_f62                   kf62       = <Esc>[1;4Q
  key_f63                   kf63       = <Esc>[1;4R
  clr_bol                   el1        = <Esc>[1K
  user6                     u6         = <Esc>[%i%d;%dR
  user7                     u7         = <Esc>[6n
  user8                     u8         = <Esc>[?%[;0123456789]c
  user9                     u9         = <Esc>[c
  orig_pair                 op         = <Esc>[39;49m
  orig_colors               oc         = <Esc>]104<C-G>
  initialize_color          initc      = <Esc>]4;%p1%d;rgb:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X<Esc>\
  enter_italics_mode        sitm       = <Esc>[3m
  exit_italics_mode         ritm       = <Esc>[23m
  key_mouse                 kmous      = <Esc>[<
  set_a_foreground          setaf      = <Esc>[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m
  set_a_background          setab      = <Esc>[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m
  set_tb_margin             smgtb      = <Esc>[%i%p1%d;%p2%dr
  memory_lock               meml       = <Esc>l
  memory_unlock             memu       = <Esc>m
Extended boolean capabilities:
  AX                        = true
  G0                        = false
  XT                        = true
Extended numeric capabilities:
  U8                        = -1
Extended string capabilities:
  Cr                        = <Esc>]112<C-G>
  Cs                        = <Esc>]12;%p1%s<C-G>
  E0                        = 
  E3                        = <Esc>[3J
  Ms                        = <Esc>]52;%p1%s;%p2%s<C-G>
  S0                        = 
  Se                        = <Esc>[2 q
  Ss                        = <Esc>[%p1%d q
  TS                        = 
  XM                        = <Esc>[?1006;1000%?%p1%{1}%=%th%el%;
  grbom                     = 
  gsbom                     = 
  kDC3                      = <Esc>[3;3~
  kDC4                      = <Esc>[3;4~
  kDC5                      = <Esc>[3;5~
  kDC6                      = <Esc>[3;6~
  kDC7                      = <Esc>[3;7~
  kDN                       = <Esc>[1;2B
  kDN3                      = <Esc>[1;3B
  kDN4                      = <Esc>[1;4B
  kDN5                      = <Esc>[1;5B
  kDN6                      = <Esc>[1;6B
  kDN7                      = <Esc>[1;7B
  kEND3                     = <Esc>[1;3F
  kEND4                     = <Esc>[1;4F
  kEND5                     = <Esc>[1;5F
  kEND6                     = <Esc>[1;6F
  kEND7                     = <Esc>[1;7F
  kEND8                     = 
  kHOM3                     = <Esc>[1;3H
  kHOM4                     = <Esc>[1;4H
  kHOM5                     = <Esc>[1;5H
  kHOM6                     = <Esc>[1;6H
  kHOM7                     = <Esc>[1;7H
  kHOM8                     = 
  kIC3                      = <Esc>[2;3~
  kIC4                      = <Esc>[2;4~
  kIC5                      = <Esc>[2;5~
  kIC6                      = <Esc>[2;6~
  kIC7                      = <Esc>[2;7~
  kLFT3                     = <Esc>[1;3D
  kLFT4                     = <Esc>[1;4D
  kLFT5                     = <Esc>[1;5D
  kLFT6                     = <Esc>[1;6D
  kLFT7                     = <Esc>[1;7D
  kNXT3                     = <Esc>[6;3~
  kNXT4                     = <Esc>[6;4~
  kNXT5                     = <Esc>[6;5~
  kNXT6                     = <Esc>[6;6~
  kNXT7                     = <Esc>[6;7~
  kPRV3                     = <Esc>[5;3~
  kPRV4                     = <Esc>[5;4~
  kPRV5                     = <Esc>[5;5~
  kPRV6                     = <Esc>[5;6~
  kPRV7                     = <Esc>[5;7~
  kRIT3                     = <Esc>[1;3C
  kRIT4                     = <Esc>[1;4C
  kRIT5                     = <Esc>[1;5C
  kRIT6                     = <Esc>[1;6C
  kRIT7                     = <Esc>[1;7C
  kUP                       = <Esc>[1;2A
  kUP3                      = <Esc>[1;3A
  kUP4                      = <Esc>[1;4A
  kUP5                      = <Esc>[1;5A
  kUP6                      = <Esc>[1;6A
  kUP7                      = <Esc>[1;7A
  ka2                       = 
  kb1                       = 
  kb3                       = 
  kc2                       = 
  rmxx                      = <Esc>[29m
  smxx                      = <Esc>[9m
  xm                        = <Esc>[<%p1%d;%p2%d;%p3%d;%?%p4%tM%em%;
  ext.resize_screen         = <Esc>[8;%p1%d;%p2%dt
  ext.reset_scroll_region   = <Esc>[r
  setrgbf                   = <Esc>[38;2;%p1%d;%p2%d;%p3%dm
  setrgbb                   = <Esc>[48;2;%p1%d;%p2%d;%p3%dm
  ext.set_cursor_color      = <Esc>]12;#%p1%06x<C-G>
  ext.reset_cursor_color    = <Esc>]112<C-G>
  ext.enable_lr_margin      = <Esc>[?69h
  ext.disable_lr_margin     = <Esc>[?69l
  ext.enable_bpaste         = <Esc>[?2004h
  ext.disable_bpaste        = <Esc>[?2004l
  ext.enable_focus          = <Esc>[?1004h
  ext.disable_focus         = <Esc>[?1004l
  ext.enable_mouse          = <Esc>[?1002h<Esc>[?1006h
  ext.disable_mouse         = <Esc>[?1002l<Esc>[?1006l
}}}
justinmk commented 5 years ago

S-F2 yeilds

$ showkey -a 
^[[1;2Q    27 0033 0x1b

S-F2 is recognized as <F14>

That matches what Nvim sees in terminfo:

  key_f14                   kf14       = <Esc>[1;2Q

So you can either reconfigure your terminal or map to <f14> in Nvim:

:nnoremap <f14> ...