Add Colorscheme and Marks Support and Telescope Commands (#167)
* Add Telescope Commands * Add Colorscheme support * Add Command for coloscehme * add marks support * rename commad
This commit is contained in:
@@ -774,4 +774,68 @@ builtin.man_pages = function(opts)
|
|||||||
}):find()
|
}):find()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
builtin.colorscheme = function(opts)
|
||||||
|
opts = opts or {}
|
||||||
|
|
||||||
|
local colors = vim.list_extend(opts.colors or {}, vim.fn.getcompletion('', 'color'))
|
||||||
|
|
||||||
|
pickers.new(opts,{
|
||||||
|
prompt = 'Change Colorscheme',
|
||||||
|
finder = finders.new_table {
|
||||||
|
results = colors
|
||||||
|
},
|
||||||
|
-- TODO: better preview?
|
||||||
|
sorter = sorters.get_generic_fuzzy_sorter(),
|
||||||
|
attach_mappings = function(prompt_bufnr, map)
|
||||||
|
local change_colorscheme = function()
|
||||||
|
local selection = actions.get_selected_entry(prompt_bufnr)
|
||||||
|
|
||||||
|
actions.close(prompt_bufnr)
|
||||||
|
print(vim.inspect(selection.value))
|
||||||
|
vim.cmd("colorscheme " .. selection.value)
|
||||||
|
end
|
||||||
|
|
||||||
|
map('i', '<CR>', change_colorscheme)
|
||||||
|
map('n', '<CR>', change_colorscheme)
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
}):find()
|
||||||
|
end
|
||||||
|
|
||||||
|
builtin.marks = function(opts)
|
||||||
|
opts = opts or {}
|
||||||
|
|
||||||
|
local marks = vim.api.nvim_exec("marks", true)
|
||||||
|
local marks_table = vim.fn.split(marks,'\n')
|
||||||
|
|
||||||
|
pickers.new(opts,{
|
||||||
|
prompt = 'Marks',
|
||||||
|
finder = finders.new_table {
|
||||||
|
results = marks_table,
|
||||||
|
},
|
||||||
|
previewer = previewers.man.new(opts),
|
||||||
|
sorter = sorters.get_generic_fuzzy_sorter(),
|
||||||
|
attach_mappings = function(prompt_bufnr, map)
|
||||||
|
local jump_marks = function()
|
||||||
|
local selection = actions.get_selected_entry(prompt_bufnr)
|
||||||
|
local marks_data = {}
|
||||||
|
for v in selection.value:gmatch("%S+") do
|
||||||
|
table.insert(marks_data,v)
|
||||||
|
end
|
||||||
|
|
||||||
|
local row,col = tonumber(marks_data[2]),tonumber(marks_data[3])
|
||||||
|
actions.close(prompt_bufnr)
|
||||||
|
vim.api.nvim_command("edit "..marks_data[4])
|
||||||
|
vim.api.nvim_win_set_cursor(0,{row,col})
|
||||||
|
end
|
||||||
|
|
||||||
|
map('i', '<CR>', jump_marks)
|
||||||
|
map('n', '<CR>', jump_marks)
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
}):find()
|
||||||
|
end
|
||||||
|
|
||||||
return builtin
|
return builtin
|
||||||
|
|||||||
@@ -27,3 +27,26 @@ cnoremap <silent> <Plug>(TelescopeFuzzyCommandSearch) <C-\>e
|
|||||||
\ "lua require('telescope.builtin').command_history {
|
\ "lua require('telescope.builtin').command_history {
|
||||||
\ default_text = [=[" . escape(getcmdline(), '"') . "]=]
|
\ default_text = [=[" . escape(getcmdline(), '"') . "]=]
|
||||||
\ }"<CR><CR>
|
\ }"<CR><CR>
|
||||||
|
|
||||||
|
" Telescope Commands
|
||||||
|
command! -nargs=0 -bar TelescopeBuiltin lua require'telescope.builtin'.builtin{}
|
||||||
|
command! -nargs=0 -bar TelescopeFindFile lua require'telescope.builtin'.find_files{}
|
||||||
|
command! -nargs=0 -bar TelescopeLiveGrep lua require'telescope.builtin'.live_grep{}
|
||||||
|
command! -nargs=0 -bar TelescopeGrepString lua require'telescope.builtin'.grep_string{}
|
||||||
|
command! -nargs=0 -bar TelescopeFindGitFile lua require'telescope.builtin'.git_files{}
|
||||||
|
command! -nargs=0 -bar TelescopeOldFiles lua require'telescope.builtin'.oldfiles{}
|
||||||
|
command! -nargs=0 -bar TelescopeQuickFix lua require'telescope.builtin'.quickfix{}
|
||||||
|
command! -nargs=0 -bar TelescopeLocalList lua require'telescope.builtin'.loclist{}
|
||||||
|
command! -nargs=0 -bar TelescopeCommandHistory lua require'telescope.builtin'.command_history{}
|
||||||
|
command! -nargs=0 -bar TelescopeBuffers lua require'telescope.builtin'.buffers{}
|
||||||
|
command! -nargs=0 -bar TelescopeLspReferences lua require'telescope.builtin'.lsp_references{}
|
||||||
|
command! -nargs=0 -bar TelescopeLspDocumentSymbols lua require'telescope.builtin'.lsp_document_symbols{}
|
||||||
|
command! -nargs=0 -bar TelescopeLspWorkSpaceSymbols lua require'telescope.builtin'.lsp_workspace_symbols{}
|
||||||
|
command! -nargs=0 -bar TelescopeLspCodeActions lua require'telescope.builtin'.lsp_code_actions{}
|
||||||
|
command! -nargs=0 -bar TelescopeTreesitter lua require'telescope.builtin'.treesitter{}
|
||||||
|
command! -nargs=0 -bar TelescopePlanets lua require'telescope.builtin'.planets{}
|
||||||
|
command! -nargs=0 -bar TelescopeHelpTags lua require'telescope.builtin'.help_tags{}
|
||||||
|
command! -nargs=0 -bar TelescopeManPages lua require'telescope.builtin'.man_pages{}
|
||||||
|
command! -nargs=0 -bar TelescopeColorscheme lua require'telescope.builtin'.colorscheme{}
|
||||||
|
command! -nargs=0 -bar TelescopeMarks lua require'telescope.builtin'.marks{}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user