-
Notifications
You must be signed in to change notification settings - Fork 55
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
Bug fix in omnifunc #360
Bug fix in omnifunc #360
Conversation
1) LspOmniFunc() causes inserted text (when selecting from a popup) to appear in the wrong column. This happens *only* when using this function separately (through `complete()` function) in combination with other completion functions. When findstart=1, this function returns column width of 1 for tab (if tabstop is set to 8), instead of 8. To fix the problem I replaced use of `charcol()` with `col()`. `:h complete-functions` recommends using `col()`. Normal users of omnifunc (<c-x><c-o>) should not notice any difference. 2) Added a function to check if omnifunc is waiting for LSP response. This is helpful for writing adapters for async completion plugins out there. M autoload/lsp/completion.vim
Thanks for the patch. Do you have a minimal script that reproduces this issue? Are you referring to the popup window showing up in column 1 instead of column 8 in your picture? Note that the completion function should return a column number (byte index) and not a virtual column number. So a tab character is counted as one byte and the index will be 1 for a tab character. |
@@ -472,6 +467,13 @@ def g:LspOmniFunc(findstart: number, base: string): any | |||
endif | |||
enddef | |||
|
|||
# For plugins that implement async completion from various sources this function | |||
# indicates if omnifunc is waiting for LSP response. | |||
def g:LspOmniCompletePending(): bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you update the doc with a description and use of this function?
I made a mistake. I did not realize that
Turn off the autocomplete in .vimrc:
GIven what I discovered, there is no need to make changes to |
For optimization reasons, it makes sense to include your changes. The current code does a regular expression comparison for each character. With your change, only a single regular expression comparison will be used. Can you reopen the PR? |
I cannot reopen this PR. The button is grayed out. Maybe because I deleted the branch. But I will submit a new PR with same changes. |
you could push the branch to the server than try to reopen it |
LspOmniFunc() causes inserted text (when selecting from a popup) to
appear in the wrong column. This happens only when using this
function separately (through
complete()
function) in combinationwith other completion functions. When findstart=1, this function
returns column width of 1 for tab (if tabstop is set to 8), instead
of 8. To fix the problem I replaced use of
charcol()
withcol()
.:h complete-functions
recommends usingcol()
.Normal users of omnifunc () should not notice any
difference.
Added a function to check if omnifunc is waiting for LSP response.
This is helpful for writing adapters for external completion
plugins out there.
Since LspOmniFunc() works correctly when used with
this PR is not essential. I leave it to the discretion of Yegappan to
decide whether to include or not.
I use this omnifunc in conjunction with other omnifunc's. I call
them first with findstart=1 and then again with findstart=0, then
combine the returned items and show them using
complete()
.I use them in async manner. The advantage of this change is that
now you can adapt this LSP to any external completion plugin
using few lines of stub code.
Here is how the bug shifts popup window (and inserts in wrong column):
M autoload/lsp/completion.vim