ray-x / go.nvim

G'day Nvimer, Joyful Gopher: Discover the Feature-Rich Go Plugin for Neovim
MIT License
1.93k stars 119 forks source link

The plugin causes the Neovim start screen to flicker. #334

Open MrZhang123 opened 1 year ago

MrZhang123 commented 1 year ago

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)
ray-x commented 1 year ago

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 ?

MrZhang123 commented 1 year ago

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

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

ray-x commented 1 year ago

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.

tr0b commented 1 year ago

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,
    }