return { { 'neovim/nvim-lspconfig', -- LSP config = function() --vim.lsp.set_log_level("debug") local status, nvim_lsp = pcall(require, "lspconfig") if (not status) then return end local protocol = require('vim.lsp.protocol') -- Use an on_attach function to only map the following keys -- after the language server attaches to the current buffer local on_attach = function(client, bufnr) local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end --Enable completion triggered by buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') -- Mappings. local opts = { noremap = true, silent = true } -- See `:help vim.lsp.*` for documentation on any of the below functions buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) buf_set_keymap('n', 'K', 'lua vim.lsp.buf.hover()', opts) buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) --buf_set_keymap('n', 'K', 'lua vim.lsp.buf.hover()', opts) end protocol.CompletionItemKind = { '', -- Text '', -- Method '', -- Function '', -- Constructor '', -- Field '', -- Variable '', -- Class 'ﰮ', -- Interface '', -- Module '', -- Property '', -- Unit '', -- Value '', -- Enum '', -- Keyword '﬌', -- Snippet '', -- Color '', -- File '', -- Reference '', -- Folder '', -- EnumMember '', -- Constant '', -- Struct '', -- Event 'ﬦ', -- Operator '', -- TypeParameter } -- Set up completion using nvim_cmp with LSP source local capabilities = require('cmp_nvim_lsp').default_capabilities( vim.lsp.protocol.make_client_capabilities() ) nvim_lsp.flow.setup { on_attach = on_attach, capabilities = capabilities } -- nvim_lsp.solargraph.setup {} nvim_lsp.ts_ls.setup { on_attach = on_attach, filetypes = { "typescript", "typescriptreact", "typescript.tsx", "javascript", "vue" }, cmd = { "typescript-language-server", "--stdio" }, capabilities = capabilities } nvim_lsp.sourcekit.setup { on_attach = on_attach, } nvim_lsp.lua_ls.setup { on_attach = on_attach, settings = { Lua = { diagnostics = { -- Get the language server to recognize the `vim` global globals = { 'vim' }, }, workspace = { -- Make the server aware of Neovim runtime files library = vim.api.nvim_get_runtime_file("", true), checkThirdParty = false }, }, }, } vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( vim.lsp.diagnostic.on_publish_diagnostics, { underline = true, update_in_insert = false, virtual_text = { spacing = 4, prefix = "●" }, severity_sort = true, } ) -- Diagnostic symbols in the sign column (gutter) local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " } for type, icon in pairs(signs) do local hl = "DiagnosticSign" .. type vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) end vim.diagnostic.config({ virtual_text = { prefix = '●' }, update_in_insert = true, float = { source = "always", -- Or "if_many" }, }) _timers = {} local function setup_diagnostics(client, buffer) if require("vim.lsp.diagnostic")._enable then return end local diagnostic_handler = function() local params = vim.lsp.util.make_text_document_params(buffer) client.request("textDocument/diagnostic", { textDocument = params }, function(err, result) if err then local err_msg = string.format("diagnostics error - %s", vim.inspect(err)) vim.lsp.log.error(err_msg) end local diagnostic_items = {} if result then diagnostic_items = result.items end vim.lsp.diagnostic.on_publish_diagnostics( nil, vim.tbl_extend("keep", params, { diagnostics = diagnostic_items }), { client_id = client.id } ) end) end diagnostic_handler() -- to request diagnostics on buffer when first attaching vim.api.nvim_buf_attach(buffer, false, { on_lines = function() if _timers[buffer] then vim.fn.timer_stop(_timers[buffer]) end _timers[buffer] = vim.fn.timer_start(200, diagnostic_handler) end, on_detach = function() if _timers[buffer] then vim.fn.timer_stop(_timers[buffer]) end end, }) end require("lspconfig").ruby_lsp.setup({ on_attach = function(client, buffer) setup_diagnostics(client, buffer) end, }) end }, { 'onsails/lspkind-nvim', -- vscode-like pictograms config = function() require('lspkind').init({ mode = 'symbol', preset = 'codicons', -- override preset symbols -- -- default: {} symbol_map = { Text = "", Method = "", Function = "", Constructor = "", Field = "ﰠ", Variable = "", Class = "ﴯ", Interface = "", Module = "", Property = "ﰠ", Unit = "塞", Value = "", Enum = "", Keyword = "", Snippet = "", Color = "", File = "", Reference = "", Folder = "", EnumMember = "", Constant = "", Struct = "פּ", Event = "", Operator = "", TypeParameter = "" }, }) end }, 'jose-elias-alvarez/null-ls.nvim', -- inject LSP diagnostics, code actions { 'glepnir/lspsaga.nvim', -- LSP UIs config = function() local opts = { noremap = true, silent = true } vim.keymap.set('n', '', 'Lspsaga diagnostic_jump_next', opts) vim.keymap.set('n', 'K', 'Lspsaga hover_doc', opts) -- vim.keymap.set('n', 'gd', 'Lspsaga lsp_finder', opts) vim.keymap.set('i', '', 'Lspsaga signature_help', opts) vim.keymap.set('n', 'gp', 'Lspsaga preview_definition', opts) vim.keymap.set('n', 'gr', 'Lspsaga rename', opts) end }, 'folke/trouble.nvim', -- better diagnostics }