Comments (7)
have to use 'zz' to manually center it
Can't reproduce, after jumping, the cursor will be centered. What's your :CocInfo
and try minimal vimrc.
from coc.nvim.
minimal vimrc
let mapleader = "," " use ',' as leader
set nocompatible " set not compatible with vi
" filetype on " set file type detection
" filetype plugin on " set load plugin by file type
set noeb " turn off error syntax prompts
syntax enable " highlight enable
syntax on " highlight auto
set background=dark " set background color
call plug#begin('~/.vim/plugged')
" auto complete
Plug 'neoclide/coc.nvim', {'branch': 'release'}
call plug#end()
" load vim default plugin
runtime macros/matchit.vim
" coc.nvim
let g:coc_disable_startup_warning = 1
inoremap <silent><expr> <TAB>
\ coc#pum#visible() ? coc#pum#next(1):
\ CheckBackspace() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
inoremap <silent><expr><right> coc#pum#visible() ? coc#pum#confirm() : "\<right>"
inoremap <silent><expr><c-p> coc#pum#visible() ? coc#pum#prev(1) : "\<c-[>"
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" coc find define
nmap <leader>u <Plug>(coc-definition)
nmap <leader>U <Plug>(coc-type-definition)
nmap <silent>gd <Plug>(coc-definition)
nmap <silent>gD <Plug>(coc-type-definition)
nmap <silent>gr <Plug>(coc-references)
nmap <silent>gi <Plug>(coc-implementation)
" coc refactor code
nmap <space>r <Plug>(coc-refactor)
nmap <leader>r <Plug>(coc-rename)
" coc find wrong
nmap <silent><F3> <Plug>(coc-diagnostic-prev)
nmap <silent><F4> <Plug>(coc-diagnostic-next)
nmap <silent>[w <Plug>(coc-diagnostic-prev)
nmap <silent>]w <Plug>(coc-diagnostic-next)
nmap <silent>-w <Plug>(coc-fix-current)
nnoremap <silent><nowait>=w :<C-u>CocList --normal diagnostics<cr>
nnoremap <silent><nowait><space>w :<C-u>CocList --normal diagnostics<cr>
" coc text obj
xmap if <Plug>(coc-funcobj-i)
omap if <Plug>(coc-funcobj-i)
xmap af <Plug>(coc-funcobj-a)
omap af <Plug>(coc-funcobj-a)
xmap ic <Plug>(coc-classobj-i)
omap ic <Plug>(coc-classobj-i)
xmap ac <Plug>(coc-classobj-a)
omap ac <Plug>(coc-classobj-a)
" coc code action
nmap <leader>a <Plug>(coc-codeaction)
xmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>l <Plug>(coc-codelens-action)
" coc select range
nmap <silent><leader>s <Plug>(coc-range-select)
xmap <silent><leader>s <Plug>(coc-range-select)
" coc format
command! -nargs=0 Format :call CocActionAsync('format')
command! -nargs=0 Import :call CocActionAsync('runCommand', 'editor.action.organizeImport')
nmap <leader><leader>f :Format<cr>
" coc config
nmap <silent><nowait><space><space>c :CocConfig<cr>
nmap <silent><nowait><space><space>l :CocList --normal extensions<cr>
nmap <silent><nowait><space><space>j :CocList outline<cr>
" coc currnt tag
nnoremap <silent><nowait><space><space>k :echo CocAction('getCurrentFunctionSymbol')<cr>
" coc help
nnoremap <silent> K :call ShowDocumentation()<cr>
nnoremap <silent> gh :call ShowDocumentation()<cr>
code demo
- The following is the example code of go
package demo
import "fmt"
func Example() {
fmt.Println("hello")
}
func main() {
fmt.Println("hello world")
Example()
}
CocInfo
## versions
vim version: NVIM v0.10.0
node version: v22.4.0
coc.nvim version: 0.0.82-c3ae5c3b 2024-05-23 20:39:40 +0800
coc.nvim directory: /Users/chenxuan/.vim/plugged/coc.nvim
term: iTerm.app
platform: darwin
## Log of coc.nvim
2024-07-30T19:30:45.888 INFO (pid:72509) [plugin] - coc.nvim initialized with node: v22.4.0 after 114
2024-07-30T19:30:45.967 INFO (pid:72509) [services] - LanguageClient gopls state change: stopped => starting
2024-07-30T19:30:46.057 INFO (pid:72509) [services] - LanguageClient gopls state change: starting => running
2024-07-30T19:30:46.060 INFO (pid:72509) [services] - service go started
2024-07-30T19:30:52.256 INFO (pid:72509) [attach] - receive notification: showInfo []
coc plug list
Steps to reproduce
- Install a specific version of the plugin
- Edit this go file
- Move the cursor to the example function in the underlying main function
- Move to this function and find that it is not automatically centered
video
Jietu20240730-194148-HD.mp4
from coc.nvim.
Sorry I still can't reproduce this, here's my tests.
set nocompatible
set runtimepath^=~/.local/share/nvim/plugged/coc.nvim
set hidden
set noexpandtab
filetype plugin indent on
syntax on
nmap <silent> gd <Plug>(coc-definition)
Tested with same coc.nvim release with coc-go, gd
on Example
in main function, will jump to Example function and centered.
from coc.nvim.
Jietu20240731-131919-HD.mp4
I used the script you provided and retested it and found that it still cannot be centered correctly. Why is this? Do you need me to provide more information? I am using a Mac laptop with an M1 chip and using nvim
from coc.nvim.
Tested with M1 as well, still debugging this issue.
from coc.nvim.
coc.nvim didn't call zz
after jumping, the cursor sometimes was centered but not always.
No plan to center the cursor after jumping, use zz
manually.
from coc.nvim.
Well, is there a way to automatically jump to the middle through configuration? I tried nmap <silent>gd <Plug>(coc-definition)zz
, but because it seems to be asynchronous, the cursor often jumps to the middle.
from coc.nvim.
Related Issues (20)
- Remove ansi escape sequence from code lens HOT 2
- New configuration like VSCode's editor.defaultFormatter HOT 9
- Open coclist diagnostics in a split pane HOT 3
- Change background color of floating windows
- `"diagnostic.separateRelatedInformationAsDiagnostics"` makes everything of customized typescript LS super lag in the file with lots of diagnostics HOT 3
- Text edits with the same start position are applied in reverse HOT 4
- cant jump to next parameter HOT 1
- using TAB for completion failed in local variable completion, when using vim with godot LSP HOT 5
- Why does it not work to use <c-space> to refresh in vim? HOT 1
- [Feature Request] Call custom function when navigating the CocList HOT 6
- what is `menu` in `suggest.formatItems` ? HOT 1
- New command named CocStop HOT 5
- Unhandled Rejection Error: "Can't find directory 'list:' in cdpath" when Using :CocList Commands HOT 5
- CocActionAsync('format') for python file HOT 6
- [Bug] Cursor position ignored during code actions that insert or edit workspace HOT 1
- watchman cannot start: path is too long HOT 10
- Can I set a separate background color for the coc error floating window? HOT 2
- toggleCodeLens only works when codeLens.enable is set to true HOT 1
- Allow for dynamic resolve of languageId value
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from coc.nvim.