diff --git a/gopls/doc/vim.md b/gopls/doc/vim.md index eedac5925f4..a114937440a 100644 --- a/gopls/doc/vim.md +++ b/gopls/doc/vim.md @@ -174,11 +174,12 @@ Use the following configuration to have your imports organized on save using the logic of `goimports` and your code formatted. ```lua -autocmd("BufWritePre", { +vim.api.nvim_create_autocmd("BufWritePre", { pattern = "*.go", callback = function() - local params = vim.lsp.util.make_range_params() - params.context = {only = {"source.organizeImports"}} + local params = vim.lsp.util.make_range_params(0, "utf-8") + params.context = { only = { "source.organizeImports" } } + -- buf_request_sync defaults to a 1000ms timeout. Depending on your -- machine and codebase, you may want longer. Add an additional -- argument after params if you find that you have to write the file @@ -193,11 +194,12 @@ autocmd("BufWritePre", { end end end - vim.lsp.buf.format({async = false}) + vim.lsp.buf.format({ async = false }) end }) ``` + ### Omnifunc In Neovim v0.8.1 and later if you don't set the option `omnifunc`, it will auto