Comments (4)
Thanks a lot for your prompt response.
Here is how the function changes if anyone else decides to use it:
let cur_top = line('w0') + &scrolloff
let target_top = line('.')
let context_height = -1
if match(&runtimepath, 'context\.vim') != -1
let [_, context_height] = context#context#get(context#line#get_base_line(line('.')))
endif
let num_down = l:target_top - l:cur_top - (l:context_height + 1)
from context.vim.
Hey! You should be able to call context#context#get()
:
https://github.com/wellle/context.vim/blob/c06541451aa94957c1c07a9f8a7130ad97d83a65/autoload/context/context.vim#LL14C1-L14C1
For example you could try something like this:
let base_line = context#line#get_base_line(line_number)
let [_, context_height] = context#context#get(base_line)
from context.vim.
I'm the maintainer of vim-smooth-scroll that MahdiNazemi has referred to.
First off, let me say that I think context.vim is very cool. This is my first experience with it. Kudos!
Mahdi has suggested that I add code to my plugin to make it compatible with context.vim. I think this is possible, but I'm not sure it's a good idea. While it would work, it seems that every plugin that does math on the height of the window would need to be compatible with context and all other plugins that fake the top of the current buffer with a line. Seems like a bit of a slippery slope into difficult-to-maintain plugins. I'm leaning towards telling him that he can maintain a fork of my plugin that is compatible with context.vim.
On the other hand, I'd like for context to be compatible with my version of smooth_scroll in some way. I imagine that the right way to do this is for neovim the display code that you have implemented in your plugin and have an API that all plugins could use that would dynamically adjust the height of the preview/context area. This would limit the coupling between plugins. That said, I'm sure that's a big ask.
As a simpler solution, I have been looking at the context presenters to see if there is a simple one that could be enabled that would enable both plugins to be used as is with a less sexy display. I see that there is a popup, preview and nvim_float presenter. I intuitively thought that preview would use the preview window, a proper vim window. However, when I try it, it seems to work the same as nvim_float. When I try popup with Vim 9, it also show the context in the same manner. Using the combination of neovim and popup, I get this error:
Using popup vim
Error detected while processing CursorMoved Autocommands for "*"..function context#update[87]..context#popup#update_context[10]..<SNR>103_show[22]..<SNR>103_open[5]..context#popup#vim#open:
line 5:
E117: Unknown function: popup_create
What am I missing? Is there a context_presenter value that will show the context in a separate proper Vim window?
from context.vim.
Hey, thanks for reaching out!
I just tried with Neovim v0.8.2 and Vim 9.0 and was able to use
let g:context_presenter = 'preview'
It looks the same as the floating/popup windows, so it can be hard to notice what's being used. In order to test if preview windows are being used, type C-WC-W. If the preview window is being used you will be able to switch your cursor to it. If it's a floating/popup window you won't.
Hope that helps!
from context.vim.
Related Issues (20)
- Doesn't work on windows vim 8.2 HOT 2
- Plugin breaks vim's visual-block append. HOT 2
- remove <context.vim> in the upper right corner HOT 3
- Can't install with Pathogen HOT 2
- 【E28 No highlight group name:Comment】
- Auto commands are not disabled by g:context_filetype_blacklist
- Support getting context of topmost line (regardless of cursor position) HOT 1
- Slow scrolling in perl files HOT 5
- Add name to filetype so it can be ignored by other plugins more easily
- Bug: When in select/selection mode it will jump back into normal mode
- Opens a [Scratch] window when using CtrlP or NerdTree
- stray background text not painted over in the context window when scrolling with Ctrl+D
- Context doesn't update when switching buffers with fzf.vim HOT 1
- [Question] is there a way to show a "header" when the matched line is a single `{`
- Feature request: syntax highlighting in context lines
- refreshing the file with `:e` raises error in file with modeline
- context.vim doesn't play nice with coc diagnostic window HOT 1
- Conflict with nvim-notify
- C preprocessor handling
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 context.vim.