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 gopls local per workspace #3053

Merged
merged 3 commits into from Oct 17, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions autoload/go/lsp.vim
Expand Up @@ -1101,6 +1101,9 @@ function! go#lsp#AddWorkspaceDirectory(...) abort
let l:workspaces = []
for l:dir in a:000
let l:dir = fnamemodify(l:dir, ':p')
if len(l:dir) > 1 && l:dir[-1:] == '/'
let l:dir = l:dir[:-2]
endif
if !isdirectory(l:dir)
continue
endif
Expand Down
8 changes: 6 additions & 2 deletions autoload/go/lsp/message.vim
Expand Up @@ -273,6 +273,7 @@ function! go#lsp#message#ConfigurationResult(items) abort

" results must be in the same order as the items
for l:item in a:items
let l:workspace = go#path#FromURI(l:item.scopeUri)
let l:config = {
\ 'buildFlags': [],
\ 'hoverKind': 'Structured',
Expand All @@ -290,6 +291,9 @@ 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()
if type(l:local) is v:t_dict
let l:local = get(l:local, l:workspace, v:null)
endif
let l:gofumpt = go#config#GoplsGofumpt()
let l:settings = go#config#GoplsSettings()

Expand Down Expand Up @@ -342,7 +346,7 @@ function! go#lsp#message#ConfigurationResult(items) abort
endif

if l:local isnot v:null
let l:config.local = l:local
let l:config.local = l:local
endif

if l:gofumpt isnot v:null
Expand All @@ -357,7 +361,7 @@ function! go#lsp#message#ConfigurationResult(items) abort
let l:config = extend(l:config, l:settings, 'keep')
endif

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

return l:result
Expand Down
8 changes: 6 additions & 2 deletions doc/vim-go.txt
Expand Up @@ -1900,8 +1900,12 @@ When it is `v:null`, `gopls`' default will be used. By default it is `v:null`.

*'g:go_gopls_local'*

Specifies the prefix for imports that `gopls` should consider group
separately.
Specifies the prefix for imports that `gopls` should group separately.

The value can either be a string or a dictionary. When it is a string, all
workspaces will use the same value. When it is a dictionary, the key should be
the absolute path of the workspace and the value is the prefix to use for
local imports within that workspace.

When it is `v:null`, `gopls`' default will be used. By default it is `v:null`.
>
Expand Down