aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--init.lua34
-rw-r--r--lspc.lua2
3 files changed, 21 insertions, 16 deletions
diff --git a/README.md b/README.md
index 6825aef..8475982 100644
--- a/README.md
+++ b/README.md
@@ -120,6 +120,7 @@ Available options are:
* `autostart = true` - try to start a language server in WIN_OPEN
* `menu_cmd = 'fzf' or 'vis-menu'` - program to prompt for user choices
* `confirm_cmd = 'vis-menu'` - program to prompt for user confirmation
+* `autoconfirm_edits = false` - apply workspaceEdits without user confirmation
* `ls_map` - a table mapping `vis` syntax names to language server configurations
* `highlight_diagnostics = 'line'` - highlight the `range` or `line`number of available diagnostics
* `diagnostic_style_id = nil` - vis style id used to highlight diagnostics, win.STYLE_LEXER_MAX is used by default
diff --git a/init.lua b/init.lua
index 469736b..29a4ed2 100644
--- a/init.lua
+++ b/init.lua
@@ -487,27 +487,29 @@ local function vis_apply_workspaceEdit(_, _, workspaceEdit)
end
end
- -- generate change summary
- local summary = '--- workspace edit summary ---\n'
- for uri, edits in pairs(file_edits) do
- local path = uri_to_path(uri)
- summary = summary .. path .. ':\n'
- for i, edit in ipairs(edits) do
- summary = summary .. '\t' .. i .. '.: ' .. lspc.json.encode(edit) .. '\n'
+ if not lspc.autoconfirm_edits then
+ -- generate change summary
+ local summary = '--- workspace edit summary ---\n'
+ for uri, edits in pairs(file_edits) do
+ local path = uri_to_path(uri)
+ summary = summary .. path .. ':\n'
+ for i, edit in ipairs(edits) do
+ summary = summary .. '\t' .. i .. '.: ' .. lspc.json.encode(edit) .. '\n'
+ end
end
- end
- lspc_show_message(summary)
- vis:redraw()
+ lspc_show_message(summary)
+ vis:redraw()
- -- get user confirmation
- local confirmation = lspc_confirm('apply changes:')
+ -- get user confirmation
+ local confirmation = lspc_confirm('apply changes:')
- -- close summary window
- lspc_close_message_win()
+ -- close summary window
+ lspc_close_message_win()
- if not confirmation then
- return
+ if not confirmation then
+ return
+ end
end
-- apply changes to open files
diff --git a/lspc.lua b/lspc.lua
index d8348a4..f34ba4d 100644
--- a/lspc.lua
+++ b/lspc.lua
@@ -23,6 +23,8 @@ local lspc = {
menu_cmd = 'vis-menu -l 10',
-- program used to ask the user for confirmation
confirm_cmd = 'vis-menu',
+ -- apply workspaceEdits without confirmation
+ autoconfirm_edits = false,
-- should diagnostics be highlighted if available
highlight_diagnostics = 'line',