sheerun / vim-polyglot

A solid language pack for Vim.
5.6k stars 296 forks source link

`ada` filetype cannot loading #755

Open Milly opened 3 years ago

Milly commented 3 years ago

Does this bug happen when you install plugin without vim-polyglot?

No

Describe the bug:

ada filetype cannot loading.

To Reproduce:

Use vim-polyglot 4d4aa5f

vimrc

set nocompatible
set rtp^=/path/to/vim-polyglot
> vim --version
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Sep 19 2021 15:55:16)
Included patches: 1-3450
...

> vim -u vimrc -c 'set ft=ada'
Error detected while processing command line..FileType Autocommands for "*"..function <SNR>7_LoadFTPlugin[17]..script /path/to/vim-polyglot/ftplugin/ada.vim[135]../path/to/system-vimruntime/compiler/gnat.vim[31]../path/to/vim-polyglot/autoload/ada.vim:
line   43:
E741: Value is locked: g:ada#DotWordRegex
line   44:
E741: Value is locked: g:ada#WordRegex
...

Cause

polyglot#init#is_disabled() is called from vim-polyglot/autoload/ada.vim and it's sourced $VIMRUNTIME/autoload/ada.vim. Therefore, it tries to change the locked variable and error occured.

Milly commented 3 years ago

Why does polyglot#init#is_disabled() try to source all autoload script of a:path in runtimepath?

https://github.com/sheerun/vim-polyglot/blob/4d4aa5fe553a47ef5c5c6d0a97bb487fdfda2d5b/autoload/polyglot/init.vim#L23-L37

I made the following changes and it worked fine.

func! polyglot#init#is_disabled(caller, name, path)
  return has_key(g:polyglot_is_disabled, a:name)
endfunc
ptzz commented 2 years ago

Looks like make test also fails due to this.