girishji / vimcomplete Goto Github PK
View Code? Open in Web Editor NEWAsync autocompletion for Vim.
License: MIT License
Async autocompletion for Vim.
License: MIT License
Hi,
I'm new to vim9 and currently want to keep a legacy .vimrc because of my custom vim functions.
So I tried to put the Vimcomplete Options to a vim9script, and sourced this file from the current .vimrc:
source ~/.vim/vim9_script.vim
,
the Vimcomplete Options was not repsected.
When I called :VimCompleteCompleters , it showed as below:
{'name': 'path', 'priority': 13, 'completor': function('vimcomplete#path#Completor')}
{'name': 'buffer', 'priority': 12, 'completor': function('vimcomplete#buffer#Completor')}
So I tried to put my options in a vim9 .vimrc and it work as expected:
{'name': 'path', 'priority': 13, 'completor': function('vimcomplete#path#Completor')}
{'name': 'vimscript', 'priority': 11, 'completor': function('vimcomplete#vimscript#Completor')}
{'name': 'buffer', 'priority': 11, 'completor': function('vimcomplete#buffer#Completor')}
{'name': 'abbrev', 'priority': 10, 'completor': function('vimcomplete#abbrev#Completor')}
{'name': 'vsnip', 'priority': 10, 'completor': function('vimcomplete#vsnip#Completor')}
Could you help to check if we could able to have the options in another vim9script file and source it from a legacy .vimrc?
Hi there; quick question: I noticed this went through: vim/vim#14878
I have fuzzy matching set in vimcomplete (completionMatcher) and lsp as well. Have you seen that patch / is it relevant to how this plugin sets completeopt?
I was wondering why completion wouldn't work for me and it turns out that VimCompleteEnable only enables completion for a single buffer. Not sure if it's intentional but using
autocmd VimEnter * VimCompleteEnable
does not work then.
Edit: using
autocmd BufRead * VimCompleteEnable
works fine
Because I just use lsp
plugin for certain filetypes and vimcomplete
for all, if I open a file which has not loaded lsp
plugin, then this error occurs.
Just like the way asyncomplete do, or give users an option to configure, because there are two reasons:
/
after a file path.~/foo
directory, I can just type /
to trigger the completion, when I select a subdirectory or file named bar
, I get ~/foo/bar
instead of ~/foo//bar
.Thanks a lot.
To Reproduce this error:
Run vim
with any file or no file, press i
to enter insert mode and type some letters, then exit insert mode and type :h set
, you'll see the same error.
It would be helpful if there is an option that limits the popup menu to open only after certain numbers of characters are typed. For example completion menu will only popup when at least 3 characters are present at cursor. However it shouldn't affect lsp's "." or "->" completions.
I would like to use vimcomplete, but my .vimrc
has been built over the years in vimscript, not vim9script. I have tried converting the sample options given in the documentation to vimscript syntax (sorry, employer seems to have disabled screenshot uploads here):
let vcoptions = {
\ "buffer": {"enable": 1, "priority": 10},
\ "lsp": { "enable": 0},
\ "omnifunc": { "enable": 1, "priority": 11 }
\}
autocmd VimEnter * g:VimCompleteOptionsSet(vcoptions)
When I open a file with vim I can tell that vimcomplete is operational, but it appears to only be getting completions from the buffer completer. If I manually use <C-X><C-O>
to activate omnicompletion, I am presented with a different set of completions (ones that are object-member aware for python builtin packages). This is even true when I disable buffer completions.
I suspect that the configuration options in my .vimrc
are not being respected, possibly because there is some fatal error occurring in the translation of vimscript to vim9script. Am I on to something? Is there anyway I can use vimcomplete without re-writing my (perhaps way to long) .vimrc
in vim9script?
This is my vim version if it helps:
$ vim --version
VIM - Vi IMproved 9.1 (2024 Jan 02, compiled Mar 05 2024 19:39:07)
...
Error detected while processing /Users/xxx/AcVim/vimfiles/bundle/ngram-complete.vim/plugin/ngram-complete.vim[8]../Users/xxx/AcVim/vimfiles/bundle/vimcomplete/import/vimcompletor.vim:
line 4:
E1053: Could not import "../autoload/util.vim"
Hi,
either :VimCompleteEnable <filetypes>
isn't working as intended or I missunderstand the documentation. In my vim I define an autocmd to limit completion to some filetypes:
autocmd VimEnter * VimCompleteEnable bash c cmake conf cpp cc dosini
\ go make objc objcpp python sh vim
Nevertheless completion is enables in a buffer with filetype markdown. When I'm doing a :VimCompleteDisable
completion get's disabled. However neither a :VimCompleteEnable
not a :VimCompleteEnable markdown
reenables completions. The only way to get completion to work is to reload the buffer with :e markdownfile.md
.
Is this a bug or I'm missing something? I want completion enabled for some filetypes by default and the ability to enabling them at a later time for all filetypes.
Ideally, vimcomplete
should respect the wildignore
setting and filter out all matching entries.
It's very laggy when you hold key down in MacVim, So want dictionary.timout = 100, But can't use T_T now version
Hi, I am using latest Gvim with patch 1677. Plugin vimcomplete is installed using K-takata minipac.
For completion I prefer to use Tab instead C-n.
If I add g:vimcomplete_tab_enable = 1 to my vimrc Gvim/vim throws following error:
Error detected while processing C:\Users\bozid\vimfiles\pack\minpac\start
\vimcomplete\plugin\plugins.vim[18]..function completor#Enable[17]..util
#TabEnable:
line 4:
E31: No such mapping
E31: No such mapping
Am I doing something wrong?
Best,
boput
My vimrc
vim9script
g:vimcomplete_tab_enable = 1
var options = {
completor: {
alwaysOn: true,
customInfoWindow: true,
kindDisplayType: "symbol",
noNewlineInCompletion: true,
noselect: true,
postfixHightlight: true,
showKind: true,
showSource: true,
},
lsp: { enable: true, priority: 10, maxCount: 8 },
omnifunc: { enable: false, priority: 1},
}
autocmd VimEnter * g:VimCompleteOptionsSet(options)
When I type Enter, it still create a newline. I also have yegappan/lsp
installed, will its autocompletion conflict with yours?
I use vim :sort command sort this dict, But It can't even find the right word by capitalizing the first letter. ( Inputting "This" word can't prompt correctly)
https://github.com/Angluca/AcVim/blob/master/vimfiles/dict/zig.dict
Hi, first of all, thank you for creating awesome plugin!
I have some question about LSP's keywordOnly option.
vimcomplete/doc/vimcomplete.txt
Lines 327 to 330 in 01bae49
According to the document, when keywordOnly option is false
, LSP candidates popup after .
typed.
But It seemed to show LSP candidates regardless of keywordOnly option.
When I type f
and candidates popup and candidates are include LSP's candidates.
I thought it didn't show LSP candidates until I hit the dot, but it does.
When the keywordOnly option is set to true, it works as documented.
I would like to know the difference between the keywordOnly option.
(Also I would like the LSP candidates to be displayed when I enter the dot)
Here is my settings.
const options = {
lsp: {
enable: true,
keywordOnly: false,
}
}
g:VimCompleteOptionsSet(options)
Thank you!
vimcomplete/doc/vimcomplete.txt
Line 1 in 9b7998e
* is missing at the beginning of line 1 in vimcomplete.txt
Hello,
When loading vimcomplete, I get this error:
Error detected when processing VimEnter Autocommands for "*" ... ~/.vim/plugged/vimcomplete/autoload/vimcomplete/lsp.vim:
Export with invalid argument: export def GetTriggerKind(): number
Shown below is my vim version info:
VIM - Vi IMproved 9.0 (2022 Jun 28, compiled May 04 2023 10:24:44)
Included patches: 1-1378, 1499
Modified by [email protected]
Compiled by [email protected]
Huge version without GUI. Features included (+) or not (-):
+acl +file_in_path +mouse_urxvt -tag_any_white
+arabic +find_in_path +mouse_xterm -tcl
+autocmd +float +multi_byte +termguicolors
+autochdir +folding +multi_lang +terminal
-autoservername -footer -mzscheme +terminfo
-balloon_eval +fork() +netbeans_intg +termresponse
+balloon_eval_term +gettext +num64 +textobjects
-browse -hangul_input +packages +textprop
++builtin_terms +iconv +path_extra +timers
+byte_offset +insert_expand -perl +title
+channel +ipv6 +persistent_undo -toolbar
+cindent +job +popupwin +user_commands
-clientserver +jumplist +postscript +vartabs
-clipboard +keymap +printer +vertsplit
+cmdline_compl +lambda +profile +vim9script
+cmdline_hist +langmap -python +viminfo
+cmdline_info +libcall -python3 +virtualedit
+comments +linebreak +quickfix +visual
+conceal +lispindent +reltime +visualextra
+cryptv +listcmds +rightleft +vreplace
+cscope +localmap -ruby +wildignore
+cursorbind -lua +scrollbind +wildmenu
+cursorshape +menu +signs +windows
+dialog_con +mksession +smartindent +writebackup
+diff +modify_fname +sodium -X11
+digraphs +mouse -sound -xfontset
-dnd -mouseshape +spell -xim
-ebcdic +mouse_dec +startuptime -xpm
+emacs_tags +mouse_gpm +statusline -xsmp
+eval -mouse_jsbterm -sun_workshop -xterm_clipboard
+ex_extra +mouse_netterm +syntax -xterm_save
+extra_search +mouse_sgr +tag_binary
-farsi -mouse_sysmouse -tag_old_static
system vimrc file: "/etc/vim/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
defaults file: "$VIMRUNTIME/defaults.vim"
fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -Wdate-time -g -O2 -ffile-prefix-map=/build/vim-JA6Vy9/vim-9.0.1378=. -fstack-protector-strong -Wformat -Werror=format-security -DSYS_VIMRC_FILE=\"/etc/vim/vimrc\" -DSYS_GVIMRC_FILE=\"/etc/vim/gvimrc\" -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim -lm -ltinfo -lselinux -lsodium -lacl -lattr -lgpm
Thank you for the help.
I installed https://github.com/yegappan/lsp and your plugin. As LS I have clangd and texlab installed.
However, the completion for .tex files does not work.
:LspShowServers
Filetype Information
====================
Filetype: 'c'
Server Name: 'clang'
Server Path: '/usr/bin/clangd'
Status: Not running
Filetype: 'tex'
Server Name: 'texlab'
Server Path: '/home/werdahias/.local/bin/texlab'
Status: Running
Filetype: 'cpp'
Server Name: 'clang'
Server Path: '/usr/bin/clangd'
Status: Not running
Buffer Information
==================
Buffer: 'test.tex'
Server Path: '/home/werdahias/.local/bin/texlab'
Status: Running
:VimCompleteCompletors
{'name': 'path', 'priority': 13, 'completor': function('path#Completor')}
{'name': 'buffer', 'priority': 12, 'completor': function('buffer#Completor')}
.vimrc:
" LSP options
let lspOpts = #{autoHighlightDiags: v:true}
autocmd User LspSetup call LspOptionsSet(lspOpts)
let lspServers = [#{
\ name: 'clang',
\ filetype: ['c', 'cpp'],
\ path: '/usr/bin/clangd',
\ args: ['--background-index']
\ },
\#{
\ name: 'texlab',
\ filetype: ['tex'],
\ path: '/home/werdahias/.local/bin/texlab',
\}]
autocmd VimEnter * call LspAddServer(lspServers)
" Autocomplete options
let g:vimcomplete_tab_enable = 1
Hi. First, thanks for a great plugin!
Would it be possible to have fuzzy completion?
Is it possible to show an indication of what the completion kind from the LSP is? Function, variable, method, keyword, etc. Without vimcomplete, the LSP supports this information, but vimcomplete disables it in lsp.vim. I think there's a highlight group for "extra information" PmenuExtra(Sel) that might refer to an area that could be used?
Is there a way to expand LSP functions/snippets? I have installed the necessary vsnip plugins and the Vim9 LSP plugin. Vsnip is enabled in the options and shown in :VimCompleteCompletors
but when I press enter on a function, vimcomplete only inserts the function name.
Hello! I am still seeing completions from other buffers even after disabling... I don't think the option is actually used. Honestly, you could probably remove it if otherBuffersCount: 0
is equivalent.
When inputting CJK characters, candidates are generated unconditionally, and item in the candidates is truncated.
In this picture, I have input 睡大觉
, buffer completion suggests 睡大<e8>
; <e8>
is actually the first byte of 觉
:
% printf 觉 | xxd
00000000: e8a7 89 ...
I have "fixed" it (I will create PR later), but the fix replaces a call to strpart()
with matchstr()
: I don't know if it will cause performance issue when input is large.
Hi @girishji,
Currently, Omnifunc Completor is crashed on startup, please check screenshot
Here is my minimal vimrc config
" min.vimrc
set encoding=utf-8
scriptencoding utf-8
set nocompatible
set cmdheight=2
set termguicolors
set runtimepath^=~/.vim/plugged/vimcomplete
syntax on
filetype plugin indent on
function! s:SetupVimComplete() abort
call VimCompleteOptionsSet({
\ 'lsp': {
\ 'enable': v:false,
\ 'maxCount': 10,
\ 'priority': 11,
\ },
\ 'omnifunc': {
\ 'enable': v:true,
\ 'filetypes': ['*'],
\ 'priority': 11,
\ },
\ })
endfunction
augroup MyAutoCmd
autocmd VimEnter * call <SID>SetupVimComplete()
augroup END
Could you please help check this issue, thanks.
I want the first candidate to be selected and (even better) filled in.
For example, I typed "he", and my first candidate is "hello". I would like to see hello being selected. And I can just type to complete.
Would it be possible to add support/integration for tmux completion source?
typing "apl" currently does not give apples as a potential result completion. I think it would be a beneficial feature.
Hi
Is it possible to get support for getting the completion list to show after I enter a "." (dot).
E.g. (in python)
"". <-- this should trigger a list with all possible string commands/attributes
Alternatively, it would be nice to be able to manually decide when the completion list should open, fx. when I press "Ctrl+Space".
I am looking for a sample configuration for my .vimrc.
In order to get the LSP working, I have already had to generate a compile_commands.json
. Ideally, the autocomplete could be configured to look there. I see that there are many options on the main page, but I am not sure how to use them syntactically in a vimrc.
My vim stack is:
ale
vim-lsp
vim-lsp-ale
clang compiler
and its compile_commands.json
vim 9
on macOS
I am thinking I would want some sort of precedence (highest to lowest):
I typically use ctags as well, though I could write something that uses both.
g:vimcomplete_tab_enable = 1
After using the above option, I need to press the key again to select the first item after the completion menu appears. How can I automatically select the first item after it pops up?
I've set this in vimrc
, and <Tab>
key works well:
let g:vimcomplete_tab_enable = 1
Can I have a custom map for completion menu?
nvim-cmp have this:
mapping = cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
}),
Basically what I want is to map <CR>
to behave like native <C-y>
new version error macvim 9.1
vim
Error detected while processing /Users/xxx/AcVim/vimfiles/bundle/vimcomplete/plugin/plugins.vim:
line 17:
E1053: Could not import "../autoload/vimcomplete/completor.vim"
Press ENTER or type command to continue
处理 TextChangedI 自动命令 "<buffer=1>"..function <SNR>84_VimComplete[7]..abbrev
#Completor[9]..<SNR>110_GetAbbrevs 时发生错误:
第 8 行:
E684: 列表索引超出范围: 1
vimrc config
vim9script
export var options: dict<any>
options = {
completor: { shuffleEqualPriority: true },
buffer: { enable: false, priority: 10, urlComplete: true, envComplete: true },
abbrev: { enable: true, priority: 10 },
lsp: { enable: true, priority: 10, maxCount: 5 },
omnifunc: { enable: false, priority: 8, filetypes: ['python', 'javascript'] },
vsnip: { enable: true, priority: 11 },
vimscript: { enable: true, priority: 11 },
ngram: {
enable: true,
priority: 10,
bigram: false,
filetypes: ['text', 'help', 'markdown'],
filetypesComments: ['c', 'cpp', 'python', 'java', 'nim'],
},
}
autocmd VimEnter * g:VimCompleteOptionsSet(options)
Can you detail how i link this to https://github.com/yegappan/lsp?
I'm not getting any lsp suggestions using:
var options = {
completor: { shuffleEqualPriority: true },
buffer: { enable: true, priority: 10 },
lsp: { enable: true, priority: 8 },
}
autocmd VimEnter * g:VimCompleteOptionsSet(options)
I may have misconfigured something, but I have the nil
language server for nix running... editing the buffer seems to cause this error for every key entered.
Error detected while processing function <SNR>14_AsyncGetItems[21]..<SNR>14_GetItems[6]..lsp#Completor[20]..LspOmniFunc:
line 46:
E716: Key not present in Dictionary: "completeItemsIsIncomplete"
Press ENTER or type command to continue
packadd lsp
packadd vimcomplete
g:LspOptionsSet({
completionMatcher: 'icase',
diagVirtualTextAlign: 'after',
ignoreMissingServer: true,
noNewlineInCompletion: true,
showInlayHints: true,
})
g:LspAddServer([{
name: 'nil',
filetype: ['nix'],
path: 'nil',
args: [],
rootSearch: ['flake.nix', '.git'],
workspaceConfig: {
nil: {
formatting: {
command: [ "nixpkgs-fmt" ]
},
nix: {
flake: {
autoArchive: false,
},
},
}
},
}])
g:VimCompleteOptionsSet({
completor: {
noNewlineInCompletion: true,
#recency: false,
},
lsp: {
enable: true,
priority: 20,
},
vimscript: {
enable: true,
priority: 15,
},
})
Additionally, I've noticed hitting enter in a completion popup still enters a new line despite noNewlineInCompletion: true
for both the LSP and the completion plugin.
I think it's a good idea for better user experience, so I suggest that we can group folders before files in path completion, just like the --group-directories-first
option with ls
command.
And there's another minor problem, since the trailing slash has been removed, I think that we can also remove it from the completion menu items which're displayed to users (for consistency), so when users select an item, they'll get what they see.
Hi - just a quick question about vsnip support. There are a few relevant settings:
VimCompleteOptionsSet
's vsnip/enable
,
LspOptionsSet
's snippetSupport
LspOptionsSet
's vsnipSupport
vimcomplete should probably set the right options in the LSP, but for now, I'm not sure what the correct arrangement is. I think snippetSupport
communicates the capability to the LSP, but I probably want vimcomplete's vsnip enabled and not the lsp plugin's? Additionally, I haven't yet seen a completion option marked as "snippet" yet... e.g. if I write impl Ord for X
in Rust, it will suggest cmp
and selecting it with <C-Y>
will insert the unimplemented function. It's marked as method
, but is that a snippet?
Hi, there. When a list of completions appears, I can move the selection with <c-n>
and <c-p>
, but when I press <c-y>
, it just refreshes the completion query (the list is re-built using the selected item). It would be nice if I could set <c-y>
on an LSP item to insert the completion, close the popup, and even import the item... is this something vimcomplete is concerned with or should I inquire in the LSP repo?
Press o/O key auto jump to first line if I open more buffer > 1 in vim
I use vim 9.0 and macvim 9.1 all have this question
" completor.vim
226 endif
227 all <--
228 if line == prevCompletionInput
This lsp plugin support fuzzy completion, but it doesn't work, I thought maybe it's because vimcomplete
doesn't support fuzzy completion?
And not only for lsp
plugin, I want fuzzy completion for everything, so could you add fuzzy completion support? Thanks a lot.
Hi there. Sometimes, the source appears twice (e.g. [lsp] [lsp]
)... here are a couple videos showing it happening (in a Rust file and a TypeScript file). Interestingly, it shows when backspacing in Rust but only when a single character is present in TypeScript. If you can't reproduce, I'll try to isolate potential config issues.
I should add I'm using your PR to Vim that fixes <c-p>
.
Edit: out of curiosity, why do buffer-sourced completions have a type (e.g. k
)? The buffer wouldn't be aware of that.
Thanks for your work.
I just start using it and I like it.
What it's not fit to my preferences is the path completion.
It's complete, like default vim path completion <C-X><C-F>
and it's an absolute path.
I think it's not very useful this absolute path completion.
Example:
test
with one subfolder named subfolder
./
it shows ./subdir/ [path]
but I want to see file-one [file]
and file-two [file]
Maybe it's possible to have a choice what kind of path completion to use: absolute or relative to current buffer.
Mucomplete has this possibility: mucomplete-buffer-relative-path
I use a custom <CR>
mapping for autopairs like so:
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>\<Plug>AutoPairsReturn"
I can't figure out how to get that mapping to work with vimcomplete.
My <CR>
mapping is either unmapped or overwritten, depending on the value of noNewlineInCompletion
. I think the issue lies here:
No matter what, vimcomplete changes the behavior of <CR>
.
The plugin only maps <CR>
if I haven't mapped it in my vimrc or provides an option to not modify <CR>
.
I tried a workaround by adding an autocommand on the BufNewFile and BufReadPost events like used in VimCompEnable:
autocmd Config BufNewFile,BufReadPost *
\ inoremap <expr> <buffer> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>\<Plug>AutoPairsReturn"
That autocmd didn't work though. I guess it's running before the ones set up in VimCompEnable.
Hi,
I just found that there is an issue when using omnifunc
complete with syntaxcomplete#Complete
. When opening Gemfile in Rails project, somehow this file's omnifunc
is set to syntaxcomplete#Complete
.
When typing gem "
, everytime I type "
I got this error:
Tried to check the source code, it looks the it is failed at autoload/vimcomplete/omnifunc.vim:44
, but I don't know how to fix that.
Could you please help to fix this issue? Thanks.
It would be great to be able to autocomplete the tags if they are configured.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.