diff --git a/vim/after/ftplugin/go.vim b/vim/after/ftplugin/go.vim index 757f857..b0910cb 100644 --- a/vim/after/ftplugin/go.vim +++ b/vim/after/ftplugin/go.vim @@ -29,8 +29,7 @@ nnoremap ds :GoDebugStep " Vim-Go configuration let g:go_gopls_enabled = 0 -let g:go_fmt_autosave = 1 -let g:go_fmt_command = "goimports" +let g:go_fmt_autosave = 0 let g:go_imports_autosave = 0 let g:go_textobj_enabled = 0 let g:go_auto_sameids = 0 @@ -43,8 +42,6 @@ let g:go_highlight_diagnostic_errors = 0 let g:go_highlight_diagnostic_warnings = 0 let g:go_highlight_trailing_whitespace_error=0 -let g:go_fmt_command = 'goimports' - " g:go_statusline_duration doesn't seem to work accurately, but does help " reduce the time the build/test success messages are shown in the status " line. diff --git a/vim/lua/formatter_config.lua b/vim/lua/formatter_config.lua index 5a4baee..9c66bf6 100644 --- a/vim/lua/formatter_config.lua +++ b/vim/lua/formatter_config.lua @@ -6,12 +6,20 @@ local prettier = function() } end +local goimports = function() + return { + exe = "goimports", + stdin = true, + } +end + require("formatter").setup({ log_level = vim.log.levels.INFO, filetype = { javascript = { prettier }, typescript = { prettier }, typescriptreact = { prettier }, + go = { goimports }, -- https://github.com/JohnnyMorganz/StyLua -- cargo install stylua --features lua54 @@ -26,7 +34,7 @@ vim.api.nvim_exec2( [[ augroup FormatAutogroup autocmd! - autocmd BufWritePost *.js,*.ts,*.tsx,*.lua silent FormatWrite + autocmd BufWritePost *.js,*.ts,*.tsx,*.go,*.lua silent FormatWrite augroup END ]], { output = true }