Merge branch 'develop' into psox/arch

This commit is contained in:
psox 2022-09-13 20:04:45 +01:00
commit 9fbd124ee0
6 changed files with 82 additions and 68 deletions

View File

@ -15,7 +15,7 @@ return function()
sort_by = 'relative_directory',
}
bl.setup { options = util.mconfig('config.bufferline', defaults) }
bl.setup (util.mconfig('config.bufferline', { options = defaults }))
vimp.nnoremap({'silent'}, '<TAB>', ':BufferLineCycleNext<CR>')
vimp.nnoremap({'silent'}, '<S-TAB>', ':BufferLineCyclePrev<CR>')

View File

@ -2,14 +2,9 @@ return function()
local fn, o, g = vim.fn, vim.opt, vim.g
local vimp, au = require 'vimp', require 'psoxizsh.autocmd'
if fn.executable('node') == 0 then return end
local t = function(s)
return vim.api.nvim_replace_termcodes(s, true, true, true)
end
local pumvisible = function()
return fn.pumvisible() == 1
end
g['coc_global_extensions'] = {
'coc-yank',
@ -34,42 +29,22 @@ return function()
vimp.nmap({'silent'}, '<leader>gd', '<Plug>(coc-definition)')
vimp.nmap({'silent'}, '<leader>gr', '<Plug>(coc-references)')
-- Basically, we're checking to see if the column behind the current
-- either doesn't exist or is whitespace
local ck_backspace = function()
local col = fn.col('.') - 1
-- Use tab for trigger completion with characters ahead and navigate.
-- NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
-- other plugin before putting this into your config.
vimp.inoremap({'silent', 'expr'}, '<TAB>', [[coc#pum#visible() ? coc#pum#next(1) : CheckBackspace() ? "\<Tab>" : coc#refresh()]])
vimp.inoremap({'expr'}, '<S-TAB>', [[coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"]])
return
col == 0
and true
or fn.getline('.'):sub(col, col):match('%s')
and true
or false
end
vim.cmd [[
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
]]
vimp.inoremap({'silent', 'expr'}, '<TAB>', function()
return
pumvisible()
and t'<C-n>'
or ck_backspace()
and t'<TAB>'
or fn['coc#refresh']()
end)
vimp.inoremap({'expr'}, '<S-TAB>', function()
return pumvisible() and t'<C-p>' or t'<C-h>'
end)
-- Use <c-space> to confirm completion, `<C-g>u` means break undo chain at current
-- position. Coc only does snippet and additional edit on confirm.
-- <c-space> could be remapped by other vim plugin, try `:verbose imap <CR>`.
vimp.inoremap({'expr'}, '<C-Space>', function()
local info =
fn.exists('*complete_info') == 1
and fn.complete_info().selected ~= -1
or pumvisible()
return info and t'<C-y>' or t'<C-g>u<CR>'
end)
-- Make <CR> to accept selected completion item or notify coc.nvim to format
-- <C-g>u breaks current undo, please make your own choice.
vimp.inoremap({'silent', 'expr'}, '<C-Space>', [[coc#pum#visible() ? coc#pum#confirm() : "\<C-g>u\<CR>\<C-r>=coc#on_enter()\<CR>"]])
-- Use `[g` and `]g` to navigate diagnostics
vimp.nmap({'silent'}, '[g', '<Plug>(coc-diagnostic-prev)')
@ -83,13 +58,9 @@ return function()
-- Use K to show documentation in preview window.
local show_documentation = function()
if vim.tbl_contains({'vim', 'help'}, o.filetype:get()) then
vim.cmd('help ' .. fn.expand(t'<cword>'))
elseif vim.fn['coc#rpc#ready']() == 1 then
vim.fn.CocActionAsync('doHover')
else
vim.cmd('!' .. o.keywordprg:get() .. ' ' .. fn.expand(t'<cword>'))
end
return fn.CocAction('hasProvider', 'hover')
and fn.CocActionAsync('doHover')
or fn.feedkeys('K', 'in')
end
vimp.nnoremap({'silent'}, 'K', show_documentation)

View File

@ -2,6 +2,26 @@ local cmd, bootstrap, util = vim.cmd, require 'psoxizsh.plugins.bootstrap', requ
local cb_table = {}
local packer = nil
local EARLY, LATE = { early = 1, pre = 1 }, { post = 1, late = 1 }
-- Wrap the provided function in async context that will wait until all plugins have been initialized
local function defer_wrap(fn)
if bootstrap() then return fn end
return function(plugs)
local a = require 'plenary.async'
a.run(function()
-- Yield until packer's global plugin list is available
while _G.packer_plugins == nil do
a.util.sleep(100)
end
end, function()
fn(plugs)
end)
end
end
-- Plugins provides a hook based wrapper around packer.nvim, allowing
-- callers to register hooks at specific lifecycle events such as pre
-- and post plugin load.
@ -151,9 +171,9 @@ end
--
-- @name { 'early' | 'pre' | 'post' | 'late' }
function Plugins.do_hook(self, name)
if name and name == 'post' or 'late' then
if LATE[name] then
self:_post_hook(self._hooks[name])
else
elseif EARLY[name] then
self:_pre_hook(self._hooks[name])
end
end
@ -172,7 +192,7 @@ function Plugins.register_callbacks(self, callbacks)
cmd [[autocmd!]]
for n, fn in pairs(callbacks) do
local id = self._hooks[n]
cb_table[id] = fn
cb_table[id] = self:_make_callback(n, fn)
cmd(string.format('autocmd User %s call v:lua._psoxizsh_plugins_cb("%s")', id, id))
end
cmd [[augroup END]]
@ -202,6 +222,14 @@ function Plugins._dispatch_autocmd(_, hook)
if hook then cmd('doautocmd User ' .. hook) end
end
function Plugins._make_callback(_, name, fn)
if LATE[name] then
return defer_wrap(fn)
else
return fn
end
end
-- Setup a convenience method for setting up + initializing a Plugins object
-- via directly calling the object with the opts that would normally be
-- provided to :setup/1

View File

@ -10,6 +10,9 @@ local plugins = {
-- Community patch for Vim
{ 'tpope/vim-sensible' },
-- Used in psoxizsh.* modules
{ 'nvim-lua/plenary.nvim' },
-- Utils for wrapping vimscript in lua easier
{ 'svermeulen/vimpeccable',
as = 'vimp'
@ -76,6 +79,7 @@ local plugins = {
-- IDE stuff + language highlighting
{ 'neoclide/coc.nvim',
disable = vim.fn.executable('node') ~= 1,
branch = 'release',
after = 'vimp',
config = require 'psoxizsh.plugins.config.coc'

40
vimrc
View File

@ -281,6 +281,9 @@ if has_key(plugs, 'coc.nvim') && executable("node")
let g:coc_global_extensions+=[ 'coc-markdownlint' ]
let g:coc_global_extensions+=[ 'coc-yaml' ]
" Required on Vim <= v8.2 installations to shut up annoying startup message
let g:coc_disable_startup_warning = 1
" Do action on current word
nmap <silent> <leader>. <Plug>(coc-codeaction-selected)w
@ -294,27 +297,33 @@ if has_key(plugs, 'coc.nvim') && executable("node")
nmap <silent> <leader>gd <Plug>(coc-definition)
nmap <silent> <leader>gr <Plug>(coc-references)
" Add `:Format` command to format current buffer.
command! -nargs=0 Format :call CocActionAsync('format')
" Use tab for trigger completion with characters ahead and navigate.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config.
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#pum#visible() ? coc#pum#next(1):
\ CheckBackspace() ? "\<Tab>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
function! s:check_back_space() abort
" Make <CR> to accept selected completion item or notify coc.nvim to format
" <C-g>u breaks current undo, please make your own choice.
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <c-space> to confirm completion, `<C-g>u` means break undo chain at current
" position. Coc only does snippet and additional edit on confirm.
" <c-space> could be remapped by other vim plugin, try `:verbose imap <CR>`.
if exists('*complete_info')
inoremap <expr> <C-space> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
" Use <c-space> to trigger completion.
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <expr> <C-space> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
inoremap <silent><expr> <c-@> coc#refresh()
endif
" Use `[g` and `]g` to navigate diagnostics
@ -329,14 +338,13 @@ if has_key(plugs, 'coc.nvim') && executable("node")
endif
" Use K to show documentation in preview window.
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
elseif (coc#rpc#ready())
nnoremap <silent> K :call ShowDocumentation()<CR>
function! ShowDocumentation()
if CocAction('hasProvider', 'hover')
call CocActionAsync('doHover')
else
execute '!' . &keywordprg . " " . expand('<cword>')
call feedkeys('K', 'in')
endif
endfunction

7
zshrc
View File

@ -141,7 +141,12 @@ fi
if [[ -d ~/.ssh ]]
then
zstyle :omz:plugins:ssh-agent lifetime 36h
<<<<<<< HEAD
if [[ -e ~/.ssh/autoload ]]
=======
zstyle :omz:plugins:ssh-agent agent-forwarding on
if [[ -e ~/.ssh/autoload ]]
>>>>>>> develop
then
zstyle :omz:plugins:ssh-agent identities $( cat ~/.ssh/autoload )
fi
@ -149,8 +154,6 @@ fi
[[ -d $ZSH ]] && source $ZSH/oh-my-zsh.sh
zstyle :omz:plugins:ssh-agent agent-forwarding on
# Dynamic Completion
foreach cmd in kubectl kubeadm
( which $cmd &>/dev/null ) && source <($cmd completion zsh)