1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-03-14 10:45:42 +08:00

feat(logger): add syntax highlighting for runtime log

This commit is contained in:
Shidong Wang 2021-10-29 20:52:14 +08:00
parent b07f22875e
commit be7d6130d6
No known key found for this signature in database
GPG Key ID: 41BB7053E835C848
6 changed files with 20 additions and 10 deletions

View File

@ -543,6 +543,8 @@ function! SpaceVim#layers#core#statusline#get(...) abort
\ . '%#SpaceVim_statusline_b# %{SpaceVim#plugins#flygrep#lineNr()} %#SpaceVim_statusline_b_SpaceVim_statusline_z#' . s:lsep . ' ' \ . '%#SpaceVim_statusline_b# %{SpaceVim#plugins#flygrep#lineNr()} %#SpaceVim_statusline_b_SpaceVim_statusline_z#' . s:lsep . ' '
elseif &filetype ==# 'TransientState' elseif &filetype ==# 'TransientState'
return '%#SpaceVim_statusline_a# Transient State %#SpaceVim_statusline_a_SpaceVim_statusline_b#' return '%#SpaceVim_statusline_a# Transient State %#SpaceVim_statusline_a_SpaceVim_statusline_b#'
elseif &filetype ==# 'SpaceVimLog'
return '%#SpaceVim_statusline_a# SpaceVim Runtime log %#SpaceVim_statusline_a_SpaceVim_statusline_b#'
elseif &filetype ==# 'vimcalc' elseif &filetype ==# 'vimcalc'
return '%#SpaceVim_statusline_a#' . s:winnr() . ' VimCalc %#SpaceVim_statusline_a_SpaceVim_statusline_b#' return '%#SpaceVim_statusline_a#' . s:winnr() . ' VimCalc %#SpaceVim_statusline_a_SpaceVim_statusline_b#'
elseif &filetype ==# 'HelpDescribe' elseif &filetype ==# 'HelpDescribe'

View File

@ -87,11 +87,7 @@ else
function! SpaceVim#logger#viewRuntimeLog() abort function! SpaceVim#logger#viewRuntimeLog() abort
let info = "### SpaceVim runtime log :\n\n" let info = "### SpaceVim runtime log :\n\n"
let info .= "```log\n"
let info .= s:LOGGER.view(s:LOGGER.level) let info .= s:LOGGER.view(s:LOGGER.level)
let info .= "\n```\n"
tabnew +setl\ nobuflisted tabnew +setl\ nobuflisted
nnoremap <buffer><silent> q :tabclose!<CR> nnoremap <buffer><silent> q :tabclose!<CR>
for msg in split(info, "\n") for msg in split(info, "\n")
@ -100,6 +96,7 @@ else
normal! "_dd normal! "_dd
setl nomodifiable setl nomodifiable
setl buftype=nofile setl buftype=nofile
setl filetype=SpaceVimLog
endfunction endfunction

View File

@ -44,9 +44,7 @@ end
function M.viewRuntimeLog() function M.viewRuntimeLog()
local info = "### SpaceVim runtime log :\n\n" local info = "### SpaceVim runtime log :\n\n"
.. "```log\n"
.. logger.view(logger.level) .. logger.view(logger.level)
.. "\n```\n"
cmd('tabnew') cmd('tabnew')
cmd('setl nobuflisted') cmd('setl nobuflisted')
cmd('nnoremap <buffer><silent> q :tabclose!<CR>') cmd('nnoremap <buffer><silent> q :tabclose!<CR>')
@ -54,7 +52,7 @@ function M.viewRuntimeLog()
fn.append(0, fn.split(info, "\n")) fn.append(0, fn.split(info, "\n"))
cmd('setl nomodifiable') cmd('setl nomodifiable')
cmd('setl buftype=nofile') cmd('setl buftype=nofile')
-- cmd('setl filetype=markdown') cmd('setl filetype=SpaceVimLog')
-- M.syntax_extra() -- M.syntax_extra()
end end

13
syntax/SpaceVimLog.vim Normal file
View File

@ -0,0 +1,13 @@
if exists('b:current_syntax') && b:current_syntax ==# 'SpaceVimLog'
finish
endif
let b:current_syntax = 'SpaceVimLog'
syntax case ignore
syn match SPCLogHead /^###.*/
syn match SPCLogWarn /^.*\[ Warn ].*/
syn match SPCLogError /^.*\[ Error].*/
hi def link SPCLogHead TODO
hi def link SPCLogWarn WarningMsg
hi def link SPCLogError Error