Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow exclude by buftypes #101

Merged
merged 1 commit into from
Jan 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ require'marks'.setup {
sign_priority = { lower=10, upper=15, builtin=8, bookmark=20 },
-- disables mark tracking for specific filetypes. default {}
excluded_filetypes = {},
-- disables mark tracking for specific buftypes. default {}
excluded_buftypes = {},
-- marks.nvim allows you to configure up to 10 bookmark groups, each with its own
-- sign/virttext. Bookmarks can be used to group together positions and quickly move
-- across multiple buffers. default sign is '!@#$%^&*()' (from 0 to 9), and
Expand Down
8 changes: 8 additions & 0 deletions doc/marks-nvim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ plugin. The following options are defined:
display any signs. Setting and moving to marks with ` or ' will still work, but
movement commands like "m]" or "m[" will not.

excluded_buftypes: table *marks-excluded_buftypes*
(default {})

Which buftypes to ignore. If a buffer with this buftype is opened, then
marks.nvim will not track any marks set in this buffer, and will not
display any signs. Setting and moving to marks with ` or ' will still work, but
movement commands like "m]" or "m[" will not.

bookmark_[0-9]: table *marks-bookmark_config*
(default {})

Expand Down
15 changes: 11 additions & 4 deletions lua/marks/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ function M.set()
end

if utils.is_valid_mark(input) then
if not M.excluded_fts[vim.bo.ft] then
if not M.excluded_fts[vim.bo.ft] and not M.excluded_bts[vim.bo.bt] then
M.mark_state:place_mark_cursor(input)
end
vim.cmd("normal! m" .. input)
end
end

function M.set_next()
if not M.excluded_fts[vim.bo.ft] then
if not M.excluded_fts[vim.bo.ft] and not M.excluded_bts[vim.bo.bt] then
M.mark_state:place_next_mark_cursor()
end
end

function M.toggle()
if not M.excluded_fts[vim.bo.ft] then
if not M.excluded_fts[vim.bo.ft] and not M.excluded_bts[vim.bo.bt] then
M.mark_state:toggle_mark_cursor()
end
end
Expand Down Expand Up @@ -70,7 +70,7 @@ function M.annotate()
end

function M.refresh(force_reregister)
if M.excluded_fts[vim.bo.ft] then
if M.excluded_fts[vim.bo.ft] or M.excluded_bts[vim.bo.bt] then
return
end

Expand Down Expand Up @@ -219,6 +219,13 @@ function M.setup(config)

M.excluded_fts = excluded_fts

local excluded_bts = {}
for _, bt in ipairs(config.excluded_buftypes or {}) do
excluded_bts[bt] = true
end

M.excluded_bts = excluded_bts

M.bookmark_state.opt.signs = true
M.bookmark_state.opt.buf_signs = {}

Expand Down
Loading