diff options
| author | jdhao <jdhao@hotmail.com> | 2021-10-18 22:32:38 +0800 |
|---|---|---|
| committer | jdhao <jdhao@hotmail.com> | 2021-10-18 22:32:38 +0800 |
| commit | 646453939941d92b077af56ce1d40793120bf97a (patch) | |
| tree | 6911802748db0288dfc9b898cc958bbd13e5aea5 | |
| parent | 30ca579ee9eeb38bc759007fc3d16e52b0e43d3e (diff) | |
nvim-notify update
| -rw-r--r-- | autoload/buf_utils.vim | 2 | ||||
| -rw-r--r-- | core/autocommands.vim | 4 | ||||
| -rw-r--r-- | core/mappings.vim | 2 | ||||
| -rw-r--r-- | core/ui.vim | 5 | ||||
| -rw-r--r-- | lua/config/lsp.lua | 3 | ||||
| -rw-r--r-- | lua/config/nvim-notify.lua | 9 | ||||
| -rw-r--r-- | lua/plugins.lua | 2 |
7 files changed, 18 insertions, 9 deletions
diff --git a/autoload/buf_utils.vim b/autoload/buf_utils.vim index a9e58b6..37e7a75 100644 --- a/autoload/buf_utils.vim +++ b/autoload/buf_utils.vim @@ -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 " 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. - 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 endif diff --git a/core/autocommands.vim b/core/autocommands.vim index 34a45a6..852f745 100644 --- a/core/autocommands.vim +++ b/core/autocommands.vim @@ -33,7 +33,7 @@ augroup END augroup non_utf8_file_warn autocmd! " 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 " 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. augroup auto_read 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 augroup END diff --git a/core/mappings.vim b/core/mappings.vim index d973ac0..82ba59a 100644 --- a/core/mappings.vim +++ b/core/mappings.vim @@ -104,7 +104,7 @@ inoremap <expr> <s-tab> pumvisible() ? "\<c-p>" : "\<s-tab>" " Edit and reload init.vim quickly 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> - \ 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. nnoremap <expr> <leader>v printf('`[%s`]', getregtype()[0]) diff --git a/core/ui.vim b/core/ui.vim index 9af4743..415b927 100644 --- a/core/ui.vim +++ b/core/ui.vim @@ -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) 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 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 "}} "} diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua index f65eb9e..58a5324 100644 --- a/lua/config/lsp.lua +++ b/lua/config/lsp.lua @@ -62,8 +62,7 @@ local custom_attach = function(client, bufnr) end local msg = string.format("Language server %s started!", client.name) - vim.api.nvim_echo({ { msg, "MoreMsg" } }, false, {}) - -- vim.notify(msg, 'info', {title = 'Nvim-config', timeout = 2500}) + vim.notify(msg, 'info', {title = 'Nvim-config'}) end capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) diff --git a/lua/config/nvim-notify.lua b/lua/config/nvim-notify.lua new file mode 100644 index 0000000..9ad874d --- /dev/null +++ b/lua/config/nvim-notify.lua @@ -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 diff --git a/lua/plugins.lua b/lua/plugins.lua index 4d20175..a2dcd3d 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -132,7 +132,7 @@ require("packer").startup({ use({"itchyny/vim-highlighturl", event = "VimEnter"}) -- 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 -- not be possible since we maybe in a server which disables GUI. |
