local lspconf = require("lspconfig") local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities.textDocument.completion.completionItem.snippetSupport = true lspconf.pylsp.setup{ settings = { pylsp = { plugins = { pycodestyle = { ignore = {'W391'}, maxLineLength = 100 } } } } } lspconf.phpactor.setup { capabilities = capabilities, on_attach = function() end, } lspconf.html.setup { capabilities = capabilities, } lspconf.cssls.setup({ capabilities = capabilities, }) lspconf.emmet_ls.setup({ capabilities = capabilities, filetypes = { "html", "php" }, }) lspconf.tsserver.setup({ capabilities = capabilities, on_attach = function() end, }) lspconf.eslint.setup({ capabilities = capabilities, on_attach = function() end, }) local sign = function(opts) vim.fn.sign_define(opts.name, { texthl = opts.name, text = opts.text, numhl = '' }) end sign({name = 'DiagnosticSignError', text = ''}) sign({name = 'DiagnosticSignWarn', text = ''}) sign({name = 'DiagnosticSignInfo', text = ''}) sign({name = 'DiagnosticSignHint', text = ''}) vim.diagnostic.config({ signs = true, virtual_text = false, update_in_insert = true, underline = false, severity_sort = true, float = { focusable = false, source = 'always', header = '', prefix = '', }, }) vim.diagnostic.open_float = (function(orig) return function(bufnr, opts) local lnum = vim.api.nvim_win_get_cursor(0)[1] - 1 local opts = opts or {} -- A more robust solution would check the "scope" value in `opts` to -- determine where to get diagnostics from, but if you're only using -- this for your own purposes you can make it as simple as you like local diagnostics = vim.diagnostic.get(opts.bufnr or 0, {lnum = lnum}) local max_severity = vim.diagnostic.severity.HINT for _, d in ipairs(diagnostics) do -- Equality is "less than" based on how the severities are encoded if d.severity < max_severity then max_severity = d.severity end end local border_color = ({ [vim.diagnostic.severity.HINT] = "DiagnosticHint", [vim.diagnostic.severity.INFO] = "DiagnosticInfo", [vim.diagnostic.severity.WARN] = "DiagnosticWarn", [vim.diagnostic.severity.ERROR] = "DiagnosticError", })[max_severity] opts.border = { {"╭", border_color}, {"─", border_color}, {"╮", border_color}, {"│", border_color}, {"╯", border_color}, {"─", border_color}, {"╰", border_color}, {"│", border_color}, } orig(bufnr, opts) end end)(vim.diagnostic.open_float) -- Show line diagnostics in floating popup on hover, except insert mode (CursorHoldI) vim.cmd [[autocmd CursorHold * lua vim.diagnostic.open_float()]] require("keybinds") map("n", "", "lua vim.lsp.buf.rename()") map("n", "", "lua vim.diagnostic.open_float()") map("n", "dn", "lua vim.diagnostic.goto_next()") map("n", "dp", "lua vim.diagnostic.goto_prev()") map("n", "pp", "lua vim.lsp.buf.format()") --[[ nnoremap lua vim.lsp.buf.definition() nnoremap K lua vim.lsp.buf.hover() nnoremap gD lua vim.lsp.buf.implementation() nnoremap lua vim.lsp.buf.signature_help() nnoremap 1gD lua vim.lsp.buf.type_definition() nnoremap gr lua vim.lsp.buf.references() nnoremap g0 lua vim.lsp.buf.document_symbol() nnoremap gW lua vim.lsp.buf.workspace_symbol() nnoremap gd lua vim.lsp.buf.definition() -- Jump to the definition bufmap('n', 'gd', 'lua vim.lsp.buf.definition()') -- Jump to declaration bufmap('n', 'gD', 'lua vim.lsp.buf.declaration()') -- Lists all the implementations for the symbol under the cursor bufmap('n', 'gi', 'lua vim.lsp.buf.implementation()') -- Jumps to the definition of the type symbol bufmap('n', 'go', 'lua vim.lsp.buf.type_definition()') -- Lists all the references bufmap('n', 'gr', 'lua vim.lsp.buf.references()') -- Displays a function's signature information bufmap('n', '', 'lua vim.lsp.buf.signature_help()') -- Renames all references to the symbol under the cursor bufmap('n', '', 'lua vim.lsp.buf.rename()') -- Selects a code action available at the current cursor position bufmap('n', '', 'lua vim.lsp.buf.code_action()') bufmap('x', '', 'lua vim.lsp.buf.range_code_action()') -- Show diagnostics in a floating window bufmap('n', 'gl', 'lua vim.diagnostic.open_float()') ]]