Update coc.nvim to latest release
This commit is contained in:
parent
f5d92b4f36
commit
f9025b598e
29 changed files with 3776 additions and 94329 deletions
4
pack/acp/opt/coc.nvim/.github/FUNDING.yml
vendored
Normal file
4
pack/acp/opt/coc.nvim/.github/FUNDING.yml
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
# These are supported funding model platforms
|
||||
|
||||
open_collective: cocnvim
|
||||
patreon: chemzqm
|
45
pack/acp/opt/coc.nvim/.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
45
pack/acp/opt/coc.nvim/.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
---
|
||||
|
||||
<!--
|
||||
**Warning: We will close the bug issue without the issue template and the reproduce ways.**
|
||||
|
||||
If you have question, please ask at https://gitter.im/neoclide/coc.nvim
|
||||
|
||||
If the problem related to specific language server, please checkout: https://git.io/fjCEM
|
||||
|
||||
If your have performance issue, checkout: https://git.io/fjCEX & https://git.io/Jfe00
|
||||
-->
|
||||
|
||||
## Result from CocInfo
|
||||
|
||||
<!--Run `:CocInfo` command and paste the content below.-->
|
||||
|
||||
## Describe the bug
|
||||
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
## Reproduce the bug
|
||||
|
||||
**We will close your issue when you don't provide minimal vimrc and we can't
|
||||
reproduce it**
|
||||
|
||||
- Create file `mini.vim` with:
|
||||
|
||||
```vim
|
||||
set nocompatible
|
||||
set runtimepath^=/path/to/coc.nvim
|
||||
filetype plugin indent on
|
||||
syntax on
|
||||
set hidden
|
||||
```
|
||||
|
||||
- Start (neo)vim with command: `vim -u mini.vim`
|
||||
|
||||
- Operate vim.
|
||||
|
||||
## Screenshots (optional)
|
||||
|
||||
If applicable, add screenshots to help explain your problem.
|
17
pack/acp/opt/coc.nvim/.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
17
pack/acp/opt/coc.nvim/.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
56
pack/acp/opt/coc.nvim/.github/workflows/ci.yml
vendored
Normal file
56
pack/acp/opt/coc.nvim/.github/workflows/ci.yml
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
name: coc.nvim CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
node-version: [10, 14]
|
||||
|
||||
env:
|
||||
NODE_ENV: test
|
||||
|
||||
steps:
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: Install yarn
|
||||
run: |
|
||||
curl --compressed -o- -L https://yarnpkg.com/install.sh | bash
|
||||
- uses: actions/checkout@v2
|
||||
- name: yarn install
|
||||
run: |
|
||||
yarn global add typescript
|
||||
yarn
|
||||
- name: yarn lint
|
||||
run: yarn lint
|
||||
- if: matrix.os == 'macos-latest'
|
||||
name: yarn test on macOS
|
||||
run: |
|
||||
curl -LO https://github.com/neovim/neovim/releases/download/nightly/nvim-macos.tar.gz
|
||||
tar xzf nvim-macos.tar.gz
|
||||
export PATH="${PATH}:node_modules/.bin:$(pwd)/nvim-osx64/bin"
|
||||
nvim --version
|
||||
yarn test
|
||||
- if: matrix.os == 'ubuntu-latest'
|
||||
name: yarn test on Ubuntu
|
||||
run: |
|
||||
curl -LO https://github.com/neovim/neovim/releases/download/nightly/nvim-linux64.tar.gz
|
||||
tar xzf nvim-linux64.tar.gz
|
||||
export PATH="${PATH}:node_modules/.bin:$(pwd)/nvim-linux64/bin"
|
||||
nvim --version
|
||||
yarn test
|
||||
env:
|
||||
NODE_ENV: test
|
1
pack/acp/opt/coc.nvim/.gitignore
vendored
1
pack/acp/opt/coc.nvim/.gitignore
vendored
|
@ -10,3 +10,4 @@ doc/tags
|
|||
doc/tags-cn
|
||||
node_modules
|
||||
src/__tests__/tags
|
||||
typings
|
||||
|
|
|
@ -39,7 +39,7 @@ For [vim-plug](https://github.com/junegunn/vim-plug) users:
|
|||
Plug 'neoclide/coc.nvim', {'branch': 'release'}
|
||||
|
||||
" Or build from source code by using yarn: https://yarnpkg.com
|
||||
Plug 'neoclide/coc.nvim', {'do': 'yarn install --frozen-lockfile'}
|
||||
Plug 'neoclide/coc.nvim', {'branch': 'master', 'do': 'yarn install --frozen-lockfile'}
|
||||
```
|
||||
|
||||
in your `.vimrc` or `init.vim`, then restart Vim and run `:PlugInstall`.
|
||||
|
@ -91,6 +91,10 @@ possible to avoid conflict with your other plugins.
|
|||
`:verbose imap <tab>` to make sure that your keymap has taken effect.
|
||||
|
||||
```vim
|
||||
" Set internal encoding of vim, not needed on neovim, since coc.nvim using some
|
||||
" unicode characters in the file autoload/float.vim
|
||||
set encoding=utf-8
|
||||
|
||||
" TextEdit might fail if hidden is not set.
|
||||
set hidden
|
||||
|
||||
|
@ -207,11 +211,14 @@ xmap ac <Plug>(coc-classobj-a)
|
|||
omap ac <Plug>(coc-classobj-a)
|
||||
|
||||
" Remap <C-f> and <C-b> for scroll float windows/popups.
|
||||
" Note coc#float#scroll works on neovim >= 0.4.3 or vim >= 8.2.0750
|
||||
nnoremap <nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
|
||||
nnoremap <nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
|
||||
inoremap <nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
|
||||
inoremap <nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
|
||||
if has('nvim-0.4.0') || has('patch-8.2.0750')
|
||||
nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
|
||||
nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
|
||||
inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
|
||||
inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
|
||||
vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
|
||||
vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
|
||||
endif
|
||||
|
||||
" Use CTRL-S for selections ranges.
|
||||
" Requires 'textDocument/selectionRange' support of language server.
|
||||
|
@ -276,7 +283,24 @@ Try these steps when you have problem with coc.nvim.
|
|||
- If something is not working, [create an
|
||||
issue](https://github.com/neoclide/coc.nvim/issues/new).
|
||||
|
||||
<img src="https://user-images.githubusercontent.com/251450/57566955-fb850200-7404-11e9-960f-711673f1a461.png" width="593" height="574">
|
||||
## Backers
|
||||
|
||||
[Become a backer](https://opencollective.com/cocnvim#backer) and get your image on our README on Github with a link to your site.
|
||||
|
||||
<a href="https://opencollective.com/cocnvim/backer/0/website?requireActive=false" target="_blank"><img src="https://opencollective.com/cocnvim/backer/0/avatar.svg?requireActive=false"></a>
|
||||
<a href="https://opencollective.com/cocnvim/backer/1/website?requireActive=false" target="_blank"><img src="https://opencollective.com/cocnvim/backer/1/avatar.svg?requireActive=false"></a>
|
||||
<a href="https://opencollective.com/cocnvim/backer/2/website?requireActive=false" target="_blank"><img src="https://opencollective.com/cocnvim/backer/2/avatar.svg?requireActive=false"></a>
|
||||
<a href="https://opencollective.com/cocnvim/backer/3/website?requireActive=false" target="_blank"><img src="https://opencollective.com/cocnvim/backer/3/avatar.svg?requireActive=false"></a>
|
||||
<a href="https://opencollective.com/cocnvim/backer/4/website?requireActive=false" target="_blank"><img src="https://opencollective.com/cocnvim/backer/4/avatar.svg?requireActive=false"></a>
|
||||
<a href="https://opencollective.com/cocnvim/backer/5/website?requireActive=false" target="_blank"><img src="https://opencollective.com/cocnvim/backer/5/avatar.svg?requireActive=false"></a>
|
||||
<a href="https://opencollective.com/cocnvim/backer/6/website?requireActive=false" target="_blank"><img src="https://opencollective.com/cocnvim/backer/6/avatar.svg?requireActive=false"></a>
|
||||
<a href="https://opencollective.com/cocnvim/backer/7/website?requireActive=false" target="_blank"><img src="https://opencollective.com/cocnvim/backer/7/avatar.svg?requireActive=false"></a>
|
||||
<a href="https://opencollective.com/cocnvim/backer/8/website?requireActive=false" target="_blank"><img src="https://opencollective.com/cocnvim/backer/8/avatar.svg?requireActive=false"></a>
|
||||
<a href="https://opencollective.com/cocnvim/backer/9/website?requireActive=false" target="_blank"><img src="https://opencollective.com/cocnvim/backer/9/avatar.svg?requireActive=false"></a>
|
||||
<a href="https://opencollective.com/cocnvim/backer/10/website?requireActive=false" target="_blank"><img src="https://opencollective.com/cocnvim/backer/10/avatar.svg?requireActive=false"></a>
|
||||
<a href="https://opencollective.com/cocnvim/backer/11/website?requireActive=false" target="_blank"><img src="https://opencollective.com/cocnvim/backer/11/avatar.svg?requireActive=false"></a>
|
||||
|
||||
<a href="https://opencollective.com/cocnvim#backer" target="_blank"><img src="https://images.opencollective.com/static/images/become_backer.svg"></a>
|
||||
|
||||
## License
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
let g:coc#_context = {'start': 0, 'preselect': -1,'candidates': []}
|
||||
let g:coc_user_config = get(g:, 'coc_user_config', {})
|
||||
let g:coc_global_extensions = get(g:, 'coc_global_extensions', [])
|
||||
let g:coc_cygqwin_path_prefixes = get(g:, 'coc_cygqwin_path_prefixes', {})
|
||||
let g:coc_selected_text = ''
|
||||
let g:coc_vim_commands = []
|
||||
let s:watched_keys = []
|
||||
|
@ -36,14 +35,7 @@ function! coc#refresh() abort
|
|||
endfunction
|
||||
|
||||
function! coc#on_enter()
|
||||
if !coc#rpc#ready()
|
||||
return ''
|
||||
endif
|
||||
if s:is_vim
|
||||
call coc#rpc#notify('CocAutocmd', ['Enter', bufnr('%')])
|
||||
else
|
||||
call coc#rpc#request('CocAutocmd', ['Enter', bufnr('%')])
|
||||
endif
|
||||
call coc#rpc#notify('CocAutocmd', ['Enter', bufnr('%')])
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
|
@ -102,9 +94,10 @@ endfunction
|
|||
|
||||
function! coc#_cancel()
|
||||
" hack for close pum
|
||||
if pumvisible() && &paste != 1
|
||||
if pumvisible()
|
||||
let g:coc#_context = {'start': 0, 'preselect': -1,'candidates': []}
|
||||
call feedkeys("\<Plug>CocRefresh", 'i')
|
||||
call coc#rpc#notify('stopCompletion', [])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
" Description: Client api used by vim8
|
||||
" Author: Qiming Zhao <chemzqm@gmail.com>
|
||||
" Licence: MIT licence
|
||||
" Last Modified: June 28, 2019
|
||||
" Last Modified: Nov 11, 2020
|
||||
" ============================================================================
|
||||
if has('nvim') | finish | endif
|
||||
let s:funcs = {}
|
||||
let s:prop_id = 1000
|
||||
let s:prop_offset = get(g:, 'coc_text_prop_offset', 1000)
|
||||
let s:namespace_id = 1
|
||||
let s:namespace_cache = {}
|
||||
|
||||
|
@ -121,7 +121,7 @@ function! s:funcs.get_api_info()
|
|||
endfunction
|
||||
|
||||
function! s:funcs.list_bufs()
|
||||
return map(getbufinfo({'buflisted': 1}), 'v:val["bufnr"]')
|
||||
return map(getbufinfo({'bufloaded': 1}), 'v:val["bufnr"]')
|
||||
endfunction
|
||||
|
||||
function! s:funcs.feedkeys(keys, mode, escape_csi)
|
||||
|
@ -240,18 +240,13 @@ function! s:funcs.buf_get_mark(bufnr, name)
|
|||
endfunction
|
||||
|
||||
function! s:funcs.buf_add_highlight(bufnr, srcId, hlGroup, line, colStart, colEnd) abort
|
||||
if !has('textprop')
|
||||
if !has('textprop') || !has('patch-8.1.1719')
|
||||
return
|
||||
endif
|
||||
let bufnr = a:bufnr == 0 ? bufnr('%') : a:bufnr
|
||||
let key = 'Coc'.a:hlGroup.(a:srcId != -1 ? a:srcId : '')
|
||||
if empty(prop_type_get(key, {'bufnr': a:bufnr}))
|
||||
call prop_type_add(key, {'highlight': a:hlGroup, 'combine': 1, 'bufnr': a:bufnr})
|
||||
if a:srcId != -1
|
||||
let cached = getbufvar(bufnr, 'prop_namespace_'.a:srcId, [])
|
||||
call add(cached, key)
|
||||
call setbufvar(bufnr, 'prop_namespace_'.a:srcId, cached)
|
||||
endif
|
||||
let type = 'CocHighlight'.a:hlGroup
|
||||
if empty(prop_type_get(type))
|
||||
call prop_type_add(type, {'highlight': a:hlGroup, 'combine': 1})
|
||||
endif
|
||||
let total = strlen(getbufline(bufnr, a:line + 1)[0])
|
||||
let end = a:colEnd
|
||||
|
@ -263,33 +258,44 @@ function! s:funcs.buf_add_highlight(bufnr, srcId, hlGroup, line, colStart, colEn
|
|||
if end <= a:colStart
|
||||
return
|
||||
endif
|
||||
let id = s:prop_id
|
||||
let s:prop_id = id + 1
|
||||
let srcId = a:srcId
|
||||
if srcId == 0
|
||||
while v:true
|
||||
let srcId = srcId + 1
|
||||
if empty(prop_find({'id': s:prop_offset + srcId, 'lnum' : 1}))
|
||||
break
|
||||
endif
|
||||
endwhile
|
||||
" generate srcId
|
||||
endif
|
||||
let id = srcId == -1 ? 0 : s:prop_offset + srcId
|
||||
try
|
||||
call prop_add(a:line + 1, a:colStart + 1, {'length': end - a:colStart, 'bufnr': bufnr, 'type': key, 'id': id})
|
||||
call prop_add(a:line + 1, a:colStart + 1, {'length': end - a:colStart, 'bufnr': bufnr, 'type': type, 'id': id})
|
||||
catch /^Vim\%((\a\+)\)\=:E967/
|
||||
" ignore 967
|
||||
endtry
|
||||
let g:i = srcId
|
||||
if a:srcId == 0
|
||||
" return generated srcId
|
||||
return srcId
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:funcs.buf_clear_namespace(bufnr, srcId, startLine, endLine) abort
|
||||
if !has('textprop')
|
||||
if !has('textprop') || !has('patch-8.1.1719')
|
||||
return
|
||||
endif
|
||||
let bufnr = a:bufnr == 0 ? bufnr('%') : a:bufnr
|
||||
let start = a:startLine + 1
|
||||
let end = a:endLine == -1 ? len(getbufline(bufnr, 1, '$')) : a:endLine + 1
|
||||
if a:srcId == -1
|
||||
if a:endLine == -1
|
||||
call prop_clear(a:startLine + 1, {'bufnr': a:bufnr})
|
||||
else
|
||||
call prop_clear(a:startLine + 1, a:endLine + 1, {'bufnr': a:bufnr})
|
||||
endif
|
||||
call prop_clear(start, end, {'bufnr' : bufnr})
|
||||
else
|
||||
let cached = getbufvar(a:bufnr, 'prop_namespace_'.a:srcId, [])
|
||||
if empty(cached)
|
||||
return
|
||||
endif
|
||||
for key in cached
|
||||
call prop_remove({'type': key, 'bufnr': a:bufnr, 'all': 1})
|
||||
endfor
|
||||
try
|
||||
call prop_remove({'bufnr': bufnr, 'all': 1, 'id': s:prop_offset + a:srcId}, start, end)
|
||||
catch /^Vim\%((\a\+)\)\=:E968/
|
||||
" ignore 968
|
||||
endtry
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
|
|
@ -72,25 +72,36 @@ function! s:start() dict
|
|||
let self['running'] = 1
|
||||
let self['channel'] = job_getchannel(job)
|
||||
else
|
||||
let original = {
|
||||
\ 'NODE_NO_WARNINGS': getenv('NODE_NO_WARNINGS'),
|
||||
\ 'COC_CHANNEL_TIMEOUT': getenv('COC_CHANNEL_TIMEOUT'),
|
||||
\ 'COC_NO_WARNINGS': getenv('COC_NO_WARNINGS'),
|
||||
\ 'TMPDIR': getenv('TMPDIR'),
|
||||
\ }
|
||||
let original = {'tmpdir': $TMPDIR}
|
||||
" env option not work on neovim
|
||||
call setenv('NODE_NO_WARNINGS', '1')
|
||||
call setenv('COC_CHANNEL_TIMEOUT', timeout)
|
||||
call setenv('COC_NO_WARNINGS', disable_warning)
|
||||
call setenv('TMPDIR', tmpdir)
|
||||
if exists('*setenv')
|
||||
let original = {
|
||||
\ 'NODE_NO_WARNINGS': getenv('NODE_NO_WARNINGS'),
|
||||
\ 'COC_CHANNEL_TIMEOUT': getenv('COC_CHANNEL_TIMEOUT'),
|
||||
\ 'COC_NO_WARNINGS': getenv('COC_NO_WARNINGS'),
|
||||
\ 'TMPDIR': getenv('TMPDIR'),
|
||||
\ }
|
||||
call setenv('NODE_NO_WARNINGS', '1')
|
||||
call setenv('COC_CHANNEL_TIMEOUT', timeout)
|
||||
call setenv('COC_NO_WARNINGS', disable_warning)
|
||||
call setenv('TMPDIR', tmpdir)
|
||||
else
|
||||
let $NODE_NO_WARNINGS = 1
|
||||
let $COC_NO_WARNINGS = disable_warning
|
||||
let $TMPDIR = tmpdir
|
||||
endif
|
||||
let chan_id = jobstart(self.command, {
|
||||
\ 'rpc': 1,
|
||||
\ 'on_stderr': {channel, msgs -> s:on_stderr(self.name, msgs)},
|
||||
\ 'on_exit': {channel, code -> s:on_exit(self.name, code)},
|
||||
\})
|
||||
for key in keys(original)
|
||||
call setenv(key, original[key])
|
||||
endfor
|
||||
if exists('*setenv')
|
||||
for key in keys(original)
|
||||
call setenv(key, original[key])
|
||||
endfor
|
||||
else
|
||||
let $TMPDIR = original['tmpdir']
|
||||
endif
|
||||
if chan_id <= 0
|
||||
echohl Error | echom 'Failed to start '.self.name.' service' | echohl None
|
||||
return
|
||||
|
@ -120,6 +131,10 @@ function! s:on_exit(name, code) abort
|
|||
let client['channel'] = v:null
|
||||
let client['async_req_id'] = 1
|
||||
if a:code != 0 && a:code != 143
|
||||
" could be syntax error
|
||||
if a:code == 1
|
||||
call s:check_node()
|
||||
endif
|
||||
echohl Error | echom 'client '.a:name. ' abnormal exit with: '.a:code | echohl None
|
||||
endif
|
||||
endfunction
|
||||
|
@ -311,3 +326,14 @@ function! coc#client#open_log()
|
|||
endif
|
||||
execute 'vs '.s:logfile
|
||||
endfunction
|
||||
|
||||
function! s:check_node() abort
|
||||
let node = get(g:, 'coc_node_path', $COC_NODE_PATH == '' ? 'node' : $COC_NODE_PATH)
|
||||
let output = trim(system(node . ' --version'))
|
||||
let ms = matchlist(output, 'v\(\d\+\).\(\d\+\).\(\d\+\)')
|
||||
if empty(ms) || str2nr(ms[1]) < 10 || (str2nr(ms[1]) == 10 && str2nr(ms[2]) < 12)
|
||||
echohl Error
|
||||
echon '[coc.nvim] Node version '.output.' < 10.12.0, please upgrade node.js or use g:coc_node_path variable.'
|
||||
echohl None
|
||||
endif
|
||||
endfunction
|
||||
|
|
191
pack/acp/opt/coc.nvim/autoload/coc/color.vim
Normal file
191
pack/acp/opt/coc.nvim/autoload/coc/color.vim
Normal file
|
@ -0,0 +1,191 @@
|
|||
" Returns an approximate grey index for the given grey level
|
||||
fun! s:grey_number(x)
|
||||
if &t_Co == 88
|
||||
if a:x < 23
|
||||
return 0
|
||||
elseif a:x < 69
|
||||
return 1
|
||||
elseif a:x < 103
|
||||
return 2
|
||||
elseif a:x < 127
|
||||
return 3
|
||||
elseif a:x < 150
|
||||
return 4
|
||||
elseif a:x < 173
|
||||
return 5
|
||||
elseif a:x < 196
|
||||
return 6
|
||||
elseif a:x < 219
|
||||
return 7
|
||||
elseif a:x < 243
|
||||
return 8
|
||||
else
|
||||
return 9
|
||||
endif
|
||||
else
|
||||
if a:x < 14
|
||||
return 0
|
||||
else
|
||||
let l:n = (a:x - 8) / 10
|
||||
let l:m = (a:x - 8) % 10
|
||||
if l:m < 5
|
||||
return l:n
|
||||
else
|
||||
return l:n + 1
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endfun
|
||||
|
||||
" Returns the actual grey level represented by the grey index
|
||||
fun! s:grey_level(n)
|
||||
if &t_Co == 88
|
||||
if a:n == 0
|
||||
return 0
|
||||
elseif a:n == 1
|
||||
return 46
|
||||
elseif a:n == 2
|
||||
return 92
|
||||
elseif a:n == 3
|
||||
return 115
|
||||
elseif a:n == 4
|
||||
return 139
|
||||
elseif a:n == 5
|
||||
return 162
|
||||
elseif a:n == 6
|
||||
return 185
|
||||
elseif a:n == 7
|
||||
return 208
|
||||
elseif a:n == 8
|
||||
return 231
|
||||
else
|
||||
return 255
|
||||
endif
|
||||
else
|
||||
if a:n == 0
|
||||
return 0
|
||||
else
|
||||
return 8 + (a:n * 10)
|
||||
endif
|
||||
endif
|
||||
endfun
|
||||
|
||||
" Returns the palette index for the given grey index
|
||||
fun! s:grey_colour(n)
|
||||
if &t_Co == 88
|
||||
if a:n == 0
|
||||
return 16
|
||||
elseif a:n == 9
|
||||
return 79
|
||||
else
|
||||
return 79 + a:n
|
||||
endif
|
||||
else
|
||||
if a:n == 0
|
||||
return 16
|
||||
elseif a:n == 25
|
||||
return 231
|
||||
else
|
||||
return 231 + a:n
|
||||
endif
|
||||
endif
|
||||
endfun
|
||||
|
||||
" Returns an approximate colour index for the given colour level
|
||||
fun! s:rgb_number(x)
|
||||
if &t_Co == 88
|
||||
if a:x < 69
|
||||
return 0
|
||||
elseif a:x < 172
|
||||
return 1
|
||||
elseif a:x < 230
|
||||
return 2
|
||||
else
|
||||
return 3
|
||||
endif
|
||||
else
|
||||
if a:x < 75
|
||||
return 0
|
||||
else
|
||||
let l:n = (a:x - 55) / 40
|
||||
let l:m = (a:x - 55) % 40
|
||||
if l:m < 20
|
||||
return l:n
|
||||
else
|
||||
return l:n + 1
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endfun
|
||||
|
||||
" Returns the palette index for the given R/G/B colour indices
|
||||
fun! s:rgb_colour(x, y, z)
|
||||
if &t_Co == 88
|
||||
return 16 + (a:x * 16) + (a:y * 4) + a:z
|
||||
else
|
||||
return 16 + (a:x * 36) + (a:y * 6) + a:z
|
||||
endif
|
||||
endfun
|
||||
|
||||
" Returns the actual colour level for the given colour index
|
||||
fun! s:rgb_level(n)
|
||||
if &t_Co == 88
|
||||
if a:n == 0
|
||||
return 0
|
||||
elseif a:n == 1
|
||||
return 139
|
||||
elseif a:n == 2
|
||||
return 205
|
||||
else
|
||||
return 255
|
||||
endif
|
||||
else
|
||||
if a:n == 0
|
||||
return 0
|
||||
else
|
||||
return 55 + (a:n * 40)
|
||||
endif
|
||||
endif
|
||||
endfun
|
||||
|
||||
" Returns the palette index to approximate the given R/G/B colour levels
|
||||
fun! s:colour(r, g, b)
|
||||
" Get the closest grey
|
||||
let l:gx = s:grey_number(a:r)
|
||||
let l:gy = s:grey_number(a:g)
|
||||
let l:gz = s:grey_number(a:b)
|
||||
|
||||
" Get the closest colour
|
||||
let l:x = s:rgb_number(a:r)
|
||||
let l:y = s:rgb_number(a:g)
|
||||
let l:z = s:rgb_number(a:b)
|
||||
|
||||
if l:gx == l:gy && l:gy == l:gz
|
||||
" There are two possibilities
|
||||
let l:dgr = s:grey_level(l:gx) - a:r
|
||||
let l:dgg = s:grey_level(l:gy) - a:g
|
||||
let l:dgb = s:grey_level(l:gz) - a:b
|
||||
let l:dgrey = (l:dgr * l:dgr) + (l:dgg * l:dgg) + (l:dgb * l:dgb)
|
||||
let l:dr = s:rgb_level(l:gx) - a:r
|
||||
let l:dg = s:rgb_level(l:gy) - a:g
|
||||
let l:db = s:rgb_level(l:gz) - a:b
|
||||
let l:drgb = (l:dr * l:dr) + (l:dg * l:dg) + (l:db * l:db)
|
||||
if l:dgrey < l:drgb
|
||||
" Use the grey
|
||||
return s:grey_colour(l:gx)
|
||||
else
|
||||
" Use the colour
|
||||
return s:rgb_colour(l:x, l:y, l:z)
|
||||
endif
|
||||
else
|
||||
" Only one possibility
|
||||
return s:rgb_colour(l:x, l:y, l:z)
|
||||
endif
|
||||
endfun
|
||||
|
||||
function! coc#color#rgb2term(rgb)
|
||||
let l:r = ("0x" . strpart(a:rgb, 0, 2)) + 0
|
||||
let l:g = ("0x" . strpart(a:rgb, 2, 2)) + 0
|
||||
let l:b = ("0x" . strpart(a:rgb, 4, 2)) + 0
|
||||
return s:colour(l:r, l:g, l:b)
|
||||
endfun
|
133
pack/acp/opt/coc.nvim/autoload/coc/compat.vim
Normal file
133
pack/acp/opt/coc.nvim/autoload/coc/compat.vim
Normal file
|
@ -0,0 +1,133 @@
|
|||
let s:is_vim = !has('nvim')
|
||||
|
||||
" first window id for bufnr
|
||||
" builtin bufwinid returns window of current tab only
|
||||
function! coc#compat#buf_win_id(bufnr) abort
|
||||
let info = filter(getwininfo(), 'v:val["bufnr"] =='.a:bufnr)
|
||||
if empty(info)
|
||||
return -1
|
||||
endif
|
||||
return info[0]['winid']
|
||||
endfunction
|
||||
|
||||
function! coc#compat#win_is_valid(winid) abort
|
||||
if exists('*nvim_win_is_valid')
|
||||
return nvim_win_is_valid(a:winid)
|
||||
endif
|
||||
return !empty(getwininfo(a:winid))
|
||||
endfunction
|
||||
|
||||
" clear matches by window id, not throw on none exists window.
|
||||
" may not work on vim < 8.1.1084 & neovim < 0.4.0
|
||||
function! coc#compat#clear_matches(winid) abort
|
||||
if !coc#compat#win_is_valid(a:winid)
|
||||
return
|
||||
endif
|
||||
let curr = win_getid()
|
||||
if curr == a:winid
|
||||
call clearmatches()
|
||||
return
|
||||
endif
|
||||
if s:is_vim
|
||||
if has('patch-8.1.1084')
|
||||
call clearmatches(a:winid)
|
||||
endif
|
||||
else
|
||||
if exists('*nvim_set_current_win')
|
||||
noa call nvim_set_current_win(a:winid)
|
||||
call clearmatches()
|
||||
noa call nvim_set_current_win(curr)
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! coc#compat#matchaddpos(group, pos, priority, winid) abort
|
||||
let curr = win_getid()
|
||||
if curr == a:winid
|
||||
call matchaddpos(a:group, a:pos, a:priority, -1)
|
||||
else
|
||||
if s:is_vim
|
||||
if has('patch-8.1.0218')
|
||||
call matchaddpos(a:group, a:pos, a:priority, -1, {'window': a:winid})
|
||||
endif
|
||||
else
|
||||
if has('nvim-0.4.0')
|
||||
call matchaddpos(a:group, a:pos, a:priority, -1, {'window': a:winid})
|
||||
elseif exists('*nvim_set_current_win')
|
||||
noa call nvim_set_current_win(a:winid)
|
||||
call matchaddpos(a:group, a:pos, a:priority, -1)
|
||||
noa call nvim_set_current_win(curr)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" hlGroup, pos, priority
|
||||
function! coc#compat#matchaddgroups(winid, groups) abort
|
||||
" add by winid
|
||||
if s:is_vim && has('patch-8.1.0218') || has('nvim-0.4.0')
|
||||
for group in a:groups
|
||||
call matchaddpos(group['hlGroup'], [group['pos']], group['priority'], -1, {'window': a:winid})
|
||||
endfor
|
||||
endif
|
||||
let curr = win_getid()
|
||||
if curr == a:winid
|
||||
for group in a:groups
|
||||
call matchaddpos(group['hlGroup'], [group['pos']], group['priority'], -1)
|
||||
endfor
|
||||
elseif exists('*nvim_set_current_win')
|
||||
noa call nvim_set_current_win(a:winid)
|
||||
for group in a:groups
|
||||
call matchaddpos(group['hlGroup'], [group['pos']], group['priority'], -1)
|
||||
endfor
|
||||
noa call nvim_set_current_win(curr)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" remove keymap for specfic buffer
|
||||
function! coc#compat#buf_del_keymap(bufnr, mode, lhs) abort
|
||||
if !bufloaded(a:bufnr)
|
||||
return
|
||||
endif
|
||||
if exists('*nvim_buf_del_keymap')
|
||||
try
|
||||
call nvim_buf_del_keymap(a:bufnr, a:mode, a:lhs)
|
||||
catch /^Vim\%((\a\+)\)\=:E5555/
|
||||
" ignore keymap not exists.
|
||||
endtry
|
||||
return
|
||||
endif
|
||||
if bufnr == a:bufnr
|
||||
execute 'silent! '.a:mode.'unmap <buffer> '.a:lhs
|
||||
return
|
||||
endif
|
||||
if exists('*win_execute')
|
||||
let winid = coc#compat#buf_win_id(a:bufnr)
|
||||
if winid != -1
|
||||
call win_execute(winid, 'silent! '.a:mode.'unmap <buffer> '.a:lhs)
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" execute command or list of commands in window
|
||||
function! coc#compat#execute(winid, command) abort
|
||||
if s:is_vim
|
||||
if !exists('*win_execute')
|
||||
throw 'win_execute function not exists, please upgrade your vim.'
|
||||
endif
|
||||
if type(a:command) == v:t_string
|
||||
keepalt call win_execute(a:winid, a:command)
|
||||
elseif type(a:command) == v:t_list
|
||||
keepalt call win_execute(a:winid, join(a:command, "\n"))
|
||||
endif
|
||||
else
|
||||
let curr = nvim_get_current_win()
|
||||
noa keepalt call nvim_set_current_win(a:winid)
|
||||
if type(a:command) == v:t_string
|
||||
exec a:command
|
||||
elseif type(a:command) == v:t_list
|
||||
exec join(a:command, "\n")
|
||||
endif
|
||||
noa keepalt call nvim_set_current_win(curr)
|
||||
endif
|
||||
endfunc
|
File diff suppressed because it is too large
Load diff
|
@ -54,3 +54,36 @@ function! coc#helper#dict_omit(dict, keys) abort
|
|||
endfor
|
||||
return res
|
||||
endfunction
|
||||
|
||||
" Return new dict with keys only
|
||||
function! coc#helper#dict_pick(dict, keys) abort
|
||||
let res = {}
|
||||
for key in keys(a:dict)
|
||||
if index(a:keys, key) != -1
|
||||
let res[key] = a:dict[key]
|
||||
endif
|
||||
endfor
|
||||
return res
|
||||
endfunction
|
||||
|
||||
" support for float values
|
||||
function! coc#helper#min(first, ...) abort
|
||||
let val = a:first
|
||||
for i in range(0, len(a:000) - 1)
|
||||
if a:000[i] < val
|
||||
let val = a:000[i]
|
||||
endif
|
||||
endfor
|
||||
return val
|
||||
endfunction
|
||||
|
||||
" support for float values
|
||||
function! coc#helper#max(first, ...) abort
|
||||
let val = a:first
|
||||
for i in range(0, len(a:000) - 1)
|
||||
if a:000[i] > val
|
||||
let val = a:000[i]
|
||||
endif
|
||||
endfor
|
||||
return val
|
||||
endfunction
|
||||
|
|
321
pack/acp/opt/coc.nvim/autoload/coc/highlight.vim
Normal file
321
pack/acp/opt/coc.nvim/autoload/coc/highlight.vim
Normal file
|
@ -0,0 +1,321 @@
|
|||
let s:is_vim = !has('nvim')
|
||||
let s:clear_match_by_window = has('nvim-0.5.0') || has('patch-8.1.1084')
|
||||
let s:namespace_map = {}
|
||||
let s:ns_id = 1
|
||||
|
||||
if has('nvim-0.5.0')
|
||||
try
|
||||
call getmatches(0)
|
||||
catch /^Vim\%((\a\+)\)\=:E118/
|
||||
let s:clear_match_by_window = 0
|
||||
endtry
|
||||
endif
|
||||
|
||||
" highlight LSP range,
|
||||
function! coc#highlight#ranges(bufnr, key, hlGroup, ranges) abort
|
||||
let bufnr = a:bufnr == 0 ? bufnr('%') : a:bufnr
|
||||
if !bufloaded(bufnr) || !exists('*getbufline')
|
||||
return
|
||||
endif
|
||||
let srcId = s:create_namespace(a:key)
|
||||
for range in a:ranges
|
||||
let start = range['start']
|
||||
let end = range['end']
|
||||
for lnum in range(start['line'] + 1, end['line'] + 1)
|
||||
let arr = getbufline(bufnr, lnum)
|
||||
let line = empty(arr) ? '' : arr[0]
|
||||
if empty(line)
|
||||
continue
|
||||
endif
|
||||
" TODO don't know how to count UTF16 code point, should work most cases.
|
||||
let colStart = lnum == start['line'] + 1 ? strlen(strcharpart(line, 0, start['character'])) : 0
|
||||
let colEnd = lnum == end['line'] + 1 ? strlen(strcharpart(line, 0, end['character'])) : -1
|
||||
if colStart == colEnd
|
||||
continue
|
||||
endif
|
||||
call coc#highlight#add_highlight(bufnr, srcId, a:hlGroup, lnum - 1, colStart, colEnd)
|
||||
endfor
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! coc#highlight#add_highlight(bufnr, src_id, hl_group, line, col_start, col_end) abort
|
||||
if has('nvim')
|
||||
call nvim_buf_add_highlight(a:bufnr, a:src_id, a:hl_group, a:line, a:col_start, a:col_end)
|
||||
else
|
||||
call coc#api#call('buf_add_highlight', [a:bufnr, a:src_id, a:hl_group, a:line, a:col_start, a:col_end])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! coc#highlight#clear_highlight(bufnr, key, start_line, end_line) abort
|
||||
let bufnr = a:bufnr == 0 ? bufnr('%') : a:bufnr
|
||||
if !bufloaded(bufnr)
|
||||
return
|
||||
endif
|
||||
let src_id = s:create_namespace(a:key)
|
||||
if has('nvim')
|
||||
call nvim_buf_clear_namespace(a:bufnr, src_id, a:start_line, a:end_line)
|
||||
else
|
||||
call coc#api#call('buf_clear_namespace', [a:bufnr, src_id, a:start_line, a:end_line])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" highlight buffer in winid with CodeBlock &HighlightItems
|
||||
" export interface HighlightItem {
|
||||
" lnum: number // 0 based
|
||||
" hlGroup: string
|
||||
" colStart: number // 0 based
|
||||
" colEnd: number
|
||||
" }
|
||||
" export interface CodeBlock {
|
||||
" filetype?: string
|
||||
" hlGroup?: string
|
||||
" startLine: number // 0 based
|
||||
" endLine: number
|
||||
" }
|
||||
function! coc#highlight#add_highlights(winid, codes, highlights) abort
|
||||
" clear highlights
|
||||
call coc#compat#execute(a:winid, 'syntax clear')
|
||||
let bufnr = winbufnr(a:winid)
|
||||
call coc#highlight#clear_highlight(bufnr, -1, 0, -1)
|
||||
if !empty(a:codes)
|
||||
call coc#highlight#highlight_lines(a:winid, a:codes)
|
||||
endif
|
||||
if !empty(a:highlights)
|
||||
for item in a:highlights
|
||||
call coc#highlight#add_highlight(bufnr, -1, item['hlGroup'], item['lnum'], item['colStart'], item['colEnd'])
|
||||
endfor
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
" Add highlights to line groups of winid, support hlGroup and filetype
|
||||
" config should have startLine, endLine (1 based, end excluded) and filetype or hlGroup
|
||||
" endLine should > startLine and endLine is excluded
|
||||
"
|
||||
" export interface CodeBlock {
|
||||
" filetype?: string
|
||||
" hlGroup?: string
|
||||
" startLine: number // 0 based
|
||||
" endLine: number
|
||||
" }
|
||||
function! coc#highlight#highlight_lines(winid, blocks) abort
|
||||
let currwin = win_getid()
|
||||
let switch = has('nvim') && currwin != a:winid
|
||||
if switch
|
||||
noa call nvim_set_current_win(a:winid)
|
||||
endif
|
||||
let defined = []
|
||||
let region_id = 1
|
||||
for config in a:blocks
|
||||
let start = config['startLine'] + 1
|
||||
let end = config['endLine'] == -1 ? len(getbufline(winbufnr(a:winid), 1, '$')) + 1 : config['endLine'] + 1
|
||||
let filetype = get(config, 'filetype', '')
|
||||
let hlGroup = get(config, 'hlGroup', '')
|
||||
if !empty(hlGroup)
|
||||
call s:execute(a:winid, 'syntax region '.hlGroup.' start=/\%'.start.'l/ end=/\%'.end.'l/')
|
||||
else
|
||||
let filetype = matchstr(filetype, '\v^\w+')
|
||||
if empty(filetype) || filetype == 'txt' || index(get(g:, 'coc_markdown_disabled_languages', []), filetype) != -1
|
||||
continue
|
||||
endif
|
||||
if index(defined, filetype) == -1
|
||||
call s:execute(a:winid, 'syntax include @'.toupper(filetype).' syntax/'.filetype.'.vim')
|
||||
if has('nvim')
|
||||
unlet! b:current_syntax
|
||||
elseif exists('*win_execute')
|
||||
call win_execute(a:winid, 'unlet! b:current_syntax')
|
||||
endif
|
||||
call add(defined, filetype)
|
||||
endif
|
||||
call s:execute(a:winid, 'syntax region CodeBlock'.region_id.' start=/\%'.start.'l/ end=/\%'.end.'l/ contains=@'.toupper(filetype))
|
||||
let region_id = region_id + 1
|
||||
endif
|
||||
endfor
|
||||
if switch
|
||||
noa call nvim_set_current_win(currwin)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Copmpose hlGroups with foreground and background colors.
|
||||
function! coc#highlight#compose_hlgroup(fgGroup, bgGroup) abort
|
||||
let hlGroup = 'Fg'.a:fgGroup.'Bg'.a:bgGroup
|
||||
if a:fgGroup == a:bgGroup
|
||||
return a:fgGroup
|
||||
endif
|
||||
if hlexists(hlGroup)
|
||||
return hlGroup
|
||||
endif
|
||||
let fg = synIDattr(synIDtrans(hlID(a:fgGroup)), 'fg', 'gui')
|
||||
let bg = synIDattr(synIDtrans(hlID(a:bgGroup)), 'bg', 'gui')
|
||||
if fg =~# '^#' || bg =~# '^#'
|
||||
call s:create_gui_hlgroup(hlGroup, fg, bg, '')
|
||||
else
|
||||
let fg = synIDattr(synIDtrans(hlID(a:fgGroup)), 'fg', 'cterm')
|
||||
let bg = synIDattr(synIDtrans(hlID(a:bgGroup)), 'bg', 'cterm')
|
||||
call s:create_cterm_hlgroup(hlGroup, fg, bg, '')
|
||||
endif
|
||||
return hlGroup
|
||||
endfunction
|
||||
|
||||
" add matches for winid, use 0 for current window.
|
||||
function! coc#highlight#match_ranges(winid, bufnr, ranges, hlGroup, priority) abort
|
||||
let winid = a:winid == 0 ? win_getid() : a:winid
|
||||
let bufnr = a:bufnr == 0 ? winbufnr(winid) : a:bufnr
|
||||
if empty(getwininfo(winid)) || (a:bufnr != 0 && winbufnr(a:winid) != a:bufnr)
|
||||
" not valid
|
||||
return []
|
||||
endif
|
||||
if !s:clear_match_by_window
|
||||
let curr = win_getid()
|
||||
if has('nvim')
|
||||
noa call nvim_set_current_win(winid)
|
||||
else
|
||||
noa call win_gotoid(winid)
|
||||
endif
|
||||
endif
|
||||
let ids = []
|
||||
for range in a:ranges
|
||||
let list = []
|
||||
let start = range['start']
|
||||
let end = range['end']
|
||||
for lnum in range(start['line'] + 1, end['line'] + 1)
|
||||
let arr = getbufline(bufnr, lnum)
|
||||
let line = empty(arr) ? '' : arr[0]
|
||||
if empty(line)
|
||||
continue
|
||||
endif
|
||||
let colStart = lnum == start['line'] + 1 ? strlen(strcharpart(line, 0, start['character'])) + 1 : 1
|
||||
let colEnd = lnum == end['line'] + 1 ? strlen(strcharpart(line, 0, end['character'])) + 1 : strlen(line) + 1
|
||||
if colStart == colEnd
|
||||
continue
|
||||
endif
|
||||
call add(list, [lnum, colStart, colEnd - colStart])
|
||||
endfor
|
||||
if !empty(list)
|
||||
let opts = s:clear_match_by_window ? {'window': a:winid} : {}
|
||||
let id = matchaddpos(a:hlGroup, list, a:priority, -1, opts)
|
||||
call add(ids, id)
|
||||
endif
|
||||
endfor
|
||||
if !s:clear_match_by_window
|
||||
if has('nvim')
|
||||
noa call nvim_set_current_win(curr)
|
||||
else
|
||||
noa call win_gotoid(curr)
|
||||
endif
|
||||
endif
|
||||
return ids
|
||||
endfunction
|
||||
|
||||
" Clear matches by hlGroup regexp.
|
||||
function! coc#highlight#clear_match_group(winid, match) abort
|
||||
let winid = a:winid == 0 ? win_getid() : a:winid
|
||||
if empty(getwininfo(winid))
|
||||
" not valid
|
||||
return
|
||||
endif
|
||||
if s:clear_match_by_window
|
||||
let arr = filter(getmatches(winid), 'v:val["group"] =~# "'.a:match.'"')
|
||||
for item in arr
|
||||
call matchdelete(item['id'], winid)
|
||||
endfor
|
||||
else
|
||||
let curr = win_getid()
|
||||
let switch = exists('*nvim_set_current_win') && curr != winid
|
||||
if switch
|
||||
noa call nvim_set_current_win(a:winid)
|
||||
endif
|
||||
if win_getid() == winid
|
||||
let arr = filter(getmatches(), 'v:val["group"] =~# "'.a:match.'"')
|
||||
for item in arr
|
||||
call matchdelete(item['id'])
|
||||
endfor
|
||||
endif
|
||||
if switch
|
||||
noa call nvim_set_current_win(curr)
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Clear matches by match ids, use 0 for current win.
|
||||
function! coc#highlight#clear_matches(winid, ids)
|
||||
let winid = a:winid == 0 ? win_getid() : a:winid
|
||||
if empty(getwininfo(winid))
|
||||
" not valid
|
||||
return
|
||||
endif
|
||||
if s:clear_match_by_window
|
||||
for id in a:ids
|
||||
try
|
||||
call matchdelete(id, winid)
|
||||
catch /^Vim\%((\a\+)\)\=:E803/
|
||||
" ignore
|
||||
endtry
|
||||
endfor
|
||||
else
|
||||
let curr = win_getid()
|
||||
let switch = exists('*nvim_set_current_win') && curr != winid
|
||||
if switch
|
||||
noa call nvim_set_current_win(a:winid)
|
||||
endif
|
||||
if win_getid() == winid
|
||||
for id in a:ids
|
||||
try
|
||||
call matchdelete(id)
|
||||
catch /^Vim\%((\a\+)\)\=:E803/
|
||||
" ignore
|
||||
endtry
|
||||
endfor
|
||||
endif
|
||||
if switch
|
||||
noa call nvim_set_current_win(curr)
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Sets the highlighting for the given group
|
||||
function! s:create_gui_hlgroup(group, fg, bg, attr)
|
||||
if a:fg != ""
|
||||
exec "silent hi " . a:group . " guifg=" . a:fg . " ctermfg=" . coc#color#rgb2term(strpart(a:fg, 1))
|
||||
endif
|
||||
if a:bg != ""
|
||||
exec "silent hi " . a:group . " guibg=" . a:bg . " ctermbg=" . coc#color#rgb2term(strpart(a:bg, 1))
|
||||
endif
|
||||
if a:attr != ""
|
||||
exec "silent hi " . a:group . " gui=" . a:attr . " cterm=" . a:attr
|
||||
endif
|
||||
endfun
|
||||
|
||||
function! s:create_cterm_hlgroup(group, fg, bg, attr) abort
|
||||
if a:fg != ""
|
||||
exec "silent hi " . a:group . " ctermfg=" . a:fg
|
||||
endif
|
||||
if a:bg != ""
|
||||
exec "silent hi " . a:group . " ctermbg=" . a:bg
|
||||
endif
|
||||
if a:attr != ""
|
||||
exec "silent hi " . a:group . " cterm=" . a:attr
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:execute(winid, cmd) abort
|
||||
if has('nvim')
|
||||
execute 'silent! ' a:cmd
|
||||
else
|
||||
call win_execute(a:winid, a:cmd, 'silent!')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:create_namespace(key) abort
|
||||
if type(a:key) == 0
|
||||
return a:key
|
||||
endif
|
||||
if has('nvim')
|
||||
return nvim_create_namespace('coc-'.a:key)
|
||||
endif
|
||||
if !has_key(s:namespace_map, a:key)
|
||||
let s:namespace_map[a:key] = s:ns_id
|
||||
let s:ns_id = s:ns_id + 1
|
||||
endif
|
||||
return s:namespace_map[a:key]
|
||||
endfunction
|
|
@ -1,178 +1,31 @@
|
|||
let s:activated = 0
|
||||
let s:is_vim = !has('nvim')
|
||||
let s:saved_ve = &t_ve
|
||||
let s:saved_cursor = &guicursor
|
||||
let s:gui = has('gui_running') || has('nvim')
|
||||
|
||||
function! coc#list#get_chars()
|
||||
return {
|
||||
\ '<plug>': "\<Plug>",
|
||||
\ '<esc>': "\<Esc>",
|
||||
\ '<tab>': "\<Tab>",
|
||||
\ '<s-tab>': "\<S-Tab>",
|
||||
\ '<bs>': "\<bs>",
|
||||
\ '<right>': "\<right>",
|
||||
\ '<left>': "\<left>",
|
||||
\ '<up>': "\<up>",
|
||||
\ '<down>': "\<down>",
|
||||
\ '<home>': "\<home>",
|
||||
\ '<end>': "\<end>",
|
||||
\ '<cr>': "\<cr>",
|
||||
\ '<PageUp>' : "\<PageUp>",
|
||||
\ '<PageDown>' : "\<PageDown>",
|
||||
\ '<FocusGained>' : "\<FocusGained>",
|
||||
\ '<ScrollWheelUp>': "\<ScrollWheelUp>",
|
||||
\ '<ScrollWheelDown>': "\<ScrollWheelDown>",
|
||||
\ '<LeftMouse>': "\<LeftMouse>",
|
||||
\ '<LeftDrag>': "\<LeftDrag>",
|
||||
\ '<LeftRelease>': "\<LeftRelease>",
|
||||
\ '<2-LeftMouse>': "\<2-LeftMouse>",
|
||||
\ '<C-a>': "\<C-a>",
|
||||
\ '<C-b>': "\<C-b>",
|
||||
\ '<C-c>': "\<C-c>",
|
||||
\ '<C-d>': "\<C-d>",
|
||||
\ '<C-e>': "\<C-e>",
|
||||
\ '<C-f>': "\<C-f>",
|
||||
\ '<C-g>': "\<C-g>",
|
||||
\ '<C-h>': "\<C-h>",
|
||||
\ '<C-i>': "\<C-i>",
|
||||
\ '<C-j>': "\<C-j>",
|
||||
\ '<C-k>': "\<C-k>",
|
||||
\ '<C-l>': "\<C-l>",
|
||||
\ '<C-m>': "\<C-m>",
|
||||
\ '<C-n>': "\<C-n>",
|
||||
\ '<C-o>': "\<C-o>",
|
||||
\ '<C-p>': "\<C-p>",
|
||||
\ '<C-q>': "\<C-q>",
|
||||
\ '<C-r>': "\<C-r>",
|
||||
\ '<C-s>': "\<C-s>",
|
||||
\ '<C-t>': "\<C-t>",
|
||||
\ '<C-u>': "\<C-u>",
|
||||
\ '<C-v>': "\<C-v>",
|
||||
\ '<C-w>': "\<C-w>",
|
||||
\ '<C-x>': "\<C-x>",
|
||||
\ '<C-y>': "\<C-y>",
|
||||
\ '<C-z>': "\<C-z>",
|
||||
\ '<A-a>': "\<A-a>",
|
||||
\ '<A-b>': "\<A-b>",
|
||||
\ '<A-c>': "\<A-c>",
|
||||
\ '<A-d>': "\<A-d>",
|
||||
\ '<A-e>': "\<A-e>",
|
||||
\ '<A-f>': "\<A-f>",
|
||||
\ '<A-g>': "\<A-g>",
|
||||
\ '<A-h>': "\<A-h>",
|
||||
\ '<A-i>': "\<A-i>",
|
||||
\ '<A-j>': "\<A-j>",
|
||||
\ '<A-k>': "\<A-k>",
|
||||
\ '<A-l>': "\<A-l>",
|
||||
\ '<A-m>': "\<A-m>",
|
||||
\ '<A-n>': "\<A-n>",
|
||||
\ '<A-o>': "\<A-o>",
|
||||
\ '<A-p>': "\<A-p>",
|
||||
\ '<A-q>': "\<A-q>",
|
||||
\ '<A-r>': "\<A-r>",
|
||||
\ '<A-s>': "\<A-s>",
|
||||
\ '<A-t>': "\<A-t>",
|
||||
\ '<A-u>': "\<A-u>",
|
||||
\ '<A-v>': "\<A-v>",
|
||||
\ '<A-w>': "\<A-w>",
|
||||
\ '<A-x>': "\<A-x>",
|
||||
\ '<A-y>': "\<A-y>",
|
||||
\ '<A-z>': "\<A-z>",
|
||||
\}
|
||||
endfunction
|
||||
|
||||
function! coc#list#getc() abort
|
||||
let c = getchar()
|
||||
return type(c) == type(0) ? nr2char(c) : c
|
||||
endfunction
|
||||
let s:prefix = '[List Preview]'
|
||||
" filetype detect could be slow.
|
||||
let s:filetype_map = {
|
||||
\ 'vim': 'vim',
|
||||
\ 'ts': 'typescript',
|
||||
\ 'js': 'javascript',
|
||||
\ 'html': 'html',
|
||||
\ 'css': 'css'
|
||||
\ }
|
||||
|
||||
function! coc#list#getchar() abort
|
||||
let input = coc#list#getc()
|
||||
if 1 != &iminsert
|
||||
return input
|
||||
endif
|
||||
"a language keymap is activated, so input must be resolved to the mapped values.
|
||||
let partial_keymap = mapcheck(input, "l")
|
||||
while partial_keymap !=# ""
|
||||
let full_keymap = maparg(input, "l")
|
||||
if full_keymap ==# "" && len(input) >= 3 "HACK: assume there are no keymaps longer than 3.
|
||||
return input
|
||||
elseif full_keymap ==# partial_keymap
|
||||
return full_keymap
|
||||
endif
|
||||
let c = coc#list#getc()
|
||||
if c ==# "\<Esc>" || c ==# "\<CR>"
|
||||
"if the short sequence has a valid mapping, return that.
|
||||
if !empty(full_keymap)
|
||||
return full_keymap
|
||||
endif
|
||||
return input
|
||||
endif
|
||||
let input .= c
|
||||
let partial_keymap = mapcheck(input, "l")
|
||||
endwhile
|
||||
return input
|
||||
return coc#prompt#getchar()
|
||||
endfunction
|
||||
|
||||
function! coc#list#start_prompt(...) abort
|
||||
let eventName = get(a:, 1, 'InputChar')
|
||||
if s:is_vim
|
||||
call s:start_prompt_vim(eventName)
|
||||
else
|
||||
call s:start_prompt(eventName)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:start_prompt_vim(eventName) abort
|
||||
call timer_start(10, {-> s:start_prompt(a:eventName)})
|
||||
endfunction
|
||||
|
||||
function! s:start_prompt(eventName)
|
||||
if s:activated | return | endif
|
||||
if !get(g:, 'coc_disable_transparent_cursor', 0)
|
||||
if s:gui
|
||||
if has('nvim-0.5.0') && !empty(s:saved_cursor)
|
||||
set guicursor+=a:ver1-CocCursorTransparent/lCursor
|
||||
endif
|
||||
elseif s:is_vim
|
||||
set t_ve=
|
||||
endif
|
||||
endif
|
||||
let s:activated = 1
|
||||
try
|
||||
while s:activated
|
||||
let ch = coc#list#getchar()
|
||||
if ch ==# "\u26d4"
|
||||
break
|
||||
endif
|
||||
if ch ==# "\<FocusLost>" || ch ==# "\<FocusGained>" || ch ==# "\<CursorHold>"
|
||||
continue
|
||||
else
|
||||
call coc#rpc#notify(a:eventName, [ch, getcharmod()])
|
||||
endif
|
||||
endwhile
|
||||
catch /^Vim:Interrupt$/
|
||||
let s:activated = 0
|
||||
call coc#rpc#notify(a:eventName, ["\<C-c>"])
|
||||
return
|
||||
endtry
|
||||
let s:activated = 0
|
||||
endfunction
|
||||
|
||||
function! coc#list#setlines(lines, append)
|
||||
function! coc#list#setlines(bufnr, lines, append)
|
||||
if a:append
|
||||
silent call append(line('$'), a:lines)
|
||||
silent call appendbufline(a:bufnr, '$', a:lines)
|
||||
else
|
||||
silent call append(0, a:lines)
|
||||
if exists('*deletebufline')
|
||||
call deletebufline('%', len(a:lines) + 1, '$')
|
||||
call deletebufline(a:bufnr, len(a:lines) + 1, '$')
|
||||
else
|
||||
let n = len(a:lines) + 1
|
||||
let saved_reg = @"
|
||||
silent execute n.',$d'
|
||||
let @" = saved_reg
|
||||
endif
|
||||
silent call setbufline(a:bufnr, 1, a:lines)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
@ -192,25 +45,6 @@ function! coc#list#names(...) abort
|
|||
return join(names, "\n")
|
||||
endfunction
|
||||
|
||||
function! coc#list#stop_prompt(...)
|
||||
if s:activated
|
||||
let s:activated = 0
|
||||
if get(a:, 1, 0) == 0 && !get(g:, 'coc_disable_transparent_cursor',0)
|
||||
" neovim has bug with revert empty &guicursor
|
||||
if s:gui && !empty(s:saved_cursor)
|
||||
if has('nvim-0.5.0')
|
||||
set guicursor+=a:ver1-Cursor/lCursor
|
||||
let &guicursor = s:saved_cursor
|
||||
endif
|
||||
elseif s:is_vim
|
||||
let &t_ve = s:saved_ve
|
||||
endif
|
||||
endif
|
||||
echo ""
|
||||
call feedkeys("\u26d4", 'int')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! coc#list#status(name)
|
||||
if !exists('b:list_status') | return '' | endif
|
||||
return get(b:list_status, a:name, '')
|
||||
|
@ -264,25 +98,57 @@ function! coc#list#setup(source)
|
|||
nnoremap <silent><nowait><buffer> <esc> <C-w>c
|
||||
endfunction
|
||||
|
||||
" Check if previewwindow exists on current tab.
|
||||
function! coc#list#has_preview()
|
||||
for i in range(1, winnr('$'))
|
||||
let preview = getwinvar(i, '&previewwindow')
|
||||
let preview = getwinvar(i, 'previewwindow', getwinvar(i, '&previewwindow', 0))
|
||||
if preview
|
||||
return 1
|
||||
return i
|
||||
endif
|
||||
endfor
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
function! coc#list#restore(winid, height)
|
||||
let res = win_gotoid(a:winid)
|
||||
if res == 0 | return | endif
|
||||
if winnr('$') == 1
|
||||
" Get previewwindow from tabnr, use 0 for current tab
|
||||
function! coc#list#get_preview(...) abort
|
||||
let tabnr = get(a:, 1, 0) == 0 ? tabpagenr() : a:1
|
||||
let info = gettabinfo(tabnr)
|
||||
if !empty(info)
|
||||
for win in info[0]['windows']
|
||||
if getwinvar(win, 'previewwindow', 0)
|
||||
return win
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
function! coc#list#scroll_preview(dir) abort
|
||||
let winnr = coc#list#has_preview()
|
||||
if !winnr
|
||||
return
|
||||
endif
|
||||
execute 'resize '.a:height
|
||||
if s:is_vim
|
||||
redraw
|
||||
let winid = win_getid(winnr)
|
||||
if exists('*win_execute')
|
||||
call win_execute(winid, "normal! ".(a:dir ==# 'up' ? "\<C-u>" : "\<C-d>"))
|
||||
else
|
||||
let id = win_getid()
|
||||
noa call win_gotoid(winid)
|
||||
execute "normal! ".(a:dir ==# 'up' ? "\<C-u>" : "\<C-d>")
|
||||
noa call win_gotoid(id)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! coc#list#restore(winid, height)
|
||||
if has('nvim')
|
||||
if nvim_win_is_valid(a:winid)
|
||||
call nvim_win_set_height(a:winid, a:height)
|
||||
endif
|
||||
else
|
||||
if exists('win_execute')
|
||||
call win_execute(a:winid, 'noa resize '.a:height, 'silent!')
|
||||
redraw
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
@ -290,3 +156,187 @@ function! coc#list#set_height(height) abort
|
|||
if winnr('$') == 1| return | endif
|
||||
execute 'resize '.a:height
|
||||
endfunction
|
||||
|
||||
function! coc#list#hide(original, height, winid) abort
|
||||
let arr = win_id2tabwin(a:winid)
|
||||
" close preview window
|
||||
if !empty(arr) && arr[0] != 0
|
||||
silent! pclose!
|
||||
let previewwin = coc#list#get_preview(arr[0])
|
||||
call s:close_win(previewwin)
|
||||
endif
|
||||
if !empty(getwininfo(a:original))
|
||||
call win_gotoid(a:original)
|
||||
endif
|
||||
if a:winid
|
||||
call s:close_win(a:winid)
|
||||
endif
|
||||
if !empty(a:height) && win_getid() == a:original
|
||||
if exists('*nvim_win_set_height')
|
||||
call nvim_win_set_height(a:original, a:height)
|
||||
elseif win_getid() == a:original
|
||||
execute 'resize '.a:height
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:close_win(winid) abort
|
||||
if empty(a:winid) || a:winid == -1 || empty(getwininfo(a:winid))
|
||||
return
|
||||
endif
|
||||
if s:is_vim
|
||||
if exists('*win_execute')
|
||||
noa call win_execute(a:winid, 'close!', 'silent!')
|
||||
else
|
||||
if win_getid() == a:winid
|
||||
noa silent! close!
|
||||
else
|
||||
let winid = win_getid()
|
||||
let res = win_gotoid(winid)
|
||||
if res
|
||||
noa silent! close!
|
||||
noa wincmd p
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
else
|
||||
if nvim_win_is_valid(a:winid)
|
||||
silent! noa call nvim_win_close(a:winid, 1)
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Improve preview performance by reused window & buffer.
|
||||
" lines - list of lines
|
||||
" config.position - could be 'below' 'top' 'tab'.
|
||||
" config.winid - id of original window.
|
||||
" config.name - (optional )name of preview buffer.
|
||||
" config.splitRight - (optional) split to right when 1.
|
||||
" config.lnum - (optional) current line number
|
||||
" config.filetype - (optional) filetype of lines.
|
||||
" config.hlGroup - (optional) highlight group.
|
||||
" config.maxHeight - (optional) max height of window, valid for 'below' & 'top' position.
|
||||
function! coc#list#preview(lines, config) abort
|
||||
if s:is_vim && !exists('*win_execute')
|
||||
throw 'win_execute function required for preview, please upgrade your vim.'
|
||||
return
|
||||
endif
|
||||
let name = fnamemodify(get(a:config, 'name', ''), ':.')
|
||||
let lines = a:lines
|
||||
if empty(lines)
|
||||
if get(a:config, 'scheme', 'file') != 'file'
|
||||
let bufnr = s:load_buffer(name)
|
||||
if bufnr != 0
|
||||
let lines = getbufline(bufnr, 1, '$')
|
||||
else
|
||||
let lines = ['']
|
||||
endif
|
||||
else
|
||||
" Show empty lines so not close window.
|
||||
let lines = ['']
|
||||
endif
|
||||
endif
|
||||
let winid = coc#list#get_preview(0)
|
||||
let bufnr = winid == -1 ? 0 : winbufnr(winid)
|
||||
" Try reuse buffer & window
|
||||
let bufnr = coc#float#create_buf(bufnr, lines)
|
||||
if bufnr == 0
|
||||
return
|
||||
endif
|
||||
call setbufvar(bufnr, '&synmaxcol', 500)
|
||||
let filetype = get(a:config, 'filetype', '')
|
||||
let extname = matchstr(name, '\.\zs[^.]\+$')
|
||||
if empty(filetype) && !empty(extname)
|
||||
let filetype = get(s:filetype_map, extname, '')
|
||||
endif
|
||||
let range = get(a:config, 'range', v:null)
|
||||
let hlGroup = get(a:config, 'hlGroup', 'Search')
|
||||
let lnum = get(a:config, 'lnum', 1)
|
||||
let position = get(a:config, 'position', 'below')
|
||||
let original = get(a:config, 'winid', -1)
|
||||
if winid == -1
|
||||
let change = position != 'tab' && get(a:config, 'splitRight', 0)
|
||||
let curr = win_getid()
|
||||
if change
|
||||
if original && win_id2win(original)
|
||||
noa call win_gotoid(original)
|
||||
else
|
||||
noa wincmd t
|
||||
endif
|
||||
execute 'noa belowright vert sb '.bufnr
|
||||
let winid = win_getid()
|
||||
elseif position == 'tab' || get(a:config, 'splitRight', 0)
|
||||
execute 'noa belowright vert sb '.bufnr
|
||||
let winid = win_getid()
|
||||
else
|
||||
let mod = position == 'top' ? 'below' : 'above'
|
||||
let height = s:get_height(lines, a:config)
|
||||
execute 'noa '.mod.' sb +resize\ '.height.' '.bufnr
|
||||
let winid = win_getid()
|
||||
endif
|
||||
noa call winrestview({"lnum": lnum ,"topline":max([1, lnum - 3])})
|
||||
call setwinvar(winid, '&signcolumn', 'no')
|
||||
call setwinvar(winid, '&number', 1)
|
||||
call setwinvar(winid, '&cursorline', 0)
|
||||
call setwinvar(winid, '&relativenumber', 0)
|
||||
call setwinvar(winid, 'previewwindow', 1)
|
||||
noa call win_gotoid(curr)
|
||||
else
|
||||
let height = s:get_height(lines, a:config)
|
||||
if height > 0
|
||||
if s:is_vim
|
||||
let curr = win_getid()
|
||||
noa call win_gotoid(winid)
|
||||
execute 'silent! noa resize '.height
|
||||
noa call win_gotoid(curr)
|
||||
else
|
||||
call nvim_win_set_height(winid, height)
|
||||
endif
|
||||
endif
|
||||
call coc#compat#execute(winid, ['syntax clear', 'noa call winrestview({"lnum":'.lnum.',"topline":'.max([1, lnum - 3]).'})'])
|
||||
endif
|
||||
if s:prefix.' '.name != bufname(bufnr)
|
||||
if s:is_vim
|
||||
call win_execute(winid, 'noa file '.fnameescape(s:prefix.' '.name), 'silent!')
|
||||
else
|
||||
silent! noa call nvim_buf_set_name(bufnr, s:prefix.' '.name)
|
||||
endif
|
||||
endif
|
||||
" highlights
|
||||
if !empty(filetype)
|
||||
let start = max([0, lnum - 300])
|
||||
let end = min([len(lines), lnum + 300])
|
||||
call coc#highlight#highlight_lines(winid, [{'filetype': filetype, 'startLine': start, 'endLine': end}])
|
||||
call coc#compat#execute(winid, 'syn sync fromstart')
|
||||
else
|
||||
call coc#compat#execute(winid, 'filetype detect')
|
||||
let ft = getbufvar(bufnr, '&filetype', '')
|
||||
if !empty(extname) && !empty(ft)
|
||||
let s:filetype_map[extname] = ft
|
||||
endif
|
||||
endif
|
||||
call sign_unplace('coc', {'buffer': bufnr})
|
||||
call coc#compat#execute(winid, 'call clearmatches()')
|
||||
if !empty(range)
|
||||
call sign_place(1, 'coc', 'CocCurrentLine', bufnr, {'lnum': lnum})
|
||||
call coc#highlight#match_ranges(winid, bufnr, [range], hlGroup, 10)
|
||||
endif
|
||||
redraw
|
||||
endfunction
|
||||
|
||||
function! s:get_height(lines, config) abort
|
||||
if get(a:config, 'splitRight', 0) || get(a:config, 'position', 'below') == 'tab'
|
||||
return 0
|
||||
endif
|
||||
let height = min([get(a:config, 'maxHeight', 10), len(a:lines), &lines - &cmdheight - 2])
|
||||
return height
|
||||
endfunction
|
||||
|
||||
function! s:load_buffer(name) abort
|
||||
if exists('*bufadd') && exists('*bufload')
|
||||
let bufnr = bufadd(a:name)
|
||||
call bufload(bufnr)
|
||||
return bufnr
|
||||
endif
|
||||
return 0
|
||||
endfunction
|
||||
|
|
208
pack/acp/opt/coc.nvim/autoload/coc/prompt.vim
Normal file
208
pack/acp/opt/coc.nvim/autoload/coc/prompt.vim
Normal file
|
@ -0,0 +1,208 @@
|
|||
let s:is_vim = !has('nvim')
|
||||
let s:activated = 0
|
||||
let s:session_names = []
|
||||
let s:saved_ve = &t_ve
|
||||
let s:saved_cursor = &guicursor
|
||||
let s:gui = has('gui_running') || has('nvim')
|
||||
|
||||
let s:char_map = {
|
||||
\ "\<Plug>": '<plug>',
|
||||
\ "\<Esc>": '<esc>',
|
||||
\ "\<Tab>": '<tab>',
|
||||
\ "\<S-Tab>": '<s-tab>',
|
||||
\ "\<bs>": '<bs>',
|
||||
\ "\<right>": '<right>',
|
||||
\ "\<left>": '<left>',
|
||||
\ "\<up>": '<up>',
|
||||
\ "\<down>": '<down>',
|
||||
\ "\<home>": '<home>',
|
||||
\ "\<end>": '<end>',
|
||||
\ "\<cr>": '<cr>',
|
||||
\ "\<PageUp>":'<PageUp>' ,
|
||||
\ "\<PageDown>":'<PageDown>' ,
|
||||
\ "\<FocusGained>":'<FocusGained>' ,
|
||||
\ "\<ScrollWheelUp>": '<ScrollWheelUp>',
|
||||
\ "\<ScrollWheelDown>": '<ScrollWheelDown>',
|
||||
\ "\<LeftMouse>": '<LeftMouse>',
|
||||
\ "\<LeftDrag>": '<LeftDrag>',
|
||||
\ "\<LeftRelease>": '<LeftRelease>',
|
||||
\ "\<2-LeftMouse>": '<2-LeftMouse>',
|
||||
\ "\<C-a>": '<C-a>',
|
||||
\ "\<C-b>": '<C-b>',
|
||||
\ "\<C-c>": '<C-c>',
|
||||
\ "\<C-d>": '<C-d>',
|
||||
\ "\<C-e>": '<C-e>',
|
||||
\ "\<C-f>": '<C-f>',
|
||||
\ "\<C-g>": '<C-g>',
|
||||
\ "\<C-h>": '<C-h>',
|
||||
\ "\<C-j>": '<C-j>',
|
||||
\ "\<C-k>": '<C-k>',
|
||||
\ "\<C-l>": '<C-l>',
|
||||
\ "\<C-n>": '<C-n>',
|
||||
\ "\<C-o>": '<C-o>',
|
||||
\ "\<C-p>": '<C-p>',
|
||||
\ "\<C-q>": '<C-q>',
|
||||
\ "\<C-r>": '<C-r>',
|
||||
\ "\<C-s>": '<C-s>',
|
||||
\ "\<C-t>": '<C-t>',
|
||||
\ "\<C-u>": '<C-u>',
|
||||
\ "\<C-v>": '<C-v>',
|
||||
\ "\<C-w>": '<C-w>',
|
||||
\ "\<C-x>": '<C-x>',
|
||||
\ "\<C-y>": '<C-y>',
|
||||
\ "\<C-z>": '<C-z>',
|
||||
\ "\<A-a>": '<A-a>',
|
||||
\ "\<A-b>": '<A-b>',
|
||||
\ "\<A-c>": '<A-c>',
|
||||
\ "\<A-d>": '<A-d>',
|
||||
\ "\<A-e>": '<A-e>',
|
||||
\ "\<A-f>": '<A-f>',
|
||||
\ "\<A-g>": '<A-g>',
|
||||
\ "\<A-h>": '<A-h>',
|
||||
\ "\<A-i>": '<A-i>',
|
||||
\ "\<A-j>": '<A-j>',
|
||||
\ "\<A-k>": '<A-k>',
|
||||
\ "\<A-l>": '<A-l>',
|
||||
\ "\<A-m>": '<A-m>',
|
||||
\ "\<A-n>": '<A-n>',
|
||||
\ "\<A-o>": '<A-o>',
|
||||
\ "\<A-p>": '<A-p>',
|
||||
\ "\<A-q>": '<A-q>',
|
||||
\ "\<A-r>": '<A-r>',
|
||||
\ "\<A-s>": '<A-s>',
|
||||
\ "\<A-t>": '<A-t>',
|
||||
\ "\<A-u>": '<A-u>',
|
||||
\ "\<A-v>": '<A-v>',
|
||||
\ "\<A-w>": '<A-w>',
|
||||
\ "\<A-x>": '<A-x>',
|
||||
\ "\<A-y>": '<A-y>',
|
||||
\ "\<A-z>": '<A-z>',
|
||||
\ }
|
||||
|
||||
function! coc#prompt#getc() abort
|
||||
let c = getchar()
|
||||
return type(c) == type(0) ? nr2char(c) : c
|
||||
endfunction
|
||||
|
||||
function! coc#prompt#getchar() abort
|
||||
let input = coc#prompt#getc()
|
||||
if 1 != &iminsert
|
||||
return input
|
||||
endif
|
||||
"a language keymap is activated, so input must be resolved to the mapped values.
|
||||
let partial_keymap = mapcheck(input, "l")
|
||||
while partial_keymap !=# ""
|
||||
let full_keymap = maparg(input, "l")
|
||||
if full_keymap ==# "" && len(input) >= 3 "HACK: assume there are no keymaps longer than 3.
|
||||
return input
|
||||
elseif full_keymap ==# partial_keymap
|
||||
return full_keymap
|
||||
endif
|
||||
let c = coc#prompt#getc()
|
||||
if c ==# "\<Esc>" || c ==# "\<CR>"
|
||||
"if the short sequence has a valid mapping, return that.
|
||||
if !empty(full_keymap)
|
||||
return full_keymap
|
||||
endif
|
||||
return input
|
||||
endif
|
||||
let input .= c
|
||||
let partial_keymap = mapcheck(input, "l")
|
||||
endwhile
|
||||
return input
|
||||
endfunction
|
||||
|
||||
function! coc#prompt#start_prompt(session) abort
|
||||
let s:session_names = s:filter(s:session_names, a:session)
|
||||
call add(s:session_names, a:session)
|
||||
if s:activated | return | endif
|
||||
if s:is_vim
|
||||
call s:start_prompt_vim()
|
||||
else
|
||||
call s:start_prompt()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:start_prompt_vim() abort
|
||||
call timer_start(10, {-> s:start_prompt()})
|
||||
endfunction
|
||||
|
||||
function! s:start_prompt()
|
||||
if s:activated | return | endif
|
||||
if !get(g:, 'coc_disable_transparent_cursor', 0)
|
||||
if s:gui
|
||||
if has('nvim-0.5.0') && !empty(s:saved_cursor)
|
||||
set guicursor+=a:ver1-CocCursorTransparent/lCursor
|
||||
endif
|
||||
elseif s:is_vim
|
||||
set t_ve=
|
||||
endif
|
||||
endif
|
||||
let s:activated = 1
|
||||
try
|
||||
while s:activated
|
||||
let ch = coc#prompt#getchar()
|
||||
if ch ==# "\<FocusLost>" || ch ==# "\<FocusGained>" || ch ==# "\<CursorHold>"
|
||||
continue
|
||||
else
|
||||
let curr = s:current_session()
|
||||
let mapped = get(s:char_map, ch, ch)
|
||||
if !empty(curr)
|
||||
call coc#rpc#notify('InputChar', [curr, mapped, getcharmod()])
|
||||
endif
|
||||
if mapped == '<esc>'
|
||||
let s:session_names = []
|
||||
call s:reset()
|
||||
break
|
||||
endif
|
||||
endif
|
||||
endwhile
|
||||
catch /^Vim:Interrupt$/
|
||||
let s:activated = 0
|
||||
call coc#rpc#notify('InputChar', [s:current_session(), '<esc>'])
|
||||
return
|
||||
endtry
|
||||
let s:activated = 0
|
||||
endfunction
|
||||
|
||||
function! coc#prompt#stop_prompt(session)
|
||||
let s:session_names = s:filter(s:session_names, a:session)
|
||||
if len(s:session_names)
|
||||
return
|
||||
endif
|
||||
if s:activated
|
||||
let s:activated = 0
|
||||
call s:reset()
|
||||
call feedkeys("\<esc>", 'int')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! coc#prompt#activated() abort
|
||||
return s:activated
|
||||
endfunction
|
||||
|
||||
function! s:reset() abort
|
||||
if !get(g:, 'coc_disable_transparent_cursor',0)
|
||||
" neovim has bug with revert empty &guicursor
|
||||
if s:gui && !empty(s:saved_cursor)
|
||||
if has('nvim-0.5.0')
|
||||
set guicursor+=a:ver1-Cursor/lCursor
|
||||
let &guicursor = s:saved_cursor
|
||||
endif
|
||||
elseif s:is_vim
|
||||
let &t_ve = s:saved_ve
|
||||
endif
|
||||
endif
|
||||
echo ""
|
||||
endfunction
|
||||
|
||||
function! s:current_session() abort
|
||||
if empty(s:session_names)
|
||||
return v:null
|
||||
endif
|
||||
return s:session_names[len(s:session_names) - 1]
|
||||
endfunction
|
||||
|
||||
function! s:filter(list, id) abort
|
||||
return filter(copy(a:list), 'v:val !=# a:id')
|
||||
endfunction
|
|
@ -117,11 +117,11 @@ endfunction
|
|||
|
||||
" send async response to server
|
||||
function! coc#rpc#async_request(id, method, args)
|
||||
let l:Cb = {err, res -> coc#rpc#notify('nvim_async_response_event', [a:id, err, res])}
|
||||
let l:Cb = {err, ... -> coc#rpc#notify('nvim_async_response_event', [a:id, err, get(a:000, 0, v:null)])}
|
||||
let args = a:args + [l:Cb]
|
||||
try
|
||||
call call(a:method, args)
|
||||
catch /.*/
|
||||
call coc#rpc#notify('nvim_async_response_event', [a:id, v:exception])
|
||||
call coc#rpc#notify('nvim_async_response_event', [a:id, v:exception, v:null])
|
||||
endtry
|
||||
endfunction
|
||||
|
|
|
@ -3,11 +3,14 @@
|
|||
" Author: Qiming Zhao <chemzqm@gmail.com>
|
||||
" Licence: MIT licence
|
||||
" Version: 0.1
|
||||
" Last Modified: April 08, 2019
|
||||
" Last Modified: Dec 12, 2020
|
||||
" ============================================================================
|
||||
|
||||
let s:is_vim = !has('nvim')
|
||||
let s:running_task = {}
|
||||
" neovim emit strings that part of lines.
|
||||
let s:out_remain_text = {}
|
||||
let s:err_remain_text = {}
|
||||
|
||||
function! coc#task#start(id, opts)
|
||||
if coc#task#running(a:id)
|
||||
|
@ -15,6 +18,7 @@ function! coc#task#start(id, opts)
|
|||
endif
|
||||
let cmd = [a:opts['cmd']] + get(a:opts, 'args', [])
|
||||
let cwd = get(a:opts, 'cwd', getcwd())
|
||||
let env = get(a:opts, 'env', {})
|
||||
" cmd args cwd pty
|
||||
if s:is_vim
|
||||
let options = {
|
||||
|
@ -24,6 +28,7 @@ function! coc#task#start(id, opts)
|
|||
\ 'err_cb': {channel, message -> s:on_stderr(a:id, [message])},
|
||||
\ 'out_cb': {channel, message -> s:on_stdout(a:id, [message])},
|
||||
\ 'exit_cb': {channel, code -> s:on_exit(a:id, code)},
|
||||
\ 'env': env,
|
||||
\}
|
||||
if has("patch-8.1.350")
|
||||
let options['noblock'] = 1
|
||||
|
@ -41,15 +46,27 @@ function! coc#task#start(id, opts)
|
|||
else
|
||||
let options = {
|
||||
\ 'cwd': cwd,
|
||||
\ 'on_stderr': {channel, msgs -> s:on_stderr(a:id, filter(msgs, 'v:val !=""'))},
|
||||
\ 'on_stdout': {channel, msgs -> s:on_stdout(a:id, filter(msgs, 'v:val !=""'))},
|
||||
\ 'on_stderr': {channel, msgs -> s:on_stderr(a:id, msgs)},
|
||||
\ 'on_stdout': {channel, msgs -> s:on_stdout(a:id, msgs)},
|
||||
\ 'on_exit': {channel, code -> s:on_exit(a:id, code)},
|
||||
\ 'detach': get(a:opts, 'detach', 0),
|
||||
\}
|
||||
let original = {}
|
||||
if !empty(env) && exists('*setenv') && exists('*getenv')
|
||||
for key in keys(env)
|
||||
let original[key] = getenv(key)
|
||||
call setenv(key, env[key])
|
||||
endfor
|
||||
endif
|
||||
if get(a:opts, 'pty', 0)
|
||||
let options['pty'] = 1
|
||||
endif
|
||||
let chan_id = jobstart(cmd, options)
|
||||
if !empty(original)
|
||||
for key in keys(original)
|
||||
call setenv(key, original[key])
|
||||
endfor
|
||||
endif
|
||||
if chan_id <= 0
|
||||
echohl Error | echom 'Failed to start '.a:id.' task' | echohl None
|
||||
return v:false
|
||||
|
@ -76,6 +93,10 @@ endfunction
|
|||
|
||||
function! s:on_exit(id, code) abort
|
||||
if get(g:, 'coc_vim_leaving', 0) | return | endif
|
||||
if has('nvim')
|
||||
let s:out_remain_text[a:id] = ''
|
||||
let s:err_remain_text[a:id] = ''
|
||||
endif
|
||||
if has_key(s:running_task, a:id)
|
||||
call remove(s:running_task, a:id)
|
||||
endif
|
||||
|
@ -84,14 +105,58 @@ endfunction
|
|||
|
||||
function! s:on_stderr(id, msgs)
|
||||
if get(g:, 'coc_vim_leaving', 0) | return | endif
|
||||
if len(a:msgs)
|
||||
if empty(a:msgs)
|
||||
return
|
||||
endif
|
||||
if s:is_vim
|
||||
call coc#rpc#notify('TaskStderr', [a:id, a:msgs])
|
||||
else
|
||||
let remain = get(s:err_remain_text, a:id, '')
|
||||
let eof = (a:msgs == [''])
|
||||
let msgs = copy(a:msgs)
|
||||
if len(remain) > 0
|
||||
if msgs[0] == ''
|
||||
let msgs[0] = remain
|
||||
else
|
||||
let msgs[0] = remain . msgs[0]
|
||||
endif
|
||||
endif
|
||||
let last = msgs[len(msgs) - 1]
|
||||
let s:err_remain_text[a:id] = len(last) > 0 ? last : ''
|
||||
" all lines from 0 to n - 2
|
||||
if len(msgs) > 1
|
||||
call coc#rpc#notify('TaskStderr', [a:id, msgs[:len(msgs)-2]])
|
||||
elseif eof && len(msgs[0]) > 0
|
||||
call coc#rpc#notify('TaskStderr', [a:id, msgs])
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:on_stdout(id, msgs)
|
||||
if len(a:msgs)
|
||||
if empty(a:msgs)
|
||||
return
|
||||
endif
|
||||
if s:is_vim
|
||||
call coc#rpc#notify('TaskStdout', [a:id, a:msgs])
|
||||
else
|
||||
let remain = get(s:out_remain_text, a:id, '')
|
||||
let eof = (a:msgs == [''])
|
||||
let msgs = copy(a:msgs)
|
||||
if len(remain) > 0
|
||||
if msgs[0] == ''
|
||||
let msgs[0] = remain
|
||||
else
|
||||
let msgs[0] = remain . msgs[0]
|
||||
endif
|
||||
endif
|
||||
let last = msgs[len(msgs) - 1]
|
||||
let s:out_remain_text[a:id] = len(last) > 0 ? last : ''
|
||||
" all lines from 0 to n - 2
|
||||
if len(msgs) > 1
|
||||
call coc#rpc#notify('TaskStdout', [a:id, msgs[:len(msgs)-2]])
|
||||
elseif eof && len(msgs[0]) > 0
|
||||
call coc#rpc#notify('TaskStdout', [a:id, msgs])
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ function! coc#terminal#start(cmd, cwd, env) abort
|
|||
" use env option when possible
|
||||
if s:is_vim
|
||||
let env = copy(a:env)
|
||||
else
|
||||
elseif exists('*setenv')
|
||||
for key in keys(a:env)
|
||||
let original[key] = getenv(key)
|
||||
call setenv(key, a:env[key])
|
||||
|
@ -44,7 +44,7 @@ function! coc#terminal#start(cmd, cwd, env) abort
|
|||
\ 'on_exit': {job, status -> s:OnExit(status)},
|
||||
\ 'env': env,
|
||||
\ })
|
||||
if !empty(original)
|
||||
if !empty(original) && exists('*setenv')
|
||||
for key in keys(original)
|
||||
call setenv(key, original[key])
|
||||
endfor
|
||||
|
|
|
@ -2,6 +2,7 @@ let s:root = expand('<sfile>:h:h:h')
|
|||
let s:is_win = has('win32') || has('win64')
|
||||
let s:is_vim = !has('nvim')
|
||||
let s:clear_match_by_id = has('nvim-0.5.0') || has('patch-8.1.1084')
|
||||
let s:vim_api_version = 8
|
||||
|
||||
let s:activate = ""
|
||||
let s:quit = ""
|
||||
|
@ -26,95 +27,13 @@ function! coc#util#has_preview()
|
|||
return 0
|
||||
endfunction
|
||||
|
||||
function! coc#util#scroll_preview(dir) abort
|
||||
let winnr = coc#util#has_preview()
|
||||
if !winnr
|
||||
return
|
||||
endif
|
||||
let winid = win_getid(winnr)
|
||||
if exists('*win_execute')
|
||||
call win_execute(winid, "normal! ".(a:dir ==# 'up' ? "\<C-u>" : "\<C-d>"))
|
||||
else
|
||||
let id = win_getid()
|
||||
noa call win_gotoid(winid)
|
||||
execute "normal! ".(a:dir ==# 'up' ? "\<C-u>" : "\<C-d>")
|
||||
noa call win_gotoid(id)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! coc#util#has_float()
|
||||
echohl Error | echon 'coc#util#has_float is deprecated, use coc#float#has_float instead' | echohl None
|
||||
return coc#float#has_float()
|
||||
endfunction
|
||||
|
||||
function! coc#util#float_hide()
|
||||
echohl Error | echon 'coc#util#float_hide is deprecated, use coc#float#close_all instead' | echohl None
|
||||
call coc#float#close_all()
|
||||
endfunction
|
||||
|
||||
function! coc#util#float_jump()
|
||||
echohl Error | echon 'coc#util#float_jump is deprecated, use coc#float#jump instead' | echohl None
|
||||
endfunction
|
||||
|
||||
" close all float/popup window
|
||||
function! coc#util#close_floats() abort
|
||||
echohl WarningMsg | echon 'coc#util#close_floats is deprecated, use coc#float#close_all instead' | echohl None
|
||||
call coc#float#close_all()
|
||||
endfunction
|
||||
|
||||
function! coc#util#close_win(id)
|
||||
echohl WarningMsg | echon 'coc#util#close_win is deprecated, use coc#float#close instead' | echohl None
|
||||
call coc#float#close(a:id)
|
||||
endfunction
|
||||
|
||||
function! coc#util#float_scroll(forward)
|
||||
echohl WarningMsg | echon 'coc#util#close_win is deprecated, use coc#float#scroll instead' | echohl None
|
||||
call coc#float#scroll(a:forward)
|
||||
endfunction
|
||||
|
||||
" scroll float without exiting insert mode (nvim only)
|
||||
function! coc#util#float_scroll_i(amount)
|
||||
let float = coc#float#get_float_win()
|
||||
if !float | return '' | endif
|
||||
let buf = nvim_win_get_buf(float)
|
||||
let buf_height = nvim_buf_line_count(buf)
|
||||
let win_height = nvim_win_get_height(float)
|
||||
if buf_height < win_height | return '' | endif
|
||||
let pos = nvim_win_get_cursor(float)
|
||||
try
|
||||
let last_amount = nvim_win_get_var(float, 'coc_float_scroll_last_amount')
|
||||
catch
|
||||
let last_amount = 0
|
||||
endtry
|
||||
if a:amount > 0
|
||||
if pos[0] == 1
|
||||
let pos[0] += a:amount + win_height - 2
|
||||
elseif last_amount > 0
|
||||
let pos[0] += a:amount
|
||||
else
|
||||
let pos[0] += a:amount + win_height - 3
|
||||
endif
|
||||
let pos[0] = pos[0] < buf_height ? pos[0] : buf_height
|
||||
elseif a:amount < 0
|
||||
if pos[0] == buf_height
|
||||
let pos[0] += a:amount - win_height + 2
|
||||
elseif last_amount < 0
|
||||
let pos[0] += a:amount
|
||||
else
|
||||
let pos[0] += a:amount - win_height + 3
|
||||
endif
|
||||
let pos[0] = pos[0] > 1 ? pos[0] : 1
|
||||
endif
|
||||
call nvim_win_set_var(float, 'coc_float_scroll_last_amount', a:amount)
|
||||
call nvim_win_set_cursor(float, pos)
|
||||
return ''
|
||||
function! coc#util#api_version() abort
|
||||
return s:vim_api_version
|
||||
endfunction
|
||||
|
||||
" get cursor position
|
||||
function! coc#util#cursor()
|
||||
let pos = getcurpos()
|
||||
let content = pos[2] == 1 ? '' : getline('.')[0: pos[2] - 2]
|
||||
return [pos[1] - 1, strchars(content)]
|
||||
return [line('.') - 1, strchars(strpart(getline('.'), 0, col('.') - 1))]
|
||||
endfunction
|
||||
|
||||
function! coc#util#path_replace_patterns() abort
|
||||
|
@ -178,20 +97,11 @@ function! coc#util#job_command()
|
|||
echohl Error | echom '[coc.nvim] "'.node.'" is not executable, checkout https://nodejs.org/en/download/' | echohl None
|
||||
return
|
||||
endif
|
||||
if filereadable(s:root.'/bin/server.js') && filereadable(s:root.'/src/index.ts') && !get(g:, 'coc_force_bundle', 0)
|
||||
if !filereadable(s:root.'/lib/attach.js')
|
||||
echohl Error | echom '[coc.nvim] javascript bundle not found, please try :call coc#util#install()' | echohl None
|
||||
return
|
||||
endif
|
||||
"use javascript from lib
|
||||
return [node] + get(g:, 'coc_node_args', ['--no-warnings']) + [s:root.'/bin/server.js']
|
||||
else
|
||||
if !filereadable(s:root.'/build/index.js')
|
||||
echohl Error | echom '[coc.nvim] build/index.js not found, reinstall coc.nvim to fix it.' | echohl None
|
||||
return
|
||||
endif
|
||||
return [node] + get(g:, 'coc_node_args', ['--no-warnings']) + [s:root.'/build/index.js']
|
||||
if !filereadable(s:root.'/build/index.js')
|
||||
echohl Error | echom '[coc.nvim] build/index.js not found, please compile the code by esbuild.' | echohl None
|
||||
return
|
||||
endif
|
||||
return [node] + get(g:, 'coc_node_args', ['--no-warnings']) + [s:root.'/build/index.js']
|
||||
endfunction
|
||||
|
||||
function! coc#util#echo_hover(msg)
|
||||
|
@ -212,13 +122,21 @@ function! coc#util#execute(cmd)
|
|||
endfunction
|
||||
|
||||
function! coc#util#jump(cmd, filepath, ...) abort
|
||||
silent! normal! m'
|
||||
if a:cmd != 'pedit'
|
||||
silent! normal! m'
|
||||
endif
|
||||
let path = a:filepath
|
||||
if (has('win32unix'))
|
||||
let path = substitute(a:filepath, '\v\\', '/', 'g')
|
||||
endif
|
||||
let file = fnamemodify(path, ":~:.")
|
||||
exe a:cmd.' '.fnameescape(file)
|
||||
if a:cmd == 'pedit'
|
||||
let extra = empty(get(a:, 1, [])) ? '' : '+'.(a:1[0] + 1)
|
||||
exe 'pedit '.extra.' '.fnameescape(file)
|
||||
return
|
||||
else
|
||||
exe a:cmd.' '.fnameescape(file)
|
||||
endif
|
||||
if !empty(get(a:, 1, []))
|
||||
let line = getline(a:1[0] + 1)
|
||||
" TODO need to use utf16 here
|
||||
|
@ -243,6 +161,13 @@ function! coc#util#jumpTo(line, character) abort
|
|||
call cursor(a:line + 1, col)
|
||||
endfunction
|
||||
|
||||
" Position of cursor relative to screen cell
|
||||
function! coc#util#cursor_pos() abort
|
||||
let nr = winnr()
|
||||
let [row, col] = win_screenpos(nr)
|
||||
return [row + winline() - 2, col + wincol() - 2]
|
||||
endfunction
|
||||
|
||||
function! coc#util#echo_messages(hl, msgs)
|
||||
if a:hl !~# 'Error' && (mode() !~# '\v^(i|n)$')
|
||||
return
|
||||
|
@ -275,7 +200,7 @@ function! s:Call(method, args)
|
|||
endtry
|
||||
endfunction
|
||||
|
||||
function! coc#util#get_bufoptions(bufnr) abort
|
||||
function! coc#util#get_bufoptions(bufnr, maxFileSize) abort
|
||||
if !bufloaded(a:bufnr) | return v:null | endif
|
||||
let bufname = bufname(a:bufnr)
|
||||
let buftype = getbufvar(a:bufnr, '&buftype')
|
||||
|
@ -290,24 +215,29 @@ function! coc#util#get_bufoptions(bufnr) abort
|
|||
elseif !empty(bufname)
|
||||
let size = getfsize(bufname)
|
||||
endif
|
||||
let lines = []
|
||||
if getbufvar(a:bufnr, 'coc_enabled', 1) && (buftype == '' || buftype == 'acwrite') && size < a:maxFileSize
|
||||
let lines = getbufline(a:bufnr, 1, '$')
|
||||
endif
|
||||
return {
|
||||
\ 'bufname': bufname,
|
||||
\ 'size': size,
|
||||
\ 'eol': getbufvar(a:bufnr, '&eol'),
|
||||
\ 'buftype': buftype,
|
||||
\ 'winid': winid,
|
||||
\ 'previewwindow': previewwindow == 0 ? v:false : v:true,
|
||||
\ 'variables': s:variables(a:bufnr),
|
||||
\ 'fullpath': empty(bufname) ? '' : fnamemodify(bufname, ':p'),
|
||||
\ 'eol': getbufvar(a:bufnr, '&eol'),
|
||||
\ 'filetype': getbufvar(a:bufnr, '&filetype'),
|
||||
\ 'iskeyword': getbufvar(a:bufnr, '&iskeyword'),
|
||||
\ 'changedtick': getbufvar(a:bufnr, 'changedtick'),
|
||||
\ 'lines': lines,
|
||||
\}
|
||||
endfunction
|
||||
|
||||
function! s:variables(bufnr) abort
|
||||
let info = getbufinfo({'bufnr':a:bufnr, 'variables': 1})
|
||||
let variables = copy(info[0]['variables'])
|
||||
let info = getbufinfo(a:bufnr)
|
||||
let variables = empty(info) ? {} : copy(info[0]['variables'])
|
||||
for key in keys(variables)
|
||||
if key !~# '\v^coc'
|
||||
unlet variables[key]
|
||||
|
@ -392,13 +322,11 @@ function! coc#util#get_data_home()
|
|||
endfunction
|
||||
|
||||
function! coc#util#get_input()
|
||||
let pos = getcurpos()
|
||||
let line = getline('.')
|
||||
let l:start = pos[2] - 1
|
||||
while l:start > 0 && line[l:start - 1] =~# '\k'
|
||||
let l:start -= 1
|
||||
endwhile
|
||||
return pos[2] == 1 ? '' : line[l:start : pos[2] - 2]
|
||||
let before = strpart(getline('.'), 0, col('.')-1)
|
||||
if len(before) == 0
|
||||
return ''
|
||||
endif
|
||||
return matchstr(before, '\k*$')
|
||||
endfunction
|
||||
|
||||
function! coc#util#move_cursor(delta)
|
||||
|
@ -407,26 +335,13 @@ function! coc#util#move_cursor(delta)
|
|||
endfunction
|
||||
|
||||
function! coc#util#get_complete_option()
|
||||
let disabled = get(b:, 'coc_suggest_disable', 0)
|
||||
if disabled | return | endif
|
||||
let blacklist = get(b:, 'coc_suggest_blacklist', [])
|
||||
let pos = getcurpos()
|
||||
let l:start = pos[2] - 1
|
||||
let line = getline(pos[1])
|
||||
for char in reverse(split(line[0: l:start - 1], '\zs'))
|
||||
if l:start > 0 && char =~# '\k'
|
||||
let l:start = l:start - strlen(char)
|
||||
else
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
let input = pos[2] == 1 ? '' : line[l:start : pos[2] - 2]
|
||||
if !empty(blacklist) && index(blacklist, input) >= 0
|
||||
return
|
||||
endif
|
||||
let synname = synIDattr(synID(pos[1], l:start, 1),"name")
|
||||
let input = matchstr(strpart(line, 0, pos[2] - 1), '\k*$')
|
||||
let col = pos[2] - strlen(input)
|
||||
let synname = synIDattr(synID(pos[1], col, 1), 'name')
|
||||
return {
|
||||
\ 'word': matchstr(line[l:start : ], '^\k\+'),
|
||||
\ 'word': matchstr(strpart(line, col - 1), '^\k\+'),
|
||||
\ 'input': empty(input) ? '' : input,
|
||||
\ 'line': line,
|
||||
\ 'filetype': &filetype,
|
||||
|
@ -434,10 +349,10 @@ function! coc#util#get_complete_option()
|
|||
\ 'bufnr': bufnr('%'),
|
||||
\ 'linenr': pos[1],
|
||||
\ 'colnr' : pos[2],
|
||||
\ 'col': l:start,
|
||||
\ 'col': col - 1,
|
||||
\ 'synname': synname,
|
||||
\ 'changedtick': b:changedtick,
|
||||
\ 'blacklist': blacklist,
|
||||
\ 'blacklist': get(b:, 'coc_suggest_blacklist', []),
|
||||
\}
|
||||
endfunction
|
||||
|
||||
|
@ -475,6 +390,7 @@ function! coc#util#quickpick(title, items, cb) abort
|
|||
\ 'filter': function('s:QuickpickFilter'),
|
||||
\ 'callback': function('s:QuickpickHandler'),
|
||||
\ })
|
||||
redraw
|
||||
catch /.*/
|
||||
call a:cb(v:exception)
|
||||
endtry
|
||||
|
@ -484,55 +400,6 @@ function! coc#util#quickpick(title, items, cb) abort
|
|||
endif
|
||||
endfunction
|
||||
|
||||
function! coc#util#prompt(title, cb) abort
|
||||
if exists('*popup_dialog')
|
||||
function! s:PromptHandler(id, result) closure
|
||||
call a:cb(v:null, a:result)
|
||||
endfunction
|
||||
try
|
||||
call popup_dialog(a:title. ' (y/n)', #{
|
||||
\ filter: 'popup_filter_yesno',
|
||||
\ callback: function('s:PromptHandler'),
|
||||
\ })
|
||||
catch /.*/
|
||||
call a:cb(v:exception)
|
||||
endtry
|
||||
elseif !s:is_vim && exists('*confirm')
|
||||
let choice = confirm(a:title, "&Yes\n&No")
|
||||
call a:cb(v:null, choice == 1)
|
||||
else
|
||||
echohl MoreMsg
|
||||
echom a:title.' (y/n)'
|
||||
echohl None
|
||||
let confirm = nr2char(getchar())
|
||||
redraw!
|
||||
if !(confirm ==? "y" || confirm ==? "\r")
|
||||
echohl Moremsg | echo 'Cancelled.' | echohl None
|
||||
return 0
|
||||
call a:cb(v:null, 0)
|
||||
end
|
||||
call a:cb(v:null, 1)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! coc#util#prompt_confirm(title)
|
||||
if exists('*confirm') && !s:is_vim
|
||||
let choice = confirm(a:title, "&Yes\n&No")
|
||||
return choice == 1
|
||||
else
|
||||
echohl MoreMsg
|
||||
echom a:title.' (y/n)'
|
||||
echohl None
|
||||
let confirm = nr2char(getchar())
|
||||
redraw!
|
||||
if !(confirm ==? "y" || confirm ==? "\r")
|
||||
echohl Moremsg | echo 'Cancelled.' | echohl None
|
||||
return 0
|
||||
end
|
||||
return 1
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! coc#util#get_syntax_name(lnum, col)
|
||||
return synIDattr(synIDtrans(synID(a:lnum,a:col,1)),"name")
|
||||
endfunction
|
||||
|
@ -654,10 +521,10 @@ endfunction
|
|||
|
||||
function! coc#util#vim_info()
|
||||
return {
|
||||
\ 'apiversion': s:vim_api_version,
|
||||
\ 'mode': mode(),
|
||||
\ 'floating': has('nvim') && exists('*nvim_open_win') ? v:true : v:false,
|
||||
\ 'extensionRoot': coc#util#extension_root(),
|
||||
\ 'watchExtensions': get(g:, 'coc_watch_extensions', []),
|
||||
\ 'globalExtensions': get(g:, 'coc_global_extensions', []),
|
||||
\ 'config': get(g:, 'coc_user_config', {}),
|
||||
\ 'pid': coc#util#getpid(),
|
||||
|
@ -680,7 +547,9 @@ function! coc#util#vim_info()
|
|||
\ 'progpath': v:progpath,
|
||||
\ 'guicursor': &guicursor,
|
||||
\ 'vimCommands': get(g:, 'coc_vim_commands', []),
|
||||
\ 'sign': exists('*sign_place') && exists('*sign_unplace'),
|
||||
\ 'textprop': has('textprop') && has('patch-8.1.1719') && !has('nvim') ? v:true : v:false,
|
||||
\ 'dialog': has('nvim-0.4.0') || has('patch-8.2.0750') ? v:true : v:false,
|
||||
\ 'disabledSources': get(g:, 'coc_sources_disable_map', {}),
|
||||
\}
|
||||
endfunction
|
||||
|
@ -693,11 +562,53 @@ function! coc#util#highlight_options()
|
|||
\}
|
||||
endfunction
|
||||
|
||||
" used by vim
|
||||
function! coc#util#get_content(bufnr)
|
||||
if !bufloaded(a:bufnr) | return '' | endif
|
||||
function! coc#util#set_lines(bufnr, replacement, start, end) abort
|
||||
if !s:is_vim
|
||||
call nvim_buf_set_lines(a:bufnr, a:start, a:end, 0, a:replacement)
|
||||
else
|
||||
call coc#api#notify('buf_set_lines', [a:bufnr, a:start, a:end, 0, a:replacement])
|
||||
endif
|
||||
return {
|
||||
\ 'content': join(getbufline(a:bufnr, 1, '$'), "\n"),
|
||||
\ 'lines': getbufline(a:bufnr, 1, '$'),
|
||||
\ 'changedtick': getbufvar(a:bufnr, 'changedtick')
|
||||
\ }
|
||||
endfunction
|
||||
|
||||
function! coc#util#change_lines(bufnr, list) abort
|
||||
if !bufloaded(a:bufnr) | return v:null | endif
|
||||
undojoin
|
||||
if exists('*setbufline')
|
||||
for [lnum, line] in a:list
|
||||
call setbufline(a:bufnr, lnum + 1, line)
|
||||
endfor
|
||||
elseif a:bufnr == bufnr('%')
|
||||
for [lnum, line] in a:list
|
||||
call setline(lnum + 1, line)
|
||||
endfor
|
||||
else
|
||||
let bufnr = bufnr('%')
|
||||
exe 'noa buffer '.a:bufnr
|
||||
for [lnum, line] in a:list
|
||||
call setline(lnum + 1, line)
|
||||
endfor
|
||||
exe 'noa buffer '.bufnr
|
||||
endif
|
||||
return {
|
||||
\ 'lines': getbufline(a:bufnr, 1, '$'),
|
||||
\ 'changedtick': getbufvar(a:bufnr, 'changedtick')
|
||||
\ }
|
||||
endfunction
|
||||
|
||||
|
||||
" used by vim
|
||||
function! coc#util#get_buf_lines(bufnr, changedtick)
|
||||
if !bufloaded(a:bufnr) | return '' | endif
|
||||
let changedtick = getbufvar(a:bufnr, 'changedtick')
|
||||
if changedtick == a:changedtick
|
||||
return v:null
|
||||
endif
|
||||
return {
|
||||
\ 'lines': getbufline(a:bufnr, 1, '$'),
|
||||
\ 'changedtick': getbufvar(a:bufnr, 'changedtick')
|
||||
\ }
|
||||
endfunction
|
||||
|
@ -758,9 +669,10 @@ function! coc#util#open_url(url)
|
|||
endfunction
|
||||
|
||||
function! coc#util#install() abort
|
||||
let yarncmd = get(g:, 'coc_install_yarn_cmd', executable('yarnpkg') ? 'yarnpkg' : 'yarn')
|
||||
call coc#util#open_terminal({
|
||||
\ 'cwd': s:root,
|
||||
\ 'cmd': 'yarn install --frozen-lockfile',
|
||||
\ 'cmd': yarncmd.' install --frozen-lockfile --ignore-engines',
|
||||
\ 'autoclose': 0,
|
||||
\ })
|
||||
endfunction
|
||||
|
@ -940,26 +852,6 @@ function! coc#util#set_buf_var(bufnr, name, val) abort
|
|||
call setbufvar(a:bufnr, a:name, a:val)
|
||||
endfunction
|
||||
|
||||
function! coc#util#change_lines(bufnr, list) abort
|
||||
if !bufloaded(a:bufnr) | return | endif
|
||||
if exists('*setbufline')
|
||||
for [lnum, line] in a:list
|
||||
call setbufline(a:bufnr, lnum + 1, line)
|
||||
endfor
|
||||
elseif a:bufnr == bufnr('%')
|
||||
for [lnum, line] in a:list
|
||||
call setline(lnum + 1, line)
|
||||
endfor
|
||||
else
|
||||
let bufnr = bufnr('%')
|
||||
exe 'noa buffer '.a:bufnr
|
||||
for [lnum, line] in a:list
|
||||
call setline(lnum + 1, line)
|
||||
endfor
|
||||
exe 'noa buffer '.bufnr
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! coc#util#unmap(bufnr, keys) abort
|
||||
if bufnr('%') == a:bufnr
|
||||
for key in a:keys
|
||||
|
@ -973,6 +865,7 @@ function! coc#util#open_files(files)
|
|||
" added on latest vim8
|
||||
if exists('*bufadd') && exists('*bufload')
|
||||
for file in a:files
|
||||
let file = fnamemodify(file, ':.')
|
||||
if bufloaded(file)
|
||||
call add(bufnrs, bufnr(file))
|
||||
else
|
||||
|
@ -985,6 +878,7 @@ function! coc#util#open_files(files)
|
|||
else
|
||||
noa keepalt 1new +setl\ bufhidden=wipe
|
||||
for file in a:files
|
||||
let file = fnamemodify(file, ':.')
|
||||
execute 'noa edit +setl\ bufhidden=hide '.fnameescape(file)
|
||||
if &filetype ==# ''
|
||||
filetype detect
|
||||
|
@ -1037,67 +931,23 @@ function! coc#util#get_format_opts(bufnr) abort
|
|||
return [tabsize, &expandtab]
|
||||
endfunction
|
||||
|
||||
function! coc#util#clear_pos_matches(match, ...) abort
|
||||
let winid = get(a:, 1, win_getid())
|
||||
if empty(getwininfo(winid))
|
||||
" not valid
|
||||
return
|
||||
endif
|
||||
if win_getid() == winid
|
||||
let arr = filter(getmatches(), 'v:val["group"] =~# "'.a:match.'"')
|
||||
for item in arr
|
||||
call matchdelete(item['id'])
|
||||
endfor
|
||||
elseif s:clear_match_by_id
|
||||
let arr = filter(getmatches(winid), 'v:val["group"] =~# "'.a:match.'"')
|
||||
for item in arr
|
||||
call matchdelete(item['id'], winid)
|
||||
endfor
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! coc#util#clearmatches(ids, ...)
|
||||
let winid = get(a:, 1, win_getid())
|
||||
if empty(getwininfo(winid))
|
||||
return
|
||||
endif
|
||||
if win_getid() == winid
|
||||
for id in a:ids
|
||||
try
|
||||
call matchdelete(id)
|
||||
catch /.*/
|
||||
" matches have been cleared in other ways,
|
||||
endtry
|
||||
endfor
|
||||
elseif s:clear_match_by_id
|
||||
for id in a:ids
|
||||
try
|
||||
call matchdelete(id, winid)
|
||||
catch /.*/
|
||||
" matches have been cleared in other ways,
|
||||
endtry
|
||||
endfor
|
||||
endif
|
||||
call coc#highlight#clear_matches(winid, a:ids)
|
||||
endfunction
|
||||
|
||||
" clear document highlights of current window
|
||||
function! coc#util#clear_highlights(...) abort
|
||||
let winid = get(a:, 1, win_getid())
|
||||
if empty(getwininfo(winid))
|
||||
" not valid
|
||||
return
|
||||
endif
|
||||
if winid == win_getid()
|
||||
let arr = filter(getmatches(), 'v:val["group"] =~# "^CocHighlight"')
|
||||
for item in arr
|
||||
call matchdelete(item['id'])
|
||||
endfor
|
||||
elseif s:clear_match_by_id
|
||||
let arr = filter(getmatches(winid), 'v:val["group"] =~# "^CocHighlight"')
|
||||
for item in arr
|
||||
call matchdelete(item['id'], winid)
|
||||
endfor
|
||||
" Character offset of current cursor
|
||||
function! coc#util#get_offset() abort
|
||||
let offset = 0
|
||||
let lnum = line('.')
|
||||
for i in range(1, lnum)
|
||||
if i == lnum
|
||||
let offset += strchars(strpart(getline('.'), 0, col('.')-1))
|
||||
else
|
||||
let offset += strchars(getline(i)) + 1
|
||||
endif
|
||||
endfor
|
||||
return offset
|
||||
endfunction
|
||||
|
||||
" Make sure window exists
|
||||
|
@ -1107,11 +957,3 @@ function! coc#util#win_gotoid(winid) abort
|
|||
throw 'Invalid window number'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Make sure pum is visible
|
||||
function! coc#util#pumvisible() abort
|
||||
let visible = pumvisible()
|
||||
if !visible
|
||||
throw 'Pum not visible'
|
||||
endif
|
||||
endfunction
|
||||
|
|
|
@ -41,20 +41,11 @@ function! s:checkEnvironment() abort
|
|||
endfunction
|
||||
|
||||
function! s:checkCommand()
|
||||
let file = s:root.'/bin/server.js'
|
||||
let file = s:root.'/build/index.js'
|
||||
if filereadable(file)
|
||||
if !filereadable(s:root.'/lib/attach.js')
|
||||
call health#report_error('Javascript entry not found, run "yarn install --frozen-lockfile" in terminal to fix it.')
|
||||
else
|
||||
call health#report_ok('Javascript entry lib/attach.js found')
|
||||
endif
|
||||
call health#report_ok('Javascript bundle build/index.js found')
|
||||
else
|
||||
let file = s:root.'/build/index.js'
|
||||
if filereadable(file)
|
||||
call health#report_ok('Javascript bundle build/index.js found')
|
||||
else
|
||||
call health#report_error('Javascript entry not found, reinstall coc.nvim to fix it.')
|
||||
endif
|
||||
call health#report_error('Javascript entry not found, please compile coc.nvim by esbuild.')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
|
73
pack/acp/opt/coc.nvim/bin/prompt.js
Normal file
73
pack/acp/opt/coc.nvim/bin/prompt.js
Normal file
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Used for prompt popup on vim
|
||||
*/
|
||||
const readline = require("readline")
|
||||
const rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout,
|
||||
escapeCodeTimeout: 0
|
||||
})
|
||||
rl.setPrompt('')
|
||||
let value = process.argv[2]
|
||||
if (value) {
|
||||
rl.write(value)
|
||||
}
|
||||
rl.on('line', input => {
|
||||
let text = input.replace(/"/g, '\\"')
|
||||
console.log(createSequences(JSON.stringify(['call', 'CocPopupCallback', ['confirm', text]])))
|
||||
process.exit()
|
||||
})
|
||||
|
||||
function createSequences(str) {
|
||||
return '\033]51;' + str + '\x07'
|
||||
}
|
||||
|
||||
process.stdin.on('keypress', (_, key) => {
|
||||
if (key) {
|
||||
let k = getKey(key)
|
||||
if (k == '<bs>') {
|
||||
return
|
||||
}
|
||||
if (k == '<cr>') {
|
||||
process.exit()
|
||||
return
|
||||
}
|
||||
if (k == '<esc>') {
|
||||
console.log(createSequences(JSON.stringify(['call', 'CocPopupCallback', ['exit', '']])))
|
||||
process.exit()
|
||||
return
|
||||
}
|
||||
if (k) {
|
||||
console.log(createSequences(JSON.stringify(['call', 'CocPopupCallback', ['send', k]])))
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
function getKey(key) {
|
||||
if (key.sequence == '\u001b') {
|
||||
return '<esc>'
|
||||
}
|
||||
if (key.sequence == '\r') {
|
||||
return '<cr>'
|
||||
}
|
||||
if (key.sequence == '\t') {
|
||||
return key.shift ? '<s-tab>' : '<tab>'
|
||||
}
|
||||
// handle them can cause bug with terminal
|
||||
// if (key.name == 'backspace') {
|
||||
// return '<bs>'
|
||||
// }
|
||||
// if (key.name == 'left') {
|
||||
// return '<left>'
|
||||
// }
|
||||
// if (key.name == 'right') {
|
||||
// return '<right>'
|
||||
// }
|
||||
if (key.name == 'up') {
|
||||
return '<up>'
|
||||
}
|
||||
if (key.name == 'down') {
|
||||
return '<down>'
|
||||
}
|
||||
return ''
|
||||
}
|
0
pack/acp/opt/coc.nvim/terminateProcess.sh → pack/acp/opt/coc.nvim/bin/terminateProcess.sh
Normal file → Executable file
0
pack/acp/opt/coc.nvim/terminateProcess.sh → pack/acp/opt/coc.nvim/bin/terminateProcess.sh
Normal file → Executable file
File diff suppressed because one or more lines are too long
|
@ -331,8 +331,8 @@
|
|||
},
|
||||
"suggest.detailField": {
|
||||
"type": "string",
|
||||
"default": "menu",
|
||||
"description": "Where to add the detail in complete item when it's less than max length.",
|
||||
"default": "preview",
|
||||
"description": "Where to show the detail text of CompleteItem from LS.",
|
||||
"enum": ["abbr", "menu", "preview"]
|
||||
},
|
||||
"suggest.autoTrigger": {
|
||||
|
@ -348,7 +348,7 @@
|
|||
},
|
||||
"suggest.numberSelect": {
|
||||
"type": "boolean",
|
||||
"description": "Input number to select complete item, works on neovim >= 0.4.3 only.",
|
||||
"description": "Input number to select complete item, works on neovim >= 0.4.0 only.",
|
||||
"default": false
|
||||
},
|
||||
"suggest.disableKind": {
|
||||
|
@ -410,7 +410,7 @@
|
|||
},
|
||||
"suggest.triggerCompletionWait": {
|
||||
"type": "integer",
|
||||
"default": 50,
|
||||
"default": 100,
|
||||
"minimum": 30,
|
||||
"maximum": 500,
|
||||
"description": "Wait time between text change and completion start, cancel completion when text changed during wait."
|
||||
|
@ -456,7 +456,7 @@
|
|||
"type": "string",
|
||||
"description": "Default sorting behavior for suggested completion items.",
|
||||
"default": "length",
|
||||
"enum": ["length", "alphabetical"]
|
||||
"enum": ["length", "alphabetical", "none"]
|
||||
},
|
||||
"suggest.completionItemKindLabels": {
|
||||
"type": "object",
|
||||
|
@ -542,11 +542,6 @@
|
|||
"description": "Enable diagnostic refresh on insert mode, default false.",
|
||||
"default": false
|
||||
},
|
||||
"diagnostic.refreshAfterSave": {
|
||||
"type": "boolean",
|
||||
"description": "Only refresh diagnostics after save, default false.",
|
||||
"default": false
|
||||
},
|
||||
"diagnostic.displayByAle": {
|
||||
"type": "boolean",
|
||||
"description": "Use Ale for display diagnostics in vim, will disable coc for display diagnostics, restart required on change.",
|
||||
|
@ -598,10 +593,10 @@
|
|||
"description": "Offset number of buffer.addHighlight, neovim only.",
|
||||
"default": 1000
|
||||
},
|
||||
"diagnostic.signOffset": {
|
||||
"diagnostic.signPriority": {
|
||||
"type": "number",
|
||||
"description": "Offset number of sign",
|
||||
"default": 1000
|
||||
"description": "Priority of diagnostic signs, default to 10",
|
||||
"default": 10
|
||||
},
|
||||
"diagnostic.errorSign": {
|
||||
"type": "string",
|
||||
|
@ -640,7 +635,7 @@
|
|||
},
|
||||
"diagnostic.format": {
|
||||
"type": "string",
|
||||
"description": "Define the diagnostic format. Available parts: source, code, severity, message",
|
||||
"description": "Define the diagnostic format that shown in float window or echoed, available parts: source, code, severity, message",
|
||||
"default": "[%source%code] [%severity] %message"
|
||||
},
|
||||
"diagnostic.separateRelatedInformationAsDiagnostics": {
|
||||
|
@ -648,6 +643,16 @@
|
|||
"default": false,
|
||||
"description": "Separate related information as diagnostics"
|
||||
},
|
||||
"diagnostic.showUnused": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Show unused variables"
|
||||
},
|
||||
"diagnostic.showDeprecated": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Show deprecated variables"
|
||||
},
|
||||
"signature.enable": {
|
||||
"type": "boolean",
|
||||
"description": "Enable signature help when trigger character typed, require restart service on change.",
|
||||
|
@ -655,15 +660,16 @@
|
|||
},
|
||||
"signature.triggerSignatureWait": {
|
||||
"type": "integer",
|
||||
"default": 50,
|
||||
"minimum": 50,
|
||||
"maximum": 300,
|
||||
"default": 500,
|
||||
"minimum": 200,
|
||||
"maximum": 1000,
|
||||
"description": "Timeout for trigger signature help, in miliseconds."
|
||||
},
|
||||
"signature.target": {
|
||||
"type": "string",
|
||||
"description": "Target of signature help, use float when possible by default.",
|
||||
"enum": ["float", "echo", "preview"]
|
||||
"default": "float",
|
||||
"enum": ["float", "echo"]
|
||||
},
|
||||
"signature.maxWindowWidth": {
|
||||
"type": "integer",
|
||||
|
@ -683,7 +689,7 @@
|
|||
},
|
||||
"signature.hideOnTextChange": {
|
||||
"type": "boolean",
|
||||
"description": "Hide signature float window when text changed, require restart service on change.",
|
||||
"description": "Hide signature float window when text changed on insert mode.",
|
||||
"default": false
|
||||
},
|
||||
"codeLens.enable": {
|
||||
|
@ -706,6 +712,11 @@
|
|||
"description": "Open command for refactor window.",
|
||||
"default": "vsplit"
|
||||
},
|
||||
"refactor.saveToFile": {
|
||||
"type": "boolean",
|
||||
"description": "Save to file when write refactor buffer with ':noa wa' command, set to false if you want save buffer by yourself.",
|
||||
"default": true
|
||||
},
|
||||
"refactor.beforeContext": {
|
||||
"type": "number",
|
||||
"default": 3,
|
||||
|
@ -716,6 +727,71 @@
|
|||
"default": 3,
|
||||
"description": "Print num lines of trailing context after each match."
|
||||
},
|
||||
"dialog.maxHeight": {
|
||||
"type": "number",
|
||||
"default": 20,
|
||||
"description": "Maximum height of dialog window."
|
||||
},
|
||||
"dialog.maxWidth": {
|
||||
"type": "number",
|
||||
"default": 80,
|
||||
"description": "Maximum width of dialog window."
|
||||
},
|
||||
"dialog.confirmKey": {
|
||||
"type": "string",
|
||||
"default": "<cr>",
|
||||
"description": "Confirm key for confirm selection used by menu and picker, you can always use <esc> to cancel."
|
||||
},
|
||||
"dialog.pickerButtons": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Show buttons for picker dialog window/popup."
|
||||
},
|
||||
"dialog.pickerButtonShortcut": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Show shortcut in buttons of picker dialog window/popup, used when dialog.pickerButtons is true."
|
||||
},
|
||||
"dialog.floatHighlight": {
|
||||
"type": ["string", "null"],
|
||||
"default": null,
|
||||
"description": "Highlight group for dialog window/popup, default to 'CocFloating'"
|
||||
},
|
||||
"dialog.floatBorderHighlight": {
|
||||
"type": ["string", "null"],
|
||||
"default": null,
|
||||
"description": "Highlight group for border of dialog window/popup, default to 'CocFloating'"
|
||||
},
|
||||
"notification.marginTop": {
|
||||
"type": "number",
|
||||
"default": 1,
|
||||
"description": "Margin top for notification dialog."
|
||||
},
|
||||
"notification.marginRight": {
|
||||
"type": "number",
|
||||
"default": 1,
|
||||
"description": "Margin right for notification dialog."
|
||||
},
|
||||
"notification.maxWidth": {
|
||||
"type": "number",
|
||||
"default": 60,
|
||||
"description": "Maximum content width of notification dialog."
|
||||
},
|
||||
"notification.maxHeight": {
|
||||
"type": "number",
|
||||
"default": 10,
|
||||
"description": "Maximum content height of notification dialog."
|
||||
},
|
||||
"notification.highlightGroup": {
|
||||
"type": "string",
|
||||
"default": "CocFloating",
|
||||
"description": "Highlight group of notification dialog."
|
||||
},
|
||||
"notification.minProgressWidth": {
|
||||
"type": "number",
|
||||
"default": 30,
|
||||
"description": "Minimum width of progress notification."
|
||||
},
|
||||
"workspace.ignoredFiletypes": {
|
||||
"type": "array",
|
||||
"default": ["markdown", "log", "txt", "help"],
|
||||
|
@ -724,11 +800,29 @@
|
|||
"type": "string"
|
||||
}
|
||||
},
|
||||
"workspace.bottomUpFiletypes": {
|
||||
"type": "array",
|
||||
"default": [],
|
||||
"description": "Filetypes that should have workspace folder should resolved from base directory of file.",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"workspace.workspaceFolderCheckCwd": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Whether the cwd directory should be checked first when resolving workspace folder."
|
||||
},
|
||||
"list.indicator": {
|
||||
"type": "string",
|
||||
"default": ">",
|
||||
"description": "The character used as first character in prompt line"
|
||||
},
|
||||
"list.alignColumns": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Whether to align lists in columns, default: `false`"
|
||||
},
|
||||
"list.interactiveDebounceTime": {
|
||||
"type": "number",
|
||||
"default": 100,
|
||||
|
@ -739,6 +833,21 @@
|
|||
"default": 10,
|
||||
"description": "Height of split list window."
|
||||
},
|
||||
"list.statusLineSegments": {
|
||||
"type": ["array", "null"],
|
||||
"default": [
|
||||
"%#CocListMode#-- %{get(b:list_status, \"mode\", \"\")} --%*",
|
||||
"%{get(b:list_status, \"loading\", \"\")}",
|
||||
"%{get(b:list_status, \"args\", \"\")}",
|
||||
"(%L/%{get(b:list_status, \"total\", \"\")})",
|
||||
"%=",
|
||||
"%#CocListPath# %{get(b:list_status, \"cwd\", \"\")} %l/%L%*"
|
||||
],
|
||||
"items": {
|
||||
"types": "string"
|
||||
},
|
||||
"description": "An array of statusline segments that will be used to draw the status line for list windows."
|
||||
},
|
||||
"list.signOffset": {
|
||||
"type": "number",
|
||||
"default": 900,
|
||||
|
@ -769,6 +878,11 @@
|
|||
"default": false,
|
||||
"description": "Use vsplit for preview window."
|
||||
},
|
||||
"list.matchHighlightGroup": {
|
||||
"type": "string",
|
||||
"default": "Search",
|
||||
"description": "Highlight group used for matched texts in list window."
|
||||
},
|
||||
"list.previewHighlightGroup": {
|
||||
"type": "string",
|
||||
"default": "Search",
|
||||
|
@ -794,10 +908,21 @@
|
|||
"default": {},
|
||||
"description": "Custom keymappings on insert mode."
|
||||
},
|
||||
"list.source.diagnostics.includeCode": {
|
||||
"type": "boolean",
|
||||
"description": "Whether to show the diagnostic code in the list.",
|
||||
"default": true
|
||||
},
|
||||
"list.source.diagnostics.pathFormat": {
|
||||
"type": "string",
|
||||
"description": "Decide how the filepath is shown in the list.",
|
||||
"enum": ["full", "short", "filename", "hidden"],
|
||||
"default": "full"
|
||||
},
|
||||
"list.source.symbols.excludes": {
|
||||
"type": "array",
|
||||
"default": [],
|
||||
"description": "Patterns of mimimatch for filepath to execlude from symbols list.",
|
||||
"description": "Patterns of minimatch for filepath to execlude from symbols list.",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
|
@ -825,6 +950,11 @@
|
|||
"default": "<C-p>",
|
||||
"description": "Key used for jump to previous cursors position."
|
||||
},
|
||||
"coc.preferences.enableMessageDialog": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Enable messages shown in notification dialog."
|
||||
},
|
||||
"coc.preferences.maxFileSize": {
|
||||
"type": "string",
|
||||
"default": "10MB",
|
||||
|
@ -890,11 +1020,6 @@
|
|||
"type": "string"
|
||||
}
|
||||
},
|
||||
"coc.preferences.formatOnInsertLeave": {
|
||||
"type": "boolean",
|
||||
"description": "Trigger format on type when insert leave by send \n to the server.",
|
||||
"default": false
|
||||
},
|
||||
"coc.preferences.enableFloatHighlight": {
|
||||
"type": "boolean",
|
||||
"description": "Enable highlight for floating window.",
|
||||
|
@ -916,7 +1041,7 @@
|
|||
"coc.preferences.jumpCommand": {
|
||||
"type": "string",
|
||||
"description": "Command used for location jump, like goto definition, goto references etc.",
|
||||
"enum": ["edit", "split", "vsplit", "tabe", "drop", "tab drop"],
|
||||
"enum": ["edit", "split", "vsplit", "tabe", "drop", "tab drop", "pedit"],
|
||||
"default": "edit"
|
||||
},
|
||||
"coc.preferences.messageLevel": {
|
||||
|
@ -962,7 +1087,7 @@
|
|||
},
|
||||
"coc.preferences.promptInput": {
|
||||
"type": "boolean",
|
||||
"description": "Use prompt buffer in float window for user input, works on neovim >= 0.4.3 only.",
|
||||
"description": "Use prompt buffer in float window for user input.",
|
||||
"default": true
|
||||
},
|
||||
"coc.preferences.enableMarkdown": {
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,6 @@
|
|||
*coc-nvim.txt* LSP support for Vim & Neovim.
|
||||
|
||||
Version: 0.0.79
|
||||
Version: 0.0.80
|
||||
Author: Qiming Zhao <chemzqm at gmail.com>
|
||||
License: MIT license
|
||||
|
||||
|
@ -17,7 +17,7 @@ Interface |coc-interface|
|
|||
Functions |coc-functions|
|
||||
Commands |coc-commands|
|
||||
Autocmds |coc-autocmds|
|
||||
Highlights |coc-highlights|
|
||||
Highlights |coc-highlights|
|
||||
List |coc-list|
|
||||
List command |coc-list-command|
|
||||
List command options |coc-list-options|
|
||||
|
@ -34,6 +34,12 @@ List |coc-list|
|
|||
Links |coc-list-links|
|
||||
Sources |coc-list-completion-sources|
|
||||
Lists |coc-list-lists|
|
||||
Dialog |coc-dialog|
|
||||
Dialog basic |coc-dialog-basic|
|
||||
Dialog confirm |coc-dialog-confirm|
|
||||
Dialog input |coc-dialog-input|
|
||||
Dialog menu |coc-dialog-menu|
|
||||
Dialog picker |coc-dialog-picker|
|
||||
Statusline support |coc-status|
|
||||
Manual |coc-status-manual|
|
||||
Airline |coc-status-airline|
|
||||
|
@ -76,7 +82,7 @@ INSTALLATION *coc-installation*
|
|||
If you're using [vim-plug](https://github.com/junegunn/vim-plug), add this to
|
||||
your `init.vim` or `.vimrc`: >
|
||||
|
||||
Plug 'neoclide/coc.nvim', {'branch': 'release'}
|
||||
Plug 'neoclide/coc.nvim'
|
||||
|
||||
And run: >
|
||||
|
||||
|
@ -155,7 +161,7 @@ Built-in configurations:~
|
|||
"suggest.detailField":~
|
||||
|
||||
Where to add the detail in complete item when it's less than max
|
||||
length, default: `"menu"`
|
||||
length, default: `"preview"` when floating documentation is enabled.
|
||||
|
||||
Valid options: ["abbr", "menu", "preview"]
|
||||
|
||||
|
@ -294,6 +300,7 @@ Built-in configurations:~
|
|||
"variable": "\ue79b",
|
||||
"value": "\uf89f",
|
||||
"operator": "\u03a8",
|
||||
"constructor": "\uf0ad",
|
||||
"function": "\u0192",
|
||||
"reference": "\ufa46",
|
||||
"constant": "\uf8fe",
|
||||
|
@ -382,10 +389,6 @@ Built-in configurations:~
|
|||
|
||||
Refresh diagnostics when in insert mode, default: `false`
|
||||
|
||||
"diagnostic.refreshAfterSave":~
|
||||
|
||||
Refresh diagnostics after file save only, default: `false`
|
||||
|
||||
"diagnostic.displayByAle":~
|
||||
|
||||
Use ALE for displaying diagnostics. This will disable coc.nvim for
|
||||
|
@ -418,9 +421,9 @@ Built-in configurations:~
|
|||
|
||||
Offset number of buffer.addHighlight, Neovim only, default: `1000`
|
||||
|
||||
"diagnostic.signOffset":~
|
||||
"diagnostic.signPriority":~
|
||||
|
||||
Offset number of sign, default: `1000`
|
||||
Priority of diagnostic sign, default to `10`, check |sign-priority|.
|
||||
|
||||
"diagnostic.errorSign":~
|
||||
|
||||
|
@ -470,7 +473,7 @@ Built-in configurations:~
|
|||
|
||||
"signature.triggerSignatureWait":~
|
||||
|
||||
Delay for signature request trigger (milliseconds), default: `50`.
|
||||
Timeout for signature request trigger (milliseconds), default: `500`.
|
||||
Change to higher value for slow Language Servers.
|
||||
|
||||
"signature.target":~
|
||||
|
@ -494,6 +497,11 @@ Built-in configurations:~
|
|||
Maximum height of floating window with the signature help, default: `8`
|
||||
|
||||
*coc-config-refactor*
|
||||
"refactor.saveToFile":~
|
||||
|
||||
Save to file when write refactor buffer with ':noa wa' command, set to
|
||||
false if you want save buffer by yourself.
|
||||
|
||||
"refactor.openCommand":~
|
||||
|
||||
Open command for refactor window, default: `vsplit`
|
||||
|
@ -506,15 +514,72 @@ Built-in configurations:~
|
|||
|
||||
Print num lines of trailing context after each match, default: `3`
|
||||
|
||||
*coc-config-dialog*
|
||||
"dialog.maxWidth": ~
|
||||
|
||||
Maximum width of dialog window.
|
||||
|
||||
"dialog.maxHeight": ~
|
||||
|
||||
Maximum height of dialog window.
|
||||
|
||||
"dialog.confirmKey":~
|
||||
|
||||
Confirm key for confirm selection used by menu and picker, you can
|
||||
always use <esc> to cancel, default to `<cr>`.
|
||||
|
||||
"dialog.pickerButtons":~
|
||||
|
||||
Show buttons for picker dialog window/popup, default `true`.
|
||||
|
||||
"dialog.pickerButtonShortcut":~
|
||||
|
||||
Show shortcut in buttons of picker dialog window/popup, used when
|
||||
dialog.pickerButtons is true, default `true`.
|
||||
|
||||
"dialog.floatHighlight":~
|
||||
|
||||
Highlight group for dialog window/popup, default to 'CocFloating'.
|
||||
|
||||
"dialog.floatBorderHighlight":~
|
||||
|
||||
Highlight group for border of dialog window/popup, default to
|
||||
'CocFloating'.
|
||||
|
||||
*coc-config-notification*
|
||||
"notification.marginTop": ~
|
||||
|
||||
Margin top for notification dialog, default to `1`.
|
||||
|
||||
"notification.marginRight": ~
|
||||
|
||||
Margin right for notification dialog, default to `1`.
|
||||
|
||||
"notification.maxWidth": ~
|
||||
|
||||
Maximum content width of notification dialog, default to `60`.
|
||||
|
||||
"notification.maxHeight": ~
|
||||
|
||||
Maximum content height of notification dialog, default to `10`.
|
||||
|
||||
"notification.highlightGroup": ~
|
||||
|
||||
Highlight group of notification dialog, default to `CocFloating`.
|
||||
|
||||
"notification.minProgressWidth": ~
|
||||
|
||||
Minimum width of progress notification, default to `30`.
|
||||
|
||||
*coc-config-codelens*
|
||||
"codeLens.enable":~
|
||||
|
||||
Enable `codeLens` feature. Requires Neovim with virtual text feature,
|
||||
default: `false`
|
||||
default: `false`.
|
||||
|
||||
"codeLens.separator":~
|
||||
|
||||
Separator text for `codeLens` in virtual text, default: `"‣"`
|
||||
Separator text for `codeLens` in virtual text, default: `"‣"`.
|
||||
|
||||
"codeLens.subseparator":~
|
||||
|
||||
|
@ -527,11 +592,25 @@ Built-in configurations:~
|
|||
|
||||
Note: This is the filetype after mapping by `g:coc_filetype_map`.
|
||||
|
||||
"workspace.bottomUpFiletypes":~
|
||||
|
||||
Filetypes that should have workspace folder should resolved from
|
||||
base directory of file.
|
||||
|
||||
"workspace.workspaceFolderCheckCwd":~
|
||||
|
||||
Whether the cwd directory should be checked first when resolving
|
||||
workspace folder of current buffer.
|
||||
|
||||
*coc-config-list*
|
||||
"list.indicator":~
|
||||
|
||||
The character used as first character in prompt line, default: `">"`
|
||||
|
||||
"list.alignColumns":~
|
||||
|
||||
Whether to align lists in columns, default: `false`
|
||||
|
||||
"list.height":~
|
||||
|
||||
Height of split list window, default: `10`
|
||||
|
@ -552,6 +631,11 @@ Built-in configurations:~
|
|||
|
||||
Max height for preview window of list, default: `12`
|
||||
|
||||
"list.matchHighlightGroup":~
|
||||
|
||||
Highlight group used for matched texts in list window.
|
||||
default: `"Search"`
|
||||
|
||||
"list.previewHighlightGroup":~
|
||||
|
||||
Highlight group used for highlighting the range in preview window,
|
||||
|
@ -588,7 +672,7 @@ Built-in configurations:~
|
|||
|
||||
"list.source.symbols.excludes":~
|
||||
|
||||
Patterns of mimimatch for filepath to execlude from symbols list,
|
||||
Patterns of minimatch for filepath to execlude from symbols list,
|
||||
default: `[]`
|
||||
|
||||
"list.source.outline.ctagsFilestypes":~
|
||||
|
@ -596,7 +680,26 @@ Built-in configurations:~
|
|||
Filetypes that should use `ctags` for outline instead of language server,
|
||||
default: `[]`
|
||||
|
||||
|
||||
"list.source.diagnostics.pathFormat":~
|
||||
|
||||
Decide how the filepath is shown in the list.
|
||||
|
||||
Valid options: ["full", "short", "filename", "hidden"].
|
||||
|
||||
default: `"full"`
|
||||
|
||||
"list.source.diagnostics.includeCode":~
|
||||
|
||||
Whether to show the diagnostic code in the list.
|
||||
|
||||
default: `true`
|
||||
|
||||
*coc-config-preferences*
|
||||
"coc.preferences.enableMessageDialog"~
|
||||
|
||||
Enable messages shown in notification dialog, default: `false`
|
||||
|
||||
"coc.preferences.maxFileSize":~
|
||||
|
||||
Maximum file size in bytes that coc.nvim should handle, default: `'10MB'`
|
||||
|
@ -647,11 +750,6 @@ Built-in configurations:~
|
|||
Automatically update the value of `b:coc_current_function` on `CursorHold`
|
||||
event, default: `false`
|
||||
|
||||
"coc.preferences.formatOnInsertLeave":~
|
||||
|
||||
Trigger format on type when insert leave by send \n to the server.
|
||||
Default: `false`
|
||||
|
||||
"coc.preferences.formatOnSaveFiletypes":~
|
||||
|
||||
Filetypes for which formatting triggers after saving, default: `[]`
|
||||
|
@ -693,7 +791,8 @@ Built-in configurations:~
|
|||
"coc.preferences.bracketEnterImprove":~
|
||||
|
||||
Improve handling of pressing enter inside brackets (`<> {} [] ()`) by
|
||||
adding a new empty line below and moving the cursor to it.
|
||||
create a new empty line in the middle, the indent is calculated by vim,
|
||||
checkout |indentexpr| for details.
|
||||
|
||||
Works with |coc#on_enter()|, default: `true`
|
||||
|
||||
|
@ -724,8 +823,7 @@ Built-in configurations:~
|
|||
|
||||
"coc.preferences.promptInput":~
|
||||
|
||||
Use prompt buffer in float window for user input, works on latest
|
||||
neovim >= 0.4.3 only.
|
||||
Use prompt buffer in float window for user input.
|
||||
Default: `true`
|
||||
|
||||
"coc.preferences.enableMarkdown":~
|
||||
|
@ -781,7 +879,7 @@ Built-in configurations:~
|
|||
- "env": Environment variables for child process.
|
||||
|
||||
- "settings": Settings for languageserver, received on server
|
||||
initialiation.
|
||||
initialization.
|
||||
|
||||
- "trace.server": Trace level of communication between server and
|
||||
client that showed with output channel.
|
||||
|
@ -1026,12 +1124,17 @@ normal mode, `v_` works for visual mode.
|
|||
|
||||
<Plug>(coc-codeaction) *n_coc-codeaction*
|
||||
|
||||
Get and run code action(s) for current file.
|
||||
Get and run code action(s) for current file, use |coc-codeaction-cursor|
|
||||
for same beharior as VSCode.
|
||||
|
||||
<Plug>(coc-codeaction-line) *n_coc-codeaction-line*
|
||||
|
||||
Get and run code action(s) for current line.
|
||||
|
||||
<Plug>(coc-codeaction-cursor) *n_coc-codeaction-cursor*
|
||||
|
||||
Get and run code action(s) using empty range at current cursor.
|
||||
|
||||
<Plug>(coc-codeaction-selected) *n_coc-codeaction-selected*
|
||||
*v_coc-codeaction-selected*
|
||||
|
||||
|
@ -1179,6 +1282,11 @@ b:coc_current_function *b:coc_current_function*
|
|||
Set `"coc.preferences.currentFunctionSymbolAutoUpdate": true`
|
||||
in coc-settings.json to update it on CursorHold.
|
||||
|
||||
b:coc_cursors_activated *b:coc_cursors_activated*
|
||||
|
||||
Use expression `get(b:, 'coc_cursors_activated',0)` to check if
|
||||
cursors session is activated for current buffer.
|
||||
|
||||
g:coc_disable_startup_warning *g:coc_disable_startup_warning*
|
||||
|
||||
Disable possible warning on startup for old vim/node version.
|
||||
|
@ -1220,7 +1328,6 @@ g:coc_start_at_startup *g:coc_start_at_startup*
|
|||
|
||||
g:coc_user_config *g:coc_user_config*
|
||||
|
||||
|
||||
User configuration object, define this variable when you can't use
|
||||
|coc#config()|
|
||||
|
||||
|
@ -1309,14 +1416,6 @@ g:coc_node_path *g:coc_node_path*
|
|||
|
||||
Note: you can use `~` as home directory.
|
||||
|
||||
g:coc_force_bundle *g:coc_force_bundle*
|
||||
|
||||
When lib folder with javascript code exists, coc.nvim would use
|
||||
compiled javascript from lib folder, set this variable to `1` if you
|
||||
want it use `build/index.js` created by webpack.
|
||||
|
||||
Default: 0
|
||||
|
||||
g:coc_node_args *g:coc_node_args*
|
||||
|
||||
Arguments passed to node when starting coc service from source code.
|
||||
|
@ -1357,11 +1456,6 @@ g:coc_status_warning_sign *g:coc_status_warning_sign*
|
|||
|
||||
Warning character used for statusline, default: `W`
|
||||
|
||||
g:coc_watch_extensions *g:coc_watch_extensions*
|
||||
|
||||
Extensions to watch for reload, used for developing extensions only,
|
||||
need watchman installed.
|
||||
|
||||
g:coc_quickfix_open_command *g:coc_quickfix_open_command*
|
||||
|
||||
Command used for open quickfix list. To jump fist position after
|
||||
|
@ -1387,11 +1481,6 @@ g:node_client_debug *g:node_client_debug*
|
|||
|
||||
Default: `0`
|
||||
|
||||
g:coc_cursors_activated *g:coc_cursors_activated*
|
||||
|
||||
Use expression `get(g:, 'coc_cursors_activated',0)` to check if
|
||||
cursors session is activated.
|
||||
|
||||
g:coc_config_home *g:coc_config_home*
|
||||
|
||||
Configure the directory which will be used to look for
|
||||
|
@ -1424,12 +1513,33 @@ g:coc_borderchars *g:coc_borderchars*
|
|||
Border characters used by border window, default to:
|
||||
>
|
||||
['─', '│', '─', '│', '┌', '┐', '┘', '└']
|
||||
<
|
||||
Note: you may need special font like Nerd font to show them.
|
||||
|
||||
g:coc_border_joinchars *g:coc_border_joinchars*
|
||||
|
||||
Border join characters used by float window/popup, default to:
|
||||
>
|
||||
['┬', '┤', '┴', '├']
|
||||
<
|
||||
Note: you may need special font like Nerd font to show them.
|
||||
|
||||
g:coc_prompt_win_width *g:coc_prompt_win_width*
|
||||
|
||||
Width of input prompt window on neovim >= 0.5.0. Prompt buffer can't
|
||||
work with vim8's popup yet.
|
||||
|
||||
g:coc_markdown_disabled_languages *g:coc_markdown_disabled_languages*
|
||||
|
||||
Filetype list that should be disabled for highlight in markdown block, ex: >
|
||||
|
||||
let g:coc_markdown_disabled_languages = ['html']
|
||||
>
|
||||
|
||||
g:coc_install_yarn_cmd *g:coc_install_yarn_cmd*
|
||||
|
||||
Yarn command used for |coc#util#install()| function.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
Some variables are provided by coc.nvim so you can use them in your
|
||||
|
@ -1574,6 +1684,10 @@ health#coc#check() *health#coc#check()*
|
|||
Neovim only, run health check, triggered by ':checkhealth'
|
||||
command.
|
||||
|
||||
coc#util#api_version() *coc#util#api_version()*
|
||||
|
||||
Get coc.nvim's vim api version number, start from `1`.
|
||||
|
||||
coc#util#job_command() *coc#util#job_command()*
|
||||
|
||||
Get the job command used for starting the coc service.
|
||||
|
@ -1594,10 +1708,6 @@ coc#util#rebuild() *coc#util#rebuild()*
|
|||
|
||||
Rebuild coc extensions.
|
||||
|
||||
coc#util#float_scroll({forward}) *coc#util#float_scroll()*
|
||||
|
||||
Deprecated, please use |coc#float#scroll|.
|
||||
|
||||
coc#util#root_patterns() *coc#util#root_patterns()*
|
||||
|
||||
Get root patterns used for current document.
|
||||
|
@ -1612,6 +1722,11 @@ coc#util#get_config({key}) *coc#util#get_config()*
|
|||
|
||||
:echo coc#util#get_config('coc.preferences')
|
||||
|
||||
coc#util#install() *coc#util#install()*
|
||||
|
||||
Install dependencies and compile source code, not needed unless
|
||||
you need compile typescript code.
|
||||
|
||||
coc#float#close_all() *coc#float#close_all()*
|
||||
|
||||
Close all float windows/popups.
|
||||
|
@ -1628,20 +1743,23 @@ coc#float#has_scroll() *coc#float#has_scroll()*
|
|||
Return `1` when there is scrollable float window or popup.
|
||||
Example key-mappings:
|
||||
>
|
||||
if has('nvim-0.4.3') || has('patch-8.2.0750')
|
||||
nnoremap <nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
|
||||
nnoremap <nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
|
||||
inoremap <nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
|
||||
inoremap <nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
|
||||
if has('nvim-0.4.0') || has('patch-8.2.0750')
|
||||
nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
|
||||
nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
|
||||
inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
|
||||
inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
|
||||
vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
|
||||
vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
|
||||
endif
|
||||
<
|
||||
coc#float#scroll({forward}, [{amount}])
|
||||
coc#float#scroll({forward}, [{amount}]) *coc#float#scroll()*
|
||||
|
||||
Scroll all scrollable float windows/popups, scroll backward when
|
||||
{forward} is not `1`. {amount} could be number or full page when
|
||||
omitted.
|
||||
|
||||
Note: this function requires nvim >= 0.4.3 or vim >= 8.2.750 to work.
|
||||
Note: this function requires nvim >= 0.4.0 or vim >= 8.2.750 to work.
|
||||
|
||||
|
||||
CocRequest({id}, {method}, [{params}]) *CocRequest()*
|
||||
|
||||
|
@ -1730,8 +1848,13 @@ CocHasProvider({feature}) *CocHasProvider()*
|
|||
CocTagFunc({pattern}, {flags}, {info}) *CocTagFunc()*
|
||||
|
||||
Used for vim's 'tagfunc' option, to make tag search by |CTRL-]| use
|
||||
coc.nvim as provider.
|
||||
coc.nvim as provider, tag search would be performed when no result
|
||||
from coc.nvim.
|
||||
|
||||
Make sure your vim support 'tagfunc' by
|
||||
>
|
||||
:echo exists('&tagfunc')
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*coc-action*
|
||||
Available Actions ~
|
||||
|
@ -1819,9 +1942,6 @@ Acceptable {action} names for |CocAction()| and |CocActionAsync|.
|
|||
defaults to `coc.preferences.hoverTarget` in `coc-settings.json`.
|
||||
Valid options: ["preview", "echo", "float"]
|
||||
|
||||
Note: the behavior would change in Neovim, where floating windows are
|
||||
available.
|
||||
|
||||
"getHover" *coc-action-getHover*
|
||||
|
||||
Get documentation text array on current position, returns array of
|
||||
|
@ -1839,9 +1959,24 @@ Acceptable {action} names for |CocAction()| and |CocActionAsync|.
|
|||
|
||||
Return the function string that current cursor in.
|
||||
|
||||
"documentSymbols" *coc-action-documentSymbols*
|
||||
"documentSymbols" [{bufnr}] *coc-action-documentSymbols*
|
||||
|
||||
Get a list of symbols in the current document.
|
||||
Get a list of symbols of current buffer or specific {bufnr}.
|
||||
|
||||
"ensureDocument" *coc-action-ensureDocument*
|
||||
|
||||
Ensure current document is attached to coc.nvim, should be used when
|
||||
you need invoke action of current document just after document
|
||||
created.
|
||||
|
||||
Return `v:false` when the document can't be attached, the document
|
||||
won't be attached for one of these reasons:
|
||||
|
||||
1. The 'buftype' option is neither <empty> nor acwrite.
|
||||
2. Buffer variable `b:coc_enabled` is set to `0`.
|
||||
3. Size of buffer bigger than `coc.preferences.maxFileSize`
|
||||
configuration.
|
||||
4. The buffer is used for command line window.
|
||||
|
||||
"rename" *coc-action-rename*
|
||||
|
||||
|
@ -1880,8 +2015,8 @@ Acceptable {action} names for |CocAction()| and |CocActionAsync|.
|
|||
|
||||
Prompt for a code action and do it.
|
||||
|
||||
{mode} should be result of visualmode(), when used in visualmode,
|
||||
could be empty string or v:null for none visualmode.
|
||||
{mode} could be `line` or `cursor` or result of |visualmode()|,
|
||||
current buffer range is used when it's empty string.
|
||||
|
||||
{only} can be title of a codeAction or list of CodeActionKind.
|
||||
|
||||
|
@ -2138,7 +2273,9 @@ COMMANDS *coc-commands*
|
|||
Note: the log would be cleared when coc.nvim started.
|
||||
|
||||
Use environment variable `NVIM_COC_LOG_LEVEL` to change log level
|
||||
(default 'info'). Use shell command: >
|
||||
(default 'info', could be 'all', 'trace', 'debug', 'info',
|
||||
'warn', 'error', 'off').
|
||||
Use shell command: >
|
||||
|
||||
export NVIM_COC_LOG_LEVEL=debug
|
||||
<
|
||||
|
@ -2210,6 +2347,11 @@ COMMANDS *coc-commands*
|
|||
related files. You can make any kind of changes, including add lines
|
||||
and remove lines.
|
||||
|
||||
:CocWatch [extension] *:CocWatch*
|
||||
|
||||
Watch loaded [extension] for reload on file change, use <tab> for
|
||||
complete extension id.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
AUTOCMD *coc-autocmds*
|
||||
|
||||
|
@ -2287,6 +2429,42 @@ Note: highlight commands should appear after the |:colorscheme| command or use
|
|||
|ColorScheme| autocmd to make sure customized highlight works after color
|
||||
scheme change.
|
||||
|
||||
CocUnderline *CocUnderline*
|
||||
|
||||
Default: `hi default CocUnderline cterm=underline gui=underline`
|
||||
|
||||
The highlight for underlined text.
|
||||
|
||||
CocBold *CocBold*
|
||||
|
||||
Default: `hi default CocBold term=bold cterm=bold gui=bold`
|
||||
|
||||
The highlight for bold text.
|
||||
|
||||
CocItalic *CocItalic*
|
||||
|
||||
Default: `hi default CocItalic term=italic cterm=italic gui=italic`
|
||||
|
||||
The highlight for italic text.
|
||||
|
||||
CocMarkdownCode *CocMarkdownCode*
|
||||
|
||||
Default: `hi default link CocMarkdownCode markdownCode`
|
||||
|
||||
The highlight for markdown code in floating window/popup.
|
||||
|
||||
CocMarkdownHeader *CocMarkdownHeader*
|
||||
|
||||
Default: `hi default link CocMarkdownHeader markdownH1`
|
||||
|
||||
The highlight for markdown header in floating window/popup.
|
||||
|
||||
CocMarkdownLink *CocMarkdownLink*
|
||||
|
||||
Default: `hi default CocMarkdownLink ctermfg=Blue guifg=#15aabf guibg=NONE`
|
||||
|
||||
The highlight for markdown link text in floating window/popup.
|
||||
|
||||
CocErrorSign *CocErrorSign*
|
||||
|
||||
Default: `hi CocErrorSign ctermfg=Red guifg=#ff0000`
|
||||
|
@ -2454,7 +2632,9 @@ CocMenuSel *CocMenuSel*
|
|||
|
||||
Default: `hi default link CocMenuSel PmenuSel`
|
||||
|
||||
The highlight used for selected menu item, works on neovim only.
|
||||
The highlight used for current menu item in menu dialog,
|
||||
works on neovim only since vim doesn't support change highlight
|
||||
group of cursorline inside popup.
|
||||
|
||||
CocListMode *CocListMode*
|
||||
|
||||
|
@ -2516,6 +2696,10 @@ LIST COMMAND *coc-list-command*
|
|||
|
||||
Reopen last opened list, input and cursor position will be preserved.
|
||||
|
||||
:CocListCancel *:CocListCancel*
|
||||
|
||||
Close list, useful when the list is not the current window.
|
||||
|
||||
:CocPrev [{name}] *:CocPrev*
|
||||
|
||||
Invoke default action for the previous item in the last {name} list.
|
||||
|
@ -2649,6 +2833,7 @@ LIST MAPPINGS *coc-list-mappings*
|
|||
Default mappings on insert mode:
|
||||
|
||||
<Esc> - cancel list session.
|
||||
<CR> - do default action with selected items or current item.
|
||||
<C-c> - stop loading task.
|
||||
<C-v> - paste text from system clipboard.
|
||||
<C-l> - reload list.
|
||||
|
@ -2676,6 +2861,7 @@ Default mappings on insert mode:
|
|||
Default mappings on normal mode:
|
||||
|
||||
<Esc> - cancel list session.
|
||||
<CR> - do default action with selected items or current item.
|
||||
<C-c> - stop source from fetching more items.
|
||||
<C-l> - reload list.
|
||||
<C-a> - mark all visible items selected.
|
||||
|
@ -2733,8 +2919,9 @@ The mapping expression should be `command:arguments`, available commands:
|
|||
'togglemode' - toggle between insert and normal mode.
|
||||
'previous' - move cursor to previous item.
|
||||
'next' - move cursor to next item.
|
||||
'defaultaction' - execute default action.
|
||||
'defaultaction' - do default action for selected items or current item.
|
||||
'jumpback' - stop prompt and jump back to original window.
|
||||
'previewtoggle' - toggle preview window, requires preview action exists.
|
||||
'previewup' - scroll preview window up.
|
||||
'previewdown' - scroll preview window down.
|
||||
'help' - show help.
|
||||
|
@ -2885,6 +3072,105 @@ lists *coc-list-lists*
|
|||
|
||||
==============================================================================
|
||||
|
||||
DIALOG SUPPORT *coc-dialog*
|
||||
|
||||
Dialog is special float window/popup that could response to user actions,
|
||||
dialog have close button, border, title (optional), bottom buttons(optional).
|
||||
|
||||
Note bottom buttons work different on neovim and vim, on neovim you can
|
||||
click the button since neovim allows focus of window, on vim you have to type
|
||||
highlighted character to trigger button callback.
|
||||
|
||||
Note dialog feature requires neovim >= 0.4.0 or vim >= 8.2.0750 to work.
|
||||
|
||||
See |coc-config-dialog| for available configurations.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
*coc-dialog-basic*
|
||||
|
||||
A basic dialog is create by 'window.showDialog' api, which is just some texts
|
||||
with optional buttons.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
*coc-dialog-confirm*
|
||||
|
||||
A confirm dialog is used for user to confirm an action, normally created by
|
||||
`window.showPrompt()` Confirm dialog uses filter feature on vim8 and
|
||||
|getchar()| on neoivm.
|
||||
|
||||
The difference is you can operate vim on vim8, but not on neovim.
|
||||
|
||||
Supported key-mappings:
|
||||
|
||||
<C-c> - force cancel, return -1 for callback.
|
||||
<esc>, n, N - reject the action, return 0 for callback.
|
||||
y,Y - accept the action, return 1 for callback.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
*coc-dialog-input*
|
||||
|
||||
A input dialog request user input with optional default value, normally
|
||||
created by `window.requestInput`, when `"coc.preferences.promptInput"` is
|
||||
false, vim's commandline input prompt is used instead.
|
||||
|
||||
Supported key-mappings:
|
||||
|
||||
<C-a> - move cursor to first col.
|
||||
<C-e> - move cursor to last col.
|
||||
<esc> - cancel input, an empty string is received by callback.
|
||||
<cr> - confirm current input.
|
||||
|
||||
And other insert mode key-mappings that your neovim provided.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
*coc-dialog-menu*
|
||||
|
||||
A menu dialog is shown aside current cursor position for pick a single item
|
||||
from list of items, |coc-codeaction| uses menu dialog by default when it's
|
||||
supported, extensions could use `window.showMenuPicker` to create menu
|
||||
dialog.
|
||||
|
||||
Supported key-mappings:
|
||||
|
||||
<Esc> <C-c> - cancel selection.
|
||||
<cr> - confirm selection of current item.
|
||||
1-9 - select item with 1 based index.
|
||||
g - move to first item.
|
||||
G - move to last item.
|
||||
j <tab> <down> <C-n> - move to next item.
|
||||
k <s-tab> <up> <C-p> - move to previous item.
|
||||
<C-f> - scroll forward.
|
||||
<C-b> - scroll backward.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
*coc-dialog-picker*
|
||||
|
||||
A picker dialog is used for multiple selection. On neovim, it's possible to
|
||||
toggle selection by mouse click inside the bracket. Extensions could use
|
||||
`window.showPickerDialog` to create picker dialog.
|
||||
|
||||
Supported key-mappings:
|
||||
|
||||
<Esc> <C-c> - cancel selection.
|
||||
<cr> - confirm selection of selected items.
|
||||
<space> - toggle selection of current item.
|
||||
g - move to first item.
|
||||
G - move to last item.
|
||||
j <tab> <down> <C-n> - move to next item.
|
||||
k <s-tab> <up> <C-p> - move to previous item.
|
||||
<C-f> - scroll forward.
|
||||
<C-b> - scroll backward.
|
||||
|
||||
Note when close button is clicked, the selection is canceled with undefined
|
||||
result (same as <esc>).
|
||||
|
||||
==============================================================================
|
||||
|
||||
STATUSLINE SUPPORT *coc-status*
|
||||
|
||||
Diagnostics info and other status info contributed by extensions could be
|
||||
|
@ -2961,7 +3247,7 @@ Use configuration like: >
|
|||
\ },
|
||||
\ }
|
||||
|
||||
" Use auocmd to force lightline update.
|
||||
" Use autocmd to force lightline update.
|
||||
autocmd User CocStatusChange,CocDiagnosticChange call lightline#update()
|
||||
<
|
||||
==============================================================================
|
||||
|
@ -2992,7 +3278,7 @@ A: On neovim, coc.nvim uses background neovim instance which load syntax
|
|||
Q: I don't have float/popup window shown up.
|
||||
|
||||
A: For vim8, make sure `echo has('textprop') && has('patch-8.1.1719')`
|
||||
echo 1. For neovim, you need neovim >= 0.4.3.
|
||||
echo 1. For neovim, you need neovim >= 0.4.0.
|
||||
|
||||
|
||||
==============================================================================
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "coc.nvim",
|
||||
"version": "0.0.79",
|
||||
"version": "0.0.80",
|
||||
"description": "LSP based intellisense engine for neovim & vim8.",
|
||||
"main": "./lib/index.js",
|
||||
"engines": {
|
||||
|
@ -25,6 +25,9 @@
|
|||
"globals": {
|
||||
"__TEST__": true
|
||||
},
|
||||
"projects": [
|
||||
"<rootDir>"
|
||||
],
|
||||
"watchman": false,
|
||||
"clearMocks": true,
|
||||
"globalSetup": "./jest.js",
|
||||
|
@ -44,3 +47,4 @@
|
|||
"devDependencies": {},
|
||||
"dependencies": {}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,18 +22,9 @@ function! s:checkVersion() abort
|
|||
echohl None
|
||||
sleep 2
|
||||
else
|
||||
if has('nvim') && !has('nvim-0.4.3')
|
||||
if !has('nvim-0.4.0') && !has('patch-8.1.1719')
|
||||
echohl WarningMsg
|
||||
echom "coc.nvim works best on neovim >= 0.4.3, consider upgrade your neovim."
|
||||
echom "You can add this to your vimrc to avoid this message:"
|
||||
echom " let g:coc_disable_startup_warning = 1"
|
||||
echom "Note that some features may behave incorrectly."
|
||||
echohl None
|
||||
sleep 2
|
||||
elseif !has('nvim') && !has('patch-8.1.1719')
|
||||
echohl WarningMsg
|
||||
echom "coc.nvim need vim >= 8.1.1719 to support features like popup and text property."
|
||||
echom "Consider upgrade your vim for better experience."
|
||||
echom "coc.nvim works best on vim >= 8.1.1719 and neovim >= 0.4.0, consider upgrade your vim."
|
||||
echom "You can add this to your vimrc to avoid this message:"
|
||||
echom " let g:coc_disable_startup_warning = 1"
|
||||
echom "Note that some features may behave incorrectly."
|
||||
|
@ -66,7 +57,21 @@ function! CocTagFunc(pattern, flags, info) abort
|
|||
return coc#rpc#request('getTagList', [])
|
||||
endfunction
|
||||
|
||||
function! CocPopupCallback(bufnr, arglist) abort
|
||||
if len(a:arglist) == 2
|
||||
if a:arglist[0] == 'confirm'
|
||||
call coc#rpc#notify('PromptInsert', [a:arglist[1]])
|
||||
elseif a:arglist[0] == 'exit'
|
||||
execute 'silent! bd! '.a:bufnr
|
||||
"call coc#rpc#notify('PromptUpdate', [a:arglist[1]])
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! CocAction(name, ...) abort
|
||||
if !get(g:, 'coc_service_initialized', 0)
|
||||
throw 'coc.nvim not ready when invoke CocAction "'.a:name.'"'
|
||||
endif
|
||||
return coc#rpc#request(a:name, a:000)
|
||||
endfunction
|
||||
|
||||
|
@ -138,6 +143,11 @@ function! s:SearchOptions(...) abort
|
|||
return join(list, "\n")
|
||||
endfunction
|
||||
|
||||
function! s:LoadedExtensions(...) abort
|
||||
let list = CocAction('loadedExtensions')
|
||||
return join(list, "\n")
|
||||
endfunction
|
||||
|
||||
function! s:InstallOptions(...)abort
|
||||
let list = ['-terminal', '-sync']
|
||||
return join(list, "\n")
|
||||
|
@ -146,7 +156,16 @@ endfunction
|
|||
function! s:OpenConfig()
|
||||
let home = coc#util#get_config_home()
|
||||
if !isdirectory(home)
|
||||
call mkdir(home, 'p')
|
||||
echohl MoreMsg
|
||||
echom 'Config directory "'.home.'" not exists, create? (y/n)'
|
||||
echohl None
|
||||
let confirm = nr2char(getchar())
|
||||
redraw!
|
||||
if !(confirm ==? "y" || confirm ==? "\r")
|
||||
return
|
||||
else
|
||||
call mkdir(home, 'p')
|
||||
end
|
||||
endif
|
||||
execute 'edit '.home.'/coc-settings.json'
|
||||
endfunction
|
||||
|
@ -259,14 +278,15 @@ function! s:Enable(initialize)
|
|||
autocmd DirChanged * call s:Autocmd('DirChanged', get(v:event, 'cwd', ''))
|
||||
autocmd TermOpen * call s:Autocmd('TermOpen', +expand('<abuf>'))
|
||||
autocmd TermClose * call s:Autocmd('TermClose', +expand('<abuf>'))
|
||||
autocmd CursorMoved * call coc#float#nvim_refresh_scrollbar()
|
||||
autocmd WinEnter * call coc#float#nvim_check_close(win_getid())
|
||||
autocmd CursorHold * call coc#float#nvim_check_related()
|
||||
autocmd CursorMoved * call coc#float#nvim_refresh_scrollbar(win_getid())
|
||||
autocmd WinEnter * call coc#float#nvim_win_enter(win_getid())
|
||||
if exists('##WinClosed')
|
||||
autocmd WinClosed * call coc#float#nvim_close_related(+expand('<afile>'))
|
||||
autocmd WinClosed * call coc#float#close_related(+expand('<afile>'))
|
||||
endif
|
||||
endif
|
||||
autocmd WinLeave * call coc#util#clear_highlights()
|
||||
if has('nvim-0.4.0') || has('patch-8.1.1719')
|
||||
autocmd CursorHold * call coc#float#check_related()
|
||||
endif
|
||||
autocmd WinLeave * call s:Autocmd('WinLeave', win_getid())
|
||||
autocmd WinEnter * call s:Autocmd('WinEnter', win_getid())
|
||||
autocmd BufWinLeave * call s:Autocmd('BufWinLeave', +expand('<abuf>'), bufwinid(+expand('<abuf>')))
|
||||
|
@ -289,7 +309,7 @@ function! s:Enable(initialize)
|
|||
autocmd CursorHold * call s:Autocmd('CursorHold', +expand('<abuf>'))
|
||||
autocmd CursorHoldI * call s:Autocmd('CursorHoldI', +expand('<abuf>'))
|
||||
autocmd BufNewFile,BufReadPost * call s:Autocmd('BufCreate', +expand('<abuf>'))
|
||||
autocmd BufUnload * call s:SyncAutocmd('BufUnload', +expand('<abuf>'))
|
||||
autocmd BufUnload * call s:Autocmd('BufUnload', +expand('<abuf>'))
|
||||
autocmd BufWritePre * call s:SyncAutocmd('BufWritePre', +expand('<abuf>'))
|
||||
autocmd FocusGained * if mode() !~# '^c' | call s:Autocmd('FocusGained') | endif
|
||||
autocmd VimResized * call s:Autocmd('VimResized', &columns, &lines)
|
||||
|
@ -307,14 +327,18 @@ function! s:Enable(initialize)
|
|||
endfunction
|
||||
|
||||
function! s:Hi() abort
|
||||
hi default CocErrorSign ctermfg=Red guifg=#ff0000 guibg=NONE
|
||||
hi default CocWarningSign ctermfg=Brown guifg=#ff922b guibg=NONE
|
||||
hi default CocInfoSign ctermfg=Yellow guifg=#fab005 guibg=NONE
|
||||
hi default CocHintSign ctermfg=Blue guifg=#15aabf guibg=NONE
|
||||
hi default CocSelectedText ctermfg=Red guifg=#fb4934 guibg=NONE
|
||||
hi default CocCodeLens ctermfg=Gray guifg=#999999 guibg=NONE
|
||||
hi default CocUnderline cterm=underline gui=underline
|
||||
hi default CocBold term=bold cterm=bold gui=bold
|
||||
hi default CocErrorSign ctermfg=Red guifg=#ff0000
|
||||
hi default CocWarningSign ctermfg=Brown guifg=#ff922b
|
||||
hi default CocInfoSign ctermfg=Yellow guifg=#fab005
|
||||
hi default CocHintSign ctermfg=Blue guifg=#15aabf
|
||||
hi default CocSelectedText ctermfg=Red guifg=#fb4934
|
||||
hi default CocCodeLens ctermfg=Gray guifg=#999999
|
||||
hi default CocItalic term=italic cterm=italic gui=italic
|
||||
hi default CocMarkdownLink ctermfg=Blue guifg=#15aabf guibg=NONE
|
||||
hi default link CocMarkdownCode markdownCode
|
||||
hi default link CocMarkdownHeader markdownH1
|
||||
hi default link CocMenuSel PmenuSel
|
||||
hi default link CocErrorFloat CocErrorSign
|
||||
hi default link CocWarningFloat CocWarningSign
|
||||
|
@ -336,6 +360,9 @@ function! s:Hi() abort
|
|||
else
|
||||
hi default link CocFloating Pmenu
|
||||
endif
|
||||
if !exists('*sign_getdefined') || empty(sign_getdefined('CocCurrentLine'))
|
||||
sign define CocCurrentLine linehl=CocMenuSel
|
||||
endif
|
||||
if has('nvim-0.5.0')
|
||||
hi default CocCursorTransparent gui=strikethrough blend=100
|
||||
endif
|
||||
|
@ -376,17 +403,9 @@ function! s:ShowInfo()
|
|||
endif
|
||||
endif
|
||||
" check bundle
|
||||
let file = s:root.'/bin/server.js'
|
||||
if filereadable(file)
|
||||
let file = s:root.'/lib/attach.js'
|
||||
if !filereadable(file)
|
||||
call add(lines, 'Error: javascript bundle not found, please compile the code of coc.nvim.')
|
||||
endif
|
||||
else
|
||||
let file = s:root.'/build/index.js'
|
||||
if !filereadable(file)
|
||||
call add(lines, 'Error: javascript bundle not found, please remove coc.nvim folder and reinstall it.')
|
||||
endif
|
||||
let file = s:root.'/build/index.js'
|
||||
if !filereadable(file)
|
||||
call add(lines, 'Error: javascript bundle not found, please compile code of coc.nvim by esbuild.')
|
||||
endif
|
||||
if !empty(lines)
|
||||
belowright vnew
|
||||
|
@ -412,11 +431,13 @@ command! -nargs=0 CocLocalConfig :call coc#rpc#notify('openLocalConfig', [])
|
|||
command! -nargs=0 CocRestart :call coc#rpc#restart()
|
||||
command! -nargs=0 CocStart :call coc#rpc#start_server()
|
||||
command! -nargs=0 CocRebuild :call coc#util#rebuild()
|
||||
command! -nargs=1 -complete=custom,s:LoadedExtensions CocWatch :call coc#rpc#notify('watchExtension', [<f-args>])
|
||||
command! -nargs=+ -complete=custom,s:SearchOptions CocSearch :call coc#rpc#notify('search', [<f-args>])
|
||||
command! -nargs=+ -complete=custom,s:ExtensionList CocUninstall :call CocActionAsync('uninstallExtension', <f-args>)
|
||||
command! -nargs=* -complete=custom,s:CommandList -range CocCommand :call coc#rpc#notify('runCommand', [<f-args>])
|
||||
command! -nargs=* -complete=custom,coc#list#options CocList :call coc#rpc#notify('openList', [<f-args>])
|
||||
command! -nargs=? -complete=custom,coc#list#names CocListResume :call coc#rpc#notify('listResume', [<f-args>])
|
||||
command! -nargs=0 -complete=custom,coc#list#names CocListCancel :call coc#rpc#notify('listCancel', [])
|
||||
command! -nargs=? -complete=custom,coc#list#names CocPrev :call coc#rpc#notify('listPrev', [<f-args>])
|
||||
command! -nargs=? -complete=custom,coc#list#names CocNext :call coc#rpc#notify('listNext', [<f-args>])
|
||||
command! -nargs=? -complete=custom,coc#list#names CocFirst :call coc#rpc#notify('listFirst', [<f-args>])
|
||||
|
@ -438,7 +459,8 @@ vnoremap <silent> <Plug>(coc-format-selected) :<C-u>call CocActionAs
|
|||
vnoremap <silent> <Plug>(coc-codeaction-selected) :<C-u>call CocActionAsync('codeAction', visualmode())<CR>
|
||||
nnoremap <Plug>(coc-codeaction-selected) :<C-u>set operatorfunc=<SID>CodeActionFromSelected<CR>g@
|
||||
nnoremap <Plug>(coc-codeaction) :<C-u>call CocActionAsync('codeAction', '')<CR>
|
||||
nnoremap <Plug>(coc-codeaction-line) :<C-u>call CocActionAsync('codeAction', 'n')<CR>
|
||||
nnoremap <Plug>(coc-codeaction-line) :<C-u>call CocActionAsync('codeAction', 'line')<CR>
|
||||
nnoremap <Plug>(coc-codeaction-cursor) :<C-u>call CocActionAsync('codeAction', 'cursor')<CR>
|
||||
nnoremap <silent> <Plug>(coc-rename) :<C-u>call CocActionAsync('rename')<CR>
|
||||
nnoremap <silent> <Plug>(coc-format-selected) :<C-u>set operatorfunc=<SID>FormatFromSelected<CR>g@
|
||||
nnoremap <silent> <Plug>(coc-format) :<C-u>call CocActionAsync('format')<CR>
|
||||
|
|
Loading…
Reference in a new issue