diff options
author | christianchiarulli <[email protected]> | 2021-06-30 18:45:40 -0400 |
---|---|---|
committer | christianchiarulli <[email protected]> | 2021-06-30 18:45:40 -0400 |
commit | 9e7ad6074746a3f7d60e164be919b53ad17a33dd (patch) | |
tree | 6ccd7982f850908d317945fd8967119b298c4ffb /lua/lsp/go-ls.lua | |
parent | d8cf871a389d9900fa21077870a817cdb6a6b47b (diff) |
refactor autocommands
Diffstat (limited to 'lua/lsp/go-ls.lua')
-rw-r--r-- | lua/lsp/go-ls.lua | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/lua/lsp/go-ls.lua b/lua/lsp/go-ls.lua index 201873a8..4af87a9d 100644 --- a/lua/lsp/go-ls.lua +++ b/lua/lsp/go-ls.lua @@ -1,7 +1,22 @@ -require'lspconfig'.gopls.setup{ +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"), + 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 |