zsh and nvim completions

This commit is contained in:
thek4n 2024-12-05 21:36:25 +03:00
parent cf09544569
commit 44839849b6
3 changed files with 26 additions and 12 deletions

View File

@ -25,23 +25,26 @@ local function setup_cmp()
['<Tab>'] = 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" }
),
['<S-Tab>'] = cmp.mapping.select_prev_item({ behaviour = cmp.SelectBehavior.Select }),
['<C-k>'] = cmp.mapping.select_prev_item({ behaviour = cmp.SelectBehavior.Select }),
['<C-j>'] = cmp.mapping.select_next_item({ behaviour = cmp.SelectBehavior.Select }),
['<C-p>'] = cmp.mapping.scroll_docs(4),
['<C-n>'] = cmp.mapping.scroll_docs(-4),
['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Select,
select = false,
}),
}),
window = {
completion = cmp.config.window.bordered(border_opts),

View File

@ -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/\.$//'

View File

@ -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'
@ -32,3 +34,15 @@ zstyle ':completion:*:cd:*' ignore-parents parent pwd
compdef _directories _d
compdef _files _f
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