Skip to content
Open
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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ The following default mappings are included:
mx Set mark x
m, Set the next available alphabetical (lowercase) mark
m; Toggle the next available mark at the current line
Mx Toggle a inputed mark at the current line
dmx Delete mark x
dm- Delete all marks on the current line
dm<space> Delete all marks in the current buffer
Expand Down Expand Up @@ -115,6 +116,7 @@ The following keys are available to be passed to the mapping table:
```
set_next Set next available lowercase mark at cursor.
toggle Toggle next available mark at cursor.
toggle_mark Toggle a inputed mark at the current line.
delete_line Deletes all marks on current line.
delete_buf Deletes all marks in current buffer.
next Goes to next mark in buffer.
Expand Down Expand Up @@ -146,6 +148,7 @@ marks.nvim also provides a list of `<Plug>` mappings for you, in case you want t
<Plug>(Marks-set)
<Plug>(Marks-setnext)
<Plug>(Marks-toggle)
<Plug>(Marks-togglemark)
<Plug>(Marks-delete)
<Plug>(Marks-deleteline)
<Plug>(Marks-deletebuf)
Expand Down
3 changes: 3 additions & 0 deletions doc/marks-nvim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ The following mappings are defined by default:
mx Set mark x
m, Set the next available alphabetical (lowercase) mark
m; Toggle the next available mark at the current line
Mx Toggle a inputed mark at the current line
dmx Delete mark x
dm- Delete all marks on the current line
dm<space> Delete all marks in the current buffer
Expand All @@ -192,6 +193,7 @@ The following are the available keys of the mapping table (see above as well):
set_next Set the next available alphabetical mark
set Set a named mark (will wait for input).
toggle Toggle a mark at the cursor.
toggle_mark Toggle a inputed mark at the current line.
next Move to the next mark
prev Move to the previous mark.
delete Delete a mark (will wait for input).
Expand Down Expand Up @@ -258,6 +260,7 @@ on the functionality of each mapping):
<Plug>(Marks-set)
<Plug>(Marks-setnext)
<Plug>(Marks-toggle)
<Plug>(Marks-togglemark)
<Plug>(Marks-delete)
<Plug>(Marks-deleteline)
<Plug>(Marks-deletebuf)
Expand Down
32 changes: 32 additions & 0 deletions doc/tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
:BookmarksList marks-nvim.txt /*:BookmarksList*
:BookmarksListAll marks-nvim.txt /*:BookmarksListAll*
:BookmarksQFList marks-nvim.txt /*:BookmarksQFList*
:BookmarksQFListAll marks-nvim.txt /*:BookmarksQFListAll*
:MarksListAll marks-nvim.txt /*:MarksListAll*
:MarksListBuf marks-nvim.txt /*:MarksListBuf*
:MarksListGlobal marks-nvim.txt /*:MarksListGlobal*
:MarksQFListAll marks-nvim.txt /*:MarksQFListAll*
:MarksQFListBuf marks-nvim.txt /*:MarksQFListBuf*
:MarksQFListGlobal marks-nvim.txt /*:MarksQFListGlobal*
:MarksToggleSigns marks-nvim.txt /*:MarksToggleSigns*
MarkSignHL marks-nvim.txt /*MarkSignHL*
MarkSignNumHL marks-nvim.txt /*MarkSignNumHL*
MarkVirtTextHL marks-nvim.txt /*MarkVirtTextHL*
marks-bookmark_config marks-nvim.txt /*marks-bookmark_config*
marks-bookmarks marks-nvim.txt /*marks-bookmarks*
marks-builtin marks-nvim.txt /*marks-builtin*
marks-cmds marks-nvim.txt /*marks-cmds*
marks-contrib marks-nvim.txt /*marks-contrib*
marks-cyclic marks-nvim.txt /*marks-cyclic*
marks-default_mappings marks-nvim.txt /*marks-default_mappings*
marks-excluded_filetypes marks-nvim.txt /*marks-excluded_filetypes*
marks-force_write_shada marks-nvim.txt /*marks-force_write_shada*
marks-introduction marks-nvim.txt /*marks-introduction*
marks-license marks-nvim.txt /*marks-license*
marks-mappings marks-nvim.txt /*marks-mappings*
marks-nvim marks-nvim.txt /*marks-nvim*
marks-refresh_interval marks-nvim.txt /*marks-refresh_interval*
marks-setup marks-nvim.txt /*marks-setup*
marks-sign_priority marks-nvim.txt /*marks-sign_priority*
marks-signs marks-nvim.txt /*marks-signs*
marks.nvim marks-nvim.txt /*marks.nvim*
16 changes: 16 additions & 0 deletions lua/marks/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@ function M.toggle()
end
end

function M.toggle_mark()
local err, input = pcall(function()
return string.char(vim.fn.getchar())
end)
if not err then
return
end

if utils.is_valid_mark(input) then
if not M.excluded_fts[vim.bo.ft] then
M.mark_state:toggle_mark(input)
end
end
end

function M.delete()
local err, input = pcall(function()
return string.char(vim.fn.getchar())
Expand Down Expand Up @@ -138,6 +153,7 @@ M.mappings = {
set = "m",
set_next = "m,",
toggle = "m;",
toggle_mark = "M",
next = "m]",
prev = "m[",
preview = "m:",
Expand Down
18 changes: 18 additions & 0 deletions lua/marks/mark.lua
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,24 @@ function Mark:toggle_mark_cursor()
end
end

function Mark:toggle_mark(mark)
local bufnr = a.nvim_get_current_buf()
local pos = a.nvim_win_get_cursor(0)

local is_marked = false
local buffer = self.buffers[bufnr]
if buffer and buffer.placed_marks[mark] and buffer.placed_marks[mark].line == pos[1] then
is_marked = true
end

if is_marked then
self:delete_mark(mark)
else
self:register_mark(mark, pos[1], pos[2], bufnr)
vim.cmd("normal! m" .. mark)
end
end

function Mark:delete_buf_marks(clear)
clear = utils.option_nil(clear, true)
local bufnr = a.nvim_get_current_buf()
Expand Down
1 change: 1 addition & 0 deletions plugin/marks.vim
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ command! BookmarksQFListAll exe "lua require'marks'.bookmark_state:all_to_list('
nnoremap <Plug>(Marks-set) <cmd> lua require'marks'.set()<cr>
nnoremap <Plug>(Marks-setnext) <cmd> lua require'marks'.set_next()<cr>
nnoremap <Plug>(Marks-toggle) <cmd> lua require'marks'.toggle()<cr>
nnoremap <Plug>(Marks-togglemark) <cmd> lua require'marks'.toggle_mark()<cr>
nnoremap <Plug>(Marks-delete) <cmd> lua require'marks'.delete()<cr>
nnoremap <Plug>(Marks-deleteline) <cmd> lua require'marks'.delete_line()<cr>
nnoremap <Plug>(Marks-deletebuf) <cmd> lua require'marks'.delete_buf()<cr>
Expand Down