Skip to content

Commit

Permalink
Add option to ignore filetypes (#10)
Browse files Browse the repository at this point in the history
* add beacon_ignore_filetypes
* update beacon.txt with beacon_ignore_filetypes
  • Loading branch information
infinite-ops authored Jun 30, 2020
1 parent e7200be commit ce6fddc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ To ignore a buffer you can set list of regexes
g:beacon_ignore_buffers = [\w*git*\w]
```

### Ignoring filetypes
To ignore filetypes you can set list of filetypes
```viml
g:beacon_ignore_filetypes = ['fzf']
```

## Commands
There is 4 commands available.
- `:Beacon` highlight current position (even if plugin is disabled)
Expand Down
4 changes: 4 additions & 0 deletions doc/beacon.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ OPTIONS *beacon-option*
List of regexes that will be tested against buffer name, and if
matches beacon will not show up. Default [].

g:beacon_ignore_filetypes *g:beacon_ignore_filetypes*
List of filetypes that will be tested against &filetype, and if
matches beacon will not show up. Default [].

CHANGE COLOR *hl-Beacon*

Beacon is highlighted by `Beacon` group, so you can change it like this:
Expand Down
16 changes: 16 additions & 0 deletions plugin/beacon.vim
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ let g:beacon_show_jumps = get(g:, 'beacon_show_jumps', 1)
let g:beacon_shrink = get(g:, 'beacon_shrink', 1)
let g:beacon_timeout = get(g:, 'beacon_timeout', 500)
let g:beacon_ignore_buffers = get(g:, 'beacon_ignore_buffers', [])
let g:beacon_ignore_filetypes = get(g:, 'beacon_ignore_filetypes', [])

" buffer needed for floating window
if has("nvim")
Expand All @@ -48,6 +49,17 @@ let s:float = 0 " floating win id
let s:fade_timer = 0
let s:close_timer = 0

fun! s:IsIgnoreFiletype()
let name = &filetype

for i in g:beacon_ignore_filetypes
if name =~ i
return 1
endif
endfor
return 0
endf

fun! s:IsIgnoreBuffer()
let name = bufname()

Expand Down Expand Up @@ -144,6 +156,10 @@ function! s:Highlight_position(force) abort
return
endif

if s:IsIgnoreFiletype()
return
endif

" get some bugs when enabled in fugitive
if has("nvim")
if nvim_buf_get_option(0, "ft") == "fugitive"
Expand Down

0 comments on commit ce6fddc

Please sign in to comment.