0

I found this issue while editing my .vimrc. I tried to do the same in other files, such as .txt and .sh with no problems.

While in insert mode, I use <c-p> for completing words that are in the current buffer. For example, if I type Man and hit <c-n> (or <c-p>) I used to have a wildmenu with a number of options, such as Manual, Manchester , Maniacal, etc.

Now, for some reason, I get the first hit inserted and then Vim start to scan tags and it get stuck. I have to stop it with <c-c> and then the wildmenu appears.

Here is a .vimrc example to reproduce the issue

 vim9script

 if has("win64") || has("win32") || has("win16")
     g:os = "Windows"
 else
     g:os = substitute(system('uname'), '\n', '', '')
 endif

 if g:os == "Windows"
     g:tmp = "C:/temp"
     g:null_device = "NUL"
     g:dotvim = $HOME .. "/vimfiles"
 else
     g:tmp = "/tmp"
     g:null_device = "/dev/null"
     g:dotvim = $HOME .. "/.vim"
 endif

 # Internal vim variables aka 'options'
 # Set terminal with 256 colors
 set encoding=utf-8
 set belloff=all
 if has("Linux")
     set clipboard=unnamedplus
 else
     set clipboard=unnamed
 endif
 set termguicolors
 set autoread
 set number
 set nowrap
 set tabstop=4 softtabstop=4
 set shiftwidth=4
 set expandtab
 set smartindent
 set nobackup
 set backspace=indent,eol,start
 set nocompatible              # required
 set splitright
 set splitbelow
 set laststatus=2
 set incsearch # for displaying while searching
 set smartcase
 set hidden
 set noswapfile
 set spell spelllang=en_us
 set nofoldenable
 set foldmethod=syntax
 set foldlevelstart=20
 set wildmenu wildoptions=pum
 set completeopt-=preview
 set textwidth=78
 set iskeyword+="-"
 set formatoptions+=w,n,p
 set diffopt+=vertical
 set wildcharm=<tab>
 # TODO adjust path option. Move to after/ftplugin
 set path+=**
 # set cursorline

 # vim-plug
 # ----------------
 plug#begin(g:dotvim .. "/plugins/")
 Plug 'junegunn/vim-plug' # For getting the help, :h plug-options
 plug#end()
 # filetype plugin indent on
 syntax on


import g:dotvim .. "/lib/myfunctions.vim"

If I either remove the line import g:dotvim .. "/lib/myfunctions.vim" or if I remove all the following block:

 plug#begin(g:dotvim .. "/plugins/")
 Plug 'junegunn/vim-plug' # For getting the help, :h plug-options
 plug#end()
 # filetype plugin indent on
 syntax on

then, everything works fine.

May there be some conflicts between import and vim-plug?

Any idea on what is happening?

EDIT: the problem was set path option. I removed it and everything works now. Not sure if it is relevant to keep this question opened.

2 Answers 2

2

Ctrl-P and Ctrl-N in insert mode do not only complete based on words in the current buffer. Instead, they complete from all the locations specified in your 'complete' option.

By default, this includes t, which performs tag completion and i, which scans included files. If you don't want these, you can remove them from the option:

:set complete-=t,i

The default 'complete' setting also includes various other locations. If you want it to complete based only on words in the current buffer you can restrict it to do so:

:set complete=.
1
  • This is it, and explains why 'path' is the problem: path=** is likely going to be a performance problem and breaks many commands.
    – D. Ben Knoble
    Commented May 1 at 16:32
0

While in insert mode, I use for completing words that are in the current buffer.

Note that if you wish to complete words that are only in the current buffer, it may be better to use <C-x><C-p> or <C-x><C-n> instead of <C-p> or <C-n>.

From :h ins-completion:

1. Whole lines                      |i_CTRL-X_CTRL-L|
2. keywords in the current file     |i_CTRL-X_CTRL-N|
3. keywords in 'dictionary'         |i_CTRL-X_CTRL-K|
4. keywords in 'thesaurus', thesaurus-style     |i_CTRL-X_CTRL-T|
5. keywords in the current and included files   |i_CTRL-X_CTRL-I|
6. tags                             |i_CTRL-X_CTRL-]|
7. file names                       |i_CTRL-X_CTRL-F|
8. definitions or macros            |i_CTRL-X_CTRL-D|
9. Vim command-line                 |i_CTRL-X_CTRL-V|
10. User defined completion         |i_CTRL-X_CTRL-U|
11. omni completion                 |i_CTRL-X_CTRL-O|
12. Spelling suggestions            |i_CTRL-X_s|
13. keywords in 'complete'          |i_CTRL-N| |i_CTRL-P|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.