Update 05.06.23

This commit is contained in:
Loïc Gremaud 2023-06-05 01:39:31 +02:00
parent b933fbe1d9
commit 722044c88a
No known key found for this signature in database
GPG Key ID: ACD9F65FA7E19986
9 changed files with 182 additions and 13 deletions

View File

@ -36,6 +36,9 @@ M.ui = {
-- round and block will work for minimal theme only -- round and block will work for minimal theme only
separator_style = "default", separator_style = "default",
overriden_modules = nil, overriden_modules = nil,
fileInfo = function()
return require("nvchad_ui.statusline.default.fileInfo").run()
end
}, },
-- lazyload it when there are 1+ buffers -- lazyload it when there are 1+ buffers

View File

@ -42,6 +42,7 @@ opt.splitright = true
opt.termguicolors = true opt.termguicolors = true
opt.timeoutlen = 400 opt.timeoutlen = 400
opt.undofile = true opt.undofile = true
opt.scrolloff = 15
-- interval for writing swap file to disk, also used by gitsigns -- interval for writing swap file to disk, also used by gitsigns
opt.updatetime = 250 opt.updatetime = 250

View File

@ -25,7 +25,10 @@ M.general = {
["<C-k>"] = { "<C-w>k", "Window up" }, ["<C-k>"] = { "<C-w>k", "Window up" },
["<C-d>"] = { "<cmd> tab Git diff %<CR>", "Git diff this file" }, ["<C-d>"] = { "<cmd> tab Git diff %<CR>", "Git diff this file" },
["<C-p>"] = { "<cmd> tab Git diff<CR>", "Git diff global" }, ["<C-o>"] = { "<cmd> DiffviewFileHistory %<CR>", "Git history diff this file" },
-- ["<C-p>"] = { "<cmd> tab Git diff<CR>", "Git diff global" },
["<C-p>"] = { "<cmd> DiffviewOpen<CR>", "Git diff global" },
["<leader>gd"] = { "<cmd> DiffviewClose<CR>", "Git diff close" },
-- save -- save
["<C-s>"] = { "<cmd> w <CR>", "Save file" }, ["<C-s>"] = { "<cmd> w <CR>", "Save file" },
@ -53,8 +56,8 @@ M.general = {
["<leader>p"] = {"<cmd> :r! cat /tmp/vimtmp<CR>", "Restore from the global tmp file"}, ["<leader>p"] = {"<cmd> :r! cat /tmp/vimtmp<CR>", "Restore from the global tmp file"},
-- new buffer -- new buffer
["<leader>b"] = { "<cmd> enew <CR>", "New buffer" }, -- ["<leader>b"] = { "<cmd> enew <CR>", "New buffer" },
["<leader>ch"] = { "<cmd> NvCheatsheet <CR>", "Mapping cheatsheet" }, -- ["<leader>ch"] = { "<cmd> NvCheatsheet <CR>", "Mapping cheatsheet" },
}, },
t = { t = {
@ -75,12 +78,22 @@ M.general = {
}, },
} }
M.gitstuffs = { M.customstuffs = {
n = { n = {
["<Return>"] = { "o<ESC>", "Insert new line below" },
["<BS>"] = { "O<ESC>", "Insert new line above" },
["<C-c>"] = { "<cmd> vertical topleft Git <bar> vertical resize 50<CR>", "Show Git status on a left pane" }, ["<C-c>"] = { "<cmd> vertical topleft Git <bar> vertical resize 50<CR>", "Show Git status on a left pane" },
["<F1>"] = { "<cmd> tabprevious<CR>", "Previous tab" },
["<F2>"] = { "<cmd> tabnext<CR>", "Next tab" },
["<F3>"] = { "<cmd> Flog -all<CR>", "Show git tree" }, ["<F3>"] = { "<cmd> Flog -all<CR>", "Show git tree" },
["<F4>"] = { "<cmd> tab Git show -", "Git show N last commits" },
["<C-t>"] = { "<cmd> TagbarToggle<CR>", "Show tagbar" }, ["<C-t>"] = { "<cmd> TagbarToggle<CR>", "Show tagbar" },
["<leader>ra"] = { "<cmd> call VrcQuery()<CR>", "Call REST endpoint" },
["<leader>dl"] = { "0d$", "Delete line from start" },
["<leader>gp"] = { "<cmd> Git pull<CR>", "Git pull" },
["<leader>gnb"] = { ":Git checkout -b ", "Checkout to a new branch" },
["<leader>gri"] = { ":Git rebase -i HEAD~", "Git rebase interactive from HEAD" },
} }
} }
@ -119,7 +132,7 @@ M.comment = {
-- toggle comment in both modes -- toggle comment in both modes
n = { n = {
["<leader>/"] = { ["<leader>ci"] = {
function() function()
require("Comment.api").toggle.linewise.current() require("Comment.api").toggle.linewise.current()
end, end,
@ -128,7 +141,7 @@ M.comment = {
}, },
v = { v = {
["<leader>/"] = { ["<leader>ci"] = {
"<ESC><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<CR>", "<ESC><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<CR>",
"Toggle comment", "Toggle comment",
}, },
@ -288,8 +301,15 @@ M.telescope = {
["<leader>fz"] = { "<cmd> Telescope current_buffer_fuzzy_find <CR>", "Find in current buffer" }, ["<leader>fz"] = { "<cmd> Telescope current_buffer_fuzzy_find <CR>", "Find in current buffer" },
-- git -- git
["<leader>cm"] = { "<cmd> Telescope git_commits <CR>", "Git commits" }, --- Commits
["<leader>gt"] = { "<cmd> Telescope git_status <CR>", "Git status" }, ["<leader>gc"] = { "<cmd> lua require('custom.telescope').my_git_commits()<CR>", "Custom Git commits" },
--- Status
["<leader>gss"] = { "<cmd> lua require('custom.telescope').my_git_status()<CR>", "Custom Git status" },
--- Stash
["<leader>gsh"] = { "<cmd> Telescope git_stash<CR>", "Git stash" },
--- Branches
["<leader>gbb"] = { "<cmd> Telescope git_branches<CR>", "Git branches" },
["<leader>gbc"] = { "<cmd> lua require('custom.telescope').my_git_bcommits()<CR>", "Custom Git branchs commits" },
-- pick a hidden term -- pick a hidden term
["<leader>pt"] = { "<cmd> Telescope terms <CR>", "Pick hidden term" }, ["<leader>pt"] = { "<cmd> Telescope terms <CR>", "Pick hidden term" },
@ -298,6 +318,10 @@ M.telescope = {
["<leader>th"] = { "<cmd> Telescope themes <CR>", "Nvchad themes" }, ["<leader>th"] = { "<cmd> Telescope themes <CR>", "Nvchad themes" },
["<leader>ma"] = { "<cmd> Telescope marks <CR>", "telescope bookmarks" }, ["<leader>ma"] = { "<cmd> Telescope marks <CR>", "telescope bookmarks" },
-- History
["<leader>ch"] = { "<cmd> Telescope command_history <CR>", "telescope commands history" },
["<leader>/"] = { "<cmd> Telescope search_history <CR>", "telescope search history" },
}, },
} }
@ -458,7 +482,7 @@ M.gitsigns = {
"Preview hunk", "Preview hunk",
}, },
["<leader>gb"] = { ["<leader>bb"] = {
function() function()
package.loaded.gitsigns.blame_line() package.loaded.gitsigns.blame_line()
end, end,

View File

@ -6,7 +6,7 @@ local highlights = require "custom.highlights"
M.ui = { M.ui = {
theme = "gatekeeper", theme = "gatekeeper",
theme_toggle = { "gatekeeper", "one_light" }, theme_toggle = { "gatekeeper", "monekai" },
hl_override = highlights.override, hl_override = highlights.override,
hl_add = highlights.add, hl_add = highlights.add,

View File

@ -8,5 +8,5 @@ M.general = {
} }
-- more keybinds! -- more keybinds!
--
return M return M

61
lua/custom/telescope.lua Normal file
View File

@ -0,0 +1,61 @@
-- Implement delta as previewer for diffs
local previewers = require('telescope.previewers')
local builtin = require('telescope.builtin')
local E = {}
local delta = previewers.new_termopen_previewer {
get_command = function(entry)
-- this is for status
-- You can get the AM things in entry.status. So we are displaying file if entry.status == '??' or 'A '
-- just do an if and return a different command
if entry.status == '??' or 'A ' then
return { 'git', '-c', 'core.pager=delta', '-c', 'delta.side-by-side=false', 'diff', entry.value }
end
-- note we can't use pipes
-- this command is for git_commits and git_bcommits
return { 'git', '-c', 'core.pager=delta', '-c', 'delta.side-by-side=false', 'diff', entry.value .. '^!' }
end
}
E.my_git_commits = function(opts)
opts = opts or {}
opts.previewer = delta
builtin.git_commits(opts)
end
E.my_git_bcommits = function(opts)
opts = opts or {}
opts.previewer = delta
builtin.git_bcommits(opts)
end
E.my_git_status = function(opts)
opts = opts or {}
opts.previewer = delta
builtin.git_status(opts)
end
E.my_git_branches = function(opts)
opts = opts or {}
opts.previewer = delta
builtin.git_branches(opts)
end
E.project_files = function()
local opts = {} -- define here if you want to define something
vim.fn.system('git rev-parse --is-inside-work-tree')
if vim.v.shell_error == 0 then
require"telescope.builtin".git_files(opts)
else
require"telescope.builtin".find_files(opts)
end
end
return E

View File

@ -0,0 +1,5 @@
local actions = require("diffview.actions")
local options = {}
return options

View File

@ -1,3 +1,36 @@
local custom_actions = {}
local actions = require("telescope.actions")
local action_state = require("telescope.actions.state")
function custom_actions._multiopen(prompt_bufnr, open_cmd)
local picker = action_state.get_current_picker(prompt_bufnr)
local selected_entry = action_state.get_selected_entry()
local num_selections = #picker:get_multi_selection()
if not num_selections or num_selections < 1 then
actions.add_selection(prompt_bufnr)
end
actions.send_selected_to_loclist(prompt_bufnr)
vim.cmd("lfdo " .. open_cmd)
end
function custom_actions.multi_selection_open(prompt_bufnr)
return custom_actions._multiopen(prompt_bufnr, "edit")
end
function custom_actions.multi_selection_vsplit(prompt_bufnr)
return custom_actions._multiopen(prompt_bufnr, "vsplit")
end
function custom_actions.multi_selection_split(prompt_bufnr)
return custom_actions._multiopen(prompt_bufnr, "split")
end
function custom_actions.multi_selection_vtab(prompt_bufnr)
return custom_actions._multiopen(prompt_bufnr, "tabe")
end
local options = { local options = {
defaults = { defaults = {
vimgrep_arguments = { vimgrep_arguments = {
@ -48,8 +81,42 @@ local options = {
n = { ["q"] = require("telescope.actions").close }, n = { ["q"] = require("telescope.actions").close },
}, },
}, },
pickers = {
buffers = {
show_all_buffers = true,
sort_lastused = true,
mappings = {
n = {
["d"] = "delete_buffer",
},
i = {
["<C-d>"] = "delete_buffer",
}
}
},
find_files = {
mappings = {
i = {
["<CR>"] = custom_actions.multi_selection_open,
["<C-V>"] = custom_actions.multi_selection_vsplit,
["<C-X>"] = custom_actions.multi_selection_split,
["<C-T>"] = custom_actions.multi_selection_tab,
["<C-SPACE>"] = actions.send_selected_to_loclist,
},
n = i,
}
}
},
extensions_list = { "themes", "terms" }, extensions_list = { "themes", "terms", "fzf" },
extensions = {
fzf = {
fuzzy = true,
override_generic_sorter = true,
override_file_sorter = true,
case_mode = "smart_case",
}
}
} }
return options return options

View File

@ -9,8 +9,16 @@ local default_plugins = {
{"tpope/vim-obsession", lazy=false}, {"tpope/vim-obsession", lazy=false},
{"preservim/tagbar", lazy=false}, {"preservim/tagbar", lazy=false},
{"ludovicchabant/vim-gutentags", lazy=false}, {"ludovicchabant/vim-gutentags", lazy=false},
{"emaniacs/vim-rest-console", lazy=false},
{
"sindrets/diffview.nvim",
lazy=false,
opts = function()
return require "plugins.configs.diffview"
end,
},
{"nvim-telescope/telescope-fzf-native.nvim", run="make", lazy=false}, {"nvim-telescope/telescope-fzf-native.nvim", build="make"},
-- nvchad plugins -- nvchad plugins
{ "NvChad/extensions", branch = "v2.0" }, { "NvChad/extensions", branch = "v2.0" },