Skip to content

Commit f91637b

Browse files
committed
feat!: Make setup optional. (#296)
In this feature/version upgrade, we make `setup` optional by decoupling initialization and configuration of `nvim-surround`. We leverage (Neo)Vim's built-in runtimepath lazy loading to initialize the plugin, defining the public API in the form of `<Plug>` maps. Configuration is still done via `setup`. Please see `:h nvim-surround.migrating.v3_to_v4` for details on how to update your configurations.
1 parent 1098d7b commit f91637b

7 files changed

Lines changed: 442 additions & 508 deletions

File tree

.github/workflows/integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ jobs:
3737
git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ~/.local/share/nvim/site/pack/vendor/start/plenary.nvim
3838
ln -s $(pwd) ~/.local/share/nvim/site/pack/vendor/start
3939
- name: Run tests
40-
run: nvim --headless --noplugin -c 'packadd plenary.nvim' -c "PlenaryBustedDirectory tests/ { minimal_init = 'tests/minimal_init.lua' }"
40+
run: nvim --headless --noplugin -c 'packadd plenary.nvim' -c "PlenaryBustedDirectory tests/ { init = 'tests/minimal_init.lua' }"

README.md

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,38 +31,25 @@ Surround selections, stylishly :sunglasses:
3131

3232
## :package: Installation
3333

34-
Install this plugin using your favorite plugin manager, and then call
35-
`require("nvim-surround").setup()`.
34+
Install this plugin using your favorite plugin manager, and that's it! See
35+
`:h nvim-surround.configuration` for how to configure the plugin.
3636

3737
### [lazy.nvim](https://github.com/folke/lazy.nvim)
3838

3939
```lua
4040
{
4141
"kylechui/nvim-surround",
42-
version = "^3.0.0", -- Use for stability; omit to use `main` branch for the latest features
42+
version = "^4.0.0", -- Use for stability; omit to use `main` branch for the latest features
4343
event = "VeryLazy",
44-
config = function()
45-
require("nvim-surround").setup({
46-
-- Configuration here, or leave empty to use defaults
47-
})
48-
end
44+
-- Optional: See `:h nvim-surround.configuration` and `:h nvim-surround.setup` for details
45+
-- config = function()
46+
-- require("nvim-surround").setup({
47+
-- -- Put your configuration here
48+
-- })
49+
-- end
4950
}
5051
```
5152

52-
### [packer.nvim](https://github.com/wbthomason/packer.nvim)
53-
54-
```lua
55-
use({
56-
"kylechui/nvim-surround",
57-
tag = "*", -- Use for stability; omit to use `main` branch for the latest features
58-
config = function()
59-
require("nvim-surround").setup({
60-
-- Configuration here, or leave empty to use defaults
61-
})
62-
end
63-
})
64-
```
65-
6653
## :rocket: Usage
6754

6855
The three "core" operations of `add`/`delete`/`change` can be done with the
@@ -82,9 +69,10 @@ respectively. For the following examples, `*` will denote the cursor position:
8269
delete(functi*on calls) dsf function calls
8370
```
8471

85-
Note that surrounding with an opening delimiter (e.g. `(`) will add a space before/after
86-
the selection, while surrounding with the closing delimiter (e.g. `)`) will not include
87-
the spaces. Detailed information on how to use this plugin can be found in
72+
Note that surrounding with an opening delimiter (e.g. `(`) will add a space
73+
before/after the selection, while surrounding with the closing delimiter (e.g.
74+
`)`) will not include the spaces. Detailed information on how to use this plugin
75+
can be found in
8876
[`:h nvim-surround.usage`](https://github.com/kylechui/nvim-surround/blob/main/doc/nvim-surround.txt).
8977

9078
## :gear: Configuration

doc/nvim-surround.txt

Lines changed: 275 additions & 180 deletions
Large diffs are not rendered by default.

lua/nvim-surround/annotations.lua

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
---@field change change_table
3232

3333
---@class options
34-
---@field keymaps table<string, string>
3534
---@field surrounds table<string, surround>
3635
---@field aliases table<string, string|string[]>
3736
---@field highlight { duration: integer }
@@ -54,7 +53,6 @@
5453
---@field change? user_change
5554

5655
---@class user_options
57-
---@field keymaps? table<string, false|string>
5856
---@field surrounds? table<string, false|user_surround>
5957
---@field aliases? table<string, false|string|string[]>
6058
---@field highlight? { duration: false|integer }

0 commit comments

Comments
 (0)