-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommands.lua
51 lines (45 loc) · 1.28 KB
/
commands.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
-- File: Some customized convenient commands.
-- Quick Open File: view list of files using `telescope.builtin.find_files`.
function QuickOpenFile()
local ok, _ = pcall(require, 'telescope')
if not ok then
print('<Plug>telescope not loaded.')
return -- early.
end
local builtin = require('telescope.builtin')
local themes = require('telescope.themes')
builtin.find_files(themes.get_dropdown({
prompt_title = 'Quick Open', previewer = false
}))
end
vim.api.nvim_create_user_command('QuickOpenFile', QuickOpenFile, {
desc = 'Open file list in current directory',
})
vim.api.nvim_create_autocmd('VimEnter', {
pattern = '*',
-- once = true,
callback = function()
local args = vim.fn.argv()
if #args == 0 then
QuickOpenFile()
elseif args[1] == '.' then
if vim.fn.bufname() == '.' then
vim.cmd('bwipeout') -- as a bandage to remove the "." buffer.
end
QuickOpenFile()
end
end,
})
function GrepString()
local ok, _ = pcall(require, 'telescope')
if not ok then
print('<Plug>telescope not loaded.')
return
end
vim.ui.input({ prompt = 'grep_string: ' }, function(input)
require('telescope.builtin').grep_string({ search = input })
end)
end
vim.api.nvim_create_user_command('GrepString', GrepString, {
desc = 'Prompt for string, then :Telescope grep_string.',
})