diff --git a/lua/cosmic/core/pluginsInit.lua b/lua/cosmic/core/pluginsInit.lua index f795a7f..ec54e33 100644 --- a/lua/cosmic/core/pluginsInit.lua +++ b/lua/cosmic/core/pluginsInit.lua @@ -80,24 +80,20 @@ return packer.startup(function() require('cosmic.lsp') end, requires = { - { - 'ray-x/lsp_signature.nvim', - config = function() - -- must happen after servers are set up - require('lsp_signature').setup({ - bind = true, -- This is mandatory, otherwise border config won't get registered. - handler_opts = { - border = 'rounded', - }, - }) - end, - after = 'nvim-lspconfig', - }, { 'jose-elias-alvarez/nvim-lsp-ts-utils' }, { 'williamboman/nvim-lsp-installer' }, }, }) + use({ + 'CosmicNvim/cosmic-ui', + requires = { 'MunifTanjim/nui.nvim', 'nvim-lua/plenary.nvim', 'ray-x/lsp_signature.nvim' }, + config = function() + require('cosmic-ui').setup({}) + end, + after = 'nvim-lspconfig', + }) + use({ 'jose-elias-alvarez/null-ls.nvim', config = function() diff --git a/lua/cosmic/lsp/autocomplete.lua b/lua/cosmic/lsp/autocomplete.lua index a760f5e..9b70033 100644 --- a/lua/cosmic/lsp/autocomplete.lua +++ b/lua/cosmic/lsp/autocomplete.lua @@ -59,7 +59,7 @@ M.init = function() }), }, documentation = { - border = 'single', + border = 'rounded', winhighlight = 'FloatBorder:FloatBorder,Normal:Normal', }, experimental = { diff --git a/lua/cosmic/lsp/diagnostics.lua b/lua/cosmic/lsp/diagnostics.lua deleted file mode 100644 index 76b02d0..0000000 --- a/lua/cosmic/lsp/diagnostics.lua +++ /dev/null @@ -1,68 +0,0 @@ -local config = require('cosmic.config') -local icons = require('cosmic.theme.icons') - -local defaults = { - underline = true, - signs = true, - update_in_insert = false, - severity_sort = true, - float = { - header = false, - source = 'always', - border = 'single', - }, - virtual_text = { - spacing = 4, - source = 'always', - severity = { - min = vim.diagnostic.severity.HINT, - }, - -- todo: icons for diagnostics? - --[[ format = function(diagnostic) - if diagnostic.severity == vim.diagnostic.severity.ERROR then - return ('E: %s'):format(diagnostic.message) - end - return diagnostic.message - end, ]] - }, -} - -local opts = vim.tbl_deep_extend('force', defaults, config.lsp.diagnostic or {}) - -vim.diagnostic.config(opts) - -local function do_diagnostic_signs() - local signs = { - Error = icons.error .. ' ', - Warn = icons.warn .. ' ', - Hint = icons.hint .. ' ', - Info = icons.info .. ' ', - } - - local t = vim.fn.sign_getdefined('DiagnosticSignWarn') - if vim.tbl_isempty(t) then - for type, icon in pairs(signs) do - local hl = 'DiagnosticSign' .. type - vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = '' }) - end - end -end - -local function do_legacy_diagnostic_signs() - local signs = { - Error = icons.error .. ' ', - Warning = icons.warn .. ' ', - Hint = icons.hint .. ' ', - Information = icons.info .. ' ', - } - local h = vim.fn.sign_getdefined('LspDiagnosticsSignWarn') - if vim.tbl_isempty(h) then - for type, icon in pairs(signs) do - local hl = 'LspDiagnosticsSign' .. type - vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = '' }) - end - end -end - -do_diagnostic_signs() -do_legacy_diagnostic_signs() diff --git a/lua/cosmic/lsp/init.lua b/lua/cosmic/lsp/init.lua index 4905687..e3eca7c 100644 --- a/lua/cosmic/lsp/init.lua +++ b/lua/cosmic/lsp/init.lua @@ -1,7 +1,4 @@ -require('cosmic.lsp.providers') -require('cosmic.lsp.diagnostics') +-- local config = require('cosmic.config') -vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = 'single' }) -vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { - border = 'single', -}) +-- set up lsp servers +require('cosmic.lsp.providers') diff --git a/lua/cosmic/lsp/mappings.lua b/lua/cosmic/lsp/mappings.lua index 7283bf6..a07adf7 100644 --- a/lua/cosmic/lsp/mappings.lua +++ b/lua/cosmic/lsp/mappings.lua @@ -8,7 +8,7 @@ map('n', 'gD', 'lua vim.lsp.buf.declaration()') map('n', 'gi', 'lua require("telescope.builtin").lsp_implementations()') map('n', 'gt', 'lua require("telescope.builtin").lsp_type_definitions()') map('n', 'gr', 'lua require("telescope.builtin").lsp_references()') -map('n', 'gn', 'lua require("cosmic.theme.ui").rename()') +map('n', 'gn', 'lua require("cosmic-ui").rename()') -- diagnostics map('n', '[g', 'lua vim.diagnostic.goto_prev()') diff --git a/lua/cosmic/modules/statusline/init.lua b/lua/cosmic/modules/statusline/init.lua index 82b79d3..1aba5d6 100644 --- a/lua/cosmic/modules/statusline/init.lua +++ b/lua/cosmic/modules/statusline/init.lua @@ -5,7 +5,7 @@ local condition = require('galaxyline.condition') local fileinfo = require('galaxyline.providers.fileinfo') local utils = require('cosmic.utils') local colors = require('cosmic.theme.colors') -local highlight = utils.highlight +local highlight = require('cosmic.theme.highlight') local icons = require('cosmic.theme.icons') local config = require('cosmic.config') diff --git a/lua/cosmic/packer.lua b/lua/cosmic/packer.lua index 4a23f7d..ae4c722 100644 --- a/lua/cosmic/packer.lua +++ b/lua/cosmic/packer.lua @@ -33,9 +33,9 @@ end packer.init({ display = { open_fn = function() - return require('packer.util').float({ border = 'single' }) + return require('packer.util').float({ border = 'rounded' }) end, - prompt_border = 'single', + prompt_border = 'rounded', }, git = { clone_timeout = 800, -- Timeout, in seconds, for git clones diff --git a/lua/cosmic/theme/highlight.lua b/lua/cosmic/theme/highlight.lua new file mode 100644 index 0000000..6eb182a --- /dev/null +++ b/lua/cosmic/theme/highlight.lua @@ -0,0 +1,9 @@ +return function(group, bg, fg, gui) + if gui ~= nil and gui ~= '' then + vim.api.nvim_command(('hi %s guibg=%s guifg=%s gui=%s'):format(group, bg, fg, gui)) + elseif bg == nil then + vim.api.nvim_command(('hi %s guifg=%s'):format(group, fg)) + else + vim.api.nvim_command(('hi %s guibg=%s guifg=%s'):format(group, bg, fg)) + end +end diff --git a/lua/cosmic/theme/init.lua b/lua/cosmic/theme/init.lua index d3b2af5..94323b7 100644 --- a/lua/cosmic/theme/init.lua +++ b/lua/cosmic/theme/init.lua @@ -2,7 +2,7 @@ local _, colors = pcall(require, 'cosmic.theme.colors') if not colors then return end -local highlight = require('cosmic.utils').highlight +local highlight = require('cosmic.theme.highlight') -- diagnostic virtual text highlights highlight('DiagnosticVirtualTextError', 'None', colors.error) @@ -32,7 +32,7 @@ highlight('LspDiagnosticsSignInformation', 'None', colors.info) highlight('LspDiagnosticsSignHint', 'None', colors.hint) -- signature highlight color -highlight('LspSignatureActiveParameter', 'None', colors.orange) +-- highlight('LspSignatureActiveParameter', 'None', colors.orange) -- currently not working? highlight('TelescopeSelectionCaret', 'None', colors.selection_caret) diff --git a/lua/cosmic/theme/ui.lua b/lua/cosmic/theme/ui.lua deleted file mode 100644 index e5bb56f..0000000 --- a/lua/cosmic/theme/ui.lua +++ /dev/null @@ -1,99 +0,0 @@ -local M = {} - -local api = vim.api -local lsp = vim.lsp -local buf, win - -function M.rename() - local icons = require('cosmic.theme.icons') - local utils = require('cosmic.utils') - local config = require('cosmic.config') - local Logger = require('cosmic.utils.logger') - local highlight = utils.highlight - local prompt_str = ' ' .. icons.folder.arrow_closed .. ' ' - local map_opts = { noremap = true, silent = true } - local opts = { - style = 'minimal', - border = 'single', - relative = 'cursor', - width = 25, - height = 1, - row = 1, - col = 1, - } - buf, win = api.nvim_create_buf(false, true) - api.nvim_buf_set_option(buf, 'bufhidden', 'wipe') - - api.nvim_open_win(buf, true, opts) - api.nvim_win_set_option(win, 'scrolloff', 0) - api.nvim_win_set_option(win, 'sidescrolloff', 0) - api.nvim_buf_set_option(buf, 'modifiable', true) - api.nvim_buf_set_option(buf, 'buftype', 'prompt') - - local _, colors = pcall(require, 'cosmic.theme.colors') - if colors then - api.nvim_buf_add_highlight(buf, -1, 'LspRenamePrompt', 0, 0, #prompt_str) - highlight('LspRenamePrompt', 'None', colors.selection_caret) - end - - vim.fn.prompt_setprompt(buf, prompt_str) - - vim.api.nvim_command('startinsert!') - api.nvim_buf_set_keymap(buf, 'i', '', 'stopinsert q!', map_opts) - api.nvim_buf_set_keymap( - buf, - 'i', - '', - "stopinsert lua require('cosmic.theme.ui')._rename()", - map_opts - ) - - local function handler(...) - local result - local method - local err = select(1, ...) - local is_new = not select(4, ...) or type(select(4, ...)) ~= 'number' - if is_new then - method = select(3, ...).method - result = select(2, ...) - else - method = select(2, ...) - result = select(3, ...) - end - - if config.lsp.rename_notification then - if err then - Logger:error(("Error running LSP query '%s': %s"):format(method, err)) - return - end - - -- echo the resulting changes - local new_word = '' - if result and result.changes then - local msg = {} - for f, c in pairs(result.changes) do - new_word = c[1].newText - table.insert(msg, ('%d changes -> %s'):format(#c, utils.get_relative_path(f))) - end - local currName = vim.fn.expand('') - Logger:log(msg, { title = ('Rename: %s -> %s'):format(currName, new_word) }) - end - end - - vim.lsp.handlers[method](...) - end - - function M._rename() - local new_name = vim.trim(vim.fn.getline('.'):sub(5, -1)) - vim.cmd([[q!]]) - local params = lsp.util.make_position_params() - local curr_name = vim.fn.expand('') - if not (new_name and #new_name > 0) or new_name == curr_name then - return - end - params.newName = new_name - lsp.buf_request(0, 'textDocument/rename', params, handler) - end -end - -return M diff --git a/lua/cosmic/utils/init.lua b/lua/cosmic/utils/init.lua index e431322..ba71ac0 100644 --- a/lua/cosmic/utils/init.lua +++ b/lua/cosmic/utils/init.lua @@ -19,24 +19,6 @@ function M.split(str, sep) return res end -function M.highlight(group, bg, fg, gui) - if gui ~= nil and gui ~= '' then - vim.api.nvim_command(('hi %s guibg=%s guifg=%s gui=%s'):format(group, bg, fg, gui)) - elseif bg == nil then - vim.api.nvim_command(('hi %s guifg=%s'):format(group, fg)) - else - vim.api.nvim_command(('hi %s guibg=%s guifg=%s'):format(group, bg, fg)) - end -end - -function M.get_relative_path(file_path) - local plenary_path = require('plenary.path') - local parsed_path, _ = file_path:gsub('file://', '') - local path = plenary_path:new(parsed_path) - local relative_path = path:make_relative(vim.fn.getcwd()) - return './' .. relative_path -end - function M.get_active_lsp_client_names() local active_clients = vim.lsp.get_active_clients() local client_names = {}