Neovim support for LSP Inlay Hints
neovim 0.7+
using packer.nvim
use('simrat39/inlay-hints.nvim')
Look at the configuration information below to get started.
Put this in your init.lua or any lua file that is sourced.
require("inlay-hints").setup()
Pass a table to the setup call above with your configuration options.
For example:
require("inlay-hints").setup({
only_current_line = true,
eol = {
right_align = true,
}
})
Take a look at all the possible configuration options here
The plugin hooks itself to the on_attach callback of an LSP Server. Some servers might need extra configuration to enable inlay hints. See the examples below to get started.
local ih = require("inlay-hints")
local lspconfig = require("lspconfig")
lspconfig.sumneko_lua.setup({
on_attach = function(c, b)
ih.on_attach(c, b)
end,
settings = {
Lua = {
hint = {
enable = true,
},
},
},
})
local ih = require("inlay-hints")
require("rust-tools").setup({
tools = {
on_initialized = function()
ih.set_all()
end,
inlay_hints = {
auto = false,
},
},
server = {
on_attach = function(c, b)
ih.on_attach(c, b)
end,
},
})
local ih = require("inlay-hints")
local lspconfig = require("lspconfig")
lspconfig.tsserver.setup({
on_attach = function(c, b)
ih.on_attach(c, b)
end,
settings = {
javascript = {
inlayHints = {
includeInlayEnumMemberValueHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayFunctionParameterTypeHints = true,
includeInlayParameterNameHints = "all", -- 'none' | 'literals' | 'all';
includeInlayParameterNameHintsWhenArgumentMatchesName = true,
includeInlayPropertyDeclarationTypeHints = true,
includeInlayVariableTypeHints = true,
},
},
typescript = {
inlayHints = {
includeInlayEnumMemberValueHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayFunctionParameterTypeHints = true,
includeInlayParameterNameHints = "all", -- 'none' | 'literals' | 'all';
includeInlayParameterNameHintsWhenArgumentMatchesName = true,
includeInlayPropertyDeclarationTypeHints = true,
includeInlayVariableTypeHints = true,
},
},
},
})
local ih = require("inlay-hints")
local lspconfig = require("lspconfig")
lspconfig.gopls.setup({
on_attach = function(c, b)
ih.on_attach(c, b)
end,
settings = {
gopls = {
hints = {
assignVariableTypes = true,
compositeLiteralFields = true,
compositeLiteralTypes = true,
constantValues = true,
functionTypeParameters = true,
parameterNames = true,
rangeVariableTypes = true,
},
},
},
})