From a7fbecfd35abc380752cd3c6eb0e11b7c0d24a25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Sen=C3=ADn?= Date: Tue, 24 Jan 2017 11:06:53 +0100 Subject: [PATCH 1/8] Avoid to use black color with molokai colorscheme Due to using black color to colorize some words over grey background I needed to avoid black color to see this text. I'm not sure why number 6 is black using cterm colors, so I had forced to use from 8 to 30 colors and works fine now for me --- plugin/semhl.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/semhl.vim b/plugin/semhl.vim index 8c094ef..e231aea 100644 --- a/plugin/semhl.vim +++ b/plugin/semhl.vim @@ -15,7 +15,7 @@ endif " Set defaults for colors let s:semanticGUIColors = ["#9CD8F7", "#F5FA1D", "#F97C65", "#35D27F", "#EB75D6", "#E5D180", "#8997F5", "#D49DA5", "#7FEC35", "#F6B223", "#B4F1C3", "#99B730", "#F67C1B", "#3AC6BE", "#EAAFF1", "#DE9A4E", "#BBEA87", "#EEF06D", "#8FB272", "#EAA481", "#F58AAE", "#80B09B", "#5DE866", "#B5A5C5", "#88ADE6", "#4DAABD", "#EDD528", "#FA6BB2", "#47F2D4", "#F47F86", "#2ED8FF", "#B8E01C", "#C5A127", "#74BB46", "#D386F1", "#97DFD6", "#B1A96F", "#66BB75", "#97AA49", "#EF874A", "#48EDF0", "#C0AE50", "#89AAB6", "#D7D1EB", "#5EB894", "#57F0AC", "#B5AF1B", "#B7A5F0", "#8BE289", "#D38AC6", "#C8EE63", "#ED9C36", "#85BA5F", "#9DEA74", "#85C52D", "#40B7E5", "#EEA3C2", "#7CE9B6", "#8CEC58", "#D8A66C", "#51C03B", "#C4CE64", "#45E648", "#4DC15E", "#63A5F3", "#EA8C66", "#D2D43E", "#E5BCE8", "#E4B7CB", "#B092F4", "#44C58C", "#D1E998", "#76E4F2", "#E19392", "#A8E5A4", "#BF9FD6", "#E8C25B", "#58F596", "#6BAEAC", "#94C291", "#7EF1DB", "#E8D65C", "#A7EA38", "#D38AE0", "#ECF453", "#5CD8B8", "#B6BF6B", "#BEE1F1", "#B1D43E", "#EBE77B", "#84A5CD", "#CFEF7A", "#A3C557", "#E4BB34", "#ECB151", "#BDC9F2", "#5EB0E9", "#E09764", "#9BE3C8", "#B3ADDC", "#B2AC36", "#C8CD4F", "#C797AF", "#DCDB26", "#BCA85E", "#E495A5", "#F37DB8", "#70C0B1", "#5AED7D", "#E49482", "#8AA1F0", "#B3EDEE", "#DAEE34", "#EBD646", "#ECA2D2", "#A0A7E6", "#3EBFD3", "#C098BF", "#F1882E", "#77BFDF", "#7FBFC7", "#D4951F", "#A5C0D0", "#B892DE", "#F8CB31", "#75D0D9", "#A6A0B4", "#EA98E4", "#F38BE6", "#DC83A4"] -let s:semanticTermColors = range(20) +let s:semanticTermColors = range(8,30) " The user can change the GUI/Term colors, but cannot directly access the list of colors we use " If the user overrode the default in their vimrc, use that From ef0959a3e162624c8a3a946834a1038e754ed666 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Sen=C3=ADn?= Date: Tue, 24 Jan 2017 11:42:35 +0100 Subject: [PATCH 2/8] better color set with cterm I like this color set --- plugin/semhl.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/semhl.vim b/plugin/semhl.vim index e231aea..568fbfe 100644 --- a/plugin/semhl.vim +++ b/plugin/semhl.vim @@ -15,7 +15,7 @@ endif " Set defaults for colors let s:semanticGUIColors = ["#9CD8F7", "#F5FA1D", "#F97C65", "#35D27F", "#EB75D6", "#E5D180", "#8997F5", "#D49DA5", "#7FEC35", "#F6B223", "#B4F1C3", "#99B730", "#F67C1B", "#3AC6BE", "#EAAFF1", "#DE9A4E", "#BBEA87", "#EEF06D", "#8FB272", "#EAA481", "#F58AAE", "#80B09B", "#5DE866", "#B5A5C5", "#88ADE6", "#4DAABD", "#EDD528", "#FA6BB2", "#47F2D4", "#F47F86", "#2ED8FF", "#B8E01C", "#C5A127", "#74BB46", "#D386F1", "#97DFD6", "#B1A96F", "#66BB75", "#97AA49", "#EF874A", "#48EDF0", "#C0AE50", "#89AAB6", "#D7D1EB", "#5EB894", "#57F0AC", "#B5AF1B", "#B7A5F0", "#8BE289", "#D38AC6", "#C8EE63", "#ED9C36", "#85BA5F", "#9DEA74", "#85C52D", "#40B7E5", "#EEA3C2", "#7CE9B6", "#8CEC58", "#D8A66C", "#51C03B", "#C4CE64", "#45E648", "#4DC15E", "#63A5F3", "#EA8C66", "#D2D43E", "#E5BCE8", "#E4B7CB", "#B092F4", "#44C58C", "#D1E998", "#76E4F2", "#E19392", "#A8E5A4", "#BF9FD6", "#E8C25B", "#58F596", "#6BAEAC", "#94C291", "#7EF1DB", "#E8D65C", "#A7EA38", "#D38AE0", "#ECF453", "#5CD8B8", "#B6BF6B", "#BEE1F1", "#B1D43E", "#EBE77B", "#84A5CD", "#CFEF7A", "#A3C557", "#E4BB34", "#ECB151", "#BDC9F2", "#5EB0E9", "#E09764", "#9BE3C8", "#B3ADDC", "#B2AC36", "#C8CD4F", "#C797AF", "#DCDB26", "#BCA85E", "#E495A5", "#F37DB8", "#70C0B1", "#5AED7D", "#E49482", "#8AA1F0", "#B3EDEE", "#DAEE34", "#EBD646", "#ECA2D2", "#A0A7E6", "#3EBFD3", "#C098BF", "#F1882E", "#77BFDF", "#7FBFC7", "#D4951F", "#A5C0D0", "#B892DE", "#F8CB31", "#75D0D9", "#A6A0B4", "#EA98E4", "#F38BE6", "#DC83A4"] -let s:semanticTermColors = range(8,30) +let s:semanticTermColors = range(20,40) " The user can change the GUI/Term colors, but cannot directly access the list of colors we use " If the user overrode the default in their vimrc, use that From 06dc3e1dffc93ea4dd6a80383b453da718695573 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Sen=C3=ADn?= Date: Fri, 10 Mar 2017 13:39:06 +0100 Subject: [PATCH 3/8] Added a color subset excluding the most darkness --- plugin/semhl.vim | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/plugin/semhl.vim b/plugin/semhl.vim index e231aea..0679acb 100644 --- a/plugin/semhl.vim +++ b/plugin/semhl.vim @@ -13,9 +13,33 @@ if (exists('g:semanticEnableFileTypes')) endif endif +function! BuildColorSubset(start, offset, end) + echo a:start + echo a:offset + echo a:end + let subSet = range(a:start + a:offset, a:start + a:end) + echo subSet + return subSet +endfunction + +function! BuildTermColors() + let termColors = [] + let start_at = 16 + let max_colors = 195 + let offset = 6 + let subset_size = 30 + + while start_at < max_colors + let colorSubset = BuildColorSubset(start_at, offset, subset_size) + let termColors = termColors + colorSubset + let start_at = start_at + offset + subset_size + endwhile + return termColors + colorSubset +endfunction + " Set defaults for colors let s:semanticGUIColors = ["#9CD8F7", "#F5FA1D", "#F97C65", "#35D27F", "#EB75D6", "#E5D180", "#8997F5", "#D49DA5", "#7FEC35", "#F6B223", "#B4F1C3", "#99B730", "#F67C1B", "#3AC6BE", "#EAAFF1", "#DE9A4E", "#BBEA87", "#EEF06D", "#8FB272", "#EAA481", "#F58AAE", "#80B09B", "#5DE866", "#B5A5C5", "#88ADE6", "#4DAABD", "#EDD528", "#FA6BB2", "#47F2D4", "#F47F86", "#2ED8FF", "#B8E01C", "#C5A127", "#74BB46", "#D386F1", "#97DFD6", "#B1A96F", "#66BB75", "#97AA49", "#EF874A", "#48EDF0", "#C0AE50", "#89AAB6", "#D7D1EB", "#5EB894", "#57F0AC", "#B5AF1B", "#B7A5F0", "#8BE289", "#D38AC6", "#C8EE63", "#ED9C36", "#85BA5F", "#9DEA74", "#85C52D", "#40B7E5", "#EEA3C2", "#7CE9B6", "#8CEC58", "#D8A66C", "#51C03B", "#C4CE64", "#45E648", "#4DC15E", "#63A5F3", "#EA8C66", "#D2D43E", "#E5BCE8", "#E4B7CB", "#B092F4", "#44C58C", "#D1E998", "#76E4F2", "#E19392", "#A8E5A4", "#BF9FD6", "#E8C25B", "#58F596", "#6BAEAC", "#94C291", "#7EF1DB", "#E8D65C", "#A7EA38", "#D38AE0", "#ECF453", "#5CD8B8", "#B6BF6B", "#BEE1F1", "#B1D43E", "#EBE77B", "#84A5CD", "#CFEF7A", "#A3C557", "#E4BB34", "#ECB151", "#BDC9F2", "#5EB0E9", "#E09764", "#9BE3C8", "#B3ADDC", "#B2AC36", "#C8CD4F", "#C797AF", "#DCDB26", "#BCA85E", "#E495A5", "#F37DB8", "#70C0B1", "#5AED7D", "#E49482", "#8AA1F0", "#B3EDEE", "#DAEE34", "#EBD646", "#ECA2D2", "#A0A7E6", "#3EBFD3", "#C098BF", "#F1882E", "#77BFDF", "#7FBFC7", "#D4951F", "#A5C0D0", "#B892DE", "#F8CB31", "#75D0D9", "#A6A0B4", "#EA98E4", "#F38BE6", "#DC83A4"] -let s:semanticTermColors = range(8,30) +let s:semanticTermColors = BuildTermColors() " The user can change the GUI/Term colors, but cannot directly access the list of colors we use " If the user overrode the default in their vimrc, use that @@ -126,7 +150,7 @@ function! s:semHighlight() endif execute 'syn keyword _semantic' . s:getCachedColor(cur_color, match) . l:containedin . ' ' . match - let cur_color = (cur_color + 1) % colorLen + let cur_color = ((cur_color + 1) % colorLen) + 1 endif let index += len(match) + 1 From 2e7f85063a8e5afe7bd302fe3993991e9d1dadbb Mon Sep 17 00:00:00 2001 From: Alok Singh Date: Sat, 18 Mar 2017 16:56:00 -0700 Subject: [PATCH 4/8] add termguicolors --- plugin/semhl.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/semhl.vim b/plugin/semhl.vim index 8247deb..523e4a3 100644 --- a/plugin/semhl.vim +++ b/plugin/semhl.vim @@ -161,7 +161,7 @@ function! s:buildColors() else let type = 'fg' endif - if $NVIM_TUI_ENABLE_TRUE_COLOR || has('gui_running') || (exists('&guicolors') && &guicolors) + if $NVIM_TUI_ENABLE_TRUE_COLOR || has('gui_running') || (exists('&guicolors') && &guicolors) || (exists('&termguicolors') && &termguicolors) let colorType = 'gui' " Update color list in case the user made any changes let s:semanticColors = g:semanticGUIColors From 5e7b065ff72263819a9a6ceba8787a787641f101 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Tue, 21 Mar 2017 18:47:22 -0400 Subject: [PATCH 5/8] Add missing Rust keywords --- autoload/blacklist.vim | 54 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/autoload/blacklist.vim b/autoload/blacklist.vim index 7d1dd1f..0aad20f 100644 --- a/autoload/blacklist.vim +++ b/autoload/blacklist.vim @@ -484,45 +484,94 @@ let s:blacklist = { \ 'while' \ ], \ 'rust': [ - \ 'Self', \ 'as', + \ 'AsMut', + \ 'AsRef', + \ 'assert', \ 'bool', + \ 'Box', \ 'box', \ 'break', \ 'char', \ 'const', \ 'continue', + \ 'Copy', \ 'crate', + \ 'Debug', + \ 'Decodable', + \ 'Default', + \ 'DoubleEndedIterator', + \ 'Drop', \ 'else', + \ 'Encodable', \ 'enum', + \ 'Eq', + \ 'Err', + \ 'ExactSizeIterator', + \ 'Extend', \ 'extern', \ 'f32', \ 'f64', + \ 'false', + \ 'Fn', \ 'fn', + \ 'FnMut', + \ 'FnOnce', \ 'for', + \ 'From', + \ 'FromPrimitive', + \ 'Hash', + \ 'i128', \ 'i16', \ 'i32', \ 'i64', \ 'i8', \ 'if', \ 'impl', + \ 'in', + \ 'Into', + \ 'IntoIterator', \ 'isize', + \ 'Iterator', \ 'let', \ 'loop', \ 'match', \ 'mod', \ 'move', \ 'mut', + \ 'None', + \ 'Ok', + \ 'Option', + \ 'Ord', + \ 'panic', + \ 'PartialEq', + \ 'PartialOrd', \ 'pub', - \ 'return', + \ 'Rand', \ 'ref', + \ 'Result', + \ 'return', + \ 'RustcDecodable', + \ 'RustcEncodable', + \ 'Self', \ 'self', + \ 'Send', + \ 'Show', + \ 'Sized', + \ 'SliceConcatExt', + \ 'Some', \ 'static', \ 'str', + \ 'String', \ 'struct', \ 'super', + \ 'Sync', + \ 'ToOwned', + \ 'ToString', \ 'trait', + \ 'true', \ 'type', + \ 'u128', \ 'u16', \ 'u32', \ 'u64', @@ -530,6 +579,7 @@ let s:blacklist = { \ 'unsafe', \ 'use', \ 'usize', + \ 'Vec', \ 'where', \ 'while', \ ], From d0dbe5a69f51d20b0de08f1bc064f24a51297670 Mon Sep 17 00:00:00 2001 From: Jose Date: Wed, 10 Jan 2018 18:24:48 +0100 Subject: [PATCH 6/8] True color terminals fix Tested in my mac, before this fix cannot use true colors themes --- plugin/semhl.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/semhl.vim b/plugin/semhl.vim index 8247deb..8d8e5d8 100644 --- a/plugin/semhl.vim +++ b/plugin/semhl.vim @@ -124,8 +124,8 @@ function! s:semHighlight() let buflen = line('$') let pattern = '\<[\$]*[a-zA-Z\_][a-zA-Z0-9\_]*\>' - let cur_color = 0 let colorLen = len(s:semanticColors) + let cur_color = str2nr(matchstr(reltimestr(reltime()), '\v\.@<=\d+')[1:]) % colorLen while buflen let curline = getline(buflen) @@ -161,7 +161,7 @@ function! s:buildColors() else let type = 'fg' endif - if $NVIM_TUI_ENABLE_TRUE_COLOR || has('gui_running') || (exists('&guicolors') && &guicolors) + if $NVIM_TUI_ENABLE_TRUE_COLOR || has('gui_running') || (exists('&guicolors') && &guicolors) || (exists('&termguicolors') && &termguicolors) let colorType = 'gui' " Update color list in case the user made any changes let s:semanticColors = g:semanticGUIColors From e473f43edcd4865e83e0b24fec0c660a0cde2803 Mon Sep 17 00:00:00 2001 From: jorge Date: Sun, 6 Feb 2022 01:59:43 +0100 Subject: [PATCH 7/8] Avoid repeated matches due blank spaces or tabs --- plugin/semhl.vim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugin/semhl.vim b/plugin/semhl.vim index 8d8e5d8..b6ab537 100644 --- a/plugin/semhl.vim +++ b/plugin/semhl.vim @@ -123,15 +123,15 @@ function! s:semHighlight() let b:cache_defined = {} let buflen = line('$') - let pattern = '\<[\$]*[a-zA-Z\_][a-zA-Z0-9\_]*\>' + let pattern = '\<[\$@]*[a-zA-Z\_][a-zA-Z0-9\_]*\>' let colorLen = len(s:semanticColors) - let cur_color = str2nr(matchstr(reltimestr(reltime()), '\v\.@<=\d+')[1:]) % colorLen + let cur_color = str2nr(matchstr(reltimestr(reltime()), '\v\.@<=\d+')[1:]) % colorLen " found on https://stackoverflow.com/questions/12737977/native-vim-random-number-script while buflen let curline = getline(buflen) let index = 0 while 1 - let match = matchstr(curline, pattern, index) + let [match, start_at, stop_at] = matchstrpos(curline, pattern, index) if (empty(match)) break @@ -149,7 +149,7 @@ function! s:semHighlight() let cur_color = ((cur_color + 1) % colorLen) + 1 endif - let index += len(match) + 1 + let index = stop_at endwhile let buflen -= 1 endwhile From bdf3d7a9d3105c40e69b768aff25f49a3763ded0 Mon Sep 17 00:00:00 2001 From: jorge Date: Wed, 9 Feb 2022 13:33:10 +0100 Subject: [PATCH 8/8] Refactor names --- plugin/semhl.vim | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/plugin/semhl.vim b/plugin/semhl.vim index b6ab537..d524a65 100644 --- a/plugin/semhl.vim +++ b/plugin/semhl.vim @@ -126,6 +126,7 @@ function! s:semHighlight() let pattern = '\<[\$@]*[a-zA-Z\_][a-zA-Z0-9\_]*\>' let colorLen = len(s:semanticColors) let cur_color = str2nr(matchstr(reltimestr(reltime()), '\v\.@<=\d+')[1:]) % colorLen " found on https://stackoverflow.com/questions/12737977/native-vim-random-number-script + let l:blacklist_exists_for_filetype = !empty(s:blacklist) && has_key(s:blacklist, &filetype) while buflen let curline = getline(buflen) @@ -136,19 +137,24 @@ function! s:semHighlight() if (empty(match)) break endif - - let l:no_blacklist_exists_for_filetype = empty(s:blacklist) || !has_key(s:blacklist, &filetype) - if ((l:no_blacklist_exists_for_filetype || index(s:blacklist[&filetype], match) == -1) && !has_key(b:cache_defined, match)) - let b:cache_defined[match] = 1 - let l:containedin = '' - if (!empty(s:containedinlist) && has_key(s:containedinlist, &filetype)) - let l:containedin = ' containedin=' . s:containedinlist[&filetype] - endif - - execute 'syn keyword _semantic' . s:getCachedColor(cur_color, match) . l:containedin . ' ' . match - let cur_color = ((cur_color + 1) % colorLen) + 1 - endif - + + let l:match_is_blacklisted = l:blacklist_exists_for_filetype && index(s:blacklist[&filetype], match) > 0 + let l:is_already_cached = has_key(b:cache_defined, match) + let l:is_already_contained_in_list = !empty(s:containedinlist) && has_key(s:containedinlist, &filetype) + + if (l:match_is_blacklisted || l:is_already_cached) + break + endif + + let b:cache_defined[match] = 1 + let l:containedin = '' + if (l:is_already_contained_in_list) + let l:containedin = ' containedin=' . s:containedinlist[&filetype] + endif + + execute 'syn keyword _semantic' . s:getCachedColor(cur_color, match) . l:containedin . ' ' . match + + let cur_color = ((cur_color + 1) % colorLen) + 1 let index = stop_at endwhile let buflen -= 1