Skip to content

Commit

Permalink
Fix auto formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
creasty committed Sep 4, 2023
1 parent 296af3d commit ae0cea3
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion nvim/autoload/user/plugin/coc.vim
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,23 @@ function! user#plugin#coc#init() abort
autocmd User CocJumpPlaceholder silent call CocActionAsync('showSignatureHelp')

" Auto format
autocmd FocusLost,BufLeave *.go silent call CocActionAsync('format')
autocmd FocusLost,BufLeave *.go call user#plugin#coc#auto_format()

" Override plugin commands
autocmd VimEnter * command! -nargs=0 CocRestart :silent call coc#rpc#restart()
augroup END
endfunction

function! user#plugin#coc#auto_format() abort
if &readonly || !&modifiable
return
endif
if mode() ==# 'n'
return
endif
silent call CocActionAsync('format')
endfunction

" Custom actions
"-----------------------------------------------
nnoremap <Plug>(coc-hover) <Cmd>call CocActionAsync('doHover')<CR>
Expand Down

0 comments on commit ae0cea3

Please sign in to comment.