Git Product home page Git Product logo

Comments (7)

Bekaboo avatar Bekaboo commented on June 25, 2024

Hi, thanks for reporting this issue. Unfortunately I cannot reproduce this bug.

The following is the behavior of this plugin under normal mode, is this what you expected? If not, please provide the minimal config that can reproduce this bug and screen recording:

simplescreenrecorder-2023-03-31_09.49.22.mp4

from deadcolumn.nvim.

ribru17 avatar ribru17 commented on June 25, 2024

Should've mentioned that this bug doesn't occur when using $ to set cursor to last column of the line, sorry. Here's a demo with MRE.
https://user-images.githubusercontent.com/55766287/229184947-2f1b1f2c-26ac-4b12-b726-340f4b551901.mp4

-- ~/.config/nvim/init.lua
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    "--branch=stable", -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)

-- load installed plugins and their configurations
require("lazy").setup("plugins", {
  performance = {
    cache = {
      enabled = true,
    },
    reset_packpath = true,
    rtp = {
      reset = true,
      disabled_plugins = {
        "gzip",
        "matchit",
        "matchparen",
        "netrwPlugin",
        "tarPlugin",
        "tohtml",
        "tutor",
        "zipPlugin",
      },
    },
  },
})
-- ~/.config/nvim/lua/plugins/ui.lua
return {
  {
    'Bekaboo/deadcolumn.nvim',
    event = { 'BufReadPre', 'BufNewFile' },
    opts = {
      blending = {
        threshold = 0.75,
      },
      warning = {
        colorcode = '#ED8796',
      }
    }
  }
}

from deadcolumn.nvim.

ribru17 avatar ribru17 commented on June 25, 2024

I found a naive solution which is to remove the WinScrolled and CursorMoved events from the redraw_colorcolumn autocmd (this function somehow causes the editor to forget the cursor position) but I don't think this should be an accepted solution because it will of course break the plugin for users that want the color column to show in the normal mode scope. I think some vim api function is causing this breakage perhaps but I don't know which.

from deadcolumn.nvim.

Bekaboo avatar Bekaboo commented on June 25, 2024

Good catch, but the real problem here is not vim api functions, it is setting vim.wo.cc that make neovim forget the cursor position. If you comment out all commands that set vim.wo.cc in function redraw_colorcolumn, the bug disappears, but that is not what we want. I think it is a neovim issue and not related to this plugin.

The reason why I conclude the problem comes from option setting is that if you open neovim with nvim --clean somefile, first put your cursor at column, say, 10, then moves up and down, you can observe that the position is memorized; but if you put the cursor on an empty line then set an option in cmdline, for example, :set cc=30 or :set tw=79, the cursor position will be lost.

This is beyond deadcolumn.nvim and I don't think there is an easy fix to this, maybe we should report it to neovim. PR is welcome.

from deadcolumn.nvim.

ribru17 avatar ribru17 commented on June 25, 2024

Interesting, thanks for the response and quick fix. I also noticed that this can be fixed by saving and restoring the window state. I tested both methods and I think with this way the cursor is always saved even when switching tabs or buffers for example, which will cause the cursor to reset with the current fix. But definitely not a big issue as the main problem is largely fixed. Still, if you're interested I will link the change and up to you if you want to do anything with this, thanks again:
ribru17@7eca7b1

from deadcolumn.nvim.

Bekaboo avatar Bekaboo commented on June 25, 2024

Seems that it is a better solution, please make a PR and I will be happy to accept it.

PS: is it still necessary to check vim.wo.cc before setting it given that we now have winsaveview()? Haven't tested myself.

from deadcolumn.nvim.

ribru17 avatar ribru17 commented on June 25, 2024

Sounds good, I'll make a PR very soon, going to eat now. And I'm not sure: I'll test that as well. As of now I don't know anything about vim.wo.cc to tell you the truth.

from deadcolumn.nvim.

Related Issues (17)

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.