From 505143f5e31880d66af7d562ad05895e15c77ce5 Mon Sep 17 00:00:00 2001 From: ViViDboarder Date: Thu, 9 Dec 2021 09:20:06 -0800 Subject: [PATCH] Make sure reference to ui function exists before calling --- neovim/lua/plugins/lsp.lua | 62 +++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/neovim/lua/plugins/lsp.lua b/neovim/lua/plugins/lsp.lua index 70f8d96..f38e824 100644 --- a/neovim/lua/plugins/lsp.lua +++ b/neovim/lua/plugins/lsp.lua @@ -2,6 +2,37 @@ local M = {} local utils = require("utils") +local function config_lsp_ui() + -- Add floating window boarders + vim.cmd [[autocmd ColorScheme * highlight NormalFloat guibg=#1f2335]] + vim.cmd [[autocmd ColorScheme * highlight FloatBorder guifg=white guibg=#1f2335]] + local border = { + {"┌", "FloatBorder"}, + {"─", "FloatBorder"}, + {"┐", "FloatBorder"}, + {"│", "FloatBorder"}, + {"┘", "FloatBorder"}, + {"─", "FloatBorder"}, + {"└", "FloatBorder"}, + {"│", "FloatBorder"}, + } + local orig_util_open_floating_preview = vim.lsp.util.open_floating_preview + function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...) + opts = opts or {} + opts.border = opts.border or border + return orig_util_open_floating_preview(contents, syntax, opts, ...) + end + + -- Diagnostics signs + 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 = hl }) + end + + -- vim.cmd [[autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false})]] +end + local function default_attach(client, bufnr) if utils.is_plugin_loaded("completion-nvim") then require('completion').on_attach() @@ -83,37 +114,6 @@ local function default_attach(client, bufnr) end end -local function config_lsp_ui() - -- Add floating window boarders - vim.cmd [[autocmd ColorScheme * highlight NormalFloat guibg=#1f2335]] - vim.cmd [[autocmd ColorScheme * highlight FloatBorder guifg=white guibg=#1f2335]] - local border = { - {"┌", "FloatBorder"}, - {"─", "FloatBorder"}, - {"┐", "FloatBorder"}, - {"│", "FloatBorder"}, - {"┘", "FloatBorder"}, - {"─", "FloatBorder"}, - {"└", "FloatBorder"}, - {"│", "FloatBorder"}, - } - local orig_util_open_floating_preview = vim.lsp.util.open_floating_preview - function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...) - opts = opts or {} - opts.border = opts.border or border - return orig_util_open_floating_preview(contents, syntax, opts, ...) - end - - -- Diagnostics signs - 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 = hl }) - end - - -- vim.cmd [[autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false})]] -end - function M.config_lsp() local lsp_config = require("lspconfig")