local lsp = require('lsp-zero') lsp.preset('recommended') lsp.configure('lua_ls', { settings = { Lua = { diagnostics = { globals = { 'vim' } } } } }) lsp.on_attach(function(client, bufnr) lsp.default_keymaps({buffer = bufnr}) vim.keymap.set ("n", "r", vim.lsp.buf.rename, options) vim.keymap.set ("n", "f", vim.lsp.buf.code_action, options) end) lsp.set_sign_icons({ error = '✘', warn = '▲', hint = '⚑', info = '»' }) -- lsp.on_attach = function (_, bufnr) -- print "attached" -- local options = { buffer = bufnr, remap = false } -- vim.keymap.set ("n", "K", vim.lsp.buf.hover, options) -- buffer=0 -> only in current buffer -- vim.keymap.set ("n", "gd", vim.lsp.buf.definition, options) -- goto definition -- vim.keymap.set ("n", "gT", vim.lsp.buf.type_definition, options) -- goto typedefinition -- vim.keymap.set ("n", "gi", vim.lsp.buf.implementation, options) -- goto implementation -- vim.keymap.set ("n", "dj", vim.diagnostic.goto_next, options) -- goto dignostic next -- vim.keymap.set ("n", "dk", vim.diagnostic.goto_prev, options) -- goto diognostic prev -- vim.keymap.set ("n", "dl", "Telescope diagnostic", options) -- goto list failure -- vim.keymap.set ("n", "r", vim.lsp.buf.rename, options) -- vim.keymap.set ("n", "f", vim.lsp.buf.code_action, options) -- end local cmp = require('cmp') local cmp_select = {behavior = cmp.SelectBehavior.Select} local cmp_mappings = lsp.defaults.cmp_mappings({ [''] = cmp.mapping.select_prev_item(cmp_select), [''] = cmp.mapping.select_next_item(cmp_select), [''] = cmp.mapping.confirm({ select = true }), [""] = cmp.mapping.complete(), }) lsp.setup_nvim_cmp({ mapping = cmp_mappings, }) cmp.setup({ experimental = { ghost_text = true }, }); lsp.setup() vim.diagnostic.config({ virtual_text = { -- source = "always", -- Or "if_many" prefix = '●', -- Could be '■', '▎', 'x' }, severity_sort = true, float = { source = "always", -- Or "if_many" }, })