nixos-config/programs/editors/nvim/config/autoload/buf_utls.vim
Charlotte 🦝 Delenk dd6abdb59e
All checks were successful
Hydra nixosConfigurations.container-default-x86_64-linux Hydra build #23446 of nixos-config:pr618:nixosConfigurations.container-default-x86_64-linux
Hydra nixosConfigurations.container-default-aarch64-linux Hydra build #23444 of nixos-config:pr618:nixosConfigurations.container-default-aarch64-linux
Hydra nixosConfigurations.container-default-riscv64-linux Hydra build #23445 of nixos-config:pr618:nixosConfigurations.container-default-riscv64-linux
Hydra checks.x86_64-linux.containers-default Hydra build #23443 of nixos-config:pr618:checks.x86_64-linux.containers-default
Hydra nixosConfigurations.not522 Hydra build #23447 of nixos-config:pr618:nixosConfigurations.not522
Hydra nixosConfigurations.not522-installer Hydra build #23448 of nixos-config:pr618:nixosConfigurations.not522-installer
add nvim
2024-11-03 20:36:23 +01:00

30 lines
No EOL
1,020 B
VimL

function! buf_utils#GoToBuffer(count, direction) abort
if a:count == 0
if a:direction ==# 'forward'
bnext
elseif a:direction ==# 'backward'
bprevious
else
echoerr 'Bad argument ' a:direction
endif
return
endif
" Check the validity of buffer number.
if index(s:GetBufNums(), a:count) == -1
" Using `lua vim.notify('invalid bufnr: ' .. a:count)` won't work, because
" we are essentially mixing Lua and vim script. We need to make sure that
" args inside vim.notify() are valid vim values. The conversion from vim
" value to lua value will be done by Nvim. See also https://github.com/neovim/neovim/pull/11338.
call v:lua.vim.notify('Invalid bufnr: ' . a:count, 4, {'title': 'nvim-config'})
return
endif
" Do not use {count} for gB (it is less useful)
if a:direction ==# 'forward'
silent execute('buffer' . a:count)
endif
endfunction
function! s:GetBufNums() abort
return map(copy(getbufinfo({'buflisted':1})), 'v:val.bufnr')
endfunction