Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
- cmds: Sg/SG -> query with ast grep
- rm null-ls, pounce, cmp-nvim-lua
  • Loading branch information
aceforeverd committed Aug 21, 2024
1 parent 49a39aa commit 5f2833c
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 23 deletions.
8 changes: 8 additions & 0 deletions autoload/aceforeverd/plugin.vim
Original file line number Diff line number Diff line change
Expand Up @@ -344,11 +344,19 @@ function! s:config_plugins() abort
nnoremap <Space>B :BLines<CR>
nnoremap <Space>L :Lines<CR>
" GGrep <pattern>
command! -bang -nargs=* GGrep
\ call fzf#vim#grep(
\ 'git grep --line-number -- '.shellescape(<q-args>), 0,
\ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), <bang>0)

" SG <sg pattern>. relaunch sg on every keystroke
" TODO: sg pattern do not work well with single quote pattern
command! -bang -nargs=* SG
\ call fzf#vim#grep2(
\ 'sg run --heading never --pattern ', <q-args>, 0,
\ fzf#vim#with_preview(), <bang>0)

" more for vim-rsi
let g:rsi_no_meta = 1
" <c-a> & <c-e> -> <HOME> & <END>, <c-b> & <c-f> -> forward & backward
Expand Down
19 changes: 19 additions & 0 deletions lua/aceforeverd/cmd.lua
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,
}
4 changes: 1 addition & 3 deletions lua/aceforeverd/config/cmp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ function M.setup()

-- level 1 source
local sources_1 = {
{ name = 'nvim_lsp' },
{ name = "lazydev" },
{ name = 'nvim_lsp' },
{ name = 'luasnip', option = { use_show_condition = false } },

{ name = 'nvim_lua' },
{ name = 'path' },

{ name = 'git' },
Expand Down Expand Up @@ -141,7 +140,6 @@ function M.setup()
luasnip = '[LuaSnip]',
buffer = '[Buffer]',
path = '[Path]',
nvim_lua = '[Lua]',
look = '[Look]',
emoji = '[Emoji]',
treesitter = '[TreeSitter]',
Expand Down
9 changes: 1 addition & 8 deletions lua/aceforeverd/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ local function on_term_enter()
vim.cmd[[DisableWhitespace]]
end

-- 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

function M.setup()
if vim.g.lsp_process_provider == nil then
vim.g.lsp_process_provider = 'lsp_status'
Expand Down Expand Up @@ -64,8 +58,7 @@ function M.setup()
callback = on_term_enter,
})

vim.api.nvim_create_user_command('LuaInspect', inspect, { complete = 'lua', nargs = 1 })

require('aceforeverd.cmd').setup()
require('aceforeverd.plugins').setup()

-- keymap guideline
Expand Down
23 changes: 22 additions & 1 deletion lua/aceforeverd/keymap/init.lua
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,
}
11 changes: 0 additions & 11 deletions lua/aceforeverd/plugins/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -317,16 +317,6 @@ M.plugin_list = {
event = 'VeryLazy',
},

{
'nvimtools/none-ls.nvim',
dependencies = {
'nvim-lua/plenary.nvim',
},
config = function()
require('aceforeverd.plugins.null-ls').setup()
end,
},

{
'mfussenegger/nvim-lint',
config = function()
Expand Down Expand Up @@ -424,7 +414,6 @@ M.plugin_list = {
'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-path',
'hrsh7th/cmp-nvim-lua',
'hrsh7th/cmp-emoji',
'uga-rosa/cmp-dictionary',
'ray-x/cmp-treesitter',
Expand Down

0 comments on commit 5f2833c

Please sign in to comment.