Skip to content

Commit

Permalink
add filtering buffer text method
Browse files Browse the repository at this point in the history
  • Loading branch information
kamykn committed Apr 15, 2020
1 parent 3051c0e commit 68e2847
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
33 changes: 33 additions & 0 deletions autoload/spelunker/get_buffer.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
scriptencoding utf-8

let s:save_cpo = &cpo
set cpo&vim

function! spelunker#get_buffer#all()
let l:window_text_list = getline(1, '$')
let l:window_text = join(l:window_text_list, "\n")

let l:window_text = s:filter_uri(l:window_text)
let l:window_text = s:filter_back_quoted_string(l:window_text)

echo l:window_text
endfunction

function! s:filter_uri(text)
if g:spelunker_disable_url = 1
return
endif

" FYI: https://vi.stackexchange.com/questions/3990/ignore-urls-and-email-addresses-in-spell-file/24534#24534
return substitute(a:text, '\w\+:\/\/[^[:space:]]\+', '', 'g')
endfunction

function! s:filter_back_quoted_string(text)
" for shell command
" ex) `ls -la`
if g:spelunker_disable_back_quoted_string = 1
return
endif

return substitute(a:text, '`\_.\+`', '', 'g')
endfunction
9 changes: 9 additions & 0 deletions plugin/spelunker.vim
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ if !exists('g:spelunker_disable_auto_group')
let g:spelunker_disable_auto_group = 0
endif

if !exists('g:spelunker_disable_back_quoted_string')
let g:spelunker_disable_back_quoted_string = 0
endif

if !exists('g:spelunker_disable_url')
let g:spelunker_disable_url = 0
endif


let g:spelunker_check_type_buf_lead_write = 1
let g:spelunker_check_type_cursor_hold = 2

Expand Down

0 comments on commit 68e2847

Please sign in to comment.