return { "neovim/nvim-lspconfig", event = { "BufReadPre", "BufNewFile" }, dependencies = { "williamboman/mason.nvim", "williamboman/mason-lspconfig.nvim", "hrsh7th/cmp-nvim-lsp", }, config = function() require("mason").setup() local capabilities = require("cmp_nvim_lsp").default_capabilities() local lspconfig = require("lspconfig") vim.api.nvim_create_autocmd("LspAttach", { callback = function(event) local map = function(keys, func, desc) vim.keymap.set("n", keys, func, {buffer = event.buf, desc = desc}) end -- Navigation map("gd", vim.lsp.buf.definition, "Go to definition") map("gD", vim.lsp.buf.declaration, "Go to declatation") map("gi", vim.lsp.buf.implementation, "Go to implementation") map("gr", vim.lsp.buf.definition, "Go to references") map("gt", vim.lsp.buf.type_definition, "Go to type definition") -- Documentation map("K", vim.lsp.buf.hover, "Hover documentation") map("K", vim.lsp.buf.signature_help, "Signature help") -- LSP Actions map("ca", vim.lsp.buf.code_action, "Code action") map("cr", vim.lsp.buf.rename, "Rename") map("cf", vim.lsp.buf.format, "Format") -- Diagnostics map("do", vim.diagnostic.open_float, "Show diagnostics") map("dl", vim.diagnostic.goto_next, "Next diagnostic") map("dh", vim.diagnostic.goto_prev, "Previous diagnostic") map("dF", vim.diagnostic.setloclist, "Quickfix diagnostics") map("da", vim.diagnostic.setloclist, "List diagnostics") end, }) local servers = { -- Javascript/TypeScript/React ts_ls = { settings = { typescript = { inlayHints = { includeInlayParameterNameHints = "all", includeInlayParameterNameHintsWhenArgumentMatchesName = false, includeInlayFunctionParameterTypeHints = true, includeInlayVariableTypeHints = true, }, }, }, }, -- Hyprland hyprls = {}, -- CSS/SCSS cssls = {}, -- stylelint stylelint_lsp = {}, -- HTML html = {}, -- PHP intelephense = { settings = { php = { validate = { enable = true, run = "onSave", }, }, }, }, -- Python pyright = {}, -- JSON jsonls = {}, -- TOML taplo = {}, -- YAML yamlls = {}, -- Rust rust_analyzer = { settings = { ["rust_analyzer"] = { check = { command = "clippy" }, }, }, }, -- Go gopls = {}, -- Markdown marksman = {}, -- Lua lua_ls = { settings = { Lua = { diagnostics = { globals = { "vim" } }, workspace = { checkThirdParty = false }, telemetry = { enable = false }, }, }, }, } require("mason-lspconfig").setup({ ensure_installed = vim.tbl_keys(servers), handlers = { function(server_name) local config = servers[server_name] or {} config.capabilities = capabilities lspconfig[server_name].setup(config) end, }, }) end, }