LunarVim / Launch.nvim

🚀 Launch.nvim is modular starter for Neovim.
GNU General Public License v3.0
2k stars 475 forks source link

Lua LSP error #182

Open appomsk opened 4 months ago

appomsk commented 4 months ago

When trying to edit a lua file:

LSP[lua_ls]: Error ON_ATTACH_ERROR: "...nAtNCc/usr/share/nvim/runtime/lua/vim/lsp/inlay_hint.l
ua:408: enable: expected boolean, got number"

I think the problem is in lspconfig.lua. There is some information - https://github.com/neovim/neovim/issues/26679.

aquinjay commented 3 months ago

Updating the lspconfig.lua file methods M.on_attach and M.toggle_inlay_hints with the below code fixed the issue for me.

M.on_attach = function(client, bufnr) 
  lsp_keymaps(bufnr)

  if client.supports_method "textDocument/inlayHint" then
    vim.lsp.inlay_hint.enable(true, {  bufnr })
  end
end

M.toggle_inlay_hints = function()
  local bufnr = vim.api.nvim_get_current_buf()
  vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr }), { bufnr })
end