lsp.lua 1.4 KB

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