local lsp_servers = { "lua_ls", "nil_ls", -- nix "rust_analyzer", "gopls", "pyright", "bashls", "ts_ls", "marksman", "taplo", "yamlls", "clangd", } return { "williamboman/mason.nvim", { "stevearc/conform.nvim", init = function() require("conform").setup({ formatters_by_ft = { html = { "prettier" }, }, }) end }, "zapling/mason-conform.nvim", { "neovim/nvim-lspconfig", dependencies = { "williamboman/mason.nvim", "williamboman/mason-lspconfig.nvim", "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-buffer", "hrsh7th/cmp-path", "hrsh7th/cmp-cmdline", "hrsh7th/nvim-cmp", "L3MON4D3/LuaSnip", "saadparwaiz1/cmp_luasnip", "j-hui/fidget.nvim", }, config = function() -- Add additional capabilities supported by nvim-cmp local capabilities = require("cmp_nvim_lsp").default_capabilities() local lspconfig = require('lspconfig') require("fidget").setup({}) require("mason").setup() require("mason-lspconfig").setup({ ensure_installed = lsp_servers }) -- Enable some language servers with the additional completion capabilities offered by nvim-cmp local servers = lsp_servers for _, lsp in ipairs(servers) do lspconfig[lsp].setup { -- on_attach = my_custom_on_attach, capabilities = capabilities, } end -- configure lua server (with special settings) lspconfig["lua_ls"].setup({ capabilities = capabilities, on_attach = on_attach, settings = { -- custom settings for lua Lua = { -- make the language server recognize "vim" global diagnostics = { globals = { "vim" }, }, workspace = { -- make language server aware of runtime files library = { [vim.fn.expand("$VIMRUNTIME/lua")] = true, [vim.fn.stdpath("config") .. "/lua"] = true, }, }, }, }, }) lspconfig["pyright"].setup({ capabilities = capabilities, filetypes = {"python"}, }) lspconfig["rust_analyzer"].setup({ capabilities = capabilities, filetypes = {"rust"}, settings = { ['rust-analyzer'] = { checkOnSave = true, check = { command = "clippy", }, }, }, }) -- luasnip setup local luasnip = require 'luasnip' -- nvim-cmp setup local cmp = require 'cmp' cmp.setup { snippet = { expand = function(args) luasnip.lsp_expand(args.body) end, }, mapping = cmp.mapping.preset.insert({ ['gd'] = vim.lsp.buf.definition(), -- Up [''] = cmp.mapping.scroll_docs(-4), -- Up [''] = cmp.mapping.scroll_docs(4), -- Down -- C-b (back) C-f (forward) for snippet placeholder navigation. [''] = cmp.mapping.complete(), [''] = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, select = true, }, [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() elseif luasnip.expand_or_jumpable() then luasnip.expand_or_jump() else fallback() end end, { 'i', 's' }), [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() elseif luasnip.jumpable(-1) then luasnip.jump(-1) else fallback() end end, { 'i', 's' }), }), sources = { { name = 'nvim_lsp' }, { name = 'luasnip' }, { name = "buffer" }, }, } vim.keymap.set('n', "gd", vim.lsp.buf.definition, { silent = true }) vim.keymap.set('n', "ca", vim.lsp.buf.code_action, { silent = true }) vim.keymap.set('n', "ih", function () vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()) end, { silent = true }) vim.keymap.set('n', "cf", vim.lsp.buf.format, { silent = true }) -- Show line diagnostics vim.keymap.set('n', "se", function () vim.diagnostic.open_float(nil, {focus=false}) end, { silent = true }) end }, { 'mrcjkb/rustaceanvim', dependencies = { "mfussenegger/nvim-dap", }, version = '^6', -- Recommended lazy = false, -- This plugin is already lazy init = function () -- require("rustaceanvim").setup({ -- dap = { -- adapter = require("dap").adapters.lldb -- } -- }) vim.g.rustaceanvim = { dap = { adapter = require("dap").adapters.lldb -- adapter = true } } end } }