From 356d01933deda24eaba02a1c2ffd7b48b74a844f Mon Sep 17 00:00:00 2001 From: arielherself Date: Sat, 28 Dec 2024 16:28:03 +0800 Subject: [PATCH] feat(vim): truncate completion menu width --- .vimrc | 48 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/.vimrc b/.vimrc index b0fa83b..f3720c4 100644 --- a/.vimrc +++ b/.vimrc @@ -11,7 +11,7 @@ set undofile set undodir=~/.vim/undofiles-vanilla set undolevels=10000 set undoreload=50000 -filetype off +" filetype off set expandtab set tabstop=4 set softtabstop=4 @@ -67,8 +67,8 @@ endif call plug#begin('~/.vim/plugged') -Plug 'savq/melange-nvim' Plug 'morhetz/gruvbox' +Plug 'ayu-theme/ayu-vim' Plug 'embark-theme/vim' Plug 'tpope/vim-obsession' Plug 'dhruvasagar/vim-prosession' @@ -80,6 +80,8 @@ Plug 'tpope/vim-commentary' Plug 'prabirshrestha/vim-lsp' Plug 'prabirshrestha/asyncomplete.vim' Plug 'prabirshrestha/asyncomplete-lsp.vim' +" Plug 'Shougo/ddc.vim' +" Plug 'shun/ddc-vim-lsp' Plug 'mattn/vim-lsp-settings' Plug 'jdhao/better-escape.vim' Plug 'jiangmiao/auto-pairs' @@ -87,16 +89,17 @@ Plug 'easymotion/vim-easymotion' Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } Plug 'junegunn/fzf.vim' Plug 'rhysd/conflict-marker.vim' -Plug 'nathanaelkane/vim-indent-guides' Plug 'ryanoasis/vim-devicons' Plug 'airblade/vim-gitgutter' Plug 'tpope/vim-fugitive' +Plug 'Yggdroot/indentLine' call plug#end() " Color scheme set background=dark let g:embark_terminal_italics = 1 +let ayucolor = "mirage" silent! colorscheme embark " vim-airline @@ -113,9 +116,43 @@ inoremap pumvisible() ? asyncomplete#close_popup() . "\" : "\ 50 + return a:str[:50] . '...' + else + return a:str + endif +endfunction +function! s:truncate_labels(options, matches) abort + let l:items = [] + for [l:source_name, l:matches] in items(a:matches) + for l:item in l:matches['items'] + if has_key(l:item, 'abbr') + let l:item['abbr'] = s:truncate(l:item['abbr']) + endif + call add(l:items, l:item) + endfor + endfor + + call asyncomplete#preprocess_complete(a:options, l:items) +endfunction +let g:asyncomplete_preprocessor = [function('s:truncate_labels')] " Personal keybindings nnoremap h (easymotion-bd-w) @@ -219,5 +256,10 @@ command! -bang -complete=buffer -nargs=? Bclose call Bclose(,