Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lsp: support gofumpt and unknown gopls settings #2994

Merged
merged 1 commit into from
Sep 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions autoload/go/config.vim
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,14 @@ function! go#config#GoplsLocal() abort
return get(g:, 'go_gopls_local', v:null)
endfunction

function! go#config#GoplsGofumpt() abort
return get(g:, 'go_gopls_gofumpt', v:null)
endfunction

function! go#config#GoplsSettings() abort
return get(g:, 'go_gopls_settings', v:null)
endfunction

function! go#config#GoplsEnabled() abort
return get(g:, 'go_gopls_enabled', 1)
endfunction
Expand Down
10 changes: 10 additions & 0 deletions autoload/go/lsp/message.vim
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ function! go#lsp#message#ConfigurationResult(items) abort
let l:tempModfile = go#config#GoplsTempModfile()
let l:analyses = go#config#GoplsAnalyses()
let l:local = go#config#GoplsLocal()
let l:gofumpt = go#config#GoplsGofumpt()
let l:settings = go#config#GoplsSettings()

if l:deepCompletion isnot v:null
if l:deepCompletion
Expand Down Expand Up @@ -322,6 +324,14 @@ function! go#lsp#message#ConfigurationResult(items) abort
let l:config.local = l:local
endif

if l:gofumpt isnot v:null
let l:config.gofumpt = l:local
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this a typo? I suppose it should be = l:gofumpt.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's a typo. PR coming up.

endif

if l:settings isnot v:null
let l:config = extend(l:config, l:settings, 'keep')
endif

let l:result = add(l:result, l:config)
endfor

Expand Down
18 changes: 18 additions & 0 deletions doc/vim-go.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1874,6 +1874,24 @@ is `v:null`.
let g:go_gopls_local = v:null
<

*'g:go_gopls_gofumpt'*

Specifies whether `gopls` should use `gofumpt` for formatting. When it is
`v:null`, `gopls`' default will be used. By default it is `v:null`.
>
let g:go_gopls_gofumpt = v:null
<

*'g:go_gopls_settings'*

Specifies `gopls` workspace settings for `gopls` that are not yet officially
supported by vim-go. Any value in the dictionary will be overridden by values
provided in the specific options supported by vim-go (e.g.
g:go_gopls_staticcheck) or settings statically configured by vim-go to ensure
expected behavior. By default it is `v:null`.
>
let g:go_gopls_settings = v:null
<
*'g:go_diagnostics_enabled'*

Specifies whether `gopls` diagnostics are enabled. Only the diagnostics for
Expand Down