Setting both autocomplete and complete=o makes SQL buffers almost unusable

Abierto
#21,421 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 13 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
vim
Área
tooling

Línea de trabajo

Start with $VIMRUNTIME/ftplugin/sql.vim around line 497 and $VIMRUNTIME/autoload/sqlcomplete.vim around lines 607 and 695, then reproduce the SQL buffer delay with autocomplete and complete=o enabled. Review the existing dbext check and the documented omni_sql_no_default_maps and omni_sql_default_compl_type workarounds. Done means SQL input is not blocked and an explicitly configured omnifunc is not unexpectedly overridden, with relevant behavior documented.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug
Steps to reproduce
  1. Start Vim with the following commands, setting autocomplete and complete=o in this order:

    vim --clean
    :set autocomplete
    :set complete=o
    
  2. Set the buffer's filetype to SQL and enter Insert mode:

    :set ft=sql
    i
    
  3. Input becomes unresponsive. Specifically, after pressing a key, nothing appears in the buffer for approximately two seconds. Instead, the following error message is displayed in the message area. Only after those two seconds does the typed text appear in the buffer.

    SQLComplete:The dbext plugin must be loaded for dynamic SQL completion
    
Expected behaviour

Under normal circumstances, even though the documentation explicitly states that the SQL ftplugin depends on the dbext plugin, the ftplugin should not prevent users from entering text into a buffer simply because certain built-in options are enabled.

Ideally, it should do one of the following:

  • Silently fall back to the default omnifunc.
  • Set omnifunc, but fail gracefully and without blocking when completion is triggered without dbext being installed. It should also respect any omnifunc explicitly set by the user rather than forcibly overriding it.
  • At the very least, document the potential consequences of enabling both autocomplete and complete=o.

First, regarding the cause of the input delay: in $VIMRUNTIME/autoload/sqlcomplete.vim, around line 695, the function s:SQLCCheck4dbext() contains two instances of :sleep 2.

I would not recommend simply removing these sleep commands as a fix. Although doing so would prevent input from being blocked, it would cause the error message to appear repeatedly and at a high frequency, which would be quite annoying in practice.

In fact, a similar issue was reported last year. One of the comments also pointed out that autocomplete could cause breakage. Although that issue was marked as fixed, the underlying problem described here has not actually been resolved.

More specifically:

  • The commit associated with that issue added a check for dbext during initialization in sqlcomplete.vim. This avoids one attempt to set omnifunc.

  • However, there are still two other places where omnifunc can be set while loading or using an SQL buffer:

    1. Around line 497 in $VIMRUNTIME/ftplugin/sql.vim, where omnifunc is set when an SQL buffer is loaded.
    2. Around line 607 in $VIMRUNTIME/autoload/sqlcomplete.vim, where the function is triggered by a key mapping defined by the ftplugin. If omnifunc is not sqlcomplete#Complete, it forcibly overrides the current value.

This leads to some rather undesirable behavior.

For example, when users discover that the SQL omnifunc depends on dbext, a natural workaround would be to use the following configuration:

" In after/ftplugin/sql.vim
setlocal omnifunc=syntaxcomplete#Complete

However, this does not fully work. When the user presses the key mapped by the ftplugin, omnifunc is still forcibly overridden. This is particularly problematic because the default mappings can be triggered accidentally and involve a frequently used key combination, <C-c>.

Some workarounds that actually work are:

" Workaround 1

" Set this before $VIMRUNTIME/ftplugin/sql.vim is loaded
let g:omni_sql_no_default_maps = 1

" Then override omnifunc in after/ftplugin/sql.vim
setlocal omnifunc=syntaxcomplete#Complete

Or:

" Workaround 2

" Set the completion mode used internally by sqlcomplete
" before $VIMRUNTIME/ftplugin/sql.vim is loaded
let g:omni_sql_default_compl_type = 'syntax'

However, neither of these workarounds is adequately documented.

The documentation only mentions that let g:omni_sql_no_default_maps = 1 disables the default mappings. It does not explain the relationship between these mappings and omnifunc, making it difficult for users to understand why their custom omnifunc configuration is being overridden.


Finally, I apologize for raising this runtime-related issue here on GitHub.

I checked the MAINTAINERS file beforehand, but could not find any maintainer information for the relevant files.

I then tried contacting David Fishburn ([email protected]), whose name appears in the headers of these files, directly via email. However, I have not received a response after a week.

I am not sure whether David Fishburn is still maintaining these files. If he is no longer responsible for them, it would be helpful to identify the correct contact person in the relevant files.

Finally, English is not my first language, and I used AI to help translate this issue. Please excuse any awkward or inappropriate wording.

Version of Vim

9.2.1046

Environment

System:
Kernel: 7.0.14-arch1-1 arch: x86_64 bits: 64
Console: pty pts/2 Distro: Arch Linux
Term: xterm-256color
Shell: GNU bash, version 5.3.20(1)-release (x86_64-pc-linux-gnu)

Logs and stack traces

Lenguaje dominante
Vim Script
Estrellas
41.4k
Forks
6.2k
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de vim/vim

Todos los issues de vim/vim

Issues similares

Más issues de DevTools

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.