From f7d9085a5f2294abe3535f5a808bcd228c0ed8cf Mon Sep 17 00:00:00 2001 From: Matt Leong Date: Wed, 27 Oct 2021 21:14:30 -0700 Subject: [PATCH] feat(config): toggle rename notification --- lua/cosmic/config/config.lua | 3 +++ lua/cosmic/config/init.lua | 1 + lua/cosmic/core/theme/ui.lua | 27 ++++++++++++++++----------- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/lua/cosmic/config/config.lua b/lua/cosmic/config/config.lua index 40997af..00bb2a2 100644 --- a/lua/cosmic/config/config.lua +++ b/lua/cosmic/config/config.lua @@ -13,6 +13,9 @@ config.lsp = { -- true/false or table of filetypes {'.ts', '.js',} format_on_save = true, + -- set to false to disable rename notification + rename_notification = false, + diagnostic = { -- disable diagnostic virtual text (see :h vim.diagnostic.config for all options) virtual_text = false, diff --git a/lua/cosmic/config/init.lua b/lua/cosmic/config/init.lua index 7d3b99f..efc8720 100644 --- a/lua/cosmic/config/init.lua +++ b/lua/cosmic/config/init.lua @@ -17,6 +17,7 @@ local default_config = { }, lsp = { format_on_save = true, -- true/false or table of filetypes {'.ts', '.js',} + rename_notification = true, diagnostic = { signs = true, update_in_insert = false, diff --git a/lua/cosmic/core/theme/ui.lua b/lua/cosmic/core/theme/ui.lua index c45a5e4..6e8b223 100644 --- a/lua/cosmic/core/theme/ui.lua +++ b/lua/cosmic/core/theme/ui.lua @@ -8,6 +8,7 @@ function M.rename() local colors = require('cosmic.core.theme.colors') local icons = require('cosmic.core.theme.icons') local utils = require('cosmic.utils') + local config = require('cosmic.config') local highlight = utils.highlight local prompt_str = ' ' .. icons.folder.arrow_closed .. ' ' local map_opts = { noremap = true, silent = true } @@ -55,19 +56,23 @@ function M.rename() 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 - local msg = '' - for f, c in pairs(result.changes) do - msg = msg .. ('%d changes -> %s'):format(#c, utils.get_relative_path(f)) .. '\n' + + if config.lsp.rename_notification then + 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 + local msg = '' + for f, c in pairs(result.changes) do + msg = msg .. ('%d changes -> %s'):format(#c, utils.get_relative_path(f)) .. '\n' + end + msg = msg:sub(1, #msg - 1) + vim.notify(msg, vim.log.levels.INFO) end - msg = msg:sub(1, #msg - 1) - vim.notify(msg, vim.log.levels.INFO) end + vim.lsp.handlers[method](...) end