Skip to content

Commit a8a1d6e

Browse files
author
Jan Steinke
committed
add easy access to preview and non preview functions
1 parent 40dec5b commit a8a1d6e

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ applying.
1313
* [ ] break-down by edit and not by file
1414
* [ ] one buffer for all changes in a file, view-port shifts on selection
1515
* [ ] buffer contents updates based on selected changes
16+
* [ ] Allow sorting list by token type that changes (e.g. var, class, comment)
1617
* [x] allow disabling the preview
1718

1819
## Inspired by

Diff for: lua/lsp-preview/init.lua

+13
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ local util = require("vim.lsp.util")
44

55
local M = {}
66

7+
-- The original workspace_edit from the std library of vim for backup and resets.
78
local apply_workspace_edit = util.apply_workspace_edit
89

910
function M.setup(_)
@@ -29,6 +30,12 @@ M.rename = function(new_name, opts)
2930
vim.lsp.buf.rename(new_name, opts)
3031
end
3132

33+
M.rename_preview = function(new_name, opts)
34+
opts = opts or {}
35+
opts.preview = true
36+
M.rename(new_name, opts)
37+
end
38+
3239
M.code_action = function(opts)
3340
opts = opts or {}
3441

@@ -50,4 +57,10 @@ M.code_action = function(opts)
5057
vim.lsp.buf.code_action(opts)
5158
end
5259

60+
M.code_action_preview = function(opts)
61+
opts = opts or {}
62+
opts.preview = true
63+
M.code_action(opts)
64+
end
65+
5366
return M

Diff for: lua/lsp-preview/workspace_edit.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ local lTelescope = require("lsp-preview.telescope")
44
local M = {}
55

66
---Used as injection for the telescope picker to apply the selection.
7-
---Filters the workspace edit for the selected hunks.
7+
---Filters the workspace edit for the selected hunks and applies it.
88
---@param workspace_edit WorkspaceEdit
99
---@param offset_encoding string
1010
---@return fun(selected_indices: {value: Value}[])

0 commit comments

Comments
 (0)