Skip to content

Commit 5f2833c

Browse files
committed
update
- cmds: Sg/SG -> query with ast grep - rm null-ls, pounce, cmp-nvim-lua
1 parent 49a39aa commit 5f2833c

File tree

6 files changed

+51
-23
lines changed

6 files changed

+51
-23
lines changed

autoload/aceforeverd/plugin.vim

+8
Original file line numberDiff line numberDiff line change
@@ -344,11 +344,19 @@ function! s:config_plugins() abort
344344
nnoremap <Space>B :BLines<CR>
345345
nnoremap <Space>L :Lines<CR>
346346
347+
" GGrep <pattern>
347348
command! -bang -nargs=* GGrep
348349
\ call fzf#vim#grep(
349350
\ 'git grep --line-number -- '.shellescape(<q-args>), 0,
350351
\ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), <bang>0)
351352

353+
" SG <sg pattern>. relaunch sg on every keystroke
354+
" TODO: sg pattern do not work well with single quote pattern
355+
command! -bang -nargs=* SG
356+
\ call fzf#vim#grep2(
357+
\ 'sg run --heading never --pattern ', <q-args>, 0,
358+
\ fzf#vim#with_preview(), <bang>0)
359+
352360
" more for vim-rsi
353361
let g:rsi_no_meta = 1
354362
" <c-a> & <c-e> -> <HOME> & <END>, <c-b> & <c-f> -> forward & backward

lua/aceforeverd/cmd.lua

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
-- runs a lua expr and print its results
2+
local function inspect(opts)
3+
local res = vim.api.nvim_eval('luaeval("' .. vim.fn.escape(opts.args, '"') .. '")')
4+
vim.notify(vim.inspect(res), vim.log.levels.INFO, {})
5+
end
6+
7+
return {
8+
setup = function()
9+
vim.api.nvim_create_user_command('LuaInspect', inspect, { complete = 'lua', nargs = 1 })
10+
11+
-- Sg <pattern> [<dir1> <dir2> ...]
12+
vim.api.nvim_create_user_command(
13+
'Sg',
14+
require('aceforeverd.keymap.init').ast_grep_search,
15+
-- TODO: custom complete function
16+
{ nargs = '+', desc = 'ast grep search', complete = 'dir' }
17+
)
18+
end,
19+
}

lua/aceforeverd/config/cmp.lua

+1-3
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,10 @@ function M.setup()
6666

6767
-- level 1 source
6868
local sources_1 = {
69-
{ name = 'nvim_lsp' },
7069
{ name = "lazydev" },
70+
{ name = 'nvim_lsp' },
7171
{ name = 'luasnip', option = { use_show_condition = false } },
7272

73-
{ name = 'nvim_lua' },
7473
{ name = 'path' },
7574

7675
{ name = 'git' },
@@ -141,7 +140,6 @@ function M.setup()
141140
luasnip = '[LuaSnip]',
142141
buffer = '[Buffer]',
143142
path = '[Path]',
144-
nvim_lua = '[Lua]',
145143
look = '[Look]',
146144
emoji = '[Emoji]',
147145
treesitter = '[TreeSitter]',

lua/aceforeverd/init.lua

+1-8
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ local function on_term_enter()
1919
vim.cmd[[DisableWhitespace]]
2020
end
2121

22-
-- runs a lua expr and print its results
23-
local function inspect(opts)
24-
local res = vim.api.nvim_eval('luaeval("' .. vim.fn.escape(opts.args, '"') .. '")')
25-
vim.notify(vim.inspect(res), vim.log.levels.INFO, {})
26-
end
27-
2822
function M.setup()
2923
if vim.g.lsp_process_provider == nil then
3024
vim.g.lsp_process_provider = 'lsp_status'
@@ -64,8 +58,7 @@ function M.setup()
6458
callback = on_term_enter,
6559
})
6660

67-
vim.api.nvim_create_user_command('LuaInspect', inspect, { complete = 'lua', nargs = 1 })
68-
61+
require('aceforeverd.cmd').setup()
6962
require('aceforeverd.plugins').setup()
7063

7164
-- keymap guideline

lua/aceforeverd/keymap/init.lua

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
---@param opts table ast grep search pattern
2+
local function ast_grep_search(opts)
3+
local args = opts.fargs
4+
local pattern = args[1]
5+
6+
local cmds = { 'sg', 'run', '--heading', 'never', '--pattern', pattern }
7+
for i = 2, #args, 1 do
8+
table.insert(cmds, args[i])
9+
end
10+
11+
local expr = string.format(
12+
'system([%s])',
13+
vim.iter(cmds):map(function(v)
14+
return vim.fn.shellescape(v)
15+
end):join(", ")
16+
)
17+
vim.cmd('lgetexpr ' .. expr)
18+
vim.cmd('lopen')
19+
end
20+
121
return {
2-
select_browse_plugin = require('aceforeverd.keymap.plugin_browse').select_browse_plugin
22+
select_browse_plugin = require('aceforeverd.keymap.plugin_browse').select_browse_plugin,
23+
ast_grep_search = ast_grep_search,
324
}

lua/aceforeverd/plugins/init.lua

-11
Original file line numberDiff line numberDiff line change
@@ -317,16 +317,6 @@ M.plugin_list = {
317317
event = 'VeryLazy',
318318
},
319319

320-
{
321-
'nvimtools/none-ls.nvim',
322-
dependencies = {
323-
'nvim-lua/plenary.nvim',
324-
},
325-
config = function()
326-
require('aceforeverd.plugins.null-ls').setup()
327-
end,
328-
},
329-
330320
{
331321
'mfussenegger/nvim-lint',
332322
config = function()
@@ -424,7 +414,6 @@ M.plugin_list = {
424414
'hrsh7th/cmp-nvim-lsp',
425415
'hrsh7th/cmp-buffer',
426416
'hrsh7th/cmp-path',
427-
'hrsh7th/cmp-nvim-lua',
428417
'hrsh7th/cmp-emoji',
429418
'uga-rosa/cmp-dictionary',
430419
'ray-x/cmp-treesitter',

0 commit comments

Comments
 (0)