mirror of
https://github.com/Baipyrus/nvim-config.git
synced 2024-12-26 13:21:45 +00:00
Compare commits
No commits in common. "242577f9d047faa349d4bad96e51053ab041c922" and "21206df7b36062186888958cefda0c2ceccfce21" have entirely different histories.
242577f9d0
...
21206df7b3
@ -19,7 +19,7 @@ return {
|
|||||||
-- Disable "format_on_save lsp_fallback" for languages that don't
|
-- Disable "format_on_save lsp_fallback" for languages that don't
|
||||||
-- have a well standardized coding style. You can add additional
|
-- have a well standardized coding style. You can add additional
|
||||||
-- languages here or re-enable it for the disabled ones.
|
-- languages here or re-enable it for the disabled ones.
|
||||||
local disable_filetypes = { c = true, cpp = true, php = true, html = true }
|
local disable_filetypes = { c = true, cpp = true, php = true }
|
||||||
local lsp_format_opt
|
local lsp_format_opt
|
||||||
if disable_filetypes[vim.bo[bufnr].filetype] then
|
if disable_filetypes[vim.bo[bufnr].filetype] then
|
||||||
lsp_format_opt = 'never'
|
lsp_format_opt = 'never'
|
||||||
|
@ -204,31 +204,6 @@ return {
|
|||||||
local utils = require 'telescope.utils'
|
local utils = require 'telescope.utils'
|
||||||
local action_state = require 'telescope.actions.state'
|
local action_state = require 'telescope.actions.state'
|
||||||
|
|
||||||
-- Reference: https://github.com/nvim-telescope/telescope.nvim/blob/master/lua/telescope/actions/init.lua#L587
|
|
||||||
local function git_apply_stash(prompt_bufnr)
|
|
||||||
local selection = action_state.get_selected_entry()
|
|
||||||
if selection == nil then
|
|
||||||
utils.__warn_no_selection 'actions.git_apply_stash'
|
|
||||||
return
|
|
||||||
end
|
|
||||||
actions.close(prompt_bufnr)
|
|
||||||
-- Remove unwanted '--index' flag from command
|
|
||||||
local _, ret, stderr = utils.get_os_command_output { 'git', 'stash', 'apply', selection.value }
|
|
||||||
if ret == 0 then
|
|
||||||
utils.notify('actions.git_apply_stash', {
|
|
||||||
msg = string.format("applied: '%s' ", selection.value),
|
|
||||||
level = 'INFO',
|
|
||||||
})
|
|
||||||
else
|
|
||||||
utils.notify('actions.git_apply_stash', {
|
|
||||||
---@diagnostic disable-next-line: param-type-mismatch
|
|
||||||
msg = string.format("Error when applying: %s. Git returned: '%s'", selection.value, table.concat(stderr, ' ')),
|
|
||||||
level = 'ERROR',
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
actions.select_default:replace(git_apply_stash)
|
|
||||||
|
|
||||||
-- custom function to match stash index inside curly brackets
|
-- custom function to match stash index inside curly brackets
|
||||||
local function match_bracket(str, arr)
|
local function match_bracket(str, arr)
|
||||||
string.gsub(str, '{(.-)}', function(match)
|
string.gsub(str, '{(.-)}', function(match)
|
||||||
@ -239,7 +214,7 @@ return {
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function git_drop_stash(prompt_bufnr)
|
map({ 'n', 'i' }, '<C-d>', function(prompt_bufnr)
|
||||||
local picker = action_state.get_current_picker(prompt_bufnr)
|
local picker = action_state.get_current_picker(prompt_bufnr)
|
||||||
local selection = picker:get_multi_selection()
|
local selection = picker:get_multi_selection()
|
||||||
|
|
||||||
@ -253,12 +228,8 @@ return {
|
|||||||
-- scan single selected entry
|
-- scan single selected entry
|
||||||
local entry = action_state.get_selected_entry()
|
local entry = action_state.get_selected_entry()
|
||||||
if entry == nil and #stashes == 0 then
|
if entry == nil and #stashes == 0 then
|
||||||
vim.notify(
|
-- reference: https://github.com/nvim-telescope/telescope.nvim/blob/master/lua/telescope/actions/init.lua#L589
|
||||||
---@diagnostic disable-next-line: param-type-mismatch
|
utils.__warn_no_selection 'actions.git_apply_stash'
|
||||||
string.format('WARN [%s]: Nothing currently selected', 'git_drop_stash'),
|
|
||||||
vim.log.levels.WARN,
|
|
||||||
{ title = 'telescope.nvim' }
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
match_bracket(entry.value, stashes)
|
match_bracket(entry.value, stashes)
|
||||||
@ -287,8 +258,7 @@ return {
|
|||||||
-- refresh picker
|
-- refresh picker
|
||||||
actions.close(prompt_bufnr)
|
actions.close(prompt_bufnr)
|
||||||
vim.schedule(git_stash_mappings)
|
vim.schedule(git_stash_mappings)
|
||||||
end
|
end, { desc = 'git_drop_stash' })
|
||||||
map({ 'n', 'i' }, '<C-S-d>', git_drop_stash)
|
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user