LSP doesn't show warnings until entering insert mode and typing on one machine

This is my config:

local lazypath = vim.fn.stdpath("data") .. "/lazy/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)
require("lazy").setup({
	"luukvbaal/nnn.nvim",
	"andweeb/presence.nvim",
	"nvim-telescope/telescope.nvim",
	"nvim-lua/plenary.nvim",
	"nvim-treesitter/nvim-treesitter",
	{'VonHeikemen/lsp-zero.nvim', branch = 'v3.x'},
	{'neovim/nvim-lspconfig'},
	{'hrsh7th/cmp-nvim-lsp'},
	{'hrsh7th/nvim-cmp'},
	{'L3MON4D3/LuaSnip'},
	"williamboman/mason.nvim",
	"williamboman/mason-lspconfig.nvim",
	"neovim/nvim-lspconfig",
	{
		"folke/todo-comments.nvim",
		dependencies = { "nvim-lua/plenary.nvim" },
		opts = {
			signs = true,
			sign_priority = 50,
			-- your configuration comes here
			-- or leave it empty to use the default settings
			-- refer to the configuration section below
		}
	},
	"numToStr/FTerm.nvim",
	{
	  "folke/tokyonight.nvim",
	  lazy = false,
	  priority = 1000,
	  opts = {},
	},
	"tpope/vim-fugitive",
	'vim-airline/vim-airline',
}, opts)

require("nnn").setup({
})

require("presence").setup({})
local telescope = require("telescope.builtin")

require'nvim-treesitter.configs'.setup {
  ensure_installed = "typescript",     -- one of "all", "language", or a list of languages
  highlight = {
    enable = true,              -- false will disable the whole extension
    disable = { },  -- list of language that will be disabled
  },
}

local lsp_zero = require('lsp-zero')

lsp_zero.on_attach(function(client, bufnr)
  -- see :help lsp-zero-keybindings
  -- to learn the available actions
  lsp_zero.default_keymaps({buffer = bufnr})
end)

require('lspconfig').intelephense.setup({
})

require('mason').setup({})
require('mason-lspconfig').setup({
  -- Replace the language servers listed here
  -- with the ones you want to install
  ensure_installed = {
	  'intelephense',
	  'lua_ls',
	  'vimls',
	  'rust_analyzer',
      'volar',
  },
  handlers = {
    lsp_zero.default_setup,
  },
})

local cmp = require('cmp')

cmp.setup({
  preselect = 'item',
  completion = {
    completeopt = 'menu,menuone,noinsert'
  },
  mapping = cmp.mapping.preset.insert({
      ['<Tab>'] = cmp.mapping.confirm({select = true}),
  })
})


local fterm = require('FTerm')
fterm.setup({})

vim.cmd[[colorscheme tokyonight]]

-- Set relative line numbers
vim.wo.relativenumber = true
vim.wo.number = true

-- Keymappings
vim.g.mapleader = " "
vim.api.nvim_set_keymap('n', '<Leader>fm', ':NnnExplorer<CR>', { noremap = true, silent = true })
vim.keymap.set('n', '<leader>ff', telescope.find_files, {})
vim.keymap.set('n', '<leader>fg', telescope.live_grep, {})
vim.api.nvim_set_keymap('n', '<leader>r', ':luafile ' .. vim.fn.stdpath('config') .. '/init.lua<CR>', { noremap = true, silent = true })

vim.api.nvim_set_keymap('n', '<leader>wj', ':wincmd j<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>Wj', '<C-w>s:wincmd j<CR>', { noremap = true, silent = true })

vim.api.nvim_set_keymap('n', '<leader>wk', ':wincmd k<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>Wk', '<C-w>s', { noremap = true, silent = true })

vim.api.nvim_set_keymap('n', '<leader>wh', ':wincmd h<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>Wh', '<C-w>v', { noremap = true, silent = true })

vim.api.nvim_set_keymap('n', '<leader>wl', ':wincmd l<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>Wl', '<C-w>v:wincmd l<CR>', { noremap = true, silent = true })

vim.keymap.set('n', '<leader>tf', fterm.toggle, {})
vim.keymap.set('t', '<leader>tf', fterm.toggle, {})

vim.cmd [[
set tabstop=4
set shiftwidth=4
set expandtab
]]

on one machine warnings from the lsp show up immediately after opening files in neovim and on another machine the warnings don’t show up until I enter insert mode, type at least one character, and then exit insert mode. I have already verified that the versions are the same for a great many things but here are some:

  • neovim
  • all packages installed with lazy
  • the lua language server (I’m seeing this in a lua file)
  • python3
  • node
  • npm
  • ripgrep
  • fd

I would greatly appreciate any help/insight to what may be going wrong here. I’m really new to neovim so I’m guessing that maybe I’m doing something so incredibly wrong in my config that it’s like undefined behavior or something haha. Thanks for your help!

EDIT: This is not happening in vue files so I guess it is lua_ls specific

No idea what’s causing this, but it looks like in the second case you might have something being deferred to TextChanged events, which is not happening on the first machine.

You can try to find out what’s being called when you exit insert mode by running :verbose autocmd TextChanged

Thanks so much for your reply! This is what I get when running :verbose autocmd TextChanged:

:verbose autocmd TextChanged
--- Autocommands ---
matchparen  TextChanged
    *         call s:Highlight_Matching_Pair()
        Last set from /home/linuxbrew/.linuxbrew/Cellar/neovim/0.9.2/share/nvim/runtime/plugin/matchparen.vim line 25
presence_events  TextChanged
    *         lua package.loaded.presence:handle_text_changed()
        Last set from ~/.local/share/nvim/lazy/presence.nvim/autoload/presence.vim line 7

I don’t see anything relating to lsp but I could be wrong? Thanks again

EDIT: also it’s the same on both machines for what it’s worth

Hmm, that doesn’t look like it’s related indeed.

As you’re using lspconfig, you can use :LspInfo to see the status of the LSP client. And it should also show you the path to a log file. Maybe you can find more info there.

Looks good to me?

 Press q or <Esc> to close this window. Press <Tab> to view server doc.
 
 Language client log: /Users/zaciahsawyer/.local/state/nvim/lsp.log
 Detected filetype:   lua
 
 1 client(s) attached to this buffer: 
 
 Client: lua_ls (id: 1, bufnr: [1])
 	filetypes:       lua
 	autostart:       true
 	root directory:  Running in single file mode.
 	cmd:             /Users/zaciahsawyer/.local/share/nvim/mason/bin/lua-language-server
 
 Configured servers list: vimls, rust_analyzer, volar, intelephense, lua_ls

Only have warnings about volar in the log file so seems not related:

[START][2023-10-10 14:48:00] LSP logging initiated
[WARN][2023-10-10 14:48:00] ...lsp/handlers.lua:137	"The language server volar triggers a registerCapability handler despite dynamicRegistration set to false. Report upstream, this warning is harmless"
[START][2023-10-10 14:48:25] LSP logging initiated
[WARN][2023-10-10 14:48:25] ...lsp/handlers.lua:137	"The language server volar triggers a registerCapability handler despite dynamicRegistration set to false. Report upstream, this warning is harmless"
[START][2023-10-10 14:48:39] LSP logging initiated
[WARN][2023-10-10 14:48:39] ...lsp/handlers.lua:137	"The language server volar triggers a registerCapability handler despite dynamicRegistration set to false. Report upstream, this warning is harmless"

Anything else to check? Thanks again

I’m out of ideas ¯_(ツ)_/¯

Are both of your devices running MacOS?
Maybe try the lspconfig troubleshooting guide.

I am using MacOS on both yes. I will follow that guide thanks

Facing similar issues as well, also only with the lua-language-server. I didn’t have any issues with coc.nvim, which also seems to use the lua-language-server through the coc-lua plugin, so this issue seems to be specific to how Neovim’s built-in diagnostic API outputs warnings and how it is integrated with the lua-language-server.

I’m having the same issue using vim’s lspconfig. Did you ever figure it out?

Not really. It only happens with some languages though. I haven’t found any solutions unfortunately.