Advertisement
Guest User

nvim-lspconfig + mason stuff

a guest
May 22nd, 2025
47
0
343 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.81 KB | Source Code | 0 0
  1. return {
  2.     { -- LSP Configuration & Plugins
  3.         "neovim/nvim-lspconfig",
  4.         dependencies = {
  5.        
  6.             { "williamboman/mason.nvim", config = true, name = "mason" }, -- NOTE: Must be loaded before dependants
  7.             { "williamboman/mason-lspconfig.nvim", dependencies = "mason", name = "mason-lsp" },
  8.             {
  9.                 "WhoIsSethDaniel/mason-tool-installer.nvim",
  10.                 config = function()
  11.                     require("mason-tool-installer").setup({}) -- Or your specific config
  12.                 end,
  13.                 dependencies = { "mason", "mason-lsp" }, -- Explicit dependency
  14.             },
  15.             { "j-hui/fidget.nvim" }, -- notifications
  16.  
  17.        
  18.             { "folke/neodev.nvim", opts = {} },
  19.             { "saghen/blink.cmp" }, -- completion engine
  20.         },
  21.         config = function()
  22.             vim.diagnostic.config({ -- some diagnostics configs like showing warnings inline etc
  23.                 virtual_text = true,
  24.                 -- signs = true,
  25.                 underline = true,
  26.                 update_in_insert = false,
  27.                 severity_sort = true,
  28.             })
  29.        
  30.             vim.api.nvim_create_autocmd("LspAttach", {
  31.                 group = vim.api.nvim_create_augroup("kickstart-lsp-attach", { clear = true }),
  32.                 callback = function(event)
  33.                
  34.                     local client = vim.lsp.get_client_by_id(event.data.client_id)
  35.                     if client and client.server_capabilities.documentHighlightProvider then
  36.                         local highlight_augroup = vim.api.nvim_create_augroup("kickstart-lsp-highlight", { clear = false })
  37.                         vim.api.nvim_create_autocmd({
  38.                             "CursorHold",
  39.                             "CursorHoldI",
  40.                         }, {
  41.                             buffer = event.buf,
  42.                             group = highlight_augroup,
  43.                             callback = vim.lsp.buf.document_highlight,
  44.                         })
  45.  
  46.                         vim.api.nvim_create_autocmd({
  47.                             "CursorMoved",
  48.                             "CursorMovedI",
  49.                         }, {
  50.                             buffer = event.buf,
  51.                             group = highlight_augroup,
  52.                             callback = vim.lsp.buf.clear_references,
  53.                         })
  54.  
  55.                         vim.api.nvim_create_autocmd("LspDetach", {
  56.                             group = vim.api.nvim_create_augroup("kickstart-lsp-detach", { clear = true }),
  57.                             callback = function(event2)
  58.                                 vim.lsp.buf.clear_references()
  59.                                 vim.api.nvim_clear_autocmds({
  60.                                     group = "kickstart-lsp-highlight",
  61.                                     buffer = event2.buf,
  62.                                 })
  63.                             end,
  64.                         })
  65.                     end
  66.  
  67.            
  68.                    
  69.                 end,
  70.             })
  71.  
  72.             local capabilities = vim.lsp.protocol.make_client_capabilities()
  73.            
  74.             capabilities = require("blink.cmp").get_lsp_capabilities(capabilities)
  75.  
  76.            
  77.             local servers = {
  78.        
  79.             }
  80.        
  81.             require("mason").setup()
  82.  
  83.        
  84.             local ensure_installed = vim.tbl_keys(servers or {})
  85.             vim.list_extend(ensure_installed, {
  86.                 -- i dumped all the mason installed stuff here, lsp, daps, linters, formatters etc,
  87.                 -- TODO: refactor this stuff to a separate mason file
  88.                 "stylua", -- Used to format Lua code
  89.                 "bash-language-server",
  90.                 "black",
  91.                 "chrome-debug-adapter",
  92.                 "cpplint",
  93.                 "css-lsp",
  94.                 "css-variables-language-server",
  95.                 "cssmodules-language-server",
  96.                 "delve",
  97.                 "emmet-ls",
  98.                 "eslint-lsp",
  99.                 "html-lsp",
  100.                 "htmlhint",
  101.                 "js-debug-adapter",
  102.                 "json-lsp",
  103.                 "jsonlint",
  104.                 "lua-language-server",
  105.                 "luacheck",
  106.                 "markdownlint",
  107.                 "mdformat",
  108.                 "nextls",
  109.                 "prettierd",
  110.                 "rust-analyzer",
  111.                 "shellcheck",
  112.                 "stylelint",
  113.                 "stylua",
  114.                 "systemd-language-server",
  115.                 "tailwindcss-language-server",
  116.                 "typescript-language-server",
  117.                 "typos",
  118.                 "vim-language-server",
  119.             })
  120.             require("mason-tool-installer").setup({
  121.                 ensure_installed = ensure_installed,
  122.             })
  123.  
  124.             require("mason-lspconfig").setup({
  125.                 handlers = {
  126.                     function(server_name)
  127.                         local server = servers[server_name] or {}
  128.                         server.capabilities = vim.tbl_deep_extend("force", {}, capabilities, server.capabilities or {})
  129.                         server.capabilities = require("blink.cmp").get_lsp_capabilities(server.capabilities)
  130.                         require("lspconfig")[server_name].setup(server)
  131.                     end,
  132.                 },
  133.             })
  134.         end,
  135.     },
  136. }
  137.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement