lsp.lua 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. vim.lsp.enable({
  2. "vtsls",
  3. "gopls",
  4. "jsonls",
  5. "clangd",
  6. "lua_ls",
  7. "yamlls",
  8. "graphql",
  9. "html",
  10. "cssls",
  11. "omnisharp",
  12. "svelte",
  13. "templ",
  14. "tinymist",
  15. "jdtls",
  16. "nixd",
  17. "qmlls",
  18. "zls",
  19. "tsgo",
  20. })
  21. vim.api.nvim_create_autocmd("LspAttach", {
  22. group = vim.api.nvim_create_augroup("lsp", { clear = true }),
  23. callback = function(ev)
  24. local opts = { buffer = ev.buf, silent = true }
  25. nmap("K", vim.lsp.buf.hover, vim.tbl_extend("force", opts, { desc = "Hover Doc" }))
  26. nmap("<C-h>", vim.lsp.buf.signature_help, vim.tbl_extend("force", opts, { desc = "Signature Help" }))
  27. nmap("<leader>r", vim.lsp.buf.rename, vim.tbl_extend("force", opts, { desc = "Rename" }))
  28. nmap("<leader>ca", vim.lsp.buf.code_action, vim.tbl_extend("force", opts, { desc = "Code Action" }))
  29. nmap("vd", vim.diagnostic.open_float, vim.tbl_extend("force", opts, { desc = "View Diagnostics" }))
  30. nmap("<leader>lr", "<cmd>LspRestart<CR>", vim.tbl_extend("force", opts, { desc = "Restart LSP" }))
  31. end,
  32. })
  33. -- Enhance floating preview windows
  34. local orig_util_open_floating_preview = vim.lsp.util.open_floating_preview
  35. function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...)
  36. opts = opts or {}
  37. opts.border = opts.border or "rounded"
  38. opts.max_width = opts.max_width or 80
  39. opts.max_height = opts.max_height or 20
  40. return orig_util_open_floating_preview(contents, syntax, opts, ...)
  41. end