Make sure reference to ui function exists before calling

This commit is contained in:
ViViDboarder 2021-12-09 09:20:06 -08:00
parent 84497d7009
commit 505143f5e3

View File

@ -2,6 +2,37 @@
local M = {} local M = {}
local utils = require("utils") 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) local function default_attach(client, bufnr)
if utils.is_plugin_loaded("completion-nvim") then if utils.is_plugin_loaded("completion-nvim") then
require('completion').on_attach() require('completion').on_attach()
@ -83,37 +114,6 @@ local function default_attach(client, bufnr)
end end
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() function M.config_lsp()
local lsp_config = require("lspconfig") local lsp_config = require("lspconfig")