Advertisement
oriolg

Untitled

Apr 17th, 2025
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.11 KB | None | 0 0
  1. return {
  2.     {
  3.         "williamboman/mason.nvim",
  4.         -- setup required. mason doesn't  recomend deferring the setup
  5.         config = function()
  6.             require("mason").setup()
  7.         end,
  8.     },
  9.     {
  10.  
  11.         "williamboman/mason-lspconfig.nvim",
  12.         opts = {
  13.             ensure_installed = {
  14.                 "lua_ls",
  15.                 "ts_ls",
  16.                 "svelte",
  17.                 "html",
  18.                 "tailwindcss",
  19.                 "bashls",
  20.                 "gopls",
  21.             },
  22.         },
  23.     },
  24.     {
  25.         "neovim/nvim-lspconfig",
  26.         lazy = false,
  27.         -- make lua know global vim variables:
  28.         dependencies = {
  29.  
  30.             {
  31.                 "folke/lazydev.nvim",
  32.                 ft = "lua", -- only load on lua files
  33.                 opts = {
  34.                     library = {
  35.                         -- Load luvit types when the `vim.uv` word is found
  36.                         { path = "${3rd}/luv/library", words = { "vim%.uv" } },
  37.                     },
  38.                 },
  39.             },
  40.         },
  41.         config = function()
  42.             local lspconfig = require("lspconfig")
  43.             local capabilities = require("cmp_nvim_lsp").default_capabilities()
  44.             lspconfig.lua_ls.setup({
  45.                 capabilities = capabilities,
  46.             })
  47.             lspconfig.ts_ls.setup({
  48.                 capabilities = capabilities,
  49.             })
  50.             lspconfig.svelte.setup({
  51.                 capabilities = capabilities,
  52.                 -- There is a svelte LSP bug that returns the exact same definition twice
  53.                 -- in case of multiple results go to the first one
  54.                 handlers = {
  55.                     ["textDocument/definition"] = function(err, result, ctx, config)
  56.                         if type(result) == "table" then
  57.                             result = { result[1] }
  58.                         end
  59.                         vim.lsp.handlers["textDocument/definition"](err, result, ctx, config)
  60.                     end,
  61.                 },
  62.             })
  63.             lspconfig.html.setup({
  64.                 capabilities = capabilities,
  65.             })
  66.             lspconfig.tailwindcss.setup({
  67.                 capabilities = capabilities,
  68.             })
  69.  
  70.             vim.api.nvim_create_autocmd("LspAttach", {
  71.                 desc = "LSP actions",
  72.                 callback = function(event)
  73.                     local opts = { buffer = event.buf }
  74.                     vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
  75.                     vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
  76.                     vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
  77.                     vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts)
  78.                     vim.keymap.set("n", "gt", vim.lsp.buf.type_definition, opts)
  79.                     vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
  80.                     vim.keymap.set("n", "gs", vim.lsp.buf.signature_help, opts)
  81.                     vim.keymap.set("n", "ca", vim.lsp.buf.code_action, opts)
  82.                 end,
  83.             })
  84.         end,
  85.     },
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement