|
| 1 | +local utils = require('cosmic-ui.utils') |
1 | 2 | local M = {} |
2 | 3 |
|
3 | | -M.rename = function(popup_opts, opts) |
4 | | - return require('cosmic-ui.rename')(popup_opts, opts) |
5 | | -end |
| 4 | +local default_user_opts = { |
| 5 | + lsp_signature = { |
| 6 | + bind = true, -- This is mandatory, otherwise border config won't get registered. |
| 7 | + handler_opts = { |
| 8 | + border = 'rounded', |
| 9 | + }, |
| 10 | + }, |
| 11 | + icons = { |
| 12 | + warn = '', |
| 13 | + info = '', |
| 14 | + error = '', |
| 15 | + hint = '', |
| 16 | + }, |
| 17 | + diagnostics = { |
| 18 | + underline = true, |
| 19 | + signs = true, |
| 20 | + update_in_insert = false, |
| 21 | + severity_sort = true, |
| 22 | + float = { |
| 23 | + header = false, |
| 24 | + source = 'always', |
| 25 | + border = 'rounded', |
| 26 | + }, |
| 27 | + virtual_text = { |
| 28 | + spacing = 4, |
| 29 | + source = 'always', |
| 30 | + severity = { |
| 31 | + min = vim.diagnostic.severity.HINT, |
| 32 | + }, |
| 33 | + }, |
| 34 | + }, |
| 35 | + hover = { |
| 36 | + handler = vim.lsp.handlers.hover, |
| 37 | + float = { |
| 38 | + border = 'rounded', |
| 39 | + }, |
| 40 | + }, |
| 41 | + signature_help = { |
| 42 | + handler = vim.lsp.handlers.signature_help, |
| 43 | + float = { |
| 44 | + border = 'rounded', |
| 45 | + }, |
| 46 | + }, |
| 47 | +} |
6 | 48 |
|
7 | | -M.highlight = function(group, bg, fg, gui) |
8 | | - if gui ~= nil and gui ~= '' then |
9 | | - vim.api.nvim_command(('hi %s guibg=%s guifg=%s gui=%s'):format(group, bg, fg, gui)) |
10 | | - elseif bg == nil then |
11 | | - vim.api.nvim_command(('hi %s guifg=%s'):format(group, fg)) |
| 49 | +M.setup = function(user_opts) |
| 50 | + user_opts = utils.merge(default_user_opts, user_opts or {}) |
| 51 | + |
| 52 | + -- set up lsp_signature if enabled |
| 53 | + local ok, lsp_signature = pcall(require, 'lsp_signature') |
| 54 | + if ok and user_opts.signature_help ~= false then |
| 55 | + lsp_signature.setup(user_opts.lsp_signature) |
12 | 56 | else |
13 | | - vim.api.nvim_command(('hi %s guibg=%s guifg=%s'):format(group, bg, fg)) |
| 57 | + -- set up signatureHelp |
| 58 | + require('cosmic-ui.signature-help').init(user_opts.signature_help) |
14 | 59 | end |
| 60 | + |
| 61 | + -- set up diagnostics |
| 62 | + require('cosmic-ui.diagnostics').init(user_opts.diagnostics) |
| 63 | + |
| 64 | + -- set up hover |
| 65 | + require('cosmic-ui.hover').init(user_opts.hover) |
| 66 | +end |
| 67 | + |
| 68 | +M.rename = function(popup_opts, opts) |
| 69 | + return require('cosmic-ui.rename')(popup_opts, opts) |
15 | 70 | end |
16 | 71 |
|
17 | 72 | return M |
0 commit comments