-
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.
- cmds: Sg/SG -> query with ast grep - rm null-ls, pounce, cmp-nvim-lua
- Loading branch information
1 parent
49a39aa
commit 5f2833c
Showing
6 changed files
with
51 additions
and
23 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
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,19 @@ | ||
-- runs a lua expr and print its results | ||
local function inspect(opts) | ||
local res = vim.api.nvim_eval('luaeval("' .. vim.fn.escape(opts.args, '"') .. '")') | ||
vim.notify(vim.inspect(res), vim.log.levels.INFO, {}) | ||
end | ||
|
||
return { | ||
setup = function() | ||
vim.api.nvim_create_user_command('LuaInspect', inspect, { complete = 'lua', nargs = 1 }) | ||
|
||
-- Sg <pattern> [<dir1> <dir2> ...] | ||
vim.api.nvim_create_user_command( | ||
'Sg', | ||
require('aceforeverd.keymap.init').ast_grep_search, | ||
-- TODO: custom complete function | ||
{ nargs = '+', desc = 'ast grep search', complete = 'dir' } | ||
) | ||
end, | ||
} |
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
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
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,3 +1,24 @@ | ||
---@param opts table ast grep search pattern | ||
local function ast_grep_search(opts) | ||
local args = opts.fargs | ||
local pattern = args[1] | ||
|
||
local cmds = { 'sg', 'run', '--heading', 'never', '--pattern', pattern } | ||
for i = 2, #args, 1 do | ||
table.insert(cmds, args[i]) | ||
end | ||
|
||
local expr = string.format( | ||
'system([%s])', | ||
vim.iter(cmds):map(function(v) | ||
return vim.fn.shellescape(v) | ||
end):join(", ") | ||
) | ||
vim.cmd('lgetexpr ' .. expr) | ||
vim.cmd('lopen') | ||
end | ||
|
||
return { | ||
select_browse_plugin = require('aceforeverd.keymap.plugin_browse').select_browse_plugin | ||
select_browse_plugin = require('aceforeverd.keymap.plugin_browse').select_browse_plugin, | ||
ast_grep_search = ast_grep_search, | ||
} |
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