1
0
mirror of https://github.com/jdhao/nvim-config.git synced 2025-06-08 14:14:33 +02:00

enable inlayhint for lua_ls server

The client side inlayhint can be enabled by uncommentting the code in
this PR.
This commit is contained in:
jdhao 2024-11-05 21:59:58 +01:00
parent 590bd6c7e6
commit 94cade03be

View File

@ -51,6 +51,10 @@ local custom_attach = function(client, bufnr)
map("n", "<space>f", vim.lsp.buf.format, { desc = "format code" }) map("n", "<space>f", vim.lsp.buf.format, { desc = "format code" })
end end
-- Uncomment code below to enable inlay hint from language server, some LSP server supports inlay hint,
-- but disable this feature by default, so you may need to enable inlay hint in the LSP server config.
-- vim.lsp.inlay_hint.enable(true, {buffer=bufnr})
api.nvim_create_autocmd("CursorHold", { api.nvim_create_autocmd("CursorHold", {
buffer = bufnr, buffer = bufnr,
callback = function() callback = function()
@ -220,8 +224,8 @@ if utils.executable("bash-language-server") then
} }
end end
-- settings for lua-language-server can be found on https://luals.github.io/wiki/settings/
if utils.executable("lua-language-server") then if utils.executable("lua-language-server") then
-- settings for lua-language-server can be found on https://github.com/LuaLS/lua-language-server/wiki/Settings .
lspconfig.lua_ls.setup { lspconfig.lua_ls.setup {
on_attach = custom_attach, on_attach = custom_attach,
settings = { settings = {
@ -230,6 +234,9 @@ if utils.executable("lua-language-server") then
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
version = "LuaJIT", version = "LuaJIT",
}, },
hint = {
enable = true
}
}, },
}, },
capabilities = capabilities, capabilities = capabilities,