0
0

lsp.lua 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. return {
  2. {
  3. "neovim/nvim-lspconfig",
  4. enabled = true,
  5. lazy = false,
  6. dependencies = { "williamboman/mason-lspconfig.nvim" },
  7. config = function(_, _)
  8. -- Install and configure servers
  9. require("mason").setup()
  10. require("mason-lspconfig").setup({
  11. ensure_installed = {
  12. "arduino_language_server", "basedpyright", "bashls", "clangd",
  13. "cssls", "denols", "gopls", "html", "jsonls",
  14. "kotlin_language_server", "lemminx", "lua_ls", "marksman",
  15. "ruff", "rust_analyzer", "sqlls", "taplo", "terraformls",
  16. "tsserver", "yamlls"
  17. }
  18. })
  19. -- Configuration on attach
  20. vim.api.nvim_create_autocmd("LspAttach", {
  21. group = vim.api.nvim_create_augroup("UserLspConfig", {}),
  22. callback = function(args)
  23. if vim.treesitter ~= nil and type(vim.treesitter.highlighter.active[args.buf]) ~= "nil" then
  24. local client = vim.lsp.get_client_by_id(args.data
  25. .client_id)
  26. client.server_capabilities.semanticTokensProvider = nil
  27. end
  28. vim.keymap.set("n", "SR", vim.lsp.buf.rename)
  29. vim.keymap.set("n", "Sx", vim.lsp.buf.code_action)
  30. vim.keymap.set("n", "SI", function()
  31. vim.lsp.inlay_hint.enable(
  32. not vim.lsp.inlay_hint.is_enabled())
  33. end)
  34. vim.keymap.set("n", "<Space>", vim.lsp.buf.hover)
  35. end
  36. })
  37. end
  38. }, {
  39. "williamboman/mason-lspconfig.nvim",
  40. enabled = true,
  41. lazy = false,
  42. automatic_installation = true,
  43. dependencies = { "williamboman/mason.nvim" }
  44. }, {
  45. "williamboman/mason.nvim",
  46. enabled = true,
  47. lazy = false,
  48. build = ":MasonUpdate"
  49. }
  50. }