Skip to content

Commit ab5ff6b

Browse files
committed
fix(nvim): fh, fj, fk, fl, sh, sj, sk, sl, rh, rj, rk, rl now has a special f_mode and r_mode
1 parent f4e70bb commit ab5ff6b

File tree

3 files changed

+66
-6
lines changed

3 files changed

+66
-6
lines changed

nvim/init.lua

+41-2
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ local plugins = {
4949
},
5050
{
5151
"folke/flash.nvim",
52-
commit = "48817af25f51c0590653bbc290866e4890fe1cbe",
52+
commit = "11a2e667d19d8f48c93c6ed2e2e525ac6b1b79be",
5353
event = "VeryLazy",
54-
opts = {},
54+
opts = { modes = { search = { enabled = true}}},
5555
},
5656
{ "machakann/vim-columnmove", commit = "21a43d809a03ff9bf9946d983d17b3a316bf7a64", event = "VeryLazy" },
5757

@@ -152,6 +152,7 @@ if not vim.g.vscode then
152152
vim.cmd [[ au VimEnter * :TSEnable highlight" ]]
153153
vim.cmd [[ color poimandres ]]
154154
vim.api.nvim_set_hl(0, "Comment", { fg = "#444444", bg = "NONE" })
155+
vim.api.nvim_set_hl(0, "FlashLabel", { fg = "NONE", bg = "#5FB3A1" })
155156
vim.api.nvim_set_hl(0, "Visual", { fg = "NONE", bg = "#1c1c1c" })
156157
vim.api.nvim_set_hl(0, "MiniCursorword", { fg = "NONE", bg = "#1c1c2c" })
157158
end
@@ -202,6 +203,44 @@ end
202203

203204
------------------------------------------------------------------------------------------------------------------------
204205

206+
-- vscode's keybinding.json with neovim.fullMode context for flash mode and replace mode
207+
-- https://github.com/vscode-neovim/vscode-neovim/issues/1718
208+
209+
-- to view which keypresses is mapped to, run:
210+
-- :lua vim.on_key(function(key) vim.notify(key .. vim.api.nvim_get_mode().mode) end)
211+
-- :lua vim.on_key(function(key) vim.print({ key, vim.api.nvim_get_mode().mode }) end)
212+
213+
if vim.g.vscode then
214+
vim.on_key(function(key)
215+
216+
local esc_termcode = vim.api.nvim_replace_termcodes("<esc>", true, false, true)
217+
local key_termcode = vim.api.nvim_replace_termcodes(key, true, false, true)
218+
219+
if key_termcode:find("X.*g") then
220+
-- vim.print("f_mode_enter");
221+
vscode.call("setContext", { args = { "neovim.fullMode", "f" }, })
222+
end
223+
224+
if (vim.api.nvim_get_mode().mode == "n" and key_termcode:find("'")) or key_termcode:find(esc_termcode) or key_termcode:find("X.*h") then
225+
-- vim.print("f_mode_exit");
226+
vscode.call("setContext", { args = { "neovim.fullMode", "n" }, })
227+
end
228+
229+
if vim.api.nvim_get_mode().mode == "n" and key_termcode:find("r") then
230+
-- vim.print("r_mode_enter");
231+
vscode.call("setContext", { args = { "neovim.fullMode", "r" }, })
232+
end
233+
234+
if vim.api.nvim_get_mode().mode == "R" then
235+
-- vim.print("r_mode_exit");
236+
vscode.call("setContext", { args = { "neovim.fullMode", "n" }, })
237+
end
238+
239+
end)
240+
end
241+
242+
------------------------------------------------------------------------------------------------------------------------
243+
205244
local M = {}
206245

207246
-- https://www.reddit.com/r/neovim/comments/zc720y/tip_to_manage_hlsearch/

nvim/lazy-lock.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
{
22
"codeium.vim": { "branch": "main", "commit": "31dd2962c81759be007895db6ce089feec397c86" },
3-
"flash.nvim": { "branch": "main", "commit": "48817af25f51c0590653bbc290866e4890fe1cbe" },
3+
"flash.nvim": { "branch": "main", "commit": "11a2e667d19d8f48c93c6ed2e2e525ac6b1b79be" },
44
"gitsigns.nvim": { "branch": "main", "commit": "b45ff86f5618d1421a88c12d4feb286b80a1e2d3" },
5-
"lazy.nvim": { "branch": "main", "commit": "3f13f080434ac942b150679223d54f5ca91e0d52" },
5+
"lazy.nvim": { "branch": "main", "commit": "24fa2a97085ca8a7220b5b078916f81e316036fd" },
66
"mason-lspconfig.nvim": { "branch": "main", "commit": "1a14770dc8c7cb29643870ac79788eec6f7ce1f8" },
77
"mason-null-ls.nvim": { "branch": "main", "commit": "de19726de7260c68d94691afb057fa73d3cc53e7" },
88
"mason.nvim": { "branch": "main", "commit": "751b1fcbf3d3b783fcf8d48865264a9bcd8f9b10" },
99
"mini.nvim": { "branch": "main", "commit": "04f8d6e0acd5a52d01ec1c392e3947135dbfd8ef" },
1010
"none-ls.nvim": { "branch": "main", "commit": "88821b67e6007041f43b802f58e3d9fa9bfce684" },
1111
"nvim-lspconfig": { "branch": "master", "commit": "cfa386fc4027e847156ee16141ea1f4c0bc2f0a4" },
12-
"nvim-treesitter": { "branch": "master", "commit": "c36681bb496ebce2946867459ed08774cb61788c" },
12+
"nvim-treesitter": { "branch": "master", "commit": "567a76780cd4f982dae1ec57e3dad6174bef3680" },
1313
"nvim-treesitter-textobjects": { "branch": "master", "commit": "d2a4ffc22d9d38d44edb73da007b3cf43451e9b4" },
1414
"nvim-various-textobjs": { "branch": "main", "commit": "6cefba253d69306004a641a11c395381ae428903" },
1515
"plenary.nvim": { "branch": "master", "commit": "5129a3693c482fcbc5ab99a7706ffc4360b995a0" },
1616
"poimandres.nvim": { "branch": "main", "commit": "77635055e686ae3c8a519198006ff0b43b6b2eae" },
1717
"textobj-word-column.vim": { "branch": "master", "commit": "cb40e1459817a7fa23741ff6df05e4481bde5a33" },
1818
"vim-columnmove": { "branch": "master", "commit": "21a43d809a03ff9bf9946d983d17b3a316bf7a64" }
19-
}
19+
}

package.json

+21
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,27 @@
806806
"when": "editorTextFocus && neovim.mode == normal"
807807
},
808808

809+
{
810+
"key": "h",
811+
"command": "cursorLeft",
812+
"when": "editorTextFocus && !(neovim.fullMode =~ /^(f|r)/) && neovim.mode != 'insert' && neovim.mode != 'visual' && ( isWindows || isWeb )"
813+
},
814+
{
815+
"key": "j",
816+
"command": "cursorDown",
817+
"when": "editorTextFocus && !(neovim.fullMode =~ /^(f|r)/) && neovim.mode != 'insert' && neovim.mode != 'visual' && ( isWindows || isWeb )"
818+
},
819+
{
820+
"key": "k",
821+
"command": "cursorUp",
822+
"when": "editorTextFocus && !(neovim.fullMode =~ /^(f|r)/) && neovim.mode != 'insert' && neovim.mode != 'visual' && ( isWindows || isWeb )"
823+
},
824+
{
825+
"key": "l",
826+
"command": "cursorRight",
827+
"when": "editorTextFocus && !(neovim.fullMode =~ /^(f|r)/) && neovim.mode != 'insert' && neovim.mode != 'visual' && ( isWindows || isWeb )"
828+
},
829+
809830
{ "key": "ctrl+alt+right", "command": "cursorWordPartRightSelect" }
810831
]
811832
},

0 commit comments

Comments
 (0)