Inlay hints, underlines, and signcolumns don't appear in Neovim until scrolling or editing
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
調査の方向性
まず、提供された ~/.config/nvim/init.lua と nvim ~/.config/nvim/init.lua コマンドを使って問題を再現します。LspAttach callback を読み、lua_ls を他の一覧にある LSPs と比較し、関連するタイミングまたは公開エラーがないか service.log を調べます。編集、スクロール、LSP の再起動を行わなくても、inlay hints、下線、signcolumns がすぐに表示されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
How are you using the lua-language-server?
NeoVim
Which OS are you using?
Linux
What is the issue affecting?
Annotations
Expected Behaviour
Inlay hints, underlines, and signcolumns should immediately load. One workaround is to press o, Esc, then u upon startup.
Another workaround is to delay the inline hints, but that doesn't fix the underlines and signcolumns. Remove the and False in my init.lua or use https://github.com/MysticalDevil/inlay-hints.nvim/pull/15. :LspRestart is not a good solution as it causes glitches and errors.
The bug is only with lua_ls. Other LSPs like basedpyright, clangd, and ts_ls do not require workarounds and load immediately or shortly.
Actual Behaviour
Inlay hints are missing before scrolling:
Even after scrolling, the signcolumn and the underlines are missing:
Randomly and rarely, the bug doesn't occur.
Reproduction steps
Use this .config/nvim/init.lua:
-- ~/.config/nvim/init.lua
-- Tested with go1.25.6 and neovim=0.12.0~ubuntu1+git202601110811-d62bbe24cb-793e58f65d-e9f8804254~ubuntu25.10.1
-- If you want to reset Neovim before installing this, run: rm -rf ~/.cache/nvim ~/.local/share/nvim
-- Load lazy.nvim. Press q to dismiss the installer.
-- Also, don't edit a Lua file on the 1st launch or there'll be a treesitter error
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"
-- "go to declaration" isn't supported by your Lua/Go LSP.
-- "go to definition"'s similar and works
vim.keymap.set('n', 'gd', vim.lsp.buf.definition)
require("lazy").setup({
spec = {
-- Fix lazy.nvim-caused treesitter error
-- Tested with tree-sitter --version: tree-sitter 0.26.3
{ "nvim-treesitter/nvim-treesitter", lazy = false, build = ":TSUpdate" },
{
"saghen/blink.cmp",
dependencies = "rafamadriz/friendly-snippets",
version = "1.*",
opts = {
completion = {
ghost_text = { enabled = true }, -- Syntax autocompletion
}
},
},
{
"mason-org/mason-lspconfig.nvim",
opts = {
ensure_installed = {
"basedpyright", -- MysticalDevil/inlay-hints suggests this not pyright
"clangd",
"gopls",
"lua_ls",
-- "stylua" -- Not required when lua_ls is installed
"ts_ls",
},
},
dependencies = {
{ "mason-org/mason.nvim", opts = {} },
"neovim/nvim-lspconfig",
},
-- mason-lspconfig is enough for stylua; no need for mason-tool-installer
},
-- textDocument.inlayHint is missing and doesn't do anything
-- I wanted to use this plugin but need the workaround below
-- {
-- "MysticalDevil/inlay-hints.nvim",
-- event = "LspAttach",
-- config = function()
-- require("inlay-hints").setup()
-- end,
-- },
},
checker = { enabled = true },
})
require("nvim-treesitter").install({ "lua", "vimdoc" }):wait(300000) -- Fix errors
-- Workaround to reinvent MysticalDevil/inlay-hints.nvim for lua_ls.
-- If you want to use MysticalDevil/inlay-hints.nvim, then remove this section.
-- Without this section, if inlay hints don't appear at first, just randomly edit the file e.g. press <o> <ESC> <u>.
-- With or without this section, for Lua, there's a bug where the signcolumn only appears after editing.
vim.api.nvim_create_autocmd("LspAttach", {
callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id)
if not client then
return -- https://vi.stackexchange.com/a/46784/51656
end
function enable_inlay_hints()
if vim.lsp.inlay_hint then
vim.lsp.inlay_hint.enable(true, { 0 }) -- https://stackoverflow.com/a/77678959/10477326
end
end
if client.name == "lua_ls" and False then -- Disabled workaround to showcase this bug to GitHub issues
-- Workaround: Delay to ensure inlay hints work at the start of opened Lua files
vim.defer_fn(enable_inlay_hints, 500)
else
enable_inlay_hints()
end
end,
})
-- require("lspconfig") is now vim.lsp.config
vim.lsp.config("lua_ls", {
settings = {
Lua = {
completion = {
callSnippet = "Replace",
},
misc = {
parameters = { "--loglevel=trace" }
}
}
}
})
-- Below is adapted from MysticalDevil/inlay-hints.nvim's README
-- I removed some default/outdated parameters
vim.lsp.config("gopls", {
settings = {
gopls = {
usePlaceholders = true,
hints = {
rangeVariableTypes = true,
parameterNames = true,
constantValues = true,
assignVariableTypes = true,
compositeLiteralFields = true,
compositeLiteralTypes = true,
functionTypeParameters = true,
},
},
},
})
vim.lsp.config("tsserver", {
settings = {
typescript = {
inlayHints = {
includeInlayParameterNameHints = "all",
includeInlayFunctionParameterTypeHints = true,
includeInlayVariableTypeHints = true,
includeInlayPropertyDeclarationTypeHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayEnumMemberValueHints = true,
},
},
javascript = {
inlayHints = {
includeInlayParameterNameHints = "all",
includeInlayFunctionParameterTypeHints = true,
includeInlayVariableTypeHints = true,
includeInlayPropertyDeclarationTypeHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayEnumMemberValueHints = true,
},
},
},
})
Then open the same file to edit in the Neovim editor by executing nvim ~/.config/nvim/init.lua.
Additional Notes
No response
Log File
- 主要言語
- Lua
- スター
- 4.4k
- フォーク
- 442
- 平均マージ
- 8日 9時間
- マージ済み PR(30日)
- 1
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
LuaLS/lua-language-server のほかの issue
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
LuaLS/lua-language-server#1776 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 65/100
LuaLS/lua-language-server#3463 · コメント 5 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
LuaLS/lua-language-server#3461 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
LuaLS/lua-language-server#3460 · コメント 1 件 · リアクション 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
LuaLS/lua-language-server#3459 · リアクション 1 件 ·
LuaLS/lua-language-server の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
LandSandBoat/server#11579 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
ArchiveTeam/sinavideo-grab#7 · リアクション 3 件 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
mailcow/mailcow-dockerized#7480 ·
-
mapper bug
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100