summaryrefslogtreecommitdiff
path: root/lua/lsp/go-ls.lua
blob: b2d6a82a39fa00f98945b6731c5f8fc053c394df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
require'lspconfig'.gopls.setup {
    cmd = {DATA_PATH .. "/lspinstall/go/gopls"},
    settings = {gopls = {analyses = {unusedparams = true}, staticcheck = true}},
    root_dir = require'lspconfig'.util.root_pattern(".git", "go.mod"),
    init_options = {usePlaceholders = true, completeUnimported = true},
    on_attach = require'lsp'.common_on_attach
}

if O.lang.go.autoformat then
    require('lv-utils').define_augroups({
        _go_format = {
            {'BufWritePre', '*.go', 'lua vim.lsp.buf.formatting_sync(nil,1000)'}
        },
        _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