feat(config): toggle rename notification

This commit is contained in:
Matt Leong 2021-10-27 21:14:30 -07:00
parent 6aa3e10931
commit f7d9085a5f
3 changed files with 20 additions and 11 deletions

View file

@ -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,

View file

@ -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,

View file

@ -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