Skip to content

Commit

Permalink
add easy access to preview and non preview functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Steinke committed Mar 27, 2024
1 parent 40dec5b commit a8a1d6e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ applying.
* [ ] break-down by edit and not by file
* [ ] one buffer for all changes in a file, view-port shifts on selection
* [ ] buffer contents updates based on selected changes
* [ ] Allow sorting list by token type that changes (e.g. var, class, comment)
* [x] allow disabling the preview

## Inspired by
Expand Down
13 changes: 13 additions & 0 deletions lua/lsp-preview/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ local util = require("vim.lsp.util")

local M = {}

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

function M.setup(_)
Expand All @@ -29,6 +30,12 @@ M.rename = function(new_name, opts)
vim.lsp.buf.rename(new_name, opts)
end

M.rename_preview = function(new_name, opts)
opts = opts or {}
opts.preview = true
M.rename(new_name, opts)
end

M.code_action = function(opts)
opts = opts or {}

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

M.code_action_preview = function(opts)
opts = opts or {}
opts.preview = true
M.code_action(opts)
end

return M
2 changes: 1 addition & 1 deletion lua/lsp-preview/workspace_edit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local lTelescope = require("lsp-preview.telescope")
local M = {}

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

0 comments on commit a8a1d6e

Please sign in to comment.