Skip to content

Commit

Permalink
lab/gx: visual selection 에서 한줄인 경우에 gx 를 통한 grep 지원
Browse files Browse the repository at this point in the history
  • Loading branch information
deptno committed Oct 18, 2023
1 parent dc5f1d9 commit d55c9c2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lua/lab/gx/handlers_v/grep.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
local trim = require("custom/lib/trim")
local handler = function(lines, matched)
if not pcall(require, 'telescope') then
return vim.notify('fail to require "telescope"')
end

vim.cmd(':Telescope live_grep default_text=' .. matched)
end
local match = function (lines)
if #lines == 1 then
local line = lines[1]

if line:gmatch('%w+') then
return trim(line)
end
end

return nil
end
local name = 'grep text'

return {
handler = handler,
match = match,
name = name,
}
1 change: 1 addition & 0 deletions lua/lab/gx/handlers_v/init.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
return {
require('lab/gx/handlers_v/github_commit_file_permalink'),
require('lab/gx/handlers_v/papago'),
require('lab/gx/handlers_v/grep'),
}

0 comments on commit d55c9c2

Please sign in to comment.