Setting both autocomplete and complete=o makes SQL buffers almost unusable
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
Steps to reproduce
-
Start Vim with the following commands, setting
autocompleteandcomplete=oin this order:vim --clean :set autocomplete :set complete=o -
Set the buffer's filetype to SQL and enter Insert mode:
:set ft=sql i -
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 withoutdbextbeing installed. It should also respect anyomnifuncexplicitly set by the user rather than forcibly overriding it. - At the very least, document the potential consequences of enabling both
autocompleteandcomplete=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
dbextduring initialization insqlcomplete.vim. This avoids one attempt to setomnifunc. -
However, there are still two other places where
omnifunccan be set while loading or using an SQL buffer:- Around line 497 in
$VIMRUNTIME/ftplugin/sql.vim, whereomnifuncis set when an SQL buffer is loaded. - Around line 607 in
$VIMRUNTIME/autoload/sqlcomplete.vim, where the function is triggered by a key mapping defined by the ftplugin. Ifomnifuncis notsqlcomplete#Complete, it forcibly overrides the current value.
- Around line 497 in
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
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de vim/vim
-
autoconf failes to find libsodium even when present due to implicit function declarationPosiblemente ocupada @coderjoe la tomó hoy. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 13 días
-
`json_decode()` uses a number as a string pointer when 'encoding' has no converterPosiblemente ocupada @mattn la tomó hace 7 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 13 días
-
GTK4 build's v:servername is prefixed with $XDG_RUNTIME_DIR/vimQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
vim/vim#21624 · 3 comentarios ·
Los mantenedores suelen responder en 13 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 13 días
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
vim/vim#21204 · 14 comentarios ·
Los mantenedores suelen responder en 13 días
Issues similares
-
Needs Triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
Shell completion for PowerShellAbiertoenhancement good first issue help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 90/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 78/100
anthropics/skills#2328 ·
Los mantenedores suelen responder en 1 día
-
bug good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
tonydzi/sqlite-graph-memory#133 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
area: build-and-ci S3: minor
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
manaflow-ai/cmux#72257 ·
Los mantenedores suelen responder en 1 día