1
0
mirror of https://github.com/jdhao/nvim-config.git synced 2025-06-08 14:14:33 +02:00

nvim-notify update

This commit is contained in:
jdhao 2021-10-18 22:32:38 +08:00
parent 30ca579ee9
commit 6464539399
7 changed files with 18 additions and 9 deletions

View File

@ -15,7 +15,7 @@ function! buf_utils#GoToBuffer(count, direction) abort
" we are essentially mixing Lua and vim script. We need to make sure that " we are essentially mixing Lua and vim script. We need to make sure that
" args inside vim.notify() are valid vim values. The conversion from vim " args inside vim.notify() are valid vim values. The conversion from vim
" value to lua value will be done by Nvim. See also https://github.com/neovim/neovim/pull/11338. " value to lua value will be done by Nvim. See also https://github.com/neovim/neovim/pull/11338.
call v:lua.vim.notify('Invalid bufnr: ' . a:count, 'error', {'title': 'nvim-config', 'timeout': 2500}) call v:lua.vim.notify('Invalid bufnr: ' . a:count, 'error', {'title': 'nvim-config'})
return return
endif endif

View File

@ -33,7 +33,7 @@ augroup END
augroup non_utf8_file_warn augroup non_utf8_file_warn
autocmd! autocmd!
" we can not use `lua vim.notify()`: it will error out E5107 parsing lua. " we can not use `lua vim.notify()`: it will error out E5107 parsing lua.
autocmd BufRead * if &fileencoding != 'utf-8' | call v:lua.vim.notify('File not in UTF-8 format!', 'warn', {'title': 'nvim-config', 'timeout': 2500}) | endif autocmd BufRead * if &fileencoding != 'utf-8' | call v:lua.vim.notify('File not in UTF-8 format!', 'warn', {'title': 'nvim-config'}) | endif
augroup END augroup END
" Automatically reload the file if it is changed outside of Nvim, see " Automatically reload the file if it is changed outside of Nvim, see
@ -43,7 +43,7 @@ augroup END
" https://vi.stackexchange.com/a/20397/15292. " https://vi.stackexchange.com/a/20397/15292.
augroup auto_read augroup auto_read
autocmd! autocmd!
autocmd FileChangedShellPost * call v:lua.vim.notify("File changed on disk. Buffer reloaded!", 'warn', {'title': 'nvim-config', 'timeout': 2500}) autocmd FileChangedShellPost * call v:lua.vim.notify("File changed on disk. Buffer reloaded!", 'warn', {'title': 'nvim-config'})
autocmd FocusGained,CursorHold * if getcmdwintype() == '' | checktime | endif autocmd FocusGained,CursorHold * if getcmdwintype() == '' | checktime | endif
augroup END augroup END

View File

@ -104,7 +104,7 @@ inoremap <expr> <s-tab> pumvisible() ? "\<c-p>" : "\<s-tab>"
" Edit and reload init.vim quickly " Edit and reload init.vim quickly
nnoremap <silent> <leader>ev :<C-U>tabnew $MYVIMRC <bar> tcd %:h<cr> nnoremap <silent> <leader>ev :<C-U>tabnew $MYVIMRC <bar> tcd %:h<cr>
nnoremap <silent> <leader>sv :<C-U>silent update $MYVIMRC <bar> source $MYVIMRC <bar> nnoremap <silent> <leader>sv :<C-U>silent update $MYVIMRC <bar> source $MYVIMRC <bar>
\ call v:lua.vim.notify("Nvim config successfully reloaded!", 'info', {'title': 'nvim-config', 'timeout': 2500})<cr> \ call v:lua.vim.notify("Nvim config successfully reloaded!", 'info', {'title': 'nvim-config'})<cr>
" Reselect the text that has just been pasted, see also https://stackoverflow.com/a/4317090/6064933. " Reselect the text that has just been pasted, see also https://stackoverflow.com/a/4317090/6064933.
nnoremap <expr> <leader>v printf('`[%s`]', getregtype()[0]) nnoremap <expr> <leader>v printf('`[%s`]', getregtype()[0])

View File

@ -91,10 +91,11 @@ let s:colorscheme_func = printf('s:my_theme_dict.%s()', s:theme)
if has_key(s:my_theme_dict, s:theme) if has_key(s:my_theme_dict, s:theme)
execute 'call ' . s:colorscheme_func execute 'call ' . s:colorscheme_func
echomsg "Currently loaded theme:" s:theme let s:msg1 = "Currently loaded theme: " . s:theme
call v:lua.vim.notify(s:msg1, 'info', {'title': 'nvim-config'})
else else
let s:msg = "Invalid colorscheme function: " . s:colorscheme_func let s:msg = "Invalid colorscheme function: " . s:colorscheme_func
call v:lua.vim.notify(s:msg, 'error', {'title': 'nvim-config', 'timeout': 2500}) call v:lua.vim.notify(s:msg, 'error', {'title': 'nvim-config'})
endif endif
"}} "}}
"} "}

View File

@ -62,8 +62,7 @@ local custom_attach = function(client, bufnr)
end end
local msg = string.format("Language server %s started!", client.name) local msg = string.format("Language server %s started!", client.name)
vim.api.nvim_echo({ { msg, "MoreMsg" } }, false, {}) vim.notify(msg, 'info', {title = 'Nvim-config'})
-- vim.notify(msg, 'info', {title = 'Nvim-config', timeout = 2500})
end end
capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())

View File

@ -0,0 +1,9 @@
local nvim_notify = require("notify")
nvim_notify.setup({
-- Animation style
stages = "fade_in_slide_out",
-- Default timeout for notifications
timeout = 1500,
})
vim.notify = nvim_notify

View File

@ -132,7 +132,7 @@ require("packer").startup({
use({"itchyny/vim-highlighturl", event = "VimEnter"}) use({"itchyny/vim-highlighturl", event = "VimEnter"})
-- notification plugin -- notification plugin
use({ "rcarriga/nvim-notify", event = "VimEnter", config = 'vim.notify = require("notify")' }) use({ "rcarriga/nvim-notify", event = "BufEnter", config = [[require('config.nvim-notify')]] })
-- For Windows and Mac, we can open an URL in the browser. For Linux, it may -- For Windows and Mac, we can open an URL in the browser. For Linux, it may
-- not be possible since we maybe in a server which disables GUI. -- not be possible since we maybe in a server which disables GUI.