feat(vim): truncate completion menu width

This commit is contained in:
arielherself 2024-12-28 16:28:03 +08:00
parent 6724673dd0
commit 356d01933d
Signed by: arielherself
SSH Key Fingerprint: SHA256:AK3cyo9tFsp7Mox7K0sYphleC8hReXhnRKxwuDT5LBc
1 changed files with 45 additions and 3 deletions

48
.vimrc
View File

@ -11,7 +11,7 @@ set undofile
set undodir=~/.vim/undofiles-vanilla set undodir=~/.vim/undofiles-vanilla
set undolevels=10000 set undolevels=10000
set undoreload=50000 set undoreload=50000
filetype off " filetype off
set expandtab set expandtab
set tabstop=4 set tabstop=4
set softtabstop=4 set softtabstop=4
@ -67,8 +67,8 @@ endif
call plug#begin('~/.vim/plugged') call plug#begin('~/.vim/plugged')
Plug 'savq/melange-nvim'
Plug 'morhetz/gruvbox' Plug 'morhetz/gruvbox'
Plug 'ayu-theme/ayu-vim'
Plug 'embark-theme/vim' Plug 'embark-theme/vim'
Plug 'tpope/vim-obsession' Plug 'tpope/vim-obsession'
Plug 'dhruvasagar/vim-prosession' Plug 'dhruvasagar/vim-prosession'
@ -80,6 +80,8 @@ Plug 'tpope/vim-commentary'
Plug 'prabirshrestha/vim-lsp' Plug 'prabirshrestha/vim-lsp'
Plug 'prabirshrestha/asyncomplete.vim' Plug 'prabirshrestha/asyncomplete.vim'
Plug 'prabirshrestha/asyncomplete-lsp.vim' Plug 'prabirshrestha/asyncomplete-lsp.vim'
" Plug 'Shougo/ddc.vim'
" Plug 'shun/ddc-vim-lsp'
Plug 'mattn/vim-lsp-settings' Plug 'mattn/vim-lsp-settings'
Plug 'jdhao/better-escape.vim' Plug 'jdhao/better-escape.vim'
Plug 'jiangmiao/auto-pairs' Plug 'jiangmiao/auto-pairs'
@ -87,16 +89,17 @@ Plug 'easymotion/vim-easymotion'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim' Plug 'junegunn/fzf.vim'
Plug 'rhysd/conflict-marker.vim' Plug 'rhysd/conflict-marker.vim'
Plug 'nathanaelkane/vim-indent-guides'
Plug 'ryanoasis/vim-devicons' Plug 'ryanoasis/vim-devicons'
Plug 'airblade/vim-gitgutter' Plug 'airblade/vim-gitgutter'
Plug 'tpope/vim-fugitive' Plug 'tpope/vim-fugitive'
Plug 'Yggdroot/indentLine'
call plug#end() call plug#end()
" Color scheme " Color scheme
set background=dark set background=dark
let g:embark_terminal_italics = 1 let g:embark_terminal_italics = 1
let ayucolor = "mirage"
silent! colorscheme embark silent! colorscheme embark
" vim-airline " vim-airline
@ -113,9 +116,43 @@ inoremap <expr> <cr> pumvisible() ? asyncomplete#close_popup() . "\<cr>" : "\<cr
" LSP related " LSP related
let g:asyncomplete_auto_popup = 1 let g:asyncomplete_auto_popup = 1
let g:asyncomplete_popup_delay = 0 let g:asyncomplete_popup_delay = 0
let g:lsp_completion_documentation_delay = 0
let g:lsp_diagnostics_echo_delay = 0
let g:lsp_diagnostics_highlights_delay = 0
let g:lsp_diagnostics_signs_delay = 0
let g:lsp_diagnostics_virtual_text_delay = 0
let g:lsp_document_code_action_signs_delay = 0
let g:lsp_inlay_hints_delay = 0
let g:lsp_document_highlight_delay = 0
let g:lsp_preview_max_width = 50
let g:lsp_float_max_width = 50
let g:lsp_inlay_hints_enabled = 1
let g:lsp_diagnostics_virtual_text_padding_left = 12
let g:lsp_diagnostics_echo_cursor = 1
let g:lsp_settings = { let g:lsp_settings = {
\ 'clangd': { 'cmd': [ 'clangd' ] }, \ 'clangd': { 'cmd': [ 'clangd' ] },
\} \}
function! s:truncate(str)
if len(a:str) > 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 " Personal keybindings
nnoremap <leader>h <Plug>(easymotion-bd-w) nnoremap <leader>h <Plug>(easymotion-bd-w)
@ -219,5 +256,10 @@ command! -bang -complete=buffer -nargs=? Bclose call <SID>Bclose(<q-bang>, <q-ar
let g:indent_guides_enable_on_vim_startup = 1 let g:indent_guides_enable_on_vim_startup = 1
let g:indent_guides_guide_size = 1 let g:indent_guides_guide_size = 1
" indent line
let g:indentLine_char = ''
let g:indentLine_first_char = ''
let g:indentLine_showFirstIndentLevel = 1
" Why?! " Why?!
set noshowmode set noshowmode