Closed dvtalk closed 5 months ago
Any reason you are not using standard Vim directory structure? ~/.vim/after/plugin
, .vim/autoload/
, .vim/plugin
. Placing your script in correct place obviates the need to source it. Sourcing should still work. Put echom
statements in your script and check. I suspect the function is not getting called.
Hi,
The function is called for sure. I put this file in the .vim/plugin
dir.
vim9script
#vimcomplete
var vimcomploptions = {
completor: { shuffleEqualPriority: true, postfixHighlight: true },
buffer: { enable: true, completionMatcher: 'fuzzy', priority: 11, urlComplete: false, envComplete: true },
abbrev: { enable: true, priority: 10 },
lsp: { enable: true, priority: 10, maxCount: 5 },
vsnip: { enable: true, priority: 10 },
vimscript: { enable: true, priority: 11 }
}
autocmd VimEnter * g:VimCompleteOptionsSet(vimcomploptions)
echom "test vim9_script"
And open this file:
vi vim9_script.vim
test vim9_script
Press ENTER or type command to continue
the :VimCompleteCompleters
outputs are still like this:
{'name': 'path', 'priority': 13, 'completor': function('vimcomplete#path#Completor')}
{'name': 'buffer', 'priority': 12, 'completor': function('vimcomplete#buffer#Completor')}
I have other vim9 script option in this file (such as lsp), and it works fine.
Strange indeed. Can you send me minimum configuration where I can reproduce this? Also, are you on windows?
Hi, I'm using linux, xterm-256color, tmux, pathogen for plugin manager. I'm not sure what to include since my vimrc has a lot of confiugration. However, when I try to remove all of my current plugins, keep only vimcomplete and below vim configuration and the issue still persist.
set shell=/bin/tcsh
scriptencoding utf-8
set encoding=utf-8
set nocompatible
filetype plugin indent on
set mouse=a
set showcmd
set wildmenu
set scrolloff=6
set hlsearch
set incsearch
set ignorecase
set smartcase
set nobackup
set lbr
set ai
set expandtab
set shiftwidth=3
set tabstop=3
set backspace=indent,eol,start
set nowrap
syntax on
let mapleader="\\"
set tags=tags;
set tags+=~/.vim/tag/UVM
set hidden
set clipboard=unnamed
set wildignore+=*/.git/*,*/tmp/*,*.swp "ignore these path/files in file or dir completion
set complete=.,w,b,u,
set lazyredraw
set isfname+={,}
set diffopt+=vertical
set foldenable
set foldmethod=indent
set foldlevel=1
set foldlevelstart=1
set foldcolumn=2
I reproduced the problem with just pathogen and no other customization. Pathogen is not sourcing files in vimcomplete/plugin
as Vim startup protocol requires. These files should be sourced before sourcing .vimrc
, not after. Because of this exists("g:loaded_vimcomplete")
is False, and you cannot configure Vimcomplete.
This is quite surprising. Pathogen seems like an old plugin, written before ver.8 of Vim. Is there something keeping you from moving to Vim's native package manager, or plug?
Thanks a lot, For me, Pathogen is simply easy to use; I have been using it since I became acquainted with Vim plugins. I tried https://github.com/junegunn/vim-plug, but the issue persist. The thing is I'm in a offline server, and have to download these plugins and install them manually.
call plug#begin()
" List your plugins here
Plug '~/.vim/plugged/FastFold-master'
Plug '~/.vim/plugged/footprints-master'
Plug '~/.vim/plugged/nerdcommenter-master'
Plug '~/.vim/plugged/vimcomplete-main'
call plug#end()
I think I will try another plug manager
vim-plug works. This is how I tried: Create ~/.git/
dir, and git clone https://github.com/girishji/vimcomplete
in that dir. Put this in .vimrc:
vim9script
# Download plug.vim if it doesn't exist yet
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
endif
# Run PlugInstall if there are missing plugins
autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)')) > 0
\| PlugInstall --sync | source $MYVIMRC
\| endif
plug#begin()
Plug '~/git/vimcomplete'
# Plug 'girishji/vimcomplete'
plug#end()
var vimcomploptions = {
completor: { shuffleEqualPriority: true, postfixHighlight: true },
buffer: { enable: true, completionMatcher: 'fuzzy', priority: 11, urlComplete: false, envComplete: true },
abbrev: { enable: true, priority: 10 },
lsp: { enable: true, priority: 10, maxCount: 5 },
vsnip: { enable: true, priority: 10 },
vimscript: { enable: true, priority: 11 }
}
autocmd VimEnter * g:VimCompleteOptionsSet(vimcomploptions)
And then :VimCompleteCompletors
:
~
{'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')}
Press ENTER or type command to continue
Hi, thanks for supporting.
However, is it possible that you could try to put the vimcomploptions to a vim9script in .vim/plugin/
,
and let the .vimrc
as legacy script mode (not vim9script
)?
Cuz I really want to keep my current .vimrc
It should be possible. You can keep .vimrc as legacy script. Just create a new file in .vim/plugin/ and put this:
vim9script
var vimcomploptions = {
completor: { shuffleEqualPriority: true, postfixHighlight: true },
buffer: { enable: true, completionMatcher: 'fuzzy', priority: 11, urlComplete: false, envComplete: true },
abbrev: { enable: true, priority: 10 },
lsp: { enable: true, priority: 10, maxCount: 5 },
vsnip: { enable: true, priority: 10 },
vimscript: { enable: true, priority: 11 }
}
autocmd VimEnter * g:VimCompleteOptionsSet(vimcomploptions)
I put these things in .vim/after/plugin/
Hi,
This is actually my current setup, also what I want to achieve to put the vim9script in .vim/after/plugin/
But I still could not applied the options.
Can you put 'echom' and check if your script is getting called, and if it is called before .vimrc is called?
Hi,
I put the echom in both .vimrc and the .vim/after/plugin/vim9_script.vim and here the result
vimrc echo
vim9script echo
Press ENTER or type command to continue
Looks good. Can you try:
g:VimcompleteOptionsSet(vimcomploptions)
No need for autocmd.
Hi, it still the same
var vimcomploptions = {
completor: { shuffleEqualPriority: true, postfixHighlight: true },
buffer: { enable: true, completionMatcher: 'fuzzy', priority: 11, urlComplete: false, envComplete: true },
abbrev: { enable: true, priority: 10 },
}
#autocmd VimEnter * g:VimCompleteOptionsSet(vimcomploptions)
g:VimCompleteOptionsSet(vimcomploptions)
{'name': 'path', 'priority': 13, 'completor': function('vimcomplete#path#Completor')}
{'name': 'buffer', 'priority': 12, 'completor': function('vimcomplete#buffer#Completor')}
I cannot reproduce it. Maybe you can look through my dot files and compare https://github.com/girishji/dotfiles/tree/main/vim/.vim
vimcomplete configurations are in after/plugin/opts.vim
Hmm, I have the same problem as dvtalk... The only difference is I'm using Win10. I also have a legacy .vimrc, no experience with vim9script, but a plugin I would like to use... Wouldn't it be worth the trouble to reopen? I'm willing to help with testing :-)
I have the vimcomplete options in a separate file in the after/plugin dir. I have verified that this script will load, the local variable is filled, I am able to dump it, populate it into a global variable and dump this one as well.. The problem is probably in passing this variable on for further processing.
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:So I tried to put my options in a vim9 .vimrc and it work as expected:
Could you help to check if we could able to have the options in another vim9script file and source it from a legacy .vimrc?