Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
quintin
NVCode
提交
352e8893
N
NVCode
项目概览
quintin
/
NVCode
上一次同步 9 个月
通知
2
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
NVCode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
352e8893
编写于
4月 17, 2023
作者:
Q
quintin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
✨
feat(notify): add vim-notify plugin
上级
2bb3bb31
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
108 addition
and
0 deletion
+108
-0
init.lua
init.lua
+1
-0
lua/configs/vim-notify.lua
lua/configs/vim-notify.lua
+104
-0
lua/core/plugins.lua
lua/core/plugins.lua
+3
-0
未找到文件。
init.lua
浏览文件 @
352e8893
...
...
@@ -24,6 +24,7 @@ require('configs.git-blame-virt')
require
(
'configs.goto-preview'
)
require
(
'configs.wilder'
)
require
(
'configs.tabnine'
)
require
(
'configs.vim-notify'
)
-- 主题配置
require
(
'core.theme'
)
...
...
lua/configs/vim-notify.lua
0 → 100644
浏览文件 @
352e8893
vim
.
notify
=
require
(
"notify"
)
require
(
"notify"
).
setup
({
background_color
=
"#000000"
,
})
-- Utility functions shared between progress reports for LSP and DAP
local
client_notifs
=
{}
local
function
get_notif_data
(
client_id
,
token
)
if
not
client_notifs
[
client_id
]
then
client_notifs
[
client_id
]
=
{}
end
if
not
client_notifs
[
client_id
][
token
]
then
client_notifs
[
client_id
][
token
]
=
{}
end
return
client_notifs
[
client_id
][
token
]
end
local
spinner_frames
=
{
"⣾"
,
"⣽"
,
"⣻"
,
"⢿"
,
"⡿"
,
"⣟"
,
"⣯"
,
"⣷"
}
local
function
update_spinner
(
client_id
,
token
)
local
notif_data
=
get_notif_data
(
client_id
,
token
)
if
notif_data
.
spinner
then
local
new_spinner
=
(
notif_data
.
spinner
+
1
)
%
#
spinner_frames
notif_data
.
spinner
=
new_spinner
notif_data
.
notification
=
vim
.
notify
(
nil
,
nil
,
{
hide_from_history
=
true
,
icon
=
spinner_frames
[
new_spinner
],
replace
=
notif_data
.
notification
,
})
vim
.
defer_fn
(
function
()
update_spinner
(
client_id
,
token
)
end
,
100
)
end
end
local
function
format_title
(
title
,
client_name
)
return
client_name
..
(
#
title
>
0
and
": "
..
title
or
""
)
end
local
function
format_message
(
message
,
percentage
)
return
(
percentage
and
percentage
..
"%\t"
or
""
)
..
(
message
or
""
)
end
-- LSP integration
-- Make sure to also have the snippet with the common helper functions in your config!
vim
.
lsp
.
handlers
[
"$/progress"
]
=
function
(
_
,
result
,
ctx
)
local
client_id
=
ctx
.
client_id
local
val
=
result
.
value
if
not
val
.
kind
then
return
end
local
notif_data
=
get_notif_data
(
client_id
,
result
.
token
)
if
val
.
kind
==
"begin"
then
local
message
=
format_message
(
val
.
message
,
val
.
percentage
)
notif_data
.
notification
=
vim
.
notify
(
message
,
"info"
,
{
title
=
format_title
(
val
.
title
,
vim
.
lsp
.
get_client_by_id
(
client_id
).
name
),
icon
=
spinner_frames
[
1
],
timeout
=
false
,
hide_from_history
=
false
,
})
notif_data
.
spinner
=
1
update_spinner
(
client_id
,
result
.
token
)
elseif
val
.
kind
==
"report"
and
notif_data
then
notif_data
.
notification
=
vim
.
notify
(
format_message
(
val
.
message
,
val
.
percentage
),
"info"
,
{
replace
=
notif_data
.
notification
,
hide_from_history
=
false
,
})
elseif
val
.
kind
==
"end"
and
notif_data
then
notif_data
.
notification
=
vim
.
notify
(
val
.
message
and
format_message
(
val
.
message
)
or
"Complete"
,
"info"
,
{
icon
=
""
,
replace
=
notif_data
.
notification
,
timeout
=
3000
,
})
notif_data
.
spinner
=
nil
end
end
-- table from lsp severity to vim severity.
local
severity
=
{
"error"
,
"warn"
,
"info"
,
"info"
,
-- map both hint and info to info?
}
vim
.
lsp
.
handlers
[
"window/showMessage"
]
=
function
(
err
,
method
,
params
,
client_id
)
vim
.
notify
(
method
.
message
,
severity
[
params
.
type
])
end
lua/core/plugins.lua
浏览文件 @
352e8893
...
...
@@ -204,6 +204,9 @@ return require('packer').startup({ function()
ft
=
'qf'
}
-- 美化消息通知
use
'rcarriga/nvim-notify'
-- Automatically set up your configuration after cloning packer.nvim
-- Put this at the end after all plugins
if
packer_bootstrap
then
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录