From 44839849b61ba92fbe24724eaeb4e87065087061 Mon Sep 17 00:00:00 2001 From: thek4n Date: Thu, 5 Dec 2024 21:36:25 +0300 Subject: [PATCH] zsh and nvim completions --- .../.config/nvim/lua/plugins/autocomplete.lua | 15 +++++++++------ home/user/.config/zsh/accept_line | 5 +---- home/user/.config/zsh/completion | 18 ++++++++++++++++-- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/home/user/.config/nvim/lua/plugins/autocomplete.lua b/home/user/.config/nvim/lua/plugins/autocomplete.lua index ef5dc64..b2ada71 100644 --- a/home/user/.config/nvim/lua/plugins/autocomplete.lua +++ b/home/user/.config/nvim/lua/plugins/autocomplete.lua @@ -25,23 +25,26 @@ local function setup_cmp() [''] = cmp.mapping( function(fallback) if cmp.visible() then - cmp.select_next_item() + cmp.confirm({ + behavior = cmp.ConfirmBehavior.Select, + select = true, + }) elseif has_words_before() then cmp.complete() + if cmp.visible() then + cmp.select_next_item() + end else fallback() end end, { "i", "s" } ), - [''] = cmp.mapping.select_prev_item({ behaviour = cmp.SelectBehavior.Select }), + [''] = cmp.mapping.select_prev_item({ behaviour = cmp.SelectBehavior.Select }), + [''] = cmp.mapping.select_next_item({ behaviour = cmp.SelectBehavior.Select }), [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.abort(), - [''] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Select, - select = false, - }), }), window = { completion = cmp.config.window.bordered(border_opts), diff --git a/home/user/.config/zsh/accept_line b/home/user/.config/zsh/accept_line index 341b936..dab5b15 100644 --- a/home/user/.config/zsh/accept_line +++ b/home/user/.config/zsh/accept_line @@ -10,10 +10,7 @@ aliases[=]='noglob __calc' function accept-line() { - if [[ -z "${BUFFER}" ]]; then - echo - ls - elif [[ ${BUFFER} =~ '^[ ]?\(?[-+]?[0-9]+[^a-zA-Z]+' ]]; then + if [[ ${BUFFER} =~ '^[ ]?\(?[-+]?[0-9]+[^a-zA-Z]+' ]]; then echo test "${BUFFER[1]}" != " " && print -S -- "${BUFFER}" # saving the command to history __calc "${BUFFER}" | sed 's/\.$//' diff --git a/home/user/.config/zsh/completion b/home/user/.config/zsh/completion index 11c69f1..82e7808 100644 --- a/home/user/.config/zsh/completion +++ b/home/user/.config/zsh/completion @@ -1,9 +1,11 @@ # enable completion features fpath=(~/.zfunc $fpath) +zmodload zsh/complist +setopt menucomplete autoload -Uz compinit compinit -d ~/.cache/zcompdump -zstyle ':completion:*:*:*:*:*' menu select +zstyle ':completion:*' menu yes select zstyle ':completion:*' auto-description 'specify: %d' zstyle ':completion:*' completer _expand _complete _correct _approximate zstyle ':completion:*' format 'Completing %d' @@ -31,4 +33,16 @@ zstyle ':completion:*:cd:*' ignore-parents parent pwd compdef _directories _d compdef _files _f -compdef _directories mcd \ No newline at end of file +compdef _directories mcd + + +bindkey -M menuselect '^h' vi-backward-char +bindkey -M menuselect '^k' vi-up-line-or-history +bindkey -M menuselect '^j' vi-down-line-or-history +bindkey -M menuselect '^l' vi-forward-char +bindkey -M menuselect '^[' undo +bindkey -M menuselect '^I' accept-line + +setopt list_packed +setopt always_to_end +setopt auto_param_slash \ No newline at end of file