Skip to content

Commit

Permalink
feat(vscode): make flash work properly in vscode by updating/changing…
Browse files Browse the repository at this point in the history
… the default config. Fixes #58
  • Loading branch information
folke committed Jun 25, 2023
1 parent d4c30b1 commit fa72836
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 7 additions & 1 deletion lua/flash/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
6 changes: 0 additions & 6 deletions lua/flash/prompt.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ function M.visible()
end

function M.show()
if vim.g.vscode then
return
end
if M.visible() then
return
end
Expand Down Expand Up @@ -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 }
Expand Down

0 comments on commit fa72836

Please sign in to comment.