diff --git a/lua/cosmic/core/theme/colors.lua b/lua/cosmic/core/theme/colors.lua index 429151e..1f21d60 100644 --- a/lua/cosmic/core/theme/colors.lua +++ b/lua/cosmic/core/theme/colors.lua @@ -7,6 +7,7 @@ local colors = { blue = themeColors.blue, purple = themeColors.magenta, orange = themeColors.orange, + trace = themeColors.orange, hint = themeColors.teal, red = themeColors.red, diffAdd = themeColors.git.add, diff --git a/lua/cosmic/core/theme/highlights.lua b/lua/cosmic/core/theme/highlights.lua index dc09356..e52c7a4 100644 --- a/lua/cosmic/core/theme/highlights.lua +++ b/lua/cosmic/core/theme/highlights.lua @@ -37,6 +37,20 @@ highlight('TelescopeSelectionCaret', 'None', colors.selection_caret) -- autocomplete highlights highlight('CmpItemAbbrDeprecated', 'None', colors.warn) +-- notification highlights +highlight('NotifyINFOBorder', nil, colors.hint) +highlight('NotifyINFOTitle', nil, colors.hint) +highlight('NotifyINFOIcon', nil, colors.hint) +highlight('NotifyWARNBorder', nil, colors.warn) +highlight('NotifyWARNTitle', nil, colors.warn) +highlight('NotifyWARNIcon', nil, colors.warn) +highlight('NotifyERRORBorder', nil, colors.error) +highlight('NotifyERRORTitle', nil, colors.error) +highlight('NotifyERRORIcon', nil, colors.error) +highlight('NotifyTRACEBorder', nil, colors.trace) +highlight('NotifyTRACETitle', nil, colors.trace) +highlight('NotifyTRACEIcon', nil, colors.trace) + vim.cmd([[ highlight clear NormalFloat highlight link NormalFloat Normal diff --git a/lua/cosmic/core/theme/icons.lua b/lua/cosmic/core/theme/icons.lua index 47e0cdb..f0dab12 100644 --- a/lua/cosmic/core/theme/icons.lua +++ b/lua/cosmic/core/theme/icons.lua @@ -16,6 +16,8 @@ local icons = { information = '', symlink = '', line_number = '', + debug = '', + trace = '✎', git = { unstaged = '✗', staged = '✓', diff --git a/lua/cosmic/core/theme/ui.lua b/lua/cosmic/core/theme/ui.lua index bccc7de..9a0ac55 100644 --- a/lua/cosmic/core/theme/ui.lua +++ b/lua/cosmic/core/theme/ui.lua @@ -1,14 +1,15 @@ -local colors = require('cosmic.core.theme.colors') -local icons = require('cosmic.core.theme.icons') -local highlight = require('cosmic.utils').highlight local M = {} local api = vim.api local lsp = vim.lsp local buf, win -local prompt_str = ' ' .. icons.folder.arrow_closed .. ' ' function M.rename() + local colors = require('cosmic.core.theme.colors') + local icons = require('cosmic.core.theme.icons') + local utils = require('cosmic.utils') + local highlight = utils.highlight + local prompt_str = ' ' .. icons.folder.arrow_closed .. ' ' local map_opts = { noremap = true, silent = true } local opts = { style = 'minimal', @@ -27,7 +28,7 @@ function M.rename() api.nvim_win_set_option(win, 'sidescrolloff', 0) api.nvim_buf_set_option(buf, 'modifiable', true) api.nvim_buf_set_option(buf, 'buftype', 'prompt') - api.nvim_buf_add_highlight(buf, -1, "LspRenamePrompt", 0, 0, #prompt_str) + api.nvim_buf_add_highlight(buf, -1, 'LspRenamePrompt', 0, 0, #prompt_str) highlight('LspRenamePrompt', 'None', colors.selection_caret) vim.fn.prompt_setprompt(buf, prompt_str) @@ -42,6 +43,31 @@ function M.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 err then + vim.notify(("Error running LSP query '%s': %s"):format(method, err), vim.log.levels.ERROR) + return + end + -- echo the resulting changes + if result and result.changes then + for f, c in pairs(result.changes) do + vim.notify(('%d changes -> %s'):format(#c, utils.get_relative_path(f)), vim.log.levels.INFO) + end + end + vim.lsp.handlers[method](...) + end + function M._rename() local newName = vim.trim(vim.fn.getline('.'):sub(5, -1)) vim.cmd([[q!]]) @@ -51,7 +77,7 @@ function M.rename() return end params.newName = newName - lsp.buf_request(0, 'textDocument/rename', params) + lsp.buf_request(0, 'textDocument/rename', params, handler) end end diff --git a/lua/cosmic/pluginsInit.lua b/lua/cosmic/pluginsInit.lua index 04aebb7..f3753de 100644 --- a/lua/cosmic/pluginsInit.lua +++ b/lua/cosmic/pluginsInit.lua @@ -37,6 +37,24 @@ return packer.startup(function() end, }) + use({ + 'rcarriga/nvim-notify', + config = function() + local icons = require('cosmic.core.theme.icons') + require('notify').setup({ + icons = { + ERROR = icons.error, + WARN = icons.warn, + INFO = icons.info, + DEBUG = icons.debug, + TRACE = icons.trace, + }, + }) + vim.notify = require('notify') + end, + disable = vim.tbl_contains(user_plugins.disable, 'notify'), + }) + use({ -- color scheme 'folke/tokyonight.nvim', config = function() diff --git a/lua/cosmic/utils.lua b/lua/cosmic/utils.lua index 26aae31..36f459f 100644 --- a/lua/cosmic/utils.lua +++ b/lua/cosmic/utils.lua @@ -35,9 +35,30 @@ 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(path) + local split_path = M.split(path, '/') + local split_cwd = M.split(vim.fn.getcwd(), '/') + local curr_dir = split_cwd[#split_cwd] + local nice_path = '' + + local ok = false + for _, dir in ipairs(split_path) do + if dir == curr_dir then + ok = true + end + if ok then + nice_path = nice_path .. '/' .. dir + end + end + + return '.' .. nice_path +end + return M