1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 12:50:04 +08:00

perf(statusline): improve syntax info color

This commit is contained in:
Eric Wong 2024-05-27 19:51:13 +08:00
parent 6d7ebe6891
commit 87f7eca4c5
3 changed files with 36 additions and 7 deletions

View File

@ -258,11 +258,20 @@ endfunction
function! s:syntax_checking() abort function! s:syntax_checking() abort
if SpaceVim#lsp#buf_server_ready() if SpaceVim#lsp#buf_server_ready()
let counts = v:lua.require('spacevim.lsp').lsp_diagnostic_count() let counts = v:lua.require('spacevim.lsp').lsp_diagnostic_count()
let warnings = get(counts, 1, 0)
let errors = get(counts, 0, 0) let errors = get(counts, 0, 0)
let l = warnings ? '%#SpaceVim_statusline_warn# ● ' . warnings . ' ' : '' let warnings = get(counts, 1, 0)
let l .= errors ? (warnings ? '' : ' ') . '%#SpaceVim_statusline_error#● ' . errors . ' ' : '' let infos = get(counts, 2, 0)
return l let hints = get(counts, 3, 0)
let errors_l = errors ? '%#SpaceVim_statusline_error#● ' . errors : ''
let warnings_l = warnings ? '%#SpaceVim_statusline_warn#● ' . warnings : ''
let infos_l = infos ? '%#SpaceVim_statusline_info#● ' . infos : ''
let hints_l = hints ? '%#SpaceVim_statusline_hint#● ' . hints : ''
let l = join(filter([errors_l, warnings_l, infos_l, hints_l], 'v:val != ""'), ' ')
if !empty(l)
return ' ' . l . ' '
else
return ''
endif
elseif g:spacevim_lint_engine ==# 'neomake' elseif g:spacevim_lint_engine ==# 'neomake'
if !exists('g:loaded_neomake') if !exists('g:loaded_neomake')
return '' return ''
@ -736,8 +745,10 @@ function! SpaceVim#layers#core#statusline#def_colors() abort
exe 'hi! SpaceVim_statusline_b ctermbg=' . t[1][2] . ' ctermfg=' . t[1][3] . ' guibg=' . t[1][1] . ' guifg=' . t[1][0] exe 'hi! SpaceVim_statusline_b ctermbg=' . t[1][2] . ' ctermfg=' . t[1][3] . ' guibg=' . t[1][1] . ' guifg=' . t[1][0]
exe 'hi! SpaceVim_statusline_c ctermbg=' . t[2][2] . ' ctermfg=' . t[2][3] . ' guibg=' . t[2][1] . ' guifg=' . t[2][0] exe 'hi! SpaceVim_statusline_c ctermbg=' . t[2][2] . ' ctermfg=' . t[2][3] . ' guibg=' . t[2][1] . ' guifg=' . t[2][0]
exe 'hi! SpaceVim_statusline_z ctermbg=' . t[3][1] . ' ctermfg=' . t[2][2] . ' guibg=' . t[3][0] . ' guifg=' . t[2][0] exe 'hi! SpaceVim_statusline_z ctermbg=' . t[3][1] . ' ctermfg=' . t[2][2] . ' guibg=' . t[3][0] . ' guifg=' . t[2][0]
exe 'hi! SpaceVim_statusline_error ctermbg=' . t[1][2] . ' ctermfg=Black guibg=' . t[1][1] . ' guifg=#fb4934 gui=bold' exe 'hi! SpaceVim_statusline_error ctermbg=' . t[1][2] . ' ctermfg=Black guibg=' . t[1][1] . ' guifg=#ffc0b9 gui=bold'
exe 'hi! SpaceVim_statusline_warn ctermbg=' . t[1][2] . ' ctermfg=Black guibg=' . t[1][1] . ' guifg=#fabd2f gui=bold' exe 'hi! SpaceVim_statusline_warn ctermbg=' . t[1][2] . ' ctermfg=Black guibg=' . t[1][1] . ' guifg=#fce094 gui=bold'
exe 'hi! SpaceVim_statusline_info ctermbg=' . t[1][2] . ' ctermfg=Black guibg=' . t[1][1] . ' guifg=#8cf8f7 gui=bold'
exe 'hi! SpaceVim_statusline_hint ctermbg=' . t[1][2] . ' ctermfg=Black guibg=' . t[1][1] . ' guifg=#a6dbff gui=bold'
call s:HI.hi_separator('SpaceVim_statusline_a', 'SpaceVim_statusline_b') call s:HI.hi_separator('SpaceVim_statusline_a', 'SpaceVim_statusline_b')
call s:HI.hi_separator('SpaceVim_statusline_a_bold', 'SpaceVim_statusline_b') call s:HI.hi_separator('SpaceVim_statusline_a_bold', 'SpaceVim_statusline_b')
call s:HI.hi_separator('SpaceVim_statusline_ia', 'SpaceVim_statusline_b') call s:HI.hi_separator('SpaceVim_statusline_ia', 'SpaceVim_statusline_b')

View File

@ -591,6 +591,15 @@ SpaceVim 默认使用 `nerd fonts`,可参阅其安装指南进行安装。
状态栏中语法检查信息元素如果被启用了,当语法检查结束后,会在状态栏中展示当前语法错误和警告的数量。 状态栏中语法检查信息元素如果被启用了,当语法检查结束后,会在状态栏中展示当前语法错误和警告的数量。
错误及警告的默认高亮组名称及颜色为:
| 高亮组名称 | 颜色 |
| --------------------------- | --------- |
| `SpaceVim_statusline_error` | `#ffc0b9` |
| `SpaceVim_statusline_warn` | `#fce094` |
| `SpaceVim_statusline_info` | `#8cf8f7` |
| `SpaceVim_statusline_hint` | `#a6dbff` |
**搜索结果信息:** **搜索结果信息:**
当使用 `/``?` 进行搜索时,或当按下 `n``N` 后,搜索结果序号将被展示在状态栏中,使用类似于 `20/22` 这样的分数显示搜索结果的当前序号以及结果总数。具体的效果图如下: 当使用 `/``?` 进行搜索时,或当按下 `n``N` 后,搜索结果序号将被展示在状态栏中,使用类似于 `20/22` 这样的分数显示搜索结果的当前序号以及结果总数。具体的效果图如下:

View File

@ -102,7 +102,7 @@ description: "General documentation about how to use SpaceVim, including the qui
- **Great documentation:** Everything is documented in `:h SpaceVim`. - **Great documentation:** Everything is documented in `:h SpaceVim`.
- **Better experience:** Most of the core plugins have been rewritten using Lua. - **Better experience:** Most of the core plugins have been rewritten using Lua.
- **Beautiful UI:** The interface has been carefully designed. - **Beautiful UI:** The interface has been carefully designed.
- **Mnemonic key bindings:** Key bindings are organized using mnemonic prefixes. - **Mnemonic key bindings:** Key bindings are organized using mnemonic prefixes.
- **Lower the risk of RSI:** Heavily using the `<Space>` key instead of modifiers. - **Lower the risk of RSI:** Heavily using the `<Space>` key instead of modifiers.
## Screenshots ## Screenshots
@ -635,6 +635,15 @@ By default SpaceVim uses nerd-fonts, which can be downloaded from their [website
When syntax checking major mode is enabled, a new element appears showing the number of errors and warnings. When syntax checking major mode is enabled, a new element appears showing the number of errors and warnings.
The default highlight group and colors are:
| highlight group | color |
| --------------------------- | --------- |
| `SpaceVim_statusline_error` | `#ffc0b9` |
| `SpaceVim_statusline_warn` | `#fce094` |
| `SpaceVim_statusline_info` | `#8cf8f7` |
| `SpaceVim_statusline_hint` | `#a6dbff` |
**Search index integration:** **Search index integration:**
Search index shows the number of occurrences when performing a search via `/` or `?`. Search index shows the number of occurrences when performing a search via `/` or `?`.