forked from NvChad/NvChad
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lab/gx: visual selection 에서 한줄인 경우에 gx 를 통한 grep 지원
- Loading branch information
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'), | ||
} |