diff --git a/lua/core/default_config.lua b/lua/core/default_config.lua index 3fdbe5a..f2ec8f8 100644 --- a/lua/core/default_config.lua +++ b/lua/core/default_config.lua @@ -36,6 +36,9 @@ M.ui = { -- round and block will work for minimal theme only separator_style = "default", overriden_modules = nil, + fileInfo = function() + return require("nvchad_ui.statusline.default.fileInfo").run() + end }, -- lazyload it when there are 1+ buffers diff --git a/lua/core/init.lua b/lua/core/init.lua index 145655e..194d0ba 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -42,6 +42,7 @@ opt.splitright = true opt.termguicolors = true opt.timeoutlen = 400 opt.undofile = true +opt.scrolloff = 15 -- interval for writing swap file to disk, also used by gitsigns opt.updatetime = 250 diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index 302c848..1215c69 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -25,7 +25,10 @@ M.general = { [""] = { "k", "Window up" }, [""] = { " tab Git diff %", "Git diff this file" }, - [""] = { " tab Git diff", "Git diff global" }, + [""] = { " DiffviewFileHistory %", "Git history diff this file" }, + -- [""] = { " tab Git diff", "Git diff global" }, + [""] = { " DiffviewOpen", "Git diff global" }, + ["gd"] = { " DiffviewClose", "Git diff close" }, -- save [""] = { " w ", "Save file" }, @@ -53,8 +56,8 @@ M.general = { ["p"] = {" :r! cat /tmp/vimtmp", "Restore from the global tmp file"}, -- new buffer - ["b"] = { " enew ", "New buffer" }, - ["ch"] = { " NvCheatsheet ", "Mapping cheatsheet" }, + -- ["b"] = { " enew ", "New buffer" }, + -- ["ch"] = { " NvCheatsheet ", "Mapping cheatsheet" }, }, t = { @@ -75,12 +78,22 @@ M.general = { }, } -M.gitstuffs = { +M.customstuffs = { n = { + [""] = { "o", "Insert new line below" }, + [""] = { "O", "Insert new line above" }, [""] = { " vertical topleft Git vertical resize 50", "Show Git status on a left pane" }, + [""] = { " tabprevious", "Previous tab" }, + [""] = { " tabnext", "Next tab" }, [""] = { " Flog -all", "Show git tree" }, + [""] = { " tab Git show -", "Git show N last commits" }, [""] = { " TagbarToggle", "Show tagbar" }, + ["ra"] = { " call VrcQuery()", "Call REST endpoint" }, + ["dl"] = { "0d$", "Delete line from start" }, + ["gp"] = { " Git pull", "Git pull" }, + ["gnb"] = { ":Git checkout -b ", "Checkout to a new branch" }, + ["gri"] = { ":Git rebase -i HEAD~", "Git rebase interactive from HEAD" }, } } @@ -119,7 +132,7 @@ M.comment = { -- toggle comment in both modes n = { - ["/"] = { + ["ci"] = { function() require("Comment.api").toggle.linewise.current() end, @@ -128,7 +141,7 @@ M.comment = { }, v = { - ["/"] = { + ["ci"] = { "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", "Toggle comment", }, @@ -288,8 +301,15 @@ M.telescope = { ["fz"] = { " Telescope current_buffer_fuzzy_find ", "Find in current buffer" }, -- git - ["cm"] = { " Telescope git_commits ", "Git commits" }, - ["gt"] = { " Telescope git_status ", "Git status" }, + --- Commits + ["gc"] = { " lua require('custom.telescope').my_git_commits()", "Custom Git commits" }, + --- Status + ["gss"] = { " lua require('custom.telescope').my_git_status()", "Custom Git status" }, + --- Stash + ["gsh"] = { " Telescope git_stash", "Git stash" }, + --- Branches + ["gbb"] = { " Telescope git_branches", "Git branches" }, + ["gbc"] = { " lua require('custom.telescope').my_git_bcommits()", "Custom Git branchs commits" }, -- pick a hidden term ["pt"] = { " Telescope terms ", "Pick hidden term" }, @@ -298,6 +318,10 @@ M.telescope = { ["th"] = { " Telescope themes ", "Nvchad themes" }, ["ma"] = { " Telescope marks ", "telescope bookmarks" }, + + -- History + ["ch"] = { " Telescope command_history ", "telescope commands history" }, + ["/"] = { " Telescope search_history ", "telescope search history" }, }, } @@ -458,7 +482,7 @@ M.gitsigns = { "Preview hunk", }, - ["gb"] = { + ["bb"] = { function() package.loaded.gitsigns.blame_line() end, diff --git a/lua/custom/chadrc.lua b/lua/custom/chadrc.lua index 7633979..0446c07 100644 --- a/lua/custom/chadrc.lua +++ b/lua/custom/chadrc.lua @@ -6,7 +6,7 @@ local highlights = require "custom.highlights" M.ui = { theme = "gatekeeper", - theme_toggle = { "gatekeeper", "one_light" }, + theme_toggle = { "gatekeeper", "monekai" }, hl_override = highlights.override, hl_add = highlights.add, diff --git a/lua/custom/mappings.lua b/lua/custom/mappings.lua index 9ce068a..b94c475 100644 --- a/lua/custom/mappings.lua +++ b/lua/custom/mappings.lua @@ -8,5 +8,5 @@ M.general = { } -- more keybinds! - +-- return M diff --git a/lua/custom/telescope.lua b/lua/custom/telescope.lua new file mode 100644 index 0000000..8b5fa02 --- /dev/null +++ b/lua/custom/telescope.lua @@ -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 diff --git a/lua/plugins/configs/diffview.lua b/lua/plugins/configs/diffview.lua new file mode 100644 index 0000000..7dfb2f4 --- /dev/null +++ b/lua/plugins/configs/diffview.lua @@ -0,0 +1,5 @@ +local actions = require("diffview.actions") + +local options = {} + +return options diff --git a/lua/plugins/configs/telescope.lua b/lua/plugins/configs/telescope.lua index 784fb19..3a36eb5 100644 --- a/lua/plugins/configs/telescope.lua +++ b/lua/plugins/configs/telescope.lua @@ -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 = { defaults = { vimgrep_arguments = { @@ -48,8 +81,42 @@ local options = { n = { ["q"] = require("telescope.actions").close }, }, }, + pickers = { + buffers = { + show_all_buffers = true, + sort_lastused = true, + mappings = { + n = { + ["d"] = "delete_buffer", + }, + i = { + [""] = "delete_buffer", + } + } + }, + find_files = { + mappings = { + i = { + [""] = custom_actions.multi_selection_open, + [""] = custom_actions.multi_selection_vsplit, + [""] = custom_actions.multi_selection_split, + [""] = custom_actions.multi_selection_tab, + [""] = 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 diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index e7c8cbc..bab4038 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -9,8 +9,16 @@ local default_plugins = { {"tpope/vim-obsession", lazy=false}, {"preservim/tagbar", 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/extensions", branch = "v2.0" },