Code Monkey home page Code Monkey logo

Comments (4)

MahdiNazemi avatar MahdiNazemi commented on June 1, 2024 1

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.

wellle avatar wellle commented on June 1, 2024

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.

cskeeters avatar cskeeters commented on June 1, 2024

@wellle,

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.

wellle avatar wellle commented on June 1, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.