Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ttak0422 committed Jul 28, 2024
1 parent 30ab559 commit 3177c5d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
6 changes: 3 additions & 3 deletions fnl/hook-cmdline.fnl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(local cabbrev_path args.cabbrev_path)

(let [cmd vim.api.nvim_create_user_command]
(cmd :SearchToQf (fn [opts]
(let [command (if opts.bang :vimgrepadd :vimgrep)
Expand Down Expand Up @@ -27,6 +29,4 @@
(each [_ k (ipairs N)]
(vim.keymap.set :n (. k 1) (. k 2) (or (. k 3) opts))))

(vim.cmd "
cabbrev <expr> r getcmdtype() .. getcmdline() ==# ':r' ? [getchar(), ''][1] .. '%s//g<Left><Left>' : (getcmdline() ==# ''<,'>r' ? [getchar(), ''][1] .. 's//g<Left><Left>' : 'r')
")
(vim.cmd (.. "source " cabbrev_path))
3 changes: 2 additions & 1 deletion lua/autogen/hook-cmdline.lua

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion main/hook.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ with pkgs.vimPlugins;
hooks.userEvents = [ "SpecificFileEnter" ];
};
hookCmdline = {
postConfig = read ../lua/autogen/hook-cmdline.lua;
postConfig = {
code = read ../lua/autogen/hook-cmdline.lua;
args = {
cabbrev_path = ../vim/cabbrev.vim;
};
};
hooks.events = [ "CmdlineEnter" ];
};
hookEdit = {
Expand Down
1 change: 1 addition & 0 deletions vim/cabbrev.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cabbrev <expr> r getcmdtype() .. getcmdline() ==# ":r" ? [getchar(), ""][1] .. "%s//g<Left><Left>" : (getcmdline() ==# "'<,'>r" ? [getchar(), ""][1] .. "s//g<Left><Left>" : "r")

0 comments on commit 3177c5d

Please sign in to comment.