Skip to content

Commit 5693974

Browse files
authored
Merge pull request #2696 from bhcleek/gopls/defaults
lsp: use gopls defaults by default
2 parents ccac4bc + 57ee759 commit 5693974

File tree

3 files changed

+66
-23
lines changed

3 files changed

+66
-23
lines changed

autoload/go/config.vim

+5-5
Original file line numberDiff line numberDiff line change
@@ -501,23 +501,23 @@ function! go#config#ReferrersMode() abort
501501
endfunction
502502

503503
function! go#config#GoplsCompleteUnimported() abort
504-
return get(g:, 'go_gopls_complete_unimported', 1)
504+
return get(g:, 'go_gopls_complete_unimported', v:null)
505505
endfunction
506506

507507
function! go#config#GoplsDeepCompletion() abort
508-
return get(g:, 'go_gopls_deep_completion', 1)
508+
return get(g:, 'go_gopls_deep_completion', v:null)
509509
endfunction
510510

511511
function! go#config#GoplsFuzzyMatching() abort
512-
return get(g:, 'go_gopls_fuzzy_matching', 1)
512+
return get(g:, 'go_gopls_fuzzy_matching', v:null)
513513
endfunction
514514

515515
function! go#config#GoplsStaticCheck() abort
516-
return get(g:, 'go_gopls_staticcheck', 0)
516+
return get(g:, 'go_gopls_staticcheck', v:null)
517517
endfunction
518518

519519
function! go#config#GoplsUsePlaceholders() abort
520-
return get(g:, 'go_gopls_use_placeholders', 0)
520+
return get(g:, 'go_gopls_use_placeholders', v:null)
521521
endfunction
522522

523523
function! go#config#GoplsEnabled() abort

autoload/go/lsp/message.vim

+46-5
Original file line numberDiff line numberDiff line change
@@ -197,17 +197,58 @@ function! go#lsp#message#ConfigurationResult(items) abort
197197
let l:config = {
198198
\ 'buildFlags': [],
199199
\ 'hoverKind': 'NoDocumentation',
200-
\ 'deepCompletion': go#config#GoplsDeepCompletion() ? v:true : v:false,
201-
\ 'fuzzyMatching': go#config#GoplsFuzzyMatching() ? v:true : v:false,
202-
\ 'completeUnimported': go#config#GoplsCompleteUnimported() ? v:true : v:false,
203-
\ 'staticcheck': go#config#GoplsStaticCheck() ? v:true : v:false,
204-
\ 'usePlaceholders': go#config#GoplsUsePlaceholders() ? v:true : v:false,
205200
\ }
206201
let l:buildtags = go#config#BuildTags()
207202
if buildtags isnot ''
208203
let l:config.buildFlags = extend(l:config.buildFlags, ['-tags', go#config#BuildTags()])
209204
endif
210205

206+
let l:deepCompletion = go#config#GoplsDeepCompletion()
207+
let l:fuzzyMatching = go#config#GoplsFuzzyMatching()
208+
let l:completeUnimported = go#config#GoplsCompleteUnimported()
209+
let l:staticcheck = go#config#GoplsStaticCheck()
210+
let l:usePlaceholder = go#config#GoplsUsePlaceholders()
211+
212+
if l:deepCompletion isnot v:null
213+
if l:deepCompletion
214+
let l:config.deepCompletion = v:true
215+
else
216+
let l:config.deepCompletion = v:false
217+
endif
218+
endif
219+
220+
if l:fuzzyMatching isnot v:null
221+
if l:fuzzyMatching
222+
let l:config.fuzzyMatching = v:true
223+
else
224+
let l:config.fuzzyMatching = v:false
225+
endif
226+
endif
227+
228+
if l:completeUnimported isnot v:null
229+
if l:completeUnimported
230+
let l:config.completeUnimported = v:true
231+
else
232+
let l:config.completeUnimported = v:false
233+
endif
234+
endif
235+
236+
if l:staticcheck isnot v:null
237+
if l:staticcheck
238+
let l:config.staticcheck = v:true
239+
else
240+
let l:config.staticcheck = v:false
241+
endif
242+
endif
243+
244+
if l:usePlaceholder isnot v:null
245+
if l:usePlaceholder
246+
let l:config.usePlaceholders = v:true
247+
else
248+
let l:config.usePlaceholders = v:false
249+
endif
250+
endif
251+
211252
let l:result = add(l:result, l:config)
212253
endfor
213254

doc/vim-go.txt

+15-13
Original file line numberDiff line numberDiff line change
@@ -1739,43 +1739,45 @@ options may also need to be adjusted.
17391739
*'g:go_gopls_complete_unimported'*
17401740

17411741
Specifies whether `gopls` should include suggestions from unimported packages.
1742-
By default it is enabled.
1742+
When it is v:null, `gopls`' defaults will be used. By default it is v:null.
17431743
>
1744-
let g:go_gopls_complete_unimported = 0
1744+
let g:go_gopls_complete_unimported = v:null
17451745
<
17461746

17471747
*'g:go_gopls_deep_completion'*
17481748

1749-
Specifies whether `gopls` should use deep completion. By default it is
1750-
enabled.
1749+
Specifies whether `gopls` should use deep completion. When it is v:null,
1750+
`gopls`' defaults will be used. By default it is v:null.
1751+
17511752
>
1752-
let g:go_gopls_deep_completion = 1
1753+
let g:go_gopls_deep_completion = v:null
17531754
<
17541755

17551756
*'g:go_gopls_fuzzy_matching'*
17561757

1757-
Specifies whether `gopls` should use fuzzy matching for completions.
1758-
By default it is enabled.
1758+
Specifies whether `gopls` should use fuzzy matching for completions. When it
1759+
is v:null, `gopls`' defaults will be used.
17591760
>
1760-
let g:go_gopls_fuzzy_matching = 1
1761+
let g:go_gopls_fuzzy_matching = v:null
17611762
<
17621763

17631764
*'g:go_gopls_staticcheck'*
17641765

1765-
Specifies whether `gopls` should run staticcheck checks. By default it is
1766-
disabled.
1766+
Specifies whether `gopls` should run staticcheck checks. When it is v:null,
1767+
`gopls`' defaults will be used.
17671768
>
1768-
let g:go_gopls_staticcheck = 0
1769+
let g:go_gopls_staticcheck = v:null
17691770
<
17701771

17711772
*'g:go_gopls_use_placeholders'*
17721773

17731774
Specifies whether `gopls` can provide placeholders for function parameters and
17741775
struct fields. When set, completion items will be treated as anonymous
17751776
snippets if UltiSnips is installed and configured to be used as
1776-
|'g:go_snippet_engine'|. By default it is disabled.
1777+
|'g:go_snippet_engine'|. When it is v:null, `gopls`' defaults will be used. By
1778+
default it is disabled.
17771779
>
1778-
let g:go_gopls_use_placeholders = 0
1780+
let g:go_gopls_use_placeholders = v:null
17791781
<
17801782

17811783
*'g:go_diagnostics_enabled'*

0 commit comments

Comments
 (0)