This commit is contained in:
Jeff Lance 2022-07-20 00:58:49 +02:00
parent de31ee2c56
commit c27e4373d1
5 changed files with 99 additions and 17 deletions

View File

@ -21,6 +21,25 @@ local db = require('dashboard')
local dotfiles = home .. '/dotfiles' local dotfiles = home .. '/dotfiles'
db.custom_header = {
'',
' ⣿⣿⣷⡁⢆⠈⠕⢕⢂⢕⢂⢕⢂⢔⢂⢕⢄⠂⣂⠂⠆⢂⢕⢂⢕⢂⢕⢂⢕⢂ ',
' ⣿⣿⣿⡷⠊⡢⡹⣦⡑⢂⢕⢂⢕⢂⢕⢂⠕⠔⠌⠝⠛⠶⠶⢶⣦⣄⢂⢕⢂⢕ ',
' ⣿⣿⠏⣠⣾⣦⡐⢌⢿⣷⣦⣅⡑⠕⠡⠐⢿⠿⣛⠟⠛⠛⠛⠛⠡⢷⡈⢂⢕⢂ ',
' ⠟⣡⣾⣿⣿⣿⣿⣦⣑⠝⢿⣿⣿⣿⣿⣿⡵⢁⣤⣶⣶⣿⢿⢿⢿⡟⢻⣤⢑⢂ ',
' ⣾⣿⣿⡿⢟⣛⣻⣿⣿⣿⣦⣬⣙⣻⣿⣿⣷⣿⣿⢟⢝⢕⢕⢕⢕⢽⣿⣿⣷⣔ ',
' ⣿⣿⠵⠚⠉⢀⣀⣀⣈⣿⣿⣿⣿⣿⣿⣿⣿⣿⣗⢕⢕⢕⢕⢕⢕⣽⣿⣿⣿⣿ ',
' ⢷⣂⣠⣴⣾⡿⡿⡻⡻⣿⣿⣴⣿⣿⣿⣿⣿⣿⣷⣵⣵⣵⣷⣿⣿⣿⣿⣿⣿⡿ ',
' ⢌⠻⣿⡿⡫⡪⡪⡪⡪⣺⣿⣿⣿⣿⣿⠿⠿⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠃ ',
' ⠣⡁⠹⡪⡪⡪⡪⣪⣾⣿⣿⣿⣿⠋⠐⢉⢍⢄⢌⠻⣿⣿⣿⣿⣿⣿⣿⣿⠏⠈ ',
' ⡣⡘⢄⠙⣾⣾⣾⣿⣿⣿⣿⣿⣿⡀⢐⢕⢕⢕⢕⢕⡘⣿⣿⣿⣿⣿⣿⠏⠠⠈ ',
' ⠌⢊⢂⢣⠹⣿⣿⣿⣿⣿⣿⣿⣿⣧⢐⢕⢕⢕⢕⢕⢅⣿⣿⣿⣿⡿⢋⢜⠠⠈ ',
' ⠄⠁⠕⢝⡢⠈⠻⣿⣿⣿⣿⣿⣿⣿⣷⣕⣑⣑⣑⣵⣿⣿⣿⡿⢋⢔⢕⣿⠠⠈ ',
' ⠨⡂⡀⢑⢕⡅⠂⠄⠉⠛⠻⠿⢿⣿⣿⣿⣿⣿⣿⣿⣿⡿⢋⢔⢕⢕⣿⣿⠠⠈ ',
' ⠄⠪⣂⠁⢕⠆⠄⠂⠄⠁⡀⠂⡀⠄⢈⠉⢍⢛⢛⢛⢋⢔⢕⢕⢕⣽⣿⣿⠠⠈ ',
'',
}
db.custom_center = { db.custom_center = {
{ {
icon = nil, icon = nil,
@ -35,15 +54,14 @@ db.custom_center = {
}, },
{ {
desc = 'Fichiers récemment ouverts ', desc = 'Fichiers récemment ouverts ',
action = 'DashboardFindHistory', action = "lua require('telescope.builtin').oldfiles()",
shortcut = 'SPC f h' shortcut = 'SPC f h'
}, },
{ {
desc = 'Parcourir les dotfiles ', desc = 'Parcourir les dotfiles ',
action = "lua require('telescope.builtin').find_files({" .. dotfiles .. "})", action = "lua require('telescope.builtin').find_files({ cwd = \'" .. dotfiles .. "\' })",
-- action = 'Telescope dotfiles path=' .. home .. '/dotfiles',
shortcut = 'SPC f d' shortcut = 'SPC f d'
} },
} }
-- Highlight Group -- Highlight Group

View File

@ -72,13 +72,13 @@ endfunction
" Close current buffer " Close current buffer
" If the last buffer is closed go back to Startify " If the last buffer is closed go back to startup screen
function! BufClose() function! CloseBuffer()
if (CountBuffers() == 1 || IsExplorerBuffer() || IsEmptyBuffer()) if (CountBuffers() == 1 || IsExplorerBuffer() || IsEmptyBuffer())
bwipeout bwipeout!
Dashboard Dashboard
else else
bwipeout bwipeout!
endif endif
endfunction endfunction

View File

@ -688,6 +688,15 @@ let g:suda_smart_edit = 1
" }}} " }}}
" Telescope {{{
" -----
source $HOME/.config/nvim/telescope.lua
" -----
" }}}
" Tmuxline {{{ " Tmuxline {{{
" ----- " -----

View File

@ -54,15 +54,17 @@ map <C-s> :saveas<space>
" Buffers {{{ " Buffers {{{
" ----- " -----
command! -bang -nargs=? -complete=dir Files " command! -bang -nargs=? -complete=dir Files
\ call fzf#vim#files( " \ call fzf#vim#files(
\ <q-args>, " \ <q-args>,
\ fzf#vim#with_preview( " \ fzf#vim#with_preview(
\ {'options': ['--layout=reverse', '--info=inline']} " \ {'options': ['--layout=reverse', '--info=inline']}
\ ), " \ ),
\ <bang>0 " \ <bang>0
\ ) " \ )
map <C-w> :echom 'Close buffer' <bar> :call BufClose()<cr> command -bang CloseBuffer :call CloseBuffer()
map <C-w> :echom 'Close buffer' <bar> :CloseBuffer!<cr>
map <C-o> :e<space> map <C-o> :e<space>
map <C-n> :DashboardNewFile<cr> map <C-n> :DashboardNewFile<cr>
map <A-PageDown> :bn<cr> map <A-PageDown> :bn<cr>

53
conf.d/nvim/telescope.lua Normal file
View File

@ -0,0 +1,53 @@
local previewers = require("telescope.previewers")
local Job = require("plenary.job")
local new_maker = function(filepath, bufnr, opts)
filepath = vim.fn.expand(filepath)
Job:new({
command = "file",
args = { "--mime-type", "-b", filepath },
on_exit = function(j)
local mime_type = vim.split(j:result()[1], "/")[1]
if mime_type == "text" then
previewers.buffer_previewer_maker(filepath, bufnr, opts)
else
-- maybe we want to write something to the buffer here
vim.schedule(function()
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, { "BINARY" })
end)
end
end
}):sync()
end
require("telescope").setup {
defaults = {
preview = {
mime_hook = function(filepath, bufnr, opts)
local is_image = function(filepath)
local image_extensions = {'png','jpg'} -- Supported image formats
local split_path = vim.split(filepath:lower(), '.', {plain=true})
local extension = split_path[#split_path]
return vim.tbl_contains(image_extensions, extension)
end
if is_image(filepath) then
local term = vim.api.nvim_open_term(bufnr, {})
local function send_output(_, data, _ )
for _, d in ipairs(data) do
vim.api.nvim_chan_send(term, d..'\r\n')
end
end
vim.fn.jobstart(
{
'catimg', filepath -- Terminal image viewer command
},
{on_stdout=send_output, stdout_buffered=true})
else
require("telescope.previewers.utils").set_preview_message(bufnr, opts.winid, "Binary cannot be previewed")
end
end
},
buffer_previewer_maker = new_maker,
}
}