2021-07-01 00:45:40 +02:00
|
|
|
require'lspconfig'.gopls.setup {
|
2021-03-28 11:19:58 +02:00
|
|
|
cmd = {DATA_PATH .. "/lspinstall/go/gopls"},
|
2021-04-26 06:00:53 +02:00
|
|
|
settings = {gopls = {analyses = {unusedparams = true}, staticcheck = true}},
|
2021-07-01 00:45:40 +02:00
|
|
|
root_dir = require'lspconfig'.util.root_pattern(".git", "go.mod"),
|
2021-04-26 06:00:53 +02:00
|
|
|
init_options = {usePlaceholders = true, completeUnimported = true},
|
2021-03-28 11:19:58 +02:00
|
|
|
on_attach = require'lsp'.common_on_attach
|
|
|
|
}
|
2021-07-01 00:45:40 +02:00
|
|
|
|
|
|
|
if O.lang.go.autoformat then
|
|
|
|
require('lv-utils').define_augroups({
|
|
|
|
_go_format = {
|
2021-07-01 04:09:18 +02:00
|
|
|
{'BufWritePre', '*.go', 'lua vim.lsp.buf.formatting_sync(nil,1000)'}
|
2021-07-01 00:45:40 +02:00
|
|
|
},
|
|
|
|
_go = {
|
|
|
|
-- Go generally requires Tabs instead of spaces.
|
|
|
|
{'FileType', 'go', 'setlocal tabstop=4'},
|
|
|
|
{'FileType', 'go', 'setlocal shiftwidth=4'},
|
|
|
|
{'FileType', 'go', 'setlocal softtabstop=4'},
|
|
|
|
{'FileType', 'go', 'setlocal noexpandtab'}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
end
|