From aeb2364999b2e854ba8307f1098c67e427383383 Mon Sep 17 00:00:00 2001 From: Scott Windsor Date: Mon, 21 Oct 2013 11:59:53 -0700 Subject: [PATCH 1/6] Enhancements for vim-flog * Move to highlight line over gui colors only * Add ability to toggle on/off flog * Fix typo for g:flog_enable * Minor whitespace fixes --- plugin/flog.vim | 69 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 22 deletions(-) diff --git a/plugin/flog.vim b/plugin/flog.vim index b760909..fd534f8 100644 --- a/plugin/flog.vim +++ b/plugin/flog.vim @@ -9,27 +9,27 @@ if !has('signs') || !has('ruby') finish endif -let s:low_color = "#a5c261" -let s:medium_color = "#ffc66d" -let s:high_color = "#cc7833" -let s:background_color = "#323232" +let s:low_color_hl = "term=standout ctermfg=118 ctermbg=235 guifg=#a5c261 guibg=#323232" +let s:medium_color_hl = "term=standout ctermfg=81 ctermbg=235 guifg=#ffc66d guibg=#323232" +let s:high_color_hl = "term=standout cterm=bold ctermfg=199 ctermbg=16 gui=bold guifg=#cc7833 guibg=#232526" +let s:background_hl = "guifg=#999999 guibg=#323232 gui=NONE" let s:medium_limit = 10 let s:high_limit = 20 -if exists("g:flog_low_color") - let s:low_color = g:flog_low_color +if exists("g:flog_low_color_hl") + let s:low_color_hl = g:flog_low_color_hl endif -if exists("g:flog_medium_color") - let s:medium_color = g:flog_medium_color +if exists("g:flog_medium_color_hl") + let s:medium_color_hl = g:flog_medium_color_hl endif -if exists("g:flog_high_color") - let s:high_color = g:flog_high_color +if exists("g:flog_high_color_hl") + let s:high_color_hl = g:flog_high_color_hl endif -if exists("g:flog_background_color") - let s:background_color = g:flog_background_color +if exists("g:flog_background_hl") + let s:high_background_hl = g:flog_high_background_hl endif if exists("g:flog_medium_limit") @@ -132,9 +132,9 @@ def show_complexity(results = {}) when medium_limit..high_limit then "medium_complexity" else "high_complexity" end - value = rest[0].to_i - value = "9+" if value >= 100 - VIM.command ":sign define #{value.to_s} text=#{value.to_s} texthl=#{complexity}" + value = rest[0].to_i + value = "9+" if value >= 100 + VIM.command ":sign define #{value.to_s} text=#{value.to_s} texthl=#{complexity}" VIM.command ":sign place #{line_number} line=#{line_number} name=#{value.to_s} file=#{VIM::Buffer.current.name}" end end @@ -142,10 +142,10 @@ end EOF function! s:UpdateHighlighting() - exe 'hi low_complexity guifg='.s:low_color - exe 'hi medium_complexity guifg='.s:medium_color - exe 'hi high_complexity guifg='.s:high_color - exe 'hi SignColumn guifg=#999999 guibg='.s:background_color.' gui=NONE' + exe 'hi low_complexity '.s:low_color_hl + exe 'hi medium_complexity '.s:medium_color_hl + exe 'hi high_complexity '.s:high_color_hl + exe 'hi SignColumn '.s:background_hl endfunction function! ShowComplexity() @@ -168,13 +168,38 @@ call s:UpdateHighlighting() endfunction +function! HideComplexity() + sign unplace * +call s:UpdateHighlighting() + +endfunction + +function! EnableFlog() + let g:flog_enable=1 + call ShowComplexity() + autocmd! BufReadPost,BufWritePost,FileReadPost,FileWritePost *.rb call ShowComplexity() +endfunction + +function! DisableFlog() + let g:flog_enable=0 + call HideComplexity() + autocmd! BufReadPost,BufWritePost,FileReadPost,FileWritePost *.rb +endfunction + +function! ToggleFlog() + if !exists("g:flog_enable") || g:flog_enable + call DisableFlog() + else + call EnableFlog() + end +endfunction + call s:UpdateHighlighting() sign define low_color text=XX texthl=low_complexity sign define medium_color text=XX texthl=medium_complexity sign define high_color text=XX texthl=high_complexity - -if !exists("g:flow_enable") || g:flog_enable - autocmd! BufReadPost,BufWritePost,FileReadPost,FileWritePost *.rb call ShowComplexity() +if !exists("g:flog_enable") || g:flog_enable + call EnableFlog() endif From c14cbeae8a1a46489e3b7802480c3a6f25a3f809 Mon Sep 17 00:00:00 2001 From: Scott Windsor Date: Mon, 21 Oct 2013 12:10:17 -0700 Subject: [PATCH 2/6] Update README per latest checkin --- README.md | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4d09bdc..f50e799 100644 --- a/README.md +++ b/README.md @@ -39,16 +39,16 @@ Configuration You can set the colors for the complexity indication with the following commands in your .vimrc: * Set the color of for low complexity:
- `:silent exe "let g:flog_low_color=#a5c261"` + `:let g:flog_low_color_hl = "term=standout ctermfg=118 ctermbg=235 guifg=#999999 guibg=#323232"` * Set the color of for medium complexity:
- `:silent exe "let g:flog_medium_color=#ffc66d"` + `:let g:flog_medium_color_hl = "term=standout ctermfg=81 ctermbg=235 guifg=#66D9EF guibg=#323232"` * Set the color of for high complexity:
- `:silent exe "let g:flog_high_color=#cc7833"` + `:let g:flog_high_color_hl = "term=standout cterm=bold ctermfg=199 ctermbg=16 gui=bold guifg=#F92672 guibg=#232526"` * Set the background color:
- `:silent exe "let g:flog_background_color=#323232"` + `:let s:background_hl = "guifg=#999999 guibg=#323232 gui=NONE"` You can set the limits for the complexity indication with the following commands in your .vimrc: @@ -58,6 +58,21 @@ You can set the limits for the complexity indication with the following commands * Set the limit to switch to a high complexity:
:silent exe "`let g:flog_high_limit=20"` +You can also turn flog off and on: + +* Turn on flog + :call EnableFlog() + +* Turn off flog + :call DisableFlog() + +* Toggle flog + :call ToggleFlog() + +Additionally, you can map this in your .vimrc: + + `:map ,f :call ToggleFlog()` + Credits ------- From 644e959502c5f0ed42d1682c9b601cc2952a6035 Mon Sep 17 00:00:00 2001 From: Scott Windsor Date: Mon, 21 Oct 2013 12:15:10 -0700 Subject: [PATCH 3/6] Fix readme typos --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f50e799..d4ba8b2 100644 --- a/README.md +++ b/README.md @@ -61,16 +61,15 @@ You can set the limits for the complexity indication with the following commands You can also turn flog off and on: * Turn on flog - :call EnableFlog() + `:call EnableFlog()` * Turn off flog - :call DisableFlog() + `:call DisableFlog()` * Toggle flog - :call ToggleFlog() + `:call ToggleFlog()` Additionally, you can map this in your .vimrc: - `:map ,f :call ToggleFlog()` Credits From d9ef9f66a16225eb6e3bbbdf7d7158b2e0847a8b Mon Sep 17 00:00:00 2001 From: Mando Escamilla Date: Wed, 23 Oct 2013 10:16:08 -0700 Subject: [PATCH 4/6] Change plugin URL It looks like the original URL for the plugin has changed and should now be the raw github url - otherwise, you'll get an html body with a redirect message as the plugin :) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d4ba8b2..0599f9a 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Install the Flog gem like this: `gem install flog`. To install the plugin just run this command in your Terminal: -`curl https://github.com/fousa/vim-flog/raw/master/plugin/flog.vim -o ~/.vim/plugin/flog.vim` +`curl https://raw.github.com/fousa/vim-flog/master/plugin/flog.vim -o ~/.vim/plugin/flog.vim` When this is done add `:silent exe "g:flog_enable"` to your .vimrc file. From 5b7c01de9baff405051d472350a7abc0c0f868ed Mon Sep 17 00:00:00 2001 From: alexbel Date: Tue, 16 Sep 2014 16:30:35 -0400 Subject: [PATCH 5/6] Add ability to hide low and middle coplexity levels Fix style --- README.md | 8 ++++++++ plugin/flog.vim | 26 +++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0599f9a..29b4c82 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,14 @@ You can set the limits for the complexity indication with the following commands * Set the limit to switch to a high complexity:
:silent exe "`let g:flog_high_limit=20"` +You can hide some levels of complexity: + +* Hide low complexity:
+ `:silent exe "let g:flog_hide_low=1"` + +* Hide medium complexity:
+ `:silent exe "let g:flog_hide_medium=1"` + You can also turn flog off and on: * Turn on flog diff --git a/plugin/flog.vim b/plugin/flog.vim index fd534f8..b397e80 100644 --- a/plugin/flog.vim +++ b/plugin/flog.vim @@ -15,6 +15,16 @@ let s:high_color_hl = "term=standout cterm=bold ctermfg=199 ctermbg=16 gui=bo let s:background_hl = "guifg=#999999 guibg=#323232 gui=NONE" let s:medium_limit = 10 let s:high_limit = 20 +let s:hide_low = 0 +let s:hide_medium = 0 + +if exists("g:flog_hide_low") + let s:hide_low = g:flog_hide_low +endif + +if exists("g:flog_hide_medium") + let s:hide_medium = g:flog_hide_medium +endif if exists("g:flog_low_color_hl") let s:low_color_hl = g:flog_low_color_hl @@ -132,9 +142,19 @@ def show_complexity(results = {}) when medium_limit..high_limit then "medium_complexity" else "high_complexity" end - value = rest[0].to_i - value = "9+" if value >= 100 - VIM.command ":sign define #{value.to_s} text=#{value.to_s} texthl=#{complexity}" + value = rest[0].to_i + value = "9+" if value >= 100 + VIM.command ":sign define #{value.to_s} text=#{value.to_s} texthl=#{complexity}" + render_score line_number, value, medium_limit, high_limit + end +end + +def render_score(line_number, value, medium_limit, high_limit) + hide_medium = VIM::evaluate 's:hide_medium' + hide_low = VIM::evaluate 's:hide_low' + if (hide_low == 1 && value < medium_limit) || (hide_medium == 1 && value < high_limit) + VIM.command ":sign unplace #{line_number}" + else VIM.command ":sign place #{line_number} line=#{line_number} name=#{value.to_s} file=#{VIM::Buffer.current.name}" end end From 5bfb9ad898566e9ec3b21675069f09ef63cc1bab Mon Sep 17 00:00:00 2001 From: alexbel Date: Tue, 16 Sep 2014 21:09:07 -0400 Subject: [PATCH 6/6] Fix. Do not run for non-ruby files while starting --- plugin/flog.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugin/flog.vim b/plugin/flog.vim index fd534f8..340656a 100644 --- a/plugin/flog.vim +++ b/plugin/flog.vim @@ -176,7 +176,9 @@ endfunction function! EnableFlog() let g:flog_enable=1 - call ShowComplexity() + if &filetype == 'ruby' + call ShowComplexity() + endif autocmd! BufReadPost,BufWritePost,FileReadPost,FileWritePost *.rb call ShowComplexity() endfunction