[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigator mess up context #265

Open
liketoeatcheese opened this issue Mar 21, 2023 · 18 comments
Open

Navigator mess up context #265

liketoeatcheese opened this issue Mar 21, 2023 · 18 comments
Labels
question Further information is requested windows related MS windows

Comments

@liketoeatcheese
Copy link

Hi Ray,

I'm seeing context order being messed up, whenever I move the cursor up a line, it duplicates the context showing up above it, like this:
image

While it should look like this:
image

It doesn't affect the code itself but it just pops up like that. And if the code is not formatted, and I format it using <Leader>lf, it messed up even more. It has been a while since this error show up but wasn't sure which plugin caused it. But today, after I turned off navigator, the issue disappear.

Is this a known issues? Any thoughts?

@ray-x
Copy link
Owner
ray-x commented Mar 21, 2023

I did not suffer this issue
image

Do you have a minium init.lua I can reproduce?

@liketoeatcheese
Copy link
Author

This is my navigaotr config

local navigator_status_ok, navigator = pcall(require, "navigator")
if not navigator_status_ok then
	print("can't not pull navigator plugin")
	return
end

navigator.setup({

	debug = false, -- log output, set to true and log path: ~/.cache/nvim/gh.log
	width = 0.75, -- max width ratio (number of cols for the floating window) / (window width)
	height = 0.3, -- max list window height, 0.3 by default
	preview_height = 0.35, -- max height of preview windows
	border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, -- border style, can be one of 'none', 'single', 'double',
	-- 'shadow', or a list of chars which defines the border
	on_attach = function(client, bufnr)
		-- your hook
	end,
	-- put a on_attach of your own here, e.g
	-- function(client, bufnr)
	--   -- the on_attach will be called at end of navigator on_attach
	-- end,
	-- The attach code will apply to all LSP clients

	ts_fold = false, -- modified version of treesitter folding
	default_mapping = true, -- set to false if you will remap every key or if you using old version of nvim-
	keymaps = { { key = "gK", func = vim.lsp.declaration, desc = "declaration" } }, -- a list of key maps
	-- this kepmap gK will override "gD" mapping function declaration()  in default kepmap
	-- please check mapping.lua for all keymaps
	--[[ treesitter_analysis = true, -- treesitter variable context ]]
	--[[ treesitter_navigation = true, -- bool|table false: use lsp to navigate between symbol ']r/[r', table: a list of ]]
	--lang using TS navigation
	--[[ treesitter_analysis_max_num = 100, -- how many items to run treesitter analysis ]]
	--[[ treesitter_analysis_condense = true, -- condense form for treesitter analysis ]]
	-- this value prevent slow in large projects, e.g. found 100000 reference in a project
	transparency = 50, -- 0 ~ 100 blur the main window, 100: fully transparent, 0: opaque,  set to nil or 100 to disable it

	lsp_signature_help = true, -- if you would like to hook ray-x/lsp_signature plugin in navigator
	-- setup here. if it is nil, navigator will not init signature help
	signature_help_cfg = nil, -- if you would like to init ray-x/lsp_signature plugin in navigator, and pass in your own config to signature help
	icons = {
		-- Code action
		code_action_icon = "🏏", -- note: need terminal support, for those not support unicode, might crash
		-- Diagnostics
		diagnostic_head = "🐛",
		diagnostic_head_severity_1 = "🈲",
		-- refer to lua/navigator.lua for more icons setups
	},
	mason = true, -- set to true if you would like use the lsp installed by williamboman/mason
	lsp = {
		enable = true, -- skip lsp setup, and only use treesitter in navigator.
		-- Use this if you are not using LSP servers, and only want to enable treesitter support.
		-- If you only want to prevent navigator from touching your LSP server configs,
		-- use `disable_lsp = "all"` instead.
		-- If disabled, make sure add require('navigator.lspclient.mapping').setup({bufnr=bufnr, client=client}) in your
		-- own on_attach
		code_action = { enable = true, sign = true, sign_priority = 40, virtual_text = true },
		code_lens_action = { enable = true, sign = true, sign_priority = 40, virtual_text = true },
		document_highlight = true, -- LSP reference highlight,
		-- it might already supported by you setup, e.g. LunarVim
		format_on_save = false, -- {true|false} set to false to disasble lsp code format on save (if you are using prettier/efm/formater etc)
		-- table: {enable = {'lua', 'go'}, disable = {'javascript', 'typescript'}} to enable/disable specific language
		-- enable: a whitelist of language that will be formatted on save
		-- disable: a blacklist of language that will not be formatted on save
		-- function: function(bufnr) return true end to enable/disable lsp format on save
		disable_lsp = { "all" },
		format_options = { async = true }, -- async: disable by default, the option used in vim.lsp.buf.format({async={true|false}, name = 'xxx'})
		--[[ disable_format_cap = { "sqls", "sumneko_lua", "gopls" }, -- a list of lsp disable format capacity (e.g. if you using efm or vim-codeformat etc), empty {} by default ]]
		-- If you using null-ls and want null-ls format your code
		-- you should disable all other lsp and allow only null-ls.
		-- disable_lsp = {'pylsd', 'sqlls'},  -- prevents navigator from setting up this list of servers.
		-- if you use your own LSP setup, and don't want navigator to setup
		-- any LSP server for you, use `disable_lsp = "all"`.
		-- you may need to add this to your own on_attach hook:
		-- require('navigator.lspclient.mapping').setup({bufnr=bufnr, client=client})
		-- for e.g. denols and tsserver you may want to enable one lsp server at a time.
		-- default value: {}
		diagnostic = {
			underline = true,
			virtual_text = true, -- show virtual for diagnostic message
			update_in_insert = false, -- update diagnostic message in insert mode
		},

		diagnostic_scrollbar_sign = { "▃", "▆", "█" }, -- experimental:  diagnostic status in scroll bar area; set to false to disable the diagnostic sign,
		--                for other style, set to {'╍', 'ﮆ'} or {'-', '='}
		diagnostic_virtual_text = true, -- show virtual for diagnostic message
		diagnostic_update_in_insert = false, -- update diagnostic message in insert mode
		disply_diagnostic_qf = false, -- always show quickfix if there are diagnostic errors, set to false if you want to ignore it
		tsserver = {
			filetypes = { "typescript" }, -- disable javascript etc,
			-- set to {} to disable the lspclient for all filetypes
		},
		ctags = {
			cmd = "ctags",
			tagfile = "tags",
			options = "-R --exclude=.git --exclude=node_modules --exclude=test --exclude=vendor --excmd=number",
		},
	},
})

It's possible that it may over lap with nvimtree-context as well (even though I tried turning off nvim-tree-context and left navigator on but the error still occurred), so here's my nvimtree-context:

local treesitter_context_status_ok, treesitter_context = pcall(require, "treesitter-context")
if not treesitter_context_status_ok then
  print("Can't load treesitter-context")
  return
end

treesitter_context.setup{
    enable = true, -- Enable this plugin (Can be enabled/disabled later via commands)
    max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit.
    trim_scope = 'outer', -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer'
    min_window_height = 0, -- Minimum editor window height to enable context. Values <= 0 mean no limit.
    patterns = { -- Match patterns for TS nodes. These get wrapped to match at word boundaries.
        -- For all filetypes
        -- Note that setting an entry here replaces all other patterns for this entry.
        -- By setting the 'default' entry below, you can control which nodes you want to
        -- appear in the context window.
        default = {
            'class',
            'function',
            'method',
            'for',
            'while',
            'if',
            'switch',
            'case',
        },
        -- Patterns for specific filetypes
        -- If a pattern is missing, *open a PR* so everyone can benefit.
        tex = {
            'chapter',
            'section',
            'subsection',
            'subsubsection',
        },
        rust = {
            'impl_item',
            'struct',
            'enum',
        },
        scala = {
            'object_definition',
        },
        vhdl = {
            'process_statement',
            'architecture_body',
            'entity_declaration',
        },
        markdown = {
            'section',
        },
        elixir = {
            'anonymous_function',
            'arguments',
            'block',
            'do_block',
            'list',
            'map',
            'tuple',
            'quoted_content',
        },
        json = {
            'pair',
        },
        yaml = {
            'block_mapping_pair',
        },
    },
    exact_patterns = {
        -- Example for a specific filetype with Lua patterns
        -- Treat patterns.rust as a Lua pattern (i.e "^impl_item$" will
        -- exactly match "impl_item" only)
        -- rust = true,
    },

    -- [!] The options below are exposed but shouldn't require your attention,
    --     you can safely ignore them.

    zindex = 20, -- The Z-index of the context window
    mode = 'cursor',  -- Line used to calculate context. Choices: 'cursor', 'topline'
    -- Separator between context and content. Should be a single character string, like '-'.
    -- When separator is set, the context will only show up when there are at least 2 lines above cursorline.
    separator = nil,
}

@ray-x
Copy link
Owner
ray-x commented Mar 21, 2023

Still failed to reproduce, here is my init.lua

vim.cmd([[set runtimepath=$VIMRUNTIME]])
vim.cmd([[set packpath=/tmp/nvim/lazy]])

local package_root = '/tmp/nvim/lazy'
local plugin_folder = function()
  local host = os.getenv('HOST_NAME')
  if host and (host:find('Ray') or host:find('ray')) then
    return [[~/github/ray-x]] -- vim.fn.expand("$HOME") .. '/github/'
  else
    return ''
  end
end

local lazypath = package_root .. '/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    'git',
    'clone',
    '--filter=blob:none',
    'https://github.com/folke/lazy.nvim.git',
    '--branch=stable', -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)
local function load_plugins()
  return {
    {
      'nvim-treesitter/nvim-treesitter',
      config = function()
        require('nvim-treesitter.configs').setup({
          ensure_installed = { 'go' },
          highlight = { enable = true },
        })
      end,
      build = ':TSUpdate',
    },
    {
      'nvim-treesitter/nvim-treesitter-context',
      config = function()
        require('treesitter-context').setup({
          enable = true, -- Enable this plugin (Can be enabled/disabled later via commands)
          max_lines = 3, -- How many lines the window should span. Values <= 0 mean no limit.
          trim_scope = 'outer', -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer'
          min_window_height = 0, -- Minimum editor window height to enable context. Values <= 0 mean no limit.
          patterns = { -- Match patterns for TS nodes. These get wrapped to match at word boundaries.
            -- For all filetypes
            -- Note that setting an entry here replaces all other patterns for this entry.
            -- By setting the 'default' entry below, you can control which nodes you want to
            -- appear in the context window.
            default = {
              'class',
              'function',
              'method',
              'for',
              'while',
              'if',
              'switch',
              'case',
            },
            -- Patterns for specific filetypes
            -- If a pattern is missing, *open a PR* so everyone can benefit.
            tex = {
              'chapter',
              'section',
              'subsection',
              'subsubsection',
            },
            rust = {
              'impl_item',
              'struct',
              'enum',
            },
            scala = {
              'object_definition',
            },
            vhdl = {
              'process_statement',
              'architecture_body',
              'entity_declaration',
            },
            markdown = {
              'section',
            },
            elixir = {
              'anonymous_function',
              'arguments',
              'block',
              'do_block',
              'list',
              'map',
              'tuple',
              'quoted_content',
            },
            json = {
              'pair',
            },
            yaml = {
              'block_mapping_pair',
            },
          },
          exact_patterns = {
            -- Example for a specific filetype with Lua patterns
            -- Treat patterns.rust as a Lua pattern (i.e "^impl_item$" will
            -- exactly match "impl_item" only)
            -- rust = true,
          },

          -- [!] The options below are exposed but shouldn't require your attention,
          --     you can safely ignore them.

          zindex = 20, -- The Z-index of the context window
          mode = 'cursor', -- Line used to calculate context. Choices: 'cursor', 'topline'
          -- Separator between context and content. Should be a single character string, like '-'.
          -- When separator is set, the context will only show up when there are at least 2 lines above cursorline.
          separator = nil,
        })
      end,
    },
    { 'neovim/nvim-lspconfig' },
    {
      'ray-x/navigator.lua',
      dev = (plugin_folder() ~= ''),
      -- '~/github/ray-x/navigator.lua',
      dependencies = { 'ray-x/guihua.lua', build = 'cd lua/fzy && make' },
      config = function()
        require('navigator').setup({
          debug = false, -- log output, set to true and log path: ~/.cache/nvim/gh.log
          width = 0.75, -- max width ratio (number of cols for the floating window) / (window width)
          height = 0.3, -- max list window height, 0.3 by default
          preview_height = 0.35, -- max height of preview windows
          border = { '', '', '', '', '', '', '', '' }, -- border style, can be one of 'none', 'single', 'double',
          -- 'shadow', or a list of chars which defines the border
          on_attach = function(client, bufnr)
            -- your hook
          end,
          -- put a on_attach of your own here, e.g
          -- function(client, bufnr)
          --   -- the on_attach will be called at end of navigator on_attach
          -- end,
          -- The attach code will apply to all LSP clients

          ts_fold = false, -- modified version of treesitter folding
          default_mapping = true, -- set to false if you will remap every key or if you using old version of nvim-
          keymaps = { { key = 'gK', func = vim.lsp.declaration, desc = 'declaration' } }, -- a list of key maps
          -- this kepmap gK will override "gD" mapping function declaration()  in default kepmap
          -- please check mapping.lua for all keymaps
          --[[ treesitter_analysis = true, -- treesitter variable context ]]
          --[[ treesitter_navigation = true, -- bool|table false: use lsp to navigate between symbol ']r/[r', table: a list of ]]
          --lang using TS navigation
          --[[ treesitter_analysis_max_num = 100, -- how many items to run treesitter analysis ]]
          --[[ treesitter_analysis_condense = true, -- condense form for treesitter analysis ]]
          -- this value prevent slow in large projects, e.g. found 100000 reference in a project
          transparency = 50, -- 0 ~ 100 blur the main window, 100: fully transparent, 0: opaque,  set to nil or 100 to disable it

          lsp_signature_help = true, -- if you would like to hook ray-x/lsp_signature plugin in navigator
          -- setup here. if it is nil, navigator will not init signature help
          signature_help_cfg = nil, -- if you would like to init ray-x/lsp_signature plugin in navigator, and pass in your own config to signature help
          icons = {
            -- Code action
            code_action_icon = '🏏', -- note: need terminal support, for those not support unicode, might crash
            -- Diagnostics
            diagnostic_head = '🐛',
            diagnostic_head_severity_1 = '🈲',
            -- refer to lua/navigator.lua for more icons setups
          },
          lsp = {
            enable = true, -- skip lsp setup, and only use treesitter in navigator.
            -- Use this if you are not using LSP servers, and only want to enable treesitter support.
            -- If you only want to prevent navigator from touching your LSP server configs,
            -- use `disable_lsp = "all"` instead.
            -- If disabled, make sure add require('navigator.lspclient.mapping').setup({bufnr=bufnr, client=client}) in your
            -- own on_attach
            code_action = { enable = true, sign = true, sign_priority = 40, virtual_text = true },
            code_lens_action = {
              enable = true,
              sign = true,
              sign_priority = 40,
              virtual_text = true,
            },
            document_highlight = true, -- LSP reference highlight,
            -- it might already supported by you setup, e.g. LunarVim
            format_on_save = false, -- {true|false} set to false to disasble lsp code format on save (if you are using prettier/efm/formater etc)
            -- table: {enable = {'lua', 'go'}, disable = {'javascript', 'typescript'}} to enable/disable specific language
            -- enable: a whitelist of language that will be formatted on save
            -- disable: a blacklist of language that will not be formatted on save
            -- function: function(bufnr) return true end to enable/disable lsp format on save
            disable_lsp = { 'all' },
            format_options = { async = true }, -- async: disable by default, the option used in vim.lsp.buf.format({async={true|false}, name = 'xxx'})
            --[[ disable_format_cap = { "sqls", "sumneko_lua", "gopls" }, -- a list of lsp disable format capacity (e.g. if you using efm or vim-codeformat etc), empty {} by default ]]
            -- If you using null-ls and want null-ls format your code
            -- you should disable all other lsp and allow only null-ls.
            -- disable_lsp = {'pylsd', 'sqlls'},  -- prevents navigator from setting up this list of servers.
            -- if you use your own LSP setup, and don't want navigator to setup
            -- any LSP server for you, use `disable_lsp = "all"`.
            -- you may need to add this to your own on_attach hook:
            -- require('navigator.lspclient.mapping').setup({bufnr=bufnr, client=client})
            -- for e.g. denols and tsserver you may want to enable one lsp server at a time.
            -- default value: {}
            diagnostic = {
              underline = true,
              virtual_text = true, -- show virtual for diagnostic message
              update_in_insert = false, -- update diagnostic message in insert mode
            },

            diagnostic_scrollbar_sign = { '', '', '' }, -- experimental:  diagnostic status in scroll bar area; set to false to disable the diagnostic sign,
            --                for other style, set to {'╍', 'ﮆ'} or {'-', '='}
            diagnostic_virtual_text = true, -- show virtual for diagnostic message
            diagnostic_update_in_insert = false, -- update diagnostic message in insert mode
            disply_diagnostic_qf = false, -- always show quickfix if there are diagnostic errors, set to false if you want to ignore it
            tsserver = {
              filetypes = { 'typescript' }, -- disable javascript etc,
              -- set to {} to disable the lspclient for all filetypes
            },
            ctags = {
              cmd = 'ctags',
              tagfile = 'tags',
              options = '-R --exclude=.git --exclude=node_modules --exclude=test --exclude=vendor --excmd=number',
            },
          },
        })
      end,
    },
    {
      'simrat39/rust-tools.nvim',
      config = function()
        require('rust-tools').setup({
          server = {
            on_attach = function(client, bufnr)
              require('navigator.lspclient.mapping').setup({ client = client, bufnr = bufnr }) -- setup navigator keymaps here,
              -- otherwise, you can define your own commands to call navigator functions
            end,
          },
        })
      end,
    },
    { 'ray-x/lsp_signature.nvim', dev = (plugin_folder() ~= '') },
    {
      'ray-x/go.nvim',
      dev = (plugin_folder() ~= ''),
      -- dev = true,
      ft = 'go',
      dependencies = {
        'mfussenegger/nvim-dap', -- Debug Adapter Protocol
        'rcarriga/nvim-dap-ui',
        'theHamsta/nvim-dap-virtual-text',
        'ray-x/guihua.lua',
      },
      config = function()
        require('go').setup({
          verbose = true,
          lsp_cfg = {
            handlers = {
              ['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'double' }),
              ['textDocument/signatureHelp'] = vim.lsp.with(
                vim.lsp.handlers.signature_help,
                { border = 'round' }
              ),
            },
          }, -- false: do nothing
        })
      end,
    },
  }
end

local opts = {
  root = package_root, -- directory where plugins will be installed
  default = { lazy = true },
  dev = {
    -- directory where you store your local plugin projects
    path = plugin_folder(),
  },
}

require('lazy').setup(load_plugins(), opts)

vim.cmd('colorscheme murphy')

@liketoeatcheese
Copy link
Author

I tried to make it minimal but I can't replicate it either. I have quite a bit of plugins so I think navigator is overlapping with one of them, I just don't know which one. I'll try again some other times and let you know. Thanks Ray

@ray-x
Copy link
Owner
ray-x commented Mar 22, 2023

I got a list of 180+ plugins
https://github.com/ray-x/nvim
Just keep me posted. Thanks!

@ray-x ray-x added the question Further information is requested label Mar 22, 2023
@liketoeatcheese
Copy link
Author

Hi Ray, scratching my head here. I'm trying to replicate this in a minimal file but still can't reproduce it.

Here's all my plugins:

return packer.startup(function(use)
  -- Packer can manage itself
  use("wbthomason/packer.nvim")

  -- Color themes
  use("ray-x/aurora")
  use({ "bluz71/vim-nightfly-colors" })

  use("nvim-lua/plenary.nvim")
  use("nvim-tree/nvim-web-devicons")
  use({
    "nvim-treesitter/nvim-treesitter",
    run = ":TSUpdate",
  })
  use("nvim-treesitter/nvim-treesitter-context")

  -- Cmp
  use({ "hrsh7th/nvim-cmp", commit = "b0dff0ec4f2748626aae13f011d1a47071fe9abc" })        -- The completion plugin
  use({ "hrsh7th/cmp-buffer", commit = "3022dbc9166796b644a841a02de8dd1cc1d311fa" })      -- buffer completions
  use({ "hrsh7th/cmp-path", commit = "447c87cdd6e6d6a1d2488b1d43108bfa217f56e1" })        -- path completions
  use({ "saadparwaiz1/cmp_luasnip", commit = "a9de941bcbda508d0a45d28ae366bb3f08db2e36" }) -- snippet completions
  use({ "hrsh7th/cmp-nvim-lsp", commit = "3cf38d9c957e95c397b66f91967758b31be4abe6" })
  use({ "hrsh7th/cmp-nvim-lua", commit = "d276254e7198ab7d00f117e88e223b4bd8c02d21" })
  use({ "tzachar/cmp-tabnine", run = "./install.sh", requires = "hrsh7th/nvim-cmp" })

  -- Snippets
  use({ "L3MON4D3/LuaSnip", commit = "8f8d493e7836f2697df878ef9c128337cbf2bb84" })            --snippet engine
  use({ "rafamadriz/friendly-snippets", commit = "2be79d8a9b03d4175ba6b3d14b082680de1b31b1" }) -- a bunch of snippets to use

  -- LSP
  use({ "neovim/nvim-lspconfig" })                                                               -- enable LSP
  use({ "williamboman/mason.nvim" })                                                             -- simple to use language server installer
  use({ "williamboman/mason-lspconfig.nvim" })
  use({ "jose-elias-alvarez/null-ls.nvim", commit = "c0c19f32b614b3921e17886c541c13a72748d450" }) -- for formatters and linters
  use({ "RRethy/vim-illuminate", commit = "a2e8476af3f3e993bb0d6477438aad3096512e42" })

  -- Autopairs
  use({
    "windwp/nvim-autopairs",
    config = function()
      require("nvim-autopairs").setup({})
    end,
  })

  -- Comments
  use({
    "numToStr/Comment.nvim",
    config = function()
      require("Comment").setup()
    end,
  })
  use("JoosepAlviste/nvim-ts-context-commentstring")

  -- Sidebar menu
  use({
    "nvim-tree/nvim-tree.lua",
    requires = {
      "nvim-tree/nvim-web-devicons", -- optional, for file icons
    },
    tag = "nightly",              -- optional, updated every week. (see issue #1193)
  })
  -- using buffers
  use({ "akinsho/bufferline.nvim", tag = "v3.*", requires = "nvim-tree/nvim-web-devicons" })
  use("noib3/nvim-cokeline")

  -- Shortcut keys
  use({
    "folke/which-key.nvim",
    config = function()
      require("which-key").setup({
        -- your configuration comes here
        -- or leave it empty to use the default settings
        -- refer to the configuration section below
      })
    end,
  })
  use("moll/vim-bbye")

  -- Trouble shooting
  use({
    "folke/trouble.nvim",
    requires = "kyazdani42/nvim-web-devicons",
    config = function()
      require("trouble").setup({
        -- your configuration comes here
        -- or leave it empty to use the default settings
        -- refer to the configuration section below
      })
    end,
  })

  -- Lsp
  use("mfussenegger/nvim-dap")
  use("simrat39/rust-tools.nvim")
  use("mfussenegger/nvim-jdtls")
  use({ "tamton-aquib/zone.nvim" })
  use("feline-nvim/feline.nvim")
  use({
    "ray-x/navigator.lua",
    requires = {
      { "ray-x/guihua.lua",     run = "cd lua/fzy && make" },
      { "neovim/nvim-lspconfig" },
    },
  })

  -- init.lua
  use("lukas-reineke/indent-blankline.nvim")

  -- Seach engine
  use({ "junegunn/fzf", run = "./install --bin" })
  use({
    "ibhagwan/fzf-lua",
    -- optional for icon support
    requires = { "nvim-tree/nvim-web-devicons" },
  })

  -- Format markdown
  use({ "junegunn/goyo.vim", ft = "markdown" })

  -- Autoclosing tag
  use("AndrewRadev/tagalong.vim")
  use("tpope/vim-surround")

  -- Harpoon
  use("ThePrimeagen/harpoon")

  -- ChatGPT
  -- Packer
  use({
    "jackMort/ChatGPT.nvim",
    config = function()
      require("chatgpt").setup({
        keymaps = {
          submit = "<C-s>"
        }
      })
    end,
    requires = {
      "MunifTanjim/nui.nvim",
      "nvim-lua/plenary.nvim",
      "nvim-telescope/telescope.nvim",
    },
  })

  -- Color comments:
  -- NOTE:: Some notes
  -- TODO: To do here
  -- WARNING: Some warning sign
  -- BUG: Need fixings
  -- TEST: Testing
  use({
    "folke/todo-comments.nvim",
    requires = "nvim-lua/plenary.nvim",
    config = function()
      require("todo-comments").setup({
        keywords = {
          FIX = {
            icon = " ",                        -- icon used for the sign, and in search results
            color = "error",                      -- can be a hex color, or a named color (see below)
            alt = { "FIXME", "BUG", "FIXIT", "ISSUE" }, -- a set of other keywords that all map to this FIX keywords
            -- signs = false, -- configure signs for some keywords individually
          },
          TODO = { icon = " ", color = "info" },
          HACK = { icon = " ", color = "warning" },
          WARN = { icon = " ", color = "#ea9741", alt = { "WARNING", "XXX" } },
          NOTE = { icon = " ", color = "#6aa84f", alt = { "INFO" } },
          TEST = { icon = "⏲ ", color = "test", alt = { "TESTING", "PASSED", "FAILED" } },
        },
      })
    end,
  })
  use({
    "windwp/nvim-ts-autotag",
  })
  use("xiyaowong/link-visitor.nvim")
  use("jremmen/vim-ripgrep")
end)

I tried to split a big portion of them which I think may caused the issue to a minimal file:

vim.cmd([[set runtimepath=$VIMRUNTIME]])
vim.cmd([[set packpath=/tmp/nvt-min/site]])
local package_root = "/tmp/nvt-min/site/pack"
local install_path = package_root .. "/packer/start/packer.nvim"
local function load_plugins()
  require("packer").startup({
    {
      "wbthomason/packer.nvim",
      "nvim-lua/plenary.nvim",
        { "bluz71/vim-nightfly-colors" },
      {
        "nvim-treesitter/nvim-treesitter",
        run = ":TSUpdate",
      },
      "nvim-treesitter/nvim-treesitter-context",
      "nvim-tree/nvim-web-devicons",
      -- Lsp
      "mfussenegger/nvim-dap",
      "simrat39/rust-tools.nvim",
      "mfussenegger/nvim-jdtls",
      { "tamton-aquib/zone.nvim" },
      "feline-nvim/feline.nvim",
      { "neovim/nvim-lspconfig" },                                                             -- enable LSP
      { "williamboman/mason.nvim" },                                                           -- simple to use language server installer
      { "williamboman/mason-lspconfig.nvim" },
      { "jose-elias-alvarez/null-ls.nvim",  commit = "c0c19f32b614b3921e17886c541c13a72748d450" }, -- for formatters and linters
      { "RRethy/vim-illuminate",            commit = "a2e8476af3f3e993bb0d6477438aad3096512e42" },

      -- Cmp
      { "hrsh7th/nvim-cmp",                 commit = "b0dff0ec4f2748626aae13f011d1a47071fe9abc" }, -- The completion plugin
      { "hrsh7th/cmp-buffer",               commit = "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, -- buffer completions
      { "hrsh7th/cmp-nvim-lsp",             commit = "3cf38d9c957e95c397b66f91967758b31be4abe6" },
      { "hrsh7th/cmp-nvim-lua",             commit = "d276254e7198ab7d00f117e88e223b4bd8c02d21" },
      {
        "tzachar/cmp-tabnine",
        run = "./install.sh",
        requires = "hrsh7th/nvim-cmp",
      },

      -- Snippet
      -- Snippets
      { "L3MON4D3/LuaSnip",             commit = "8f8d493e7836f2697df878ef9c128337cbf2bb84" }, --snippet engine
      { "rafamadriz/friendly-snippets", commit = "2be79d8a9b03d4175ba6b3d14b082680de1b31b1" }, -- a bunch of snippets to use

      {
        "ray-x/navigator.lua",
        requires = {
          { "ray-x/guihua.lua",     run = "cd lua/fzy && make" },
          { "neovim/nvim-lspconfig" },
        },
      },

      --[[ "nvim-treesitter/nvim-treesitter-context", ]]
      -- ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
    },
    config = {
      package_root = package_root,
      compile_path = install_path .. "/plugin/packer_compiled.lua",
      display = { non_interactive = true },
    },
  })
end
if vim.fn.isdirectory(install_path) == 0 then
  print("Installing dependencies.")
  vim.fn.system({ "git", "clone", "--depth=1", "https://github.com/wbthomason/packer.nvim", install_path })
end
load_plugins()
require("packer").sync()
vim.cmd([[autocmd User PackerComplete ++once echo "Ready!" | lua setup()]])
vim.opt.nu = true
vim.opt.rnu = true
vim.opt.timeoutlen = 500
vim.opt.tabstop = 2
vim.opt.softtabstop = 2
vim.opt.shiftwidth = 2
vim.opt.expandtab = true
vim.opt.hlsearch = false
vim.opt.incsearch = true
vim.opt.smartindent = true
vim.opt.clipboard = "unnamed"
vim.opt.cmdheight = 2
vim.opt.fileencoding = "utf-8"
vim.opt.hlsearch = true
vim.opt.ignorecase = true
vim.opt.smartcase = true
vim.opt.smartindent = true
vim.opt.splitbelow = true
vim.opt.splitright = true
vim.opt.showtabline = 2
vim.opt.swapfile = false
vim.opt.undofile = true
vim.opt.writebackup = false
vim.opt.updatetime = 300
vim.opt.cursorline = true
vim.opt.signcolumn = "yes"
vim.opt.scrolloff = 8
vim.opt.conceallevel = 0
vim.opt.sidescrolloff = 8
vim.opt.completeopt = { "menuone", "noselect" }
vim.opt.wrap = false
vim.opt.shortmess:append("c")
vim.opt.list = false
vim.cmd([[set iskeyword+=- ]])

-- disable netrw at the very start of your init.lua (strongly advised)
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1

vim.g.mapleader = " "

-- set termguicolors to enable highlight groups
vim.opt.termguicolors = true

if vim.fn.has("wsl") == 1 then
  vim.api.nvim_create_autocmd("TextYankPost", {
    group = vim.api.nvim_create_augroup("Yank", { clear = true }),
    callback = function()
      vim.fn.system("clip.exe", vim.fn.getreg('"'))
    end,
  })
end

vim.g.tagalong_filetypes = {
  "html",
  "js",
  "eco",
  "eelixir",
  "ejs",
  "eruby",
  "htmldjango",
  "javascriptreact",
  "jsx",
  "php",
  "typescriptreact",
  "xml",
}

-- nightfly color scheme settings
local custom_highlight = vim.api.nvim_create_augroup("CustomHighlight", {})
vim.api.nvim_create_autocmd("ColorScheme", {
  pattern = "nightfly",
  callback = function()
    vim.api.nvim_set_hl(0, "DiagnosticVirtualTextError", { fg = "#da5151", bold = true })
    vim.api.nvim_set_hl(0, "DiagnosticVirtualTextWarn", { fg = "#ecb91f", bold = true })
    vim.api.nvim_set_hl(0, "DiagnosticVirtualTextInfo", { fg = "#2196ef", bold = true })
    vim.api.nvim_set_hl(0, "DiagnosticVirtualTextHint", { fg = "#4f97d9", bold = true })
    vim.api.nvim_set_hl(0, "incsearch", { fg = "#efa65a", bold = true })
  end,
  group = custom_highlight,
})

vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
  underline = true,
  virtual_text = {
    spacing = 5,
    severity_limit = "Warning",
  },
  update_in_insert = true,
})

local opts = { noremap = true, silent = true }

local term_opts = { silent = true }

-- Shorten function name
local keymap = vim.api.nvim_set_keymap

--Remap space as leader key
keymap("", "<Space>", "<Nop>", opts)
vim.g.mapleader = " "
vim.g.maplocalleader = " "

vim.opt.termguicolors = true

-- Toggle nvimtree
keymap("n", "<c-n>", ":NvimTreeToggle<cr><s-h>", opts)

-- Save file
keymap("n", "<c-s>", ":w<cr>", opts)

-- MODIFY NVIM-TREE SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
_G.setup = function()
  local cmp_status_ok, cmp = pcall(require, "cmp")
  if not cmp_status_ok then
    return
  end

  local snip_status_ok, luasnip = pcall(require, "luasnip")
  if not snip_status_ok then
    return
  end

  --[[ local cmp_autopair_status_ok, cmp_autopairs = pcall('nvim-autopairs.completion.cmp') ]]
  --[[ if not cmp_autopair_status_ok then ]]
  --[[   return ]]
  require("luasnip/loaders/from_vscode").lazy_load()

  local check_backspace = function()
    local col = vim.fn.col(".") - 1
    return col == 0 or vim.fn.getline("."):sub(col, col):match("%s")
  end

  --   פּ ﯟ   some other good icons
  local kind_icons = {
    Text = "",
    Method = "m",
    Function = "",
    Constructor = "",
    Field = "",
    Variable = "",
    Class = "",
    Interface = "",
    Module = "",
    Property = "",
    Unit = "",
    Value = "",
    Enum = "",
    Keyword = "",
    Snippet = "",
    Color = "",
    File = "",
    Reference = "",
    Folder = "",
    EnumMember = "",
    Constant = "",
    Struct = "",
    Event = "",
    Operator = "",
    TypeParameter = "",
  }
  -- find more here: https://www.nerdfonts.com/cheat-sheet

  --[[ -- If you want insert `(` after select function or method item ]]
  --[[ cmp.event:on( ]]
  --[[   'confirm_done', ]]
  --[[   cmp_autopairs.on_confirm_done() ]]
  --[[ ) ]]
  cmp.setup({
    snippet = {
      expand = function(args)
        luasnip.lsp_expand(args.body) -- For `luasnip` users.
      end,
    },
    mapping = {
      ["<C-k>"] = cmp.mapping.select_prev_item(),
      ["<C-j>"] = cmp.mapping.select_next_item(),
      ["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }),
      ["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }),
      ["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
      ["<C-y>"] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
      ["<C-e>"] = cmp.mapping({
        i = cmp.mapping.abort(),
        c = cmp.mapping.close(),
      }),
      -- Accept currently selected item. If none selected, `select` first item.
      -- Set `select` to `false` to only confirm explicitly selected items.
      ["<CR>"] = cmp.mapping.confirm({ select = true }),
      ["<Tab>"] = cmp.mapping(function(fallback)
        if cmp.visible() then
          cmp.select_next_item()
        elseif luasnip.expandable() then
          luasnip.expand()
          --[[ elseif luasnip.expand_or_jumpable() then ]]
          --[[   luasnip.expand_or_jump() ]]
        elseif check_backspace() then
          fallback()
        else
          fallback()
        end
      end, {
        "i",
        "s",
      }),
      ["<S-Tab>"] = cmp.mapping(function(fallback)
        if cmp.visible() then
          cmp.select_prev_item()
          --[[ elseif luasnip.jumpable(-1) then ]]
          --[[   luasnip.jump(-1) ]]
        else
          fallback()
        end
      end, {
        "i",
        "s",
      }),
    },
    formatting = {
      fields = { "kind", "abbr", "menu" },
      format = function(entry, vim_item)
        -- Kind icons
        vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
        -- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind
        vim_item.menu = ({
          cmp_tabnine = "[TabNine]",
          nvim_lsp = "[LSP]",
          luasnip = "[Snippet]",
          buffer = "[Buffer]",
          path = "[Path]",
        })[entry.source.name]
        return vim_item
      end,
    },
    sources = {
      { name = "cmp_tabnine" },
      { name = "nvim_lsp" },
      { name = "luasnip" },
      { name = "buffer" },
      { name = "path" },
    },
    confirm_opts = {
      behavior = cmp.ConfirmBehavior.Replace,
      select = false,
    },
    window = {
      documentation = cmp.config.window.bordered(),
    },
    experimental = {
      ghost_text = false,
      native_menu = false,
    },
  })

  local tabnine = require("cmp_tabnine.config")

  tabnine.setup({
    max_lines = 1000,
    max_num_results = 20,
    sort = true,
    run_on_every_keystroke = true,
    snippet_placeholder = "..",
    ignored_file_types = {
      -- default is not to ignore
      -- uncomment to ignore in lua:
      -- lua = true
    },
    show_prediction_strength = false,
  })

  local settings = {
    ui = {
      border = "none",
      icons = {
        package_installed = "◍",
        package_pending = "◍",
        package_uninstalled = "◍",
      },
    },
    log_level = vim.log.levels.INFO,
    max_concurrent_installers = 4,
  }

  require("mason").setup(settings)

  local M = {}

  local status_cmp_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
  if not status_cmp_ok then
    return
  end

  M.capabilities = vim.lsp.protocol.make_client_capabilities()
  M.capabilities.textDocument.completion.completionItem.snippetSupport = true
  M.capabilities = cmp_nvim_lsp.default_capabilities(M.capabilities)

  M.setup = function()
    local signs = {

      { name = "DiagnosticSignError", text = "" },
      { name = "DiagnosticSignWarn",  text = "" },
      { name = "DiagnosticSignHint",  text = "" },
      { name = "DiagnosticSignInfo",  text = "" },
    }

    for _, sign in ipairs(signs) do
      vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" })
    end

    local config = {
      virtual_text = true, -- disable virtual text
      signs = {
        active = signs, -- show signs
      },
      update_in_insert = false,
      underline = true,
      severity_sort = true,
      float = {
        focusable = true,
        style = "minimal",
        border = "rounded",
        source = "always",
        header = "",
        prefix = "",
      },
    }

    vim.diagnostic.config(config)

    vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
      border = "rounded",
    })

    vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
      border = "rounded",
    })
  end

  local function lsp_keymaps(bufnr)
    local opts = { noremap = true, silent = true }
    local keymap = vim.api.nvim_buf_set_keymap
    keymap(bufnr, "n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts)
    keymap(bufnr, "n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
    keymap(bufnr, "n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
    keymap(bufnr, "n", "gI", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
    keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
    keymap(bufnr, "n", "gl", "<cmd>lua vim.diagnostic.open_float()<CR>", opts)
    keymap(bufnr, "n", "<leader>lf", "<cmd>lua vim.lsp.buf.format{ async = true }<cr>", opts)
    keymap(bufnr, "n", "<leader>li", "<cmd>LspInfo<cr>", opts)
    keymap(bufnr, "n", "<leader>lI", "<cmd>LspInstallInfo<cr>", opts)
    keymap(bufnr, "n", "<leader>la", "<cmd>lua vim.lsp.buf.code_action()<cr>", opts)
    keymap(bufnr, "n", "<leader>lj", "<cmd>lua vim.diagnostic.goto_next({buffer=0})<cr>", opts)
    keymap(bufnr, "n", "<leader>lk", "<cmd>lua vim.diagnostic.goto_prev({buffer=0})<cr>", opts)
    keymap(bufnr, "n", "<leader>lr", "<cmd>lua vim.lsp.buf.rename()<cr>", opts)
    keymap(bufnr, "n", "<leader>ls", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
    keymap(bufnr, "n", "<leader>lq", "<cmd>lua vim.diagnostic.setloclist()<CR>", opts)
  end

  M.on_attach = function(client, bufnr)
    if client.name == "tsserver" then
      client.server_capabilities.documentFormattingProvider = false
    end

    if client.name == "sumneko_lua" then
      client.server_capabilities.documentFormattingProvider = false
    end

    if client.name == "jdt.ls" then
      if JAVA_DAP_ACTIVE then
        require("jdtls").setup_dap({ hotcodereplace = "auto" })
        require("jdtlsdap").setup_dap_main_class_configs()
      end
      client.resolver_capabilities.documentFormattingProvider = false
      client.resolver_capabilities.textDocument.completion.completionItem.snippetSupport = false
    end

    lsp_keymaps(bufnr)
    local status_ok, illuminate = pcall(require, "illuminate")
    if not status_ok then
      return
    end
    illuminate.on_attach(client)
  end

  local servers = {
    --[[ "sumneko_lua", ]]
    "lua_ls",
    -- "cssls",
    -- "html",
    -- "tsserver",
    "pyright",
    -- "bashls",
    "jsonls",
    -- "golang",
    "gopls",
    -- "golang"
    "jdtls",
    -- "Bash"
    "bashls",
    -- "JavaScript"
    "quick_lint_js",
    -- "VIM"
    "vimls",
    -- "YAML"
    --[[ "yamlls", ]]
    --TypeScript
    "tsserver",
    --latex
    "ltex",
    -- Rust
    "rust_analyzer",
  }

  require("mason-lspconfig").setup({
    ensure_installed = servers,
    automatic_installation = true,
  })

  local lspconfig_status_ok, lspconfig = pcall(require, "lspconfig")
  if not lspconfig_status_ok then
    return
  end

  --[[ require'lspconfig'.java_language_server.setup{} ]]
  local opts = {}

  for _, server in pairs(servers) do
    opts = {
      on_attach = M.on_attach,
      capabilities = M.capabilities,
    }

    server = vim.split(server, "@")[1]

    lspconfig[server].setup(opts)
  end

  require("lspconfig").lua_ls.setup({
    settings = {
      Lua = {
        diagnostics = {
          globals = { "vim" },
        }, -- By default, lua-language-server sends anonymized data to its developers. Stop it using the following.
        telemetry = {
          enable = false,
        },
      },
    },
  })

  require("lspconfig").rust_analyzer.setup({
    settings = {
      ["rust-analyzer"] = {
        checkOnSave = {
          extraArgs = { "--target-dir", "/tmp/rust-analyzer-check" },
        },
      },
    },
  })

  require("lspconfig").ltex.setup({
    settings = {
      filetype = { "markdown" },
    },
  })

  require("lspconfig").yamlls.setup({
    on_attach = M.on_attach,
    capabilities = M.capabilities,
    settings = {
      yaml = {
        --[[ format = { ]]
        --[[   enable = true ]]
        --[[ }, ]]
        schemas = {
          --[[ ["https://raw.githubusercontent.com/quantumblacklabs/kedro/develop/static/jsonschema/kedro-catalog-0.17.json"] = "conf/**/*catalog*", ]]
          --[[ ["https://json.schemastore.org/github-workflow.json"] = "/.github/workflows/*", ]]
          kubernetes = "/*.yaml",
        },
      },
    },
  })
  local null_ls_status_ok, null_ls = pcall(require, "null-ls")
  if not null_ls_status_ok then
    return
  end

  -- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/formatting
  local formatting = null_ls.builtins.formatting
  -- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics
  local diagnostics = null_ls.builtins.diagnostics

  null_ls.setup({
    debug = false,
    sources = {
      formatting.prettier.with({ extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" } }),
      formatting.black.with({ extra_args = { "--fast" } }),
      formatting.stylua,
      formatting.google_java_format,
      diagnostics.flake8,
    },
  })

  local navigator_status_ok, navigator = pcall(require, "navigator")
  if not navigator_status_ok then
    print("can't not pull navigator plugin")
    return
  end

  navigator.setup({
    debug = false,                                     -- log output, set to true and log path: ~/.cache/nvim/gh.log
    width = 0.75,                                      -- max width ratio (number of cols for the floating window) / (window width)
    height = 0.3,                                      -- max list window height, 0.3 by default
    preview_height = 0.35,                             -- max height of preview windows
    border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, -- border style, can be one of 'none', 'single', 'double',
    -- 'shadow', or a list of chars which defines the border
    on_attach = function(client, bufnr)
      -- your hook
    end,
    -- put a on_attach of your own here, e.g
    -- function(client, bufnr)
    --   -- the on_attach will be called at end of navigator on_attach
    -- end,
    -- The attach code will apply to all LSP clients

    ts_fold = false,                                                              -- modified version of treesitter folding
    default_mapping = true,                                                       -- set to false if you will remap every key or if you using old version of nvim-
    keymaps = { { key = "gK", func = vim.lsp.declaration, desc = "declaration" } }, -- a list of key maps
    -- this kepmap gK will override "gD" mapping function declaration()  in default kepmap
    -- please check mapping.lua for all keymaps
    --[[ treesitter_analysis = true, -- treesitter variable context ]]
    --[[ treesitter_navigation = true, -- bool|table false: use lsp to navigate between symbol ']r/[r', table: a list of ]]
    --lang using TS navigation
    --[[ treesitter_analysis_max_num = 100, -- how many items to run treesitter analysis ]]
    --[[ treesitter_analysis_condense = true, -- condense form for treesitter analysis ]]
    -- this value prevent slow in large projects, e.g. found 100000 reference in a project
    transparency = 50,       -- 0 ~ 100 blur the main window, 100: fully transparent, 0: opaque,  set to nil or 100 to disable it
    lsp_signature_help = true, -- if you would like to hook ray-x/lsp_signature plugin in navigator
    -- setup here. if it is nil, navigator will not init signature help
    signature_help_cfg = nil, -- if you would like to init ray-x/lsp_signature plugin in navigator, and pass in your own config to signature help
    icons = {
      -- Code action
      code_action_icon = "🏏", -- note: need terminal support, for those not support unicode, might crash
      -- Diagnostics
      diagnostic_head = "🐛",
      diagnostic_head_severity_1 = "🈲",
      -- refer to lua/navigator.lua for more icons setups
    },
    mason = true, -- set to true if you would like use the lsp installed by williamboman/mason
    lsp = {
      enable = true, -- skip lsp setup, and only use treesitter in navigator.
      -- Use this if you are not using LSP servers, and only want to enable treesitter support.
      -- If you only want to prevent navigator from touching your LSP server configs,
      -- use `disable_lsp = "all"` instead.
      -- If disabled, make sure add require('navigator.lspclient.mapping').setup({bufnr=bufnr, client=client}) in your
      -- own on_attach
      code_action = { enable = true, sign = true, sign_priority = 40, virtual_text = true },
      code_lens_action = { enable = true, sign = true, sign_priority = 40, virtual_text = true },
      document_highlight = true, -- LSP reference highlight,
      -- it might already supported by you setup, e.g. LunarVim
      format_on_save = false, -- {true|false} set to false to disasble lsp code format on save (if you are using prettier/efm/formater etc)
      -- table: {enable = {'lua', 'go'}, disable = {'javascript', 'typescript'}} to enable/disable specific language
      -- enable: a whitelist of language that will be formatted on save
      -- disable: a blacklist of language that will not be formatted on save
      -- function: function(bufnr) return true end to enable/disable lsp format on save
      disable_lsp = { "all" },
      format_options = { async = true }, -- async: disable by default, the option used in vim.lsp.buf.format({async={true|false}, name = 'xxx'})
      --[[ disable_format_cap = { "sqls", "sumneko_lua", "gopls" }, -- a list of lsp disable format capacity (e.g. if you using efm or vim-codeformat etc), empty {} by default ]]
      -- If you using null-ls and want null-ls format your code
      -- you should disable all other lsp and allow only null-ls.
      -- disable_lsp = {'pylsd', 'sqlls'},  -- prevents navigator from setting up this list of servers.
      -- if you use your own LSP setup, and don't want navigator to setup
      -- any LSP server for you, use `disable_lsp = "all"`.
      -- you may need to add this to your own on_attach hook:
      -- require('navigator.lspclient.mapping').setup({bufnr=bufnr, client=client})
      -- for e.g. denols and tsserver you may want to enable one lsp server at a time.
      -- default value: {}
      diagnostic = {
        underline = true,
        virtual_text = true,                      -- show virtual for diagnostic message
        update_in_insert = false,                 -- update diagnostic message in insert mode
      },
      diagnostic_scrollbar_sign = { "▃", "▆", "█" }, -- experimental:  diagnostic status in scroll bar area; set to false to disable the diagnostic sign,
      --                for other style, set to {'╍', 'ﮆ'} or {'-', '='}
      diagnostic_virtual_text = true,             -- show virtual for diagnostic message
      diagnostic_update_in_insert = false,        -- update diagnostic message in insert mode
      disply_diagnostic_qf = false,               -- always show quickfix if there are diagnostic errors, set to false if you want to ignore it
      tsserver = {
        filetypes = { "typescript" },             -- disable javascript etc,
        -- set to {} to disable the lspclient for all filetypes
      },
      ctags = {
        cmd = "ctags",
        tagfile = "tags",
        options = "-R --exclude=.git --exclude=node_modules --exclude=test --exclude=vendor --excmd=number",
      },
    },
  })

  local treesitter_context_status_ok, treesitter_context = pcall(require, "treesitter-context")
  if not treesitter_context_status_ok then
    print("Can't load treesitter-context")
    return
  end

  treesitter_context.setup({
    enable = true,       -- Enable this plugin (Can be enabled/disabled later via commands)
    max_lines = 0,       -- How many lines the window should span. Values <= 0 mean no limit.
    trim_scope = "outer", -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer'
    min_window_height = 0, -- Minimum editor window height to enable context. Values <= 0 mean no limit.
    patterns = {
      -- Match patterns for TS nodes. These get wrapped to match at word boundaries.
      -- For all filetypes
      -- Note that setting an entry here replaces all other patterns for this entry.
      -- By setting the 'default' entry below, you can control which nodes you want to
      -- appear in the context window.
      default = {
        "class",
        "function",
        "method",
        "for",
        "while",
        "if",
        "switch",
        "case",
      },
      -- Patterns for specific filetypes
      -- If a pattern is missing, *open a PR* so everyone can benefit.
      tex = {
        "chapter",
        "section",
        "subsection",
        "subsubsection",
      },
      rust = {
        "impl_item",
        "struct",
        "enum",
      },
      scala = {
        "object_definition",
      },
      vhdl = {
        "process_statement",
        "architecture_body",
        "entity_declaration",
      },
      markdown = {
        "section",
      },
      elixir = {
        "anonymous_function",
        "arguments",
        "block",
        "do_block",
        "list",
        "map",
        "tuple",
        "quoted_content",
      },
      json = {
        "pair",
      },
      yaml = {
        "block_mapping_pair",
      },
    },
    exact_patterns = {
      -- Example for a specific filetype with Lua patterns
      -- Treat patterns.rust as a Lua pattern (i.e "^impl_item$" will
      -- exactly match "impl_item" only)
      -- rust = true,
    },
    -- [!] The options below are exposed but shouldn't require your attention,
    --     you can safely ignore them.

    zindex = 20,   -- The Z-index of the context window
    mode = "cursor", -- Line used to calculate context. Choices: 'cursor', 'topline'
    -- Separator between context and content. Should be a single character string, like '-'.
    -- When separator is set, the context will only show up when there are at least 2 lines above cursorline.
    separator = nil,
  })

  local status_ok, configs = pcall(require, "nvim-treesitter.configs")

  if not status_ok then
    return
  end

  configs.setup({
    ensure_installed = "all", -- one of "all" or a list of languages
    ignore_install = { "" }, -- List of parsers to ignore installing
    highlight = {
      enable = true,        -- false will disable the whole extension
      disable = { "css" },  -- list of language that will be disabled
    },
    autopairs = {
      enable = true,
    },
    autotag = {
      enable = true,
      filetypes = {
        "html",
        "javascript",
        "typescript",
        "javascriptreact",
        "typescriptreact",
        "svelte",
        "vue",
        "tsx",
        "jsx",
        "rescript",
        "xml",
        "php",
        "markdown",
        "glimmer",
        "handlebars",
        "hbs",
      },
    },
    indent = { enable = true, disable = { "python", "css" } },
  })

  local nvimtree_status_ok, nvimtree = pcall(require, "nvim-tree")
  if not nvimtree_status_ok then
    return
  end

  --[[ nvimtree.setup() ]]
  nvimtree.setup({
    sort_by = "case_sensitive",
    update_focused_file = {
      enable = true,
      update_root = true,
      ignore_list = {},
    },
    view = {
      adaptive_size = true,
      mappings = {
        list = {
          { key = "u", action = "dir_up" },
        },
      },
    },
    renderer = {
      group_empty = true,
      symlink_destination = false,
    },
    filters = {
      dotfiles = false,
    },
  })

  local rt_status_ok, rt = pcall(require, "rust-tools")
  if not rt_status_ok then
    return
  end

  rt.setup({
    tools = {
      -- These apply to the default RustSetInlayHints command
      inlay_hints = {
        -- automatically set inlay hints (type hints)
        -- default: true
        auto = true,
        -- Only show inlay hints for the current line
        only_current_line = false,
        -- whether to show parameter hints with the inlay hints or not
        -- default: true
        show_parameter_hints = true,
        -- prefix for parameter hints
        -- default: "<-"
        parameter_hints_prefix = ": ",
        -- prefix for all the other hints (type, chaining)
        -- default: "=>"
        other_hints_prefix = "=> ",
        -- whether to align to the length of the longest line in the file
        max_len_align = false,
        -- padding from the left if max_len_align is true
        max_len_align_padding = 1,
        -- whether to align to the extreme right or not
        right_align = false,
        -- padding from the right if right_align is true
        right_align_padding = 7,
        -- The color of the hints
        highlight = "Comment",
      },
    },
  })

  rt.inlay_hints.set()
  rt.inlay_hints.enable()

  --[[ require("nvim-tree").setup({}) ]]
end

But still couldn't reproduce it. Is there a way we can share session and debug this together? I miss navigator diagnostic functions :'(

@ray-x
Copy link
Owner
ray-x commented Mar 23, 2023

Do you have your init.lua setup in github/gitlab I can clone and test?

@liketoeatcheese
Copy link
Author

https://github.com/liketoeatcheese/nvimtest

I can finally replicate it. I also make a Docker file so you can replicate it if you have docker installed. I also make a video on how I replicate it here. You can view the error popping up around 3:16.

Steps to reproduce using docker:

  1. Clone repo:
    git clone https://github.com/liketoeatcheese/nvimtest.git
  2. cd to the repo
  3. docker build -t alpine/nvim
  4. docker run -itd alpine/nvim (This will show you the container id)
  5. docker exec -it {container-id} sh
  6. As you are inside the container: nvim ~/.config/nvim/lua/wpham/packer.lua
  7. As you are inside nvim, there will be some errors as things are not installed. Run :so %
  8. :q to quit out of nvim for packer to be installed
  9. nvim ~/.config/nvim/lua/wpham/packer.lua, press enter a few times for the errors to go away
  10. :so %
  11. :PackerSync, I just do this twice to make sure all things are installed correctly as some packages may depend on others
  12. Once all packages are installed, quit out of nvim
  13. nvim practice_progress_bar/src/main.rs which will take you to the simple rust program which I preset up to replicate the error.
  14. :LspInstall rust-analyzer
  15. Once all things are done, just quit out and go back to the file, now everything will be set up. You can to go to the end of the file and navigate around the section where the navigator.lua showed some diagnostic and you will be able to replicate it.

@ray-x
Copy link
Owner
ray-x commented Mar 24, 2023

Thanks for sending the docker setup. It is really helpful.
image

Do I need to put the cursor at a specific place or change the window size so that I can see the duplicate line?
I am using kitty but I assume the terminal does not relate to the issue.

@liketoeatcheese
Copy link
Author
liketoeatcheese commented Mar 24, 2023 via email

@ray-x
Copy link
Owner
ray-x commented Mar 25, 2023

Recorded a 2min's video with the docker.

(you can set the playback speed to 2x) I did not see anything abnormal.
https://user-images.githubusercontent.com/1681295/227667158-ea1efc7c-e440-4bc0-949c-477a31155b61.mp4

Also the packer is lazyloading. Do I need to enable some plugins before the issue showing up?

One thing I noticed is the neovim version is 0.8.1 but the current release is 0.8.3

@liketoeatcheese
Copy link
Author

So to make sure that it's not a terminal issue, I tested on both windows terminal, and allacrity. Both were tested with the local file system and in a docker container.

If you PackerSync everything on packer.lua, and LspInstall rust-analyzer, then that should be it, no need to enable anything else. Once you reenter the file, just press <Enter> key a few times till the messages on installing ls from Mason, and other trivial errors to go away. Then you can press J to go to the end of the file. The error will start appearing near trait ProgressExt: Sized { (line 73), That's where you will see navigator's inlay hint with the glasses like this:
image

In terms of versioning, my local nvim is 0.8.3, and the one in docker is 0.8.1, I built the image using the Dockerfile with apk, assuming alpine's package manager is still a bit behind in nvim versioning. But as it's also showing errors on my local nvim, we can safely say that it's not the version of nvim which caused the issue

@ray-x
Copy link
Owner
ray-x commented Mar 25, 2023

Sure, all required plugins were installed through PackerSync and MasonInstall All
Once plugins are installed, I moved cursor around:
image

Also, I think J mapped to join so I can use G to end of file

I think the issue is about lines being duplicated:
image

@liketoeatcheese
Copy link
Author

Yea that's right, it's not a permanent duplicate, but just a display issue, when I passed my cursor over the duplicated line, the duplication goes up along with my cursor (As shown in the video). That's very odd that you couldn't replicate it, hmmm. I'm not sure if it's because you're pure Linux and I'm using WSL.

@ray-x
Copy link
Owner
ray-x commented Mar 25, 2023

Could you check if enable lazydraw helps? Also you can check redrawtime. I feel it is something related to redraw. If you saw issue happen, does a manual redraw clean it up?
I feel it is something related to redrawing. Also WSL does slow down the nvim/terminal.

@liketoeatcheese
Copy link
Author

What's lazydraw? I haven't seen that option before. I don't see it as an option for vim.opt or vim.g either.
image

image

I tried to do :h lazydraw but nothing came up, any thoughts?
image

@ray-x ray-x added the windows related MS windows label Mar 25, 2023
@ray-x
Copy link
Owner
ray-x commented Mar 25, 2023

Sorry should be lazyredraw
image

@liketoeatcheese
Copy link
Author

As it's a global boolean, I did:
vim.g.lazyredraw = true (also tried with false)
but it didn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested windows related MS windows
Projects
None yet
Development

No branches or pull requests

2 participants