mirror of
https://github.com/jiriks74/presence.nvim
synced 2024-11-23 20:37:50 +01:00
Support plain strings in blacklist config
This commit is contained in:
parent
993ec869c1
commit
e632306af1
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
> Discord [Rich Presence](https://discord.com/rich-presence) plugin for [Neovim](https://neovim.io)
|
> Discord [Rich Presence](https://discord.com/rich-presence) plugin for [Neovim](https://neovim.io)
|
||||||
|
|
||||||
https://user-images.githubusercontent.com/10726590/128818164-43e56722-9afe-4051-8790-b04769abc188.mov
|
<img src="https://gist.githubusercontent.com/andweeb/df3216345530234289b87cf5080c2c60/raw/ad916fec8de921d0021801a0af877a5349621e7e/presence-demo-a.gif" width="100%" alt="demo.gif">
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
* Light and unobtrusive
|
* Light and unobtrusive
|
||||||
@ -40,7 +40,7 @@ require("presence"):setup({
|
|||||||
log_level = nil, -- Log messages at or above this level (one of the following: "debug", "info", "warn", "error")
|
log_level = nil, -- Log messages at or above this level (one of the following: "debug", "info", "warn", "error")
|
||||||
debounce_timeout = 10, -- Number of seconds to debounce events (or calls to `:lua package.loaded.presence:update(<filename>, true)`)
|
debounce_timeout = 10, -- Number of seconds to debounce events (or calls to `:lua package.loaded.presence:update(<filename>, true)`)
|
||||||
enable_line_number = false, -- Displays the current line number instead of the current project
|
enable_line_number = false, -- Displays the current line number instead of the current project
|
||||||
blacklist = {}, -- A list of strings or Lua patterns that disable Rich Presence if the current file name, path, or workspace match
|
blacklist = {}, -- A list of strings or Lua patterns that disable Rich Presence if the current file name, path, or workspace matches
|
||||||
buttons = true, -- Configure Rich Presence button(s), either a boolean to enable/disable, a static table (`{{ label = "<label>", url = "<url>" }, ...}`, or a function(buffer: string, repo_url: string|nil): table)
|
buttons = true, -- Configure Rich Presence button(s), either a boolean to enable/disable, a static table (`{{ label = "<label>", url = "<url>" }, ...}`, or a function(buffer: string, repo_url: string|nil): table)
|
||||||
|
|
||||||
-- Rich Presence text options
|
-- Rich Presence text options
|
||||||
@ -65,8 +65,8 @@ let g:presence_client_id = "793271441293967371"
|
|||||||
let g:presence_log_level
|
let g:presence_log_level
|
||||||
let g:presence_debounce_timeout = 10
|
let g:presence_debounce_timeout = 10
|
||||||
let g:presence_enable_line_number = 0
|
let g:presence_enable_line_number = 0
|
||||||
let g:presence_buttons = 1
|
|
||||||
let g:presence_blacklist = []
|
let g:presence_blacklist = []
|
||||||
|
let g:presence_buttons = 1
|
||||||
|
|
||||||
" Rich Presence text options
|
" Rich Presence text options
|
||||||
let g:presence_editing_text = "Editing %s"
|
let g:presence_editing_text = "Editing %s"
|
||||||
|
@ -634,19 +634,23 @@ function Presence:check_blacklist(buffer, parent_dirpath, project_dirpath)
|
|||||||
|
|
||||||
-- Loop over the values to see if the provided project/path is in the blacklist
|
-- Loop over the values to see if the provided project/path is in the blacklist
|
||||||
for _, val in pairs(blacklist_table) do
|
for _, val in pairs(blacklist_table) do
|
||||||
-- Match buffer
|
-- Matches buffer exactly
|
||||||
if buffer:match(val) == buffer then return true end
|
if buffer:match(val) == buffer then return true end
|
||||||
-- Match parent
|
-- Match parent either by Lua pattern or by plain string
|
||||||
local is_parent_directory_blacklisted = parent_dirpath and
|
local is_parent_directory_blacklisted = parent_dirpath and
|
||||||
(parent_dirpath:match(val) == parent_dirpath or
|
((parent_dirpath:match(val) == parent_dirpath or
|
||||||
parent_dirname:match(val) == parent_dirname)
|
parent_dirname:match(val) == parent_dirname) or
|
||||||
|
(parent_dirpath:find(val, nil, true) or
|
||||||
|
parent_dirname:find(val, nil, true)))
|
||||||
if is_parent_directory_blacklisted then
|
if is_parent_directory_blacklisted then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
-- Match project
|
-- Match project either by Lua pattern or by plain string
|
||||||
local is_project_directory_blacklisted = project_dirpath and
|
local is_project_directory_blacklisted = project_dirpath and
|
||||||
(parent_dirpath:match(val) == project_dirpath or
|
((project_dirpath:match(val) == project_dirpath or
|
||||||
parent_dirname:match(val) == project_dirname)
|
project_dirname:match(val) == project_dirname) or
|
||||||
|
(project_dirpath:find(val, nil, true) or
|
||||||
|
project_dirname:find(val, nil, true)))
|
||||||
if is_project_directory_blacklisted then
|
if is_project_directory_blacklisted then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user