Skip to content

Commit c3e8250

Browse files
committed
Allow vim-polyglot to load in non-compatible mode
1 parent 3618414 commit c3e8250

File tree

6 files changed

+28
-15
lines changed

6 files changed

+28
-15
lines changed

autoload/go/config.vim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -581,9 +581,9 @@ function! go#config#DiagnosticsEnabled() abort
581581
endfunction
582582

583583
function! go#config#DiagnosticsLevel() abort
584-
let l:default = 2
585-
if has_key(g:, 'go_diagnostics_enabled') && !g:go_diagnostics_enabled
586-
let l:default = 0
584+
let l:default = 0
585+
if has_key(g:, 'go_diagnostics_enabled') && g:go_diagnostics_enabled
586+
let l:default = 2
587587
endif
588588

589589
return get(g:, 'go_diagnostics_level', l:default)

autoload/polyglot/sleuth.vim

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
" Restore 'cpoptions'
2+
let s:cpo_save = &cpo
3+
set cpo&vim
4+
5+
" DO NOT EDIT CODE BELOW, IT IS GENERATED WITH MAKEFILE
6+
17
let s:globs = {
28
\ '8th': '*.8th',
39
\ 'Jenkinsfile': '*.jenkinsfile,*.Jenkinsfile,Jenkinsfile,Jenkinsfile*',
@@ -624,6 +630,13 @@ let s:globs = {
624630
\ 'zsh': '*.zsh,.zshrc,.zshenv,.zlogin,.zprofile,.zlogout,.zlog*,.zcompdump*,.zfbfmarks,.zsh*',
625631
\}
626632

633+
634+
" DO NOT EDIT CODE ABOVE, IT IS GENERATED WITH MAKEFILE
635+
627636
func! polyglot#sleuth#GlobForFiletype(type)
628637
return get(s:globs, a:type, '')
629638
endfunc
639+
640+
" Restore 'cpoptions'
641+
let &cpo = s:cpo_save
642+
unlet s:cpo_save

doc/vim-go.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1948,9 +1948,9 @@ disabled.
19481948

19491949
Specifies the `gopls` diagnostics level. Valid values are 0, 1, and 2. 0
19501950
ignores `gopls` diagnostics, 1 is for errors only, and 2 is for errors and
1951-
warnings. By default it is 2.
1951+
warnings. By default it is 0.
19521952
>
1953-
let g:go_diagnostics_level = 2
1953+
let g:go_diagnostics_level = 0
19541954
<
19551955

19561956
*'g:go_template_autocreate'*

ftdetect/polyglot.vim

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ endif
1010

1111
let did_load_polyglot = 1
1212

13+
" Switch to compatible mode for the time being
14+
let s:cpo_save = &cpo
15+
set cpo&vim
16+
1317
" It can happen vim filetype.vim loads first, then we need a reset
1418
if exists("did_load_filetypes")
1519
au! filetypedetect
@@ -2625,6 +2629,7 @@ au BufEnter * if &ft == "" && expand("<afile>:e") == "" |
26252629

26262630
augroup END
26272631

2632+
26282633
if !has_key(s:disabled_packages, 'autoindent')
26292634
" Code below re-implements sleuth for vim-polyglot
26302635
let g:loaded_sleuth = 1
@@ -3430,3 +3435,7 @@ if exists("did_load_filetypes") && exists("g:polyglot_disabled")
34303435
unlet did_load_filetypes
34313436
runtime! extras/filetype.vim
34323437
endif
3438+
3439+
" Restore 'cpoptions'
3440+
let &cpo = s:cpo_save
3441+
unlet s:cpo_save

scripts/build

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -848,15 +848,7 @@ def generate_plugins(packages)
848848
end
849849
output << " \\}\n\n"
850850

851-
852-
output << <<~EOS
853-
func! polyglot#sleuth#GlobForFiletype(type)
854-
return get(s:globs, a:type, '')
855-
endfunc
856-
EOS
857-
858-
859-
File.write('autoload/polyglot/sleuth.vim', output)
851+
inject_code('autoload/polyglot/sleuth.vim', output)
860852
end
861853

862854
def process_list(list, extras)

scripts/test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ def run_script(src)
77
end
88

99
def run_vimscript(src)
10-
1110
wrapper = <<~EOF
1211
vim --clean --not-a-term -u <(cat <<- "EOM"
1312
set nocompatible

0 commit comments

Comments
 (0)