diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2026-05-14 14:39:32 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2026-05-14 14:39:32 +0200 |
| commit | 5847137f3d4a58475427bc128da929a649ebea14 (patch) | |
| tree | 41951a51f10d2ebf67c306cbe357745ec3a144b1 | |
| parent | 49c26dd03681de5e194fc8ebcabe0c7c5d8960ad (diff) | |
| download | vis-lspc-5847137f3d4a58475427bc128da929a649ebea14.tar.gz vis-lspc-5847137f3d4a58475427bc128da929a649ebea14.zip | |
export lspc_select as lspc:select
This allows external code to reuse the select method.
Example visrc.lua:
local lspc = require('plugins/vis-lspc')
local choice = lspc:select({'A', 'B', 'C', '6'})
| -rw-r--r-- | README.md | 11 | ||||
| -rw-r--r-- | init.lua | 10 |
2 files changed, 16 insertions, 5 deletions
@@ -253,6 +253,17 @@ get_running_ls(win, explicit_syntax) - `win` - a window in which the language server is running - `explicit_syntax` - syntax of the language server if it differs from `win.syntax` +#### `lspc.select` + +Select an item from a list of choices by calling the external program specified by `lspc.menu_cmd`. + +```lua +lspc.select(lspc, choices) -- or +lspc:select(choices) +``` + + - `choices` - A numeric table containing the possible choices + ## License All code except otherwise noted is licensed under the term of GPL-3. @@ -215,7 +215,7 @@ local function lsp_range_starts_before(r1, r2) end -- concatenate all numeric values in choices and pass it on stdin to lspc.menu_cmd -local function lspc_select(choices) +function lspc:select(choices) local menu_input = '' local i = 0 for _, c in ipairs(choices) do @@ -228,8 +228,8 @@ local function lspc_select(choices) return choices[1] end - local fullscreen = lspc.menu_cmd == 'fzf' - local status, output = util.vis_pipe(menu_input, lspc.menu_cmd, fullscreen) + local fullscreen = self.menu_cmd == 'fzf' + local status, output = util.vis_pipe(menu_input, self.menu_cmd, fullscreen) local choice = nil if status == 0 then @@ -307,7 +307,7 @@ local function lspc_select_location(locations) end -- select a location - local choice = lspc_select(choices) + local choice = lspc:select(choices) if not choice then return nil end @@ -805,7 +805,7 @@ local function lspc_handle_completion_method_response(win, result, old_pos) end -- select a completion - local choice = lspc_select(choices) + local choice = lspc:select(choices) if not choice then return end |
