go-ls.lua 861 B

12345678910111213141516171819202122
  1. require'lspconfig'.gopls.setup {
  2. cmd = {DATA_PATH .. "/lspinstall/go/gopls"},
  3. settings = {gopls = {analyses = {unusedparams = true}, staticcheck = true}},
  4. root_dir = require'lspconfig'.util.root_pattern(".git", "go.mod"),
  5. init_options = {usePlaceholders = true, completeUnimported = true},
  6. on_attach = require'lsp'.common_on_attach
  7. }
  8. if O.lang.go.autoformat then
  9. require('lv-utils').define_augroups({
  10. _go_format = {
  11. 'BufWritePre', '*.go', 'lua vim.lsp.buf.formatting_sync(nil,1000)'
  12. },
  13. _go = {
  14. -- Go generally requires Tabs instead of spaces.
  15. {'FileType', 'go', 'setlocal tabstop=4'},
  16. {'FileType', 'go', 'setlocal shiftwidth=4'},
  17. {'FileType', 'go', 'setlocal softtabstop=4'},
  18. {'FileType', 'go', 'setlocal noexpandtab'}
  19. }
  20. })
  21. end