go.nvim icon indicating copy to clipboard operation
go.nvim copied to clipboard

The plugin causes the Neovim start screen to flicker.

Open MrZhang123 opened this issue 1 year ago • 4 comments

Thanks for making a good Go plugin for neovim, but here i found before loading the plugin, when opening neovim, the start screen is fixed in place. However, if the plugin is loaded, the start screen flickers and becomes a blank screen. How to fix ?

start screen:

WeChat76bea2aee6c7e4747d6f40d3208a6a7d

blank screen

WeChatdb689196e062e5b714deea195d5b6ed4

Here is config

require('go').setup()

vim.api.nvim_exec([[ autocmd BufWritePre *.go :silent! lua require('go.format').goimport() ]], false)

MrZhang123 avatar May 12 '23 09:05 MrZhang123

I have not see this before. Could you provide more context? e.g. your OS, nvim version. a minium config. Also the plugin has a default minium config in playground folder. Is the issue reproducible with https://github.com/ray-x/go.nvim/blob/master/playground/init_lazy.lua ?

ray-x avatar May 13 '23 08:05 ray-x

@ray-x thanks for your reply, this is my environment:

  • OS: macOS 13.3.1
  • nvim: 0.9.0
  • plugin config:
require('go').setup()

vim.api.nvim_exec([[ autocmd BufWritePre *.go :silent! lua require('go.format').goimport() ]], false)

my full config: https://github.com/MrZhang123/dotfiles/tree/master/nvim

MrZhang123 avatar May 17 '23 12:05 MrZhang123

maybe lazy load go.nvim for filetype go, gomod intead of all filetypes? I think one reason might be gopls starup time and startup check slow down the nvim.

ray-x avatar May 18 '23 01:05 ray-x

In my case i had a similar issue with this plugin. Similar to what ray-x mentioned, the workaround for me that worked for me was lazy loading go.nvim and my gopls lsp config, although I'm not sure if this isn't ideal

{
		"ray-x/go.nvim",
		ft = "go",
		config = function()
			require("go").setup({
				lsp_cfg = true,
				goimport = "gopls", -- goimport command, can be gopls[default] or goimport
				lsp_gofumpt = true, -- true: set default gofmt in gopls format to gofumpt
				lsp_on_attach = require("lsp.on_attach").setup, -- use on_attach from go.nvim
				lsp_diag_virtual_text = false, -- DO NOT overwrite my virtual text settings
				luasnip = true,
				lsp_inlay_hints = {
					parameter_hints_prefix = "󰊕",
				},
			})
			local cfg = require("go.lsp").config() -- config() return the go.nvim gopls setup
			require("lspconfig").gopls.setup(cfg)
			local format_sync_grp = vim.api.nvim_create_augroup("GoImport", {})
			vim.api.nvim_create_autocmd("BufWritePre", {
				pattern = "*.go",
				callback = function()
					require("go.format").goimport()
				end,
				group = format_sync_grp,
			})
		end,
		lazy = true,
	}

tr0b avatar Jul 03 '23 04:07 tr0b