kkklk
V2EX  ›  Python

nvim 怎么设置跳转的光标的位置

By kkklk at 2025 年 3 月 18 日 · 2199 次点击
用 lsp 时 gd 跳转到函数定义处,默认光标都会在屏幕中间,怎么配置它的偏移?让光标出现在屏幕的三分之二位置
2 条回复  •  2025-03-18 15:15:35 +08:00
pooorguy
   1
pooorguy  
   2025 年 3 月 18 日 via Android
vim.lsp.buf.definition 后面跟个 nvim_win_set_cursor()
kkklk
   2
kkklk  
OP
   2025 年 3 月 18 日
@pooorguy 好像这样需要跳转两次吧?
内容好像不会跟着移动
而且 lsp 的快捷键好多快捷键,每个都需要这样配好像挺麻烦的

我的需求是这样的:
默认光标都会在屏幕中间,跳转后函数定义也是从中间开始往下展开的,
这样看不到函数的整体内容,每次跳转后我都需要按一下 ctrl d 移动一下,
还要往上调一点点,这样才能看到函数名和更多的函数内容,
我想尽可能看到更多的内容,因为上半部分很多东西都不需要看到
推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
© 2026 V2EX · 20ms · 3.9.8.5