From fa72836760417436cfe8e33ee74edaefd8ee9e00 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 25 Jun 2023 19:42:00 +0200 Subject: [PATCH] feat(vscode): make flash work properly in vscode by updating/changing the default config. Fixes #58 --- README.md | 4 ++++ lua/flash/config.lua | 8 +++++++- lua/flash/prompt.lua | 6 ------ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 1006677..9bc2db6 100644 --- a/README.md +++ b/README.md @@ -284,6 +284,10 @@ Install the plugin with your preferred package manager: - you'll be back in the original window / position - **jump**: `require("flash").jump(opts?)` opens **flash** with the given options - type any number of characters before typing a jump label +- **VS Code**: some functionality is changed/disabled when running **flash** in **VS Code**: + - `prompt` is disabled + - `highlights` are set to different defaults that will actually work in VS Code + - `search.multi_window` is disabled, since VS Code has problems with `vim.api.nvim_set_current_win` ## 📡 API diff --git a/lua/flash/config.lua b/lua/flash/config.lua index 4836ac4..2bde9a3 100644 --- a/lua/flash/config.lua +++ b/lua/flash/config.lua @@ -207,7 +207,13 @@ function M.get(...) end end - return vim.tbl_deep_extend("force", {}, defaults, options or {}, unpack(all)) + ---@type Flash.State.Config + local ret = vim.tbl_deep_extend("force", {}, defaults, options or {}, unpack(all)) + if vim.g.vscode then + ret.prompt.enabled = false + ret.search.multi_window = false + end + return ret end return setmetatable(M, { diff --git a/lua/flash/prompt.lua b/lua/flash/prompt.lua index 827adb0..6a89c46 100644 --- a/lua/flash/prompt.lua +++ b/lua/flash/prompt.lua @@ -12,9 +12,6 @@ function M.visible() end function M.show() - if vim.g.vscode then - return - end if M.visible() then return end @@ -62,9 +59,6 @@ end ---@param pattern string function M.set(pattern) - if vim.g.vscode then - return - end M.show() local text = vim.deepcopy(Config.prompt.prefix) text[#text + 1] = { pattern }