junegunn / vim-plug

:hibiscus: Minimalist Vim Plugin Manager
https://junegunn.github.io/vim-plug/
MIT License
34.07k stars 1.93k forks source link

nvim: plugins not loading on startup unless launched in the same directory as init.vim #1181

Closed MarkusG closed 2 years ago

MarkusG commented 2 years ago

When launching nvim, plugins do not seem to be fully loaded until I run :PlugInstall. :PlugStatus lists all my plugins as OK, but none of their commands are recognized. After running :PlugInstall, which verifies that all my plugins are in fact already installed, they work as intended. This issue only seems to present if I launch nvim outside of the directory in which my init.vim resides. Launching it in that directory produces the intended behavior of the plugin commands being recognized immediately after startup with no intervention.


NVIM v0.7.0
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by builduser

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"
junegunn commented 2 years ago

Please post your configuration file.

MarkusG commented 2 years ago
" plugins
call plug#begin()

" code completion
Plug 'neoclide/coc.nvim', {'branch': 'release'}

" commands to surround things with punctuation e.g. parentheses
Plug 'tpope/vim-surround'

" commands comment out lines and regions
Plug 'tpope/vim-commentary'
nnoremap <C-k> :Commentary<CR>

" colorize hex codes and other color specifications
Plug 'lilydjwg/colorizer'

" display commit contents and diffs while writing commit messages
Plug 'rhysd/committia.vim'

" grab bag of latex improvements
Plug 'lervag/vimtex'

call plug#end()

set nocompatible
filetype off

set hlsearch
set number relativenumber
set nu rnu
set smartindent
set tabstop=4
set shiftwidth=4

" make my code nice and slim
set colorcolumn=80

" smart case
set ignorecase
set smartcase

" undo file
set undofile
set undolevels=1000
set undoreload=10000

" auto reload
set autoread

" save unwritten buffers
set hidden

" shorten things
set shortmess=atI

" unite the clipboards
if has('unnamedplus')
    set clipboard=unnamed,unnamedplus
endif

" dont make comments so sticky
set formatoptions-=r
" lists
set formatoptions+=n
" comments on line joins
set formatoptions+=j

" ignore my slow fingers
cnoreabbrev W! w!
cnoreabbrev Q! q!
cnoreabbrev Qa! qa!
cnoreabbrev Wq wq
cnoreabbrev Wa wa
cnoreabbrev wQ wq
cnoreabbrev WQ wq
cnoreabbrev W w
cnoreabbrev Q q
cnoreabbrev Qa qa

" navigate tabs with shift
nnoremap H gT
nnoremap L gt

"tab management with t leader
nnoremap tn :tabnew<CR>
nnoremap tq :tabclose<CR>

syntax on
" move through wrapped lines as if they were individual lines
map j gj
map k gk

" execute project-specific vimrc
set exrc
set secure

" latex
filetype plugin indent on
set grepprg=grep\ -nH\ $*
let g:tex_flavor = "latex"
junegunn commented 2 years ago

https://github.com/junegunn/vim-plug/wiki/tips#migrating-from-other-plugin-managers

Not an answer to the question, but you can remove filetype off, syntax on, and filetype plugin indent on as they are handled by vim-plug. It will shave off some startup time.

the directory in which my init.vim resides

which is?

MarkusG commented 2 years ago

Thanks for the tip! My init.vim is in .config/nvim

MarkusG commented 2 years ago

I've solved this, and I have no idea how or what was wrong with it in the first place. After wiping out everything related to nvim from my system and setting up vim-plug according to the README, everything works as intended.