Skip to content

Commit

Permalink
multiple
Browse files Browse the repository at this point in the history
  • Loading branch information
pmendelski committed Sep 30, 2023
1 parent 10b9a31 commit 18d2c0a
Show file tree
Hide file tree
Showing 18 changed files with 271 additions and 49 deletions.
49 changes: 48 additions & 1 deletion _init/macos/iterm2/com.googlecode.iterm2.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Actions</key>
<array/>
<key>AdjustWindowForFontSizeChange</key>
<false/>
<key>Custom Color Presets</key>
Expand Down Expand Up @@ -709,7 +711,19 @@
<key>EnableDivisionView</key>
<false/>
<key>GlobalKeyMap</key>
<dict/>
<dict>
<key>0x69-0x40000-0x22</key>
<dict>
<key>Action</key>
<integer>13</integer>
<key>Label</key>
<string></string>
<key>Text</key>
<string></string>
<key>Version</key>
<integer>1</integer>
</dict>
</dict>
<key>HapticFeedbackForEsc</key>
<false/>
<key>HideScrollbar</key>
Expand Down Expand Up @@ -1302,6 +1316,17 @@
<key>Version</key>
<integer>1</integer>
</dict>
<key>0x4b-0x120000-0x28</key>
<dict>
<key>Action</key>
<integer>38</integer>
<key>Label</key>
<string></string>
<key>Text</key>
<string>\&lt;C-K&gt;</string>
<key>Version</key>
<integer>1</integer>
</dict>
<key>0x5b-0x80000-0x21</key>
<dict>
<key>Action</key>
Expand Down Expand Up @@ -1335,6 +1360,17 @@
<key>Version</key>
<integer>1</integer>
</dict>
<key>0x62-0x100000-0xb</key>
<dict>
<key>Action</key>
<integer>38</integer>
<key>Label</key>
<string></string>
<key>Text</key>
<string>\&lt;C-b&gt;</string>
<key>Version</key>
<integer>1</integer>
</dict>
<key>0x63-0x100000-0x8</key>
<dict>
<key>Action</key>
Expand Down Expand Up @@ -1412,6 +1448,17 @@
<key>Version</key>
<integer>1</integer>
</dict>
<key>0x69-0x100000-0x22</key>
<dict>
<key>Action</key>
<integer>38</integer>
<key>Label</key>
<string></string>
<key>Text</key>
<string>\&lt;C-i&gt;</string>
<key>Version</key>
<integer>1</integer>
</dict>
<key>0x6a-0x100000-0x26</key>
<dict>
<key>Action</key>
Expand Down
54 changes: 44 additions & 10 deletions bash/.bash/plugins/fzf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ if [ -n "${BASH_VERSION}" ]; then
fi

# FZF finders
export FZF_FIND_ANY="fd --hidden --exclude .git --strip-cwd-prefix $FZF_PATHS"
export FZF_FIND_ANY="fd --exclude .git --strip-cwd-prefix $FZF_PATHS"
if [ -f "$HOME/.fzf-paths" ] && [ -x "$HOME/.fzf-paths" ]; then
# To limit paths define ~/.fzf-paths
export FZF_FIND_ANY="fd --hidden --exclude .git . \$($HOME/.fzf-paths)"
export FZF_FIND_ANY="fd --exclude .git . \$($HOME/.fzf-paths)"
fi

export FZF_FIND_FILE="$FZF_FIND_ANY --type f"
Expand All @@ -31,6 +31,8 @@ export FZF_DEFAULT_OPTS='--height 80% --layout=reverse --info=inline --color hea
export FZF_CTRL_T_COMMAND="$FZF_FIND_ANY"
export FZF_CTRL_T_OPTS="
--multi
--color header:italic
--header='C-f find file / C-d find dir ╱ C-g find any ╱ C-y copy ╱ C-e vim ╱ C-/ preview'
--bind='ctrl-g:reload($FZF_FIND_ANY)'
--bind='ctrl-g:+change-prompt()'
--bind='ctrl-g:+change-preview($FZF_PREVIEW_ANY)'
Expand All @@ -57,11 +59,14 @@ export FZF_CTRL_T_OPTS="
export FZF_ALT_C_COMMAND="$FZF_FIND_DIR"
export FZF_ALT_C_OPTS_ARR="
--preview='$FZF_PREVIEW_DIR'
--bind='ctrl-y:execute-silent(echo -n {2..} | pbcopy)+abort'
--color header:italic
--header='C-e vim ╱ C-y copy ╱ C-/ preview'
--bind='ctrl-y:execute-silent(echo -n {1..} | pbcopy)+abort'
--bind='ctrl-e:become(nvim {+})'
--bind='ctrl-/:change-preview-window(down|hidden|)'
"
export FZF_ALT_C_OPTS="${FZF_ALT_C_OPTS_ARR[*]}"
export _ZO_FZF_OPTS="$FZF_DEFAULT_OPTS $FZF_ALT_C_OPTS"

# CTRL-R - Search history
# CTRL-/ to toggle small preview window to see the full command
Expand All @@ -71,7 +76,7 @@ export FZF_CTRL_R_OPTS="
--bind 'ctrl-/:toggle-preview'
--bind 'ctrl-y:execute-silent(echo -n {2..} | pbcopy)+abort'
--color header:italic
--header 'C-y copy, C-/ preview'"
--header 'C-y copy C-/ preview'"

# https://github.com/junegunn/fzf/blob/master/ADVANCED.md#switching-between-ripgrep-mode-and-fzf-mode
export FZF_RG_PREFIX="rg --column --line-number --no-heading --color=always --smart-case "
Expand All @@ -82,15 +87,14 @@ export FZF_RG_OPTS="
--bind='ctrl-f:unbind(change,ctrl-f)+change-prompt(fzf > )+enable-search+rebind(ctrl-r)+transform-query(echo {q} > /tmp/rg-fzf-r; cat /tmp/rg-fzf-f)'
--bind='ctrl-r:unbind(ctrl-r)+change-prompt(rg > )+disable-search+reload($FZF_RG_PREFIX {q} || true)+rebind(change,ctrl-f)+transform-query(echo {q} > /tmp/rg-fzf-f; cat /tmp/rg-fzf-r)'
--bind='start:unbind(ctrl-r)'
--bind='ctrl-y:execute-silent(echo -n {2..} | pbcopy)+abort'
--bind='ctrl-e:become(nvim {+})'
--bind='ctrl-y:execute-silent(echo -n {2..} | pbcopy)+abort'
--bind='ctrl-a:select-all'
--bind='ctrl-n:deselect-all'
--bind='ctrl-e:become(nvim {1} +{2})'
--prompt='rg > '
--delimiter=':'
--header='C-r (ripgrep mode) ╱ C-f (fzf mode) ╱'
--header='C-r ripgrep ╱ C-f fzf mode'
--preview='bat --color=always {1} --highlight-line {2}'
--preview-window='up,60%,border-bottom,+{2}+3/3,~3'
"
Expand Down Expand Up @@ -152,21 +156,41 @@ fcd() {
fz() {
local -r dir="$(
INITIAL_QUERY="${1}"
FZF_DEFAULT_COMMAND="zoxide query $(printf %q "$INITIAL_QUERY")" \
FZF_DEFAULT_OPTS="$FZF_CTRL_T_OPTS --bind='change:reload:sleep 0.1; zoxide query {q} || true'" \
FZF_DEFAULT_COMMAND="zoxide query $(printf %q "$INITIAL_QUERY") -l | grep -v \"^\$(pwd)/$\" | sed \"s|\$(pwd)/|./|\" " \
FZF_DEFAULT_OPTS="
--multi
--color header:italic
--header='C-y copy ╱ C-e vim ╱ C-/ preview'
--bind='ctrl-y:execute-silent(echo -n {1..} | pbcopy)+abort'
--bind='ctrl-a:select-all'
--bind='ctrl-n:deselect-all'
--bind='ctrl-e:become(echo @nvim@{1})'
--bind='ctrl-/:change-preview-window(down|hidden|right)'
--preview='$FZF_PREVIEW_ANY'
--height='50%'
--layout='reverse'
--bind='change:reload:sleep 0.1; zoxide query {q} -l | grep -v \"^\$(pwd)$\" | sed \"s|\$(pwd)/|./|\" || true'
" \
fzf \
--disabled --query "$INITIAL_QUERY"
)"
if [ -n "$dir" ]; then
if [ "${dir:0:6}" = "@nvim@" ]; then
nvim "${dir:6}"
elif [ -n "$dir" ]; then
z "$dir"
fi
}

# Fzf file traversal with preview
fcde() {
selection="$(
FZF_DEFAULT_COMMAND="echo .. && $FZF_FIND_ANY --exact-depth 1" \
FZF_DEFAULT_COMMAND="$FZF_FIND_ANY --exact-depth 1" \
FZF_DEFAULT_OPTS="$FZF_CTRL_T_OPTS" \
fzf \
--color header:italic \
--header=$'C-c cd ╱ C-o out ╱ C-i in ╱ C-e vim\n' \
--bind='ctrl-c:become(echo @cd@{1})' \
--bind='ctrl-c:become(echo @nvim@{1})' \
--bind='ctrl-o:become(echo ..)' \
--bind='ctrl-i:become(echo {1})'
)"
Expand All @@ -179,18 +203,24 @@ fcde() {
fi
if [ "$n" = 1 ] && [ -d "$selection" ]; then
cd "$selection" && fcde
elif [ "${selection:0:6}" = "@nvim@" ]; then
nvim "${selection:6}"
elif [ "$n" = 1 ] && [ "${selection:0:4}" = "@cd@" ]; then
cd "${selection:4}"
else
nvim "$selection"
fi
}

# Fzf file
frg() {
INITIAL_QUERY="${*:-}"
FZF_DEFAULT_COMMAND="$FZF_RG_PREFIX $(printf %q "$INITIAL_QUERY")" \
FZF_DEFAULT_OPTS="$FZF_RG_OPTS" \
fzf --disabled --query "$INITIAL_QUERY"
}

# Fzf file content
fgrepp() {
local -r name="${1:?Expected file name}"
INITIAL_QUERY=""
Expand All @@ -208,6 +238,7 @@ fgrepp() {
fzf --disabled --query "$INITIAL_QUERY"
}

# Fzf all processes
fproc() {
procs="ps -ef"
killcmd="for d in {+}; do echo \"\$d\" | awk '{ print \$2 }' | xargs kill -9; done"
Expand All @@ -220,13 +251,15 @@ fproc() {
--bind="ctrl-r:reload(date; $procs)" \
--bind="enter:become($killcmd)" \
--bind="ctrl-x:execute-silent($killcmd)+reload(date; $procs)" \
--color header:italic \
--header=$'C-r reload / C-x kill\n' \
--header-lines=2 \
--preview='echo {}' \
--preview-window=down,5,wrap \
--layout=reverse --height=80%
}

# Fzf network processes
fnproc() {
procs="lsof -i -P -n | head -n 1 && lsof -i -P -n | grep IPv4 | grep LISTEN"
killcmd="for d in {+}; do echo \"\$d\" | awk '{ print \$2 }' | xargs kill -9; done"
Expand All @@ -239,6 +272,7 @@ fnproc() {
--bind="ctrl-r:reload(date; $procs)" \
--bind="enter:become($killcmd)" \
--bind="ctrl-x:execute-silent($killcmd)+reload(date; $procs)" \
--color header:italic \
--header=$'C-r reload / C-x kill\n' \
--header-lines=2 \
--preview='echo {}' \
Expand Down
11 changes: 8 additions & 3 deletions nvim/.nvim/lua/keybindings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ map("x", "§", "<esc>")
-- ]c - next change
-- [c - previous change
map("n", "<leader>ml", ":diffget LOCAL")
map("n", "<leader>mr", ":diffget BASE")
map("n", "<leader>mb", ":diffget BASE")
map("n", "<leader>mr", ":diffget REMOTE")

-- Movement
Expand Down Expand Up @@ -96,7 +96,7 @@ map("i", "<a-j>", "<esc>:m .+1<cr>gi")
map("i", "<a-k>", "<esc>:m .-2<cr>gi")
map("x", "<a-j>", ":m '>+1<cr>gv")
map("x", "<a-k>", ":m '<-2<cr>gv")
-- -- Skip buffer on delete - controversial
-- Skip buffer on delete - controversial
-- map("n", "d", '"_d')
-- map("n", "D", '"_D')
-- map("x", "d", '"_d')
Expand Down Expand Up @@ -173,4 +173,9 @@ map("n", "<leader>s", ":wa<cr>")
-- Quit
-- map('n', 'Q', ':qall!<cr>')
map("n", "Q", ":confirm qall<cr>")
map("n", "q", "<c-w>q")
map("n", "q", function()
local win = vim.api.nvim_get_current_win()
local jump_back = vim.api.nvim_replace_termcodes("<C-o>", true, false, true)
vim.api.nvim_feedkeys(jump_back, "n", false)
vim.api.nvim_win_close(win, false)
end)
2 changes: 1 addition & 1 deletion nvim/.nvim/lua/plugin/indent.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require("indent_blankline").setup({
require("ibl").setup({
char = "|",
buftype_exclude = { "terminal", "dashboard", "help", "lspinfo", "lspsaga", "NvimTree" },
filetype_exclude = { "help", "dashboard", "packer" },
Expand Down
4 changes: 2 additions & 2 deletions nvim/.nvim/lua/plugin/lsp/on-attach.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ return function(client, bufnr)
local opts = { noremap = true, silent = true }
buf_set_keymap("n", prefix .. "D", "<cmd>lua vim.lsp.buf.declaration()<cr>", opts)
buf_set_keymap("n", prefix .. "d", "<cmd>lua vim.lsp.buf.definition()<cr>", opts)
buf_set_keymap("n", prefix .. "t", "<cmd>lua vim.lsp.buf.implementation()<cr>", opts)
buf_set_keymap("n", prefix .. "i", "<cmd>lua vim.lsp.buf.implementation()<cr>", opts)
buf_set_keymap("n", prefix .. "s", "<cmd>lua vim.lsp.buf.signature_help()<cr>", opts)
buf_set_keymap("n", prefix .. "f", '<cmd>lua require("plugin/lsp/actions").format()<cr>', opts)
-- buf_set_keymap('n', prefix .. 'f', '<cmd>lua vim.lsp.buf.format()<cr>', opts)
Expand All @@ -69,7 +69,7 @@ return function(client, bufnr)
"<cmd>lua vim.lsp.buf.clear_references() vim.lsp.buf.document_highlight()<cr>",
opts
)
buf_set_keymap("n", prefix .. "T", "<cmd>lua vim.lsp.buf.type_definition()<cr>", opts)
buf_set_keymap("n", prefix .. "t", "<cmd>lua vim.lsp.buf.type_definition()<cr>", opts)
buf_set_keymap("n", prefix .. "n", "<cmd>lua vim.lsp.buf.rename()<cr>", opts)
buf_set_keymap("n", prefix .. "a", "<cmd>lua vim.lsp.buf.code_action()<cr>", opts)
buf_set_keymap("n", prefix .. "r", "<cmd>lua vim.lsp.buf.references()<cr>", opts)
Expand Down
10 changes: 7 additions & 3 deletions nvim/.nvim/lua/plugin/nvim-cmp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,19 @@ local has_words_before = function()
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end

local bordered = cmp.config.window.bordered({ border = { "", "", "", "", "", "", "", "" } })

cmp.setup({
preselect = cmp.PreselectMode.None,
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
window = {
completion = bordered,
documentation = bordered,
},
formatting = {
format = function(entry, vim_item)
-- fancy icons and a name of kind
Expand All @@ -46,9 +52,7 @@ cmp.setup({
end,
},
mapping = {
["<c-p>"] = cmp.mapping.select_prev_item(),
["<c-n>"] = cmp.mapping.select_next_item(),
["<c-d>"] = cmp.mapping.scroll_docs(-4),
["<c-b>"] = cmp.mapping.scroll_docs(-4),
["<c-f>"] = cmp.mapping.scroll_docs(4),
["<c-Space>"] = cmp.mapping.complete(),
["<c-e>"] = cmp.mapping.close(),
Expand Down
20 changes: 15 additions & 5 deletions nvim/.nvim/lua/plugin/telescope.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ function _M.keymap()
map("n", "<leader>cr", ":Telescope lsp_references<cr>")
map("n", "<leader>ca", ":Telescope lsp_code_actions<cr>")
map("n", "<leader>cx", ":Telescope diagnostics<cr>")
map("n", "<leader>ci", ":Telescope lsp_incomming_calls<cr>")
map("n", "<leader>cO", ":Telescope lsp_incomming_calls<cr>")
map("n", "<leader>co", ":Telescope lsp_outgoing_calls<cr>")
map("n", "<leader>ct", ":Telescope lsp_implementations<cr>")
map("n", "<leader>ci", ":Telescope lsp_implementations<cr>")
map("n", "<leader>cd", ":Telescope lsp_definitions<cr>")
-- git
map("n", "<leader>g", "") -- added to not trigger a command by mistake
Expand Down Expand Up @@ -102,15 +102,15 @@ function _M.config()
mappings = {
i = {
["<esc>"] = actions.close,
["<F1>"] = actions.close,
["<C-t>"] = trouble.open_with_trouble,
["<C-o>"] = actions.cycle_history_prev,
["<C-i>"] = actions.cycle_history_next,
["<C-b>"] = actions.preview_scrolling_up,
["<C-f>"] = actions.preview_scrolling_down,
["<C-Up>"] = actions.preview_scrolling_up,
["<C-Down>"] = actions.preview_scrolling_down,
["<C-h>"] = "which_key",
["<C-k>"] = lga.quote_prompt(),
["<C-g>"] = lga.quote_prompt({ postfix = " --iglob " }),
["<F1>"] = actions.close,
},
n = {
["q"] = actions.close,
Expand Down Expand Up @@ -142,6 +142,16 @@ function _M.config()
-- even more opts
}),
},
live_grep_args = {
auto_quoting = true, -- enable/disable auto-quoting
mappings = {
-- extend mappings
i = {
["<C-k>"] = lga.quote_prompt(),
["<C-K>"] = lga.quote_prompt({ postfix = " --iglob *." }),
},
},
},
},
pickers = {
lsp_document_symbols = {
Expand Down
3 changes: 1 addition & 2 deletions nvim/.nvim/lua/plugin/terminal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,9 @@ map("t", "<a-5>", '<c-\\><c-n><cmd>lua require("plugin/terminal").toggle("termin
map("n", "<a-t>", '<c-\\><c-n><cmd>lua require("plugin/terminal").toggle_active()<cr>')
map("t", "<a-t>", '<c-\\><c-n><cmd>lua require("plugin/terminal").toggle_active()<cr>')
map("t", "<a-x>", '<c-\\><c-n><cmd>lua require("plugin/terminal").close_active()<cr>')
map("t", "<esc>", '<c-\\><c-n><cmd>lua require("plugin/terminal").close_active()<cr>')
-- map("t", "<esc>", '<c-\\><c-n><cmd>lua require("plugin/terminal").close_active()<cr>') -- doesnt play well when opening nvim inside fterm
map("t", "<S-Down>", "<c-\\><c-n><c-E>")
map("t", "<S-Up>", "<c-\\><c-n><c-Y>")
-- map('t', '<esc>', '<c-\\><c-n>') -- go to normal mode
map("n", "<leader>th", '<cmd>lua require("plugin/terminal").toggle("htop")<cr>')
map("n", "<leader>tb", '<cmd>lua require("plugin/terminal").toggle("bpytop")<cr>')
map("n", "<leader>tg", '<cmd>lua require("plugin/terminal").toggle("lazygit")<cr>')
Expand Down
Loading

0 comments on commit 18d2c0a

Please sign in to comment.