Skip to content

Commit

Permalink
feat(v1.1.0): release
Browse files Browse the repository at this point in the history
  • Loading branch information
hinell committed Oct 23, 2023
1 parent 21bc577 commit ab057af
Show file tree
Hide file tree
Showing 10 changed files with 270 additions and 152 deletions.
1 change: 1 addition & 0 deletions .luarc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json",
"runtime": [ "" ],
"runtime.path": "lua/?.lua",
"workspace.library": [ "/usr/local/share/nvim/runtime/lua" ],
"format.enable": false,
"workspace.checkThirdParty": false
Expand Down
19 changes: 12 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NVIM=nvim
PROJECT_NAME="duplicate"
PROJECT_NAME=duplicate

all: doc/tags

Expand All @@ -8,18 +8,23 @@ doc/tags: doc/$(PROJECT_NAME).txt
@$(NVIM) --headless -c "helptags doc/" -c "exit"

# ts-vimdoc generate vimhelp from markdown
.SILENT:
.ONESHELL:
doc/$(PROJECT_NAME).txt: README.md
@$(NVIM) --headless -Es -c "
doc/$(PROJECT_NAME).txt: doc/index.md
$(NVIM) --headless -E -c "
lua require('ts-vimdoc').docgen({
input_file='doc/index.md',
output_file = '$@',
project_name='$(PROJECT_NAME)',
})
os.exit()
"
@command -v unicode-emoji-remove.sh &> /dev/null || {
# Use 2> error.log to read the output of the command
echo -e "$0: $(tput setaf 1)error:$(tput op) unicode-emoji-remove.sh is nout found; install it from @gtihub:hinell/dotfiles" > /dev/stderr;
command -v unicode-emoji-remove.sh &> /dev/null || {
# Use 2> error.log to read the output of the command
echo -e "$0: $(tput setaf 1)error:$(tput op) unicode-emoji-remove.sh is nout found; install it from" \
"https://github.com/hinell/dotfiles/blob/main/bash-scripts/unicode-emoji-remove.sh" \
> /dev/stderr;
}
@unicode-emoji-remove.sh -i $@
test -f $< && unicode-emoji-remove.sh -i $@
# strip <br> tags
sed -i -E -e 's/<\/?br\/?>\s*/\n/g' $@
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
https://github.com/hinell/duplicate.nvim/assets/8136158/d136146f-fb84-4a66-9a04-6152e49d411a

<div align="center">
<h1 align="center">🔌 duplicate.nvim</h2>
</div>

https://github.com/hinell/duplicate.nvim/assets/8136158/d136146f-fb84-4a66-9a04-6152e49d411a


<!-- Use badges from https://shields.io/badges/ -->
[![PayPal](https://img.shields.io/badge/-PayPal-880088?style=flat-square&logo=pay&logoColor=white&label=DONATE)](https://www.paypal.me/biteofpie)
[![License](https://img.shields.io/badge/FOSSIL-007744?style=flat-square&label=LICENSE)](https://github.com/hinell/fossil-license)
Expand Down
3 changes: 3 additions & 0 deletions doc/RELEASE
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* refactor(commands): rename LinesDuplicate -> VisualDuplicate
* fix(commands): offset wasn't taken into account by user commands
* feat(selection): put cursor inside selection depending on duplication direction
64 changes: 48 additions & 16 deletions doc/duplicate.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
*duplicate.txt* Last change: 2023 September 29
*duplicate.txt* Last change: 2023 October 14

==============================================================================
Table of Contents *duplicate-table-of-contents*

OVERVIEW ................................................ |duplicate-overview|
INSTALL .................................................. |duplicate-install|
UPDATE .................................................... |duplicate-update|
API .......................................................... |duplicate-api|
COMMANDS ................................................ |duplicate-commands|
EXAMPLES ................................................ |duplicate-examples|
KEYBINDINGS .......................................... |duplicate-keybindings|
LEGENDARY .............................................. |duplicate-legendary|
CONFIGURATION ........................ |duplicate--configuration|

------------------------------------------------------------------------------
OVERVIEW *duplicate-overview*
Expand All @@ -27,17 +30,43 @@ Use your favorite package manager (Packer, Plug, Lazy.nvim etc.)
"hinell/duplicate.nvim"
<

------------------------------------------------------------------------------
UPDATE *duplicate-update*


You may want to reinstall this plugin manually, because of specific
dev-apprach: repo of this plugin may be force-rebased, rendering all previous
commits obsolete.


------------------------------------------------------------------------------
API *duplicate-api*


>lua
-- init.lua
local config = require("duplicate.config")
local editor = require("duplicate.editor")
local duplicatedRange = editor:duplicateByOffset(5, config)
editor:selectVisual(duplicatedRange)
<

------------------------------------------------------------------------------
COMMANDS *duplicate-commands*


Plugin exports the following user commands:

* `LineDuplicate [ <arg> ]` - Duplicates lines only
* `LinesDuplicate [ <arg> ]` - Duplicates visual blocksinde
* `<arg>`: Number - optional; * 0 - no action; * no value - duplicates 1 line
downward by default * `N` - duplicates `N` line depending on the sign of the
Number
* *:LineDuplicate* <arg> - Duplicate linewise
* *:VisualDuplicate* <arg> - Charwise, linewise, and blockwise duplication
* Where `<arg>: Number` - an offset to put duplicated lines at;
* * `0` - no action;
* * `<empty>` - error in cmd
* * `-1` - duplicates 1 line upward; relateive to the top of the selection;
* * `+1` - duplicates 1 line downward; relative to the bottom of selection
* * `N` - duplicates `N` lines up/downard depending on the sign of the Number;
duplicated text is always put relative to the nearest cursor relative to the
offset.


EXAMPLES *duplicate-examples*
Expand All @@ -47,16 +76,20 @@ You can call commands directly in command pane:
* `:LineDuplicate` - duplicate currently focused line downwards
* `:LineDuplicate 0` - no action
* `:LineDuplicate +2` - duplicate line 2 lines downwards
* `'<,'>:LinesDuplicate -5` - duplicate selection upwards 5 lines
* `'<,'>:VisualDuplicate -5` - duplicate selection upwards 5 lines from the
top of the selection
* `'<,'>:VisualDuplicate +3` - same, but 3 lines from the bottom of the
selection


KEYBINDINGS *duplicate-keybindings*

By default, **NO** keybindings are exported. Use [Legendary.nvim]
By default, **NO** keybindings are set up.

>lua
-- The followng binds
-- CTRL+SHIFT+ALT+<UP/DOWN> keymap
-- Sign of the number is mandatory
vim.keymap.set({ "n" }, "<C-S-A-Up>" ,"<CMD>LineDuplicate -1<CR>")
vim.keymap.set({ "n" }, "<C-S-A-Down>" ,"<CMD>LineDuplicate +1<CR>")
<
Expand All @@ -75,25 +108,23 @@ use the following config to specify your own keymaps:
mode = { "n" }, "<C-S-A-Up>" , "<CMD>LineDuplicate -1<CR>"
},
{
description = "Line: duplicate down"
description = "Line: duplicate down",
mode = { "n" }, "<C-S-A-Down>", "<CMD>LineDuplicate +1<CR>"
},
{
description = "Selection: duplicate up"
description = "Selection: duplicate up",
mode = { "v" }, "<C-S-A-Up>", "<CMD>VisualDuplicate -1<CR>"
},
{
description = "Selection: duplicate down"
description = "Selection: duplicate down",
mode = { "v" }, "<C-S-A-Down>", "<CMD>VisualDuplicate +1<CR>"
},
...
}
})
<

==============================================================================
CONFIGURATION *duplicate--configuration*


>lua

vim.g["duplicate-nvim-config"] = {
Expand All @@ -103,7 +134,8 @@ use the following config to specify your own keymaps:
}
}
<
September 24, 2023</br> Copyright - Alexander Davronov, et.al.</br>
September 24, 2023
Copyright - Alexander Davronov, et.al.</br>


vim:tw=78:ts=8:ft=help:norl:
49 changes: 35 additions & 14 deletions doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,47 @@ Use your favorite package manager (Packer, Plug, Lazy.nvim etc.)
"hinell/duplicate.nvim"
```

## UPDATE

You may want to reinstall this plugin manually, because of specific dev-apprach:
repo of this plugin may be force-rebased, rendering all previous commits obsolete.

## API

```lua
-- init.lua
local config = require("duplicate.config")
local editor = require("duplicate.editor")
local duplicatedRange = editor:duplicateByOffset(5, config)
editor:selectVisual(duplicatedRange)

```

## COMMANDS

Plugin exports the following user commands:
* `LineDuplicate [ <arg> ]` - Duplicates lines only
* `LinesDuplicate [ <arg> ]` - Duplicates visual blockwise chunks
* Where `<arg>: Number` - optional;
* 0 - no action;
* no value - duplicates 1 line downward by default
* `N` - duplicates `N` line depending on the sign of the Number

* *:LineDuplicate* <arg> - Duplicate linewise
* *:VisualDuplicate* <arg> - Charwise, linewise, and blockwise duplication
* Where `<arg>: Number` - an offset to put duplicated lines at;
* * `0` - no action;
* * `<empty>` - error in cmd
* * `-1` - duplicates 1 line upward; relateive to the top of the selection;
* * `+1` - duplicates 1 line downward; relative to the bottom of selection
* * `N` - duplicates `N` lines up/downard depending on the sign of the Number;
duplicated text is always put relative to the nearest cursor relative to the offset.

### EXAMPLES
You can call commands directly in command pane:
* `:LineDuplicate` - duplicate currently focused line downwards
* `:LineDuplicate 0` - no action
* `:LineDuplicate +2` - duplicate line 2 lines downwards
* `'<,'>:LinesDuplicate -5` - duplicate selection upwards 5 lines
* `'<,'>:VisualDuplicate -5` - duplicate selection upwards 5 lines from the top of the selection
* `'<,'>:VisualDuplicate +3` - same, but 3 lines from the bottom of the selection

### KEYBINDINGS

By default, **NO** keybindings are exported. Use [Legendary.nvim]
By default, **NO** keybindings are set up.

```lua
-- The followng binds
Expand All @@ -48,24 +69,23 @@ legendary.keymaps({
mode = { "n" }, "<C-S-A-Up>" , "<CMD>LineDuplicate -1<CR>"
},
{
description = "Line: duplicate down"
description = "Line: duplicate down",
mode = { "n" }, "<C-S-A-Down>", "<CMD>LineDuplicate +1<CR>"
},
{
description = "Selection: duplicate up"
description = "Selection: duplicate up",
mode = { "v" }, "<C-S-A-Up>", "<CMD>VisualDuplicate -1<CR>"
},
{
description = "Selection: duplicate down"
description = "Selection: duplicate down",
mode = { "v" }, "<C-S-A-Down>", "<CMD>VisualDuplicate +1<CR>"
},
...
}
})
```

[Legendary.nvim]: https://github.com/mrjones2014/legendary.nvim

##### ⚙️ CONFIGURATION
#### ⚙️ CONFIGURATION
```lua

vim.g["duplicate-nvim-config"] = {
Expand All @@ -74,6 +94,7 @@ vim.g["duplicate-nvim-config"] = {
block = true -- disable block-wise duplication
}
}

```

----
Expand Down
4 changes: 4 additions & 0 deletions doc/tags
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
:LineDuplicate duplicate.txt /*:LineDuplicate*
:VisualDuplicate duplicate.txt /*:VisualDuplicate*
duplicate--configuration duplicate.txt /*duplicate--configuration*
duplicate-api duplicate.txt /*duplicate-api*
duplicate-commands duplicate.txt /*duplicate-commands*
duplicate-examples duplicate.txt /*duplicate-examples*
duplicate-install duplicate.txt /*duplicate-install*
duplicate-keybindings duplicate.txt /*duplicate-keybindings*
duplicate-legendary duplicate.txt /*duplicate-legendary*
duplicate-overview duplicate.txt /*duplicate-overview*
duplicate-table-of-contents duplicate.txt /*duplicate-table-of-contents*
duplicate-update duplicate.txt /*duplicate-update*
duplicate.txt duplicate.txt /*duplicate.txt*
41 changes: 41 additions & 0 deletions lua/duplicate/Range.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
-- Created-at...: September 25, 2023
-- Description..: Range class
--- @module Range
-- Extension class for lines management
-- TODO: [October 14, 2023] Move this to nvim-api.nvim
local M = {}

--- Small class for duplication
--- @class M.Range
M.Range = { prototype = { ctx = {} } }
M.Range._mt = {
__index = function(table, key)
return table.constructor.prototype[key]
or table.constructor.super
and table.constructor.super.prototype[key]
end,
}
-- LuaFormatter on

--- Creates new instance static method)
--- @tparam Table containing area
function M.Range:new(posStart, posEnd, config)
local instance = {}
instance.config = config
instance.constructor = self

instance[1] = posStart
instance[2] = posEnd

setmetatable(instance, self._mt)
return instance
end

--- Check if range is on the same line
--- @tparam
--- @treturn boolean
function M.Range.prototype:sameLine ()
return self[1][2] == self[2][2]
end

return M
Loading

0 comments on commit ab057af

Please sign in to comment.