From ad5b9e5496209bb33379aa25efbf4780d6595ce8 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 12 Mar 2024 12:55:15 +0800 Subject: [PATCH] feat(format): add layer option notify width and timeout --- autoload/SpaceVim/layers/format.vim | 16 ++++++++++++++++ bundle/neoformat/autoload/neoformat/utils.vim | 5 ++++- doc/SpaceVim.txt | 3 +++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/autoload/SpaceVim/layers/format.vim b/autoload/SpaceVim/layers/format.vim index f453e6d8b..c166d1874 100644 --- a/autoload/SpaceVim/layers/format.vim +++ b/autoload/SpaceVim/layers/format.vim @@ -18,6 +18,9 @@ " 2. `format_method`: set the format plugin, default plugin is `neoformat`. " You can also use `vim-codefmt`. " 3. `silent_format`: Runs the formatter without any messages. +" 4. `format_notify_width`: set the neoformat notify window width. +" 5. `format_notify_timeout`: set the neoformat notify clear timeout. default +" is 5000 milliseconds. " " @subsection key bindings " > @@ -33,6 +36,8 @@ else let s:format_on_save = 0 let s:silent_format = 0 let s:format_ft = [] + let s:format_notify_timeout = 5000 + let s:format_notify_width = &columns * 0.50 endif function! SpaceVim#layers#format#health() abort @@ -76,6 +81,17 @@ function! SpaceVim#layers#format#set_variable(var) abort let s:format_method = get(a:var, 'format_method', s:format_method) let s:format_on_save = get(a:var, 'format_on_save', s:format_on_save) let s:silent_format = get(a:var, 'silent_format', s:silent_format) + let s:format_notify_width = get(a:var, 'format_notify_width', s:format_notify_width) + let s:format_notify_timeout = get(a:var, 'format_notify_timeout', s:format_notify_timeout) +endfunction + +function! SpaceVim#layers#format#get_format_option() abort + + return { + \ 'format_notify_width' : s:format_notify_width, + \ 'format_notify_timeout' : s:format_notify_timeout, + \ } + endfunction function! SpaceVim#layers#format#get_options() abort diff --git a/bundle/neoformat/autoload/neoformat/utils.vim b/bundle/neoformat/autoload/neoformat/utils.vim index 3af4fdace..9bb6ca01c 100644 --- a/bundle/neoformat/autoload/neoformat/utils.vim +++ b/bundle/neoformat/autoload/neoformat/utils.vim @@ -8,8 +8,11 @@ let s:LOGGER =SpaceVim#logger#derive('neoformat') - let s:NT = SpaceVim#api#import('notify') +let s:formatopt = SpaceVim#layers#format#get_format_option() +let s:NT.notify_max_width = s:formatopt.format_notify_width +let s:NT.timeout = s:formatopt.format_notify_timeout + function! neoformat#utils#log(msg) abort call s:LOGGER.info(a:msg) diff --git a/doc/SpaceVim.txt b/doc/SpaceVim.txt index 43760966a..bf09fb04c 100644 --- a/doc/SpaceVim.txt +++ b/doc/SpaceVim.txt @@ -2233,6 +2233,9 @@ LAYER OPTIONS 2. `format_method`: set the format plugin, default plugin is `neoformat`. You can also use `vim-codefmt`. 3. `silent_format`: Runs the formatter without any messages. + 4. `format_notify_width`: set the neoformat notify window width. + 5. `format_notify_timeout`: set the neoformat notify clear timeout. default +is 5000 milliseconds. KEY BINDINGS