local config = function() local luasnip = require("luasnip") vim.diagnostic.config({ virtual_text = false, -- disable virtual text update_in_insert = true, underline = true, severity_sort = true, float = { focusable = true, style = "minimal", border = "rounded", source = true, header = "", prefix = "", }, }) vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end) vim.keymap.set("n", "Q", function() vim.lsp.buf.hover() end) vim.keymap.set("n", "vws", function() vim.lsp.buf.workspace_symbol() end) vim.keymap.set("n", "vd", function() vim.diagnostic.open_float() end) vim.keymap.set("n", "[d", function() vim.diagnostic.jump({count=-1, float=true}) end) vim.keymap.set("n", "]d", function() vim.diagnostic.jump({count=-1, float=true}) end) vim.keymap.set("n", "ca", function() vim.lsp.buf.code_action() end) vim.keymap.set("n", "vrr", function() vim.lsp.buf.references() end) vim.keymap.set("n", "vrn", function() vim.lsp.buf.rename() end) vim.keymap.set("i", "", function() vim.lsp.buf.signature_help() end) vim.keymap.set("n", "gi", function() vim.lsp.buf.implementation() end) -- nvim-lint -- vim.keymap.set("n", "li", function() -- require("lint").try_lint() -- end) -- conform -- vim.keymap.set("n", "fr", function() -- require("conform").format({ bufnr = bufnr }) -- end) -- vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { -- border = "rounded", -- }) -- -- vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { -- border = "rounded", -- }) vim.lsp.config('lua_ls', { settings = { Lua = { runtime = { -- Tell the language server which version of Lua you're using version = 'LuaJIT', }, diagnostics = { -- Get the language server to recognize the `vim` global globals = {'vim'} }, workspace = { checkThirdParty = false, library = { -- Make the server aware of Neovim runtime files vim.env.VIMRUNTIME, vim.fn.stdpath('config'), }, }, } } }) vim.lsp.config('pyright', { settings = { python = { analysis = { typeCheckingMode = "off", }, }, }, }) vim.lsp.enable('clangd') require("mason").setup() require("mason-lspconfig").setup({ ensure_installed = { "bashls", "ts_ls", "pyright", "lua_ls", "jsonls", "clangd", "biome", -- will install for formatting only -- "ruff", -- "marksman", }, automatic_enable = { exclude = { "ruff", "biome" } } }) local cmp = require("cmp") local cmp_select = { behavior = cmp.SelectBehavior.Select } require("luasnip/loaders/from_vscode").lazy_load() cmp.setup({ snippet = { expand = function(args) luasnip.lsp_expand(args.body) end, }, preselect = "item", completion = { completeopt = "menu,menuone,noinsert", }, sources = { -- { name = "mkdnflow" }, { name = "luasnip" }, { name = "path" }, { name = "nvim_lsp" }, { name = "nvim_lua" }, { name = "buffer" }, }, -- formatting = lsp_zero.cmp_format(), mapping = cmp.mapping.preset.insert({ -- [''] = cmp.mapping.select_prev_item(cmp_select), [""] = cmp.mapping.select_next_item(cmp_select), -- [""] = cmp.mapping.select_next_item(cmp_select), [""] = cmp.mapping.confirm({ select = true }), -- [""] = cmp.mapping.complete(), [""] = cmp.mapping(function(fallback) if luasnip.jumpable(1) then luasnip.jump(1) else fallback() end end, { "i", "s" }), [""] = cmp.mapping(function(fallback) if luasnip.jumpable(-1) then luasnip.jump(-1) else fallback() end end, { "i", "s" }), }), }) end return { "neovim/nvim-lspconfig", config = config, lazy = false, dependencies = { "williamboman/mason.nvim", "williamboman/mason-lspconfig.nvim", "hrsh7th/nvim-cmp", "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-buffer", "hrsh7th/cmp-path", "saadparwaiz1/cmp_luasnip", { "L3MON4D3/LuaSnip", version = "v2.*", build = "make install_jsregexp", dependencies = { "rafamadriz/friendly-snippets" }, }, }, }