Giter VIP home page Giter VIP logo

deadcolumn.nvim's Introduction

Bekaboo's GitHub stats

Top Langs

deadcolumn.nvim's People

Contributors

bekaboo avatar github-actions[bot] avatar ntbbloodbath avatar ribru17 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

deadcolumn.nvim's Issues

Repect

can shihua gg teach me how to install linux and use nvim?

Plugin doesn't work out of the box

Hi, thanks for working on this cool plugin. I decided to give it a try, because it seemed to have the most features, but can't make it work, even in vanilla vim.

repro.lua:

local root = vim.fn.fnamemodify("./.repro", ":p")
for _, name in ipairs({ "config", "data", "state", "cache" }) do
    vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
local lazypath = root .. "/plugins/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", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

local plugins = {
    -- "Bekaboo/deadcolumn.nvim"
}

require("lazy").setup(plugins, {
    root = root .. "/plugins",
})

vim.cmd[[hi ColorColumn guibg=red]]
vim.cmd[[set textwidth=20]]
vim.cmd[[set colorcolumn=-10,25,+2]]

When I run nvim -u repro.lua test.txt, it works as expected

image

but when I uncomment the line with the plugin, install it and start typing, nothing happens

image

Cursor Losing Column Position Issue in Nightly Version

Firstly, I want to express my sincere thanks for this plugin.

Description:
I've encountered an issue where the cursor loses its column position when scrolling down with the plugin active. This problem persists in nightly builds (I've tried multiple recent versions), but it doesn't occur in stable builds.

While I understand nightly builds may have issues, I wanted to report this problem for consideration.

To Reproduce:

  1. Open a Lua file filled with long lines (exceeding 80 columns).
  2. Start editing the file.
  3. Scroll down using the 'j' key down a long line, and the cursor will lose its position and jump to column 0.
Code to Reproduce
mkdir ~/.config/testcolumn
cd ~/.config/testcolumn
touch init.lua
NVIM_APPNAME=testcolumn nvim

init.lua file

vim.opt.number = true
vim.opt.relativenumber = true

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",
		lazypath,
	})
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup({
	"Bekaboo/deadcolumn.nvim",
	event = { "InsertEnter" },
	config = function()
		vim.opt.colorcolumn = "80"
		local opts = {
			modes = { "n", "i" },
			blending = {
				threshold = 0.75,
			},
			warning = {
				alpha = 0.1,
			},
		}
		require("deadcolumn").setup(opts)
	end,
})

The video demonstrates that the issue does not exist before activating the plugin. However, after inserting and saving the file, the problem occurs when scrolling down a long line.
Video:

Kapture.2024-02-13.at.11.03.30.mp4

OS: MacOS
term: wezterm
neovim version:

NVIM v0.10.0-dev-2355+g1c7b0b9d5
Build type: RelWithDebInfo
LuaJIT 2.1.1707061634

Thank you

Feature request: allow text on the column

It looks like the way you use columns is that the text must finish before the column. I like to allow text on the column but not beyond it. Do you think there could be an option to allow text on the column?

Feature request: show column as usual when it would otherwise not show

Thanks for writing and releasing deadcolumn. I have a feature request if it fits in with your plans.

I like the concept of deadcolumn but I want to see the columns permanently. Do you think there could be an option such that when the columns aren't currently shown they could be shown is the default fashion?

[Bug] deadcolumn works only in the first file

Hi, thanks for this nice plugin.

Describe the bug

  • Context

    When I open a file, it just works. But after moving to other files (eg. when opening multiple files, moving to a definition of a function in another file, etc.) it doesn't work in them. It works again when I come back to the first one.

  • Expected behavior

    I expect it to work on any file, regardless of the number or sequence of file opens.

  • Actual behavior

    It works only in the first file.

To Reproduce

  • Minimal init.lua

    -- Lazy
    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)
    require'lazy'.setup({
      { 'Bekaboo/deadcolumn.nvim' },
    }, {})
    
    -- options
    local opt = vim.opt
    opt.colorcolumn = '80'
    opt.termguicolors = true
  • Steps to reproduce the behavior

    1. Save the above config as minimal.lua
    2. Start Neovim using nvim --clean -u minimal.lua
    3. Open multiple files and check if it works in them.

Environment

  • Neovim version: NVIM v0.9.0-dev-1338+g9e7426718

  • Operating system: Ubuntu 22.04

Additional context

Add any other context about the problem here.

Horizontal cursor position clobbered

Hi and thanks for the great plugin! One small bug I noticed: when using this plugin, my horizontal cursor position is not saved in normal mode, same problem found here or here. I really like this plugin but this issue bugs me so hopefully it can be fixed, thank you!! (P.S. when disabling the plugin, horizontal cursor position is again saved correctly)

Setup error

I get the following error, when scope and modes are setup, and theme is changed programatically afterwards:

Error detected while processing ./minimal.lua:
E5113: Error while calling lua chunk: ./minimal.lua:28: /Users/simon.mandlik/Downloads/test_deadcolumn/minimal.lua..ColorScheme Autocommands for "*": Vim(append):Erro
r executing lua callback: ...column/.repro/plugins/deadcolumn.nvim/lua/deadcolumn.lua:154: bad argument #1 to 'scope' (number expected, got no value)
stack traceback:
        [C]: in function 'scope'
        ...column/.repro/plugins/deadcolumn.nvim/lua/deadcolumn.lua:154: in function <...column/.repro/plugins/deadcolumn.nvim/lua/deadcolumn.lua:140>
        [C]: in function 'nvim_command'
        ./minimal.lua:28: in main chunk
stack traceback:
        [C]: in function 'nvim_command'
        ./minimal.lua:28: in main chunk

minimal.lua:

local root = vim.fn.fnamemodify("./.repro", ":p")
for _, name in ipairs({ "config", "data", "state", "cache" }) do
    vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
local lazypath = root .. "/plugins/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", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

local plugins = {
    "Bekaboo/deadcolumn.nvim",
    opts = {
        scope = "buffer",
        modes = function(mode)
            return mode:find('^[nictRss\x13]') ~= nil
        end,
    }
}

vim.cmd[[set termguicolors]]
vim.cmd[[set colorcolumn=20]]

require("lazy").setup(plugins, {
    root = root .. "/plugins",
})

vim.api.nvim_command("colorscheme default")

How exactly blending works?

Hi, I wanted to achieve a simple colorcolumn, that would behave like vanilla colorcolumn, but would start appearing once the cursor is getting closer to it.

What I need from deadcolumn is to show "standard" colorcolumn when the text is longer than textwidth, and only slowly "fade in" and "fade out".

But I can't even make colorcolumn have the same background color as ColorColumn highlight group.

This is my minimal.lua:

local root = vim.fn.fnamemodify("./.repro", ":p")
for _, name in ipairs({ "config", "data", "state", "cache" }) do
    vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
local lazypath = root .. "/plugins/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", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

local plugins = {
    {
        "Bekaboo/deadcolumn.nvim",
        init = function()
            require('deadcolumn').setup {
                blend = { hlgroup = { "ColorColumn", "bg" }, },
                warning = { hlgroup = { "ColorColumn", "bg" }, },
            }
        end
    }
}

require("lazy").setup(plugins, {
    root = root .. "/plugins",
})

vim.cmd[[set termguicolors]]
vim.cmd[[hi ColorColumn guibg=blue]]
vim.cmd[[set colorcolumn=20]]

And this is the behavior:

deadcolumn_2.mov

Color column has red color instead of blue, and once the text length exceeds the column, it turns into brown.

Can I somehow make the colorcolumn have the same color as the ColorColumn highlight group and basically "turn off" the warning functionality, only display fully opaque color column?

Thanks!

Adjust behavior based on modes

I wanted to change behavior to be more proactive at alerting me to long lines of code. So my current setup is:

require('deadcolumn').setup{
  scope = 'visible',
  modes = { "n", "i", "ic", "ix", "R", "Rc", "Rx", "Rv", "Rvc", "Rvx" }
}

I changed scope to visible to widen the scope.
I added n for normal mode so deadcolumn is shown in normal mode, which is a bit spicy.

I think something nice that would make it a little bit less spicy is if I could e.g. change the threshold for normal mode, and only make deadcolumn appear if a line is longer than the limit, just in normal mode.

This plugin doesn't work sometimes

Sorry for the low-quality bug report, but sometimes this plugin just... doesn't work. I enter insert mode and see no color column, despite there being a long line visible on my screen (I'm using scope 'visible'). Restarting vim fixes the issue.

I peeked at the implementation, and I see it's incredibly involved and complicated. So thanks for packaging this up into a plugin and trying to maintain all of the complexity behind an interface, but unfortunately, it seems something so far was missed.

Has anyone else experienced this issue? I'm afraid I don't have a reliable repro.

Normal mode when used with scope buffer works but throws below error while opening a file!

It throws below error:
Error detected while processing /Users/username/.config/nvim/init.lua:
E5113: Error while calling lua chunk: vim/_editor.lua:0: /Users/username/.config/nvim/init.lua..nvim_exec2() called at /Users/username/.config/nvim/init.lua:0..ColorScheme Autocommands for "*": Vim(append):Error executing lua callback: ...re/nvim/lazy/deadcolumn.nvim/lua/deadcolumn/autocmds.lua:73: bad argument 1 to '?' (number expected, got no value)
stack traceback:
[builtin#61]: at 0x0103a18aa4
...re/nvim/lazy/deadcolumn.nvim/lua/deadcolumn/autocmds.lua:73: in function <...re/nvim/lazy/deadcolumn.nvim/lua/deadcolumn/autocmds.lua:58>
[C]: in function 'nvim_exec2'
vim/_editor.lua: in function 'cmd'
/Users/username/.config/nvim/init.lua:57: in main chunk
stack traceback:
[C]: in function 'nvim_exec2'
vim/_editor.lua: in function 'cmd'
/Users/username/.config/nvim/init.lua:57: in main chunk
Press ENTER or type command to continue

Always show colorcolumn if a line crosses it

This plugin works really freaking well, I'm always a fan of reducing visual noise, but one this I miss is that I can no longer tell of a line in the current view crosses the column.

If I set scope to "visible", then the point of the plugin is largely lost, I don't want to see the colorcolumn as long as nothing crosses it.

What would be perfect is if the plugin did exactly what it currently does, but if a currently visible line crosses the colorcolumn, it should be displayed no matter what.

Unless I've misunderstood the documentation, this isn't currently possible. Is there a elegant way this can be implemented?


Maybe something like:

warningscope = "buffer" | "visible"

Works like scope, but overrides it if a line actually crosses the colorcolumn. My ideal behavior would be scope = "line" and warningscope = "visible". I would also probably like warningscope = "buffer" so I would immediately know if any line in the current file was too long.

Errors on colors.lua:41: invalid key: create

After upgrading my nvim packages, I got this:

Error detected while processing /home/mort/.config/nvim/init.lua:
E5113: Error while calling lua chunk: /home/mort/.config/nvim/lua/theme.lua:3: /home/mort/.config/nvim/init.lua..ColorScheme Autocommands for "*": Vim(append):Error executing lua callback:
...hare/nvim/lazy/deadcolumn.nvim/lua/deadcolumn/colors.lua:41: invalid key: create
stack traceback:
        [C]: in function 'nvim_get_hl'
        ...hare/nvim/lazy/deadcolumn.nvim/lua/deadcolumn/colors.lua:41: in function 'get'
        ...local/share/nvim/lazy/deadcolumn.nvim/lua/deadcolumn.lua:17: in function 'get_hl_hex'
        ...local/share/nvim/lazy/deadcolumn.nvim/lua/deadcolumn.lua:24: in function <...local/share/nvim/lazy/deadcolumn.nvim/lua/deadcolumn.lua:23>
        [C]: in function 'colorscheme'
        /home/mort/.config/nvim/lua/theme.lua:3: in main chunk
        [C]: in function 'require'
        /home/mort/.config/nvim/init.lua:8: in main chunk
stack traceback:
        [C]: in function 'colorscheme'
        /home/mort/.config/nvim/lua/theme.lua:3: in main chunk
        [C]: in function 'require'
        /home/mort/.config/nvim/init.lua:8: in main chunk

Just installing the package without any config.

My system:

NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1693350652

Setting winhighlight conflicts with other plugins

In a nutshell winhighlight conflicts with vim.api.nvim_win_set_hl_ns. The documentation says that either way of setting highlights takes precedence over another way. In practice, it means that if a highlight is set by winhighlight, it completely disables all highlights that were set by nvim_win_set_hl_ns.

winhighlight help
					*'winhighlight'* *'winhl'*
'winhighlight' 'winhl'	string	(default "")
			local to window
	Window-local highlights.  Comma-delimited list of highlight
	|group-name| pairs "{hl-from}:{hl-to},..." where each {hl-from} is
	a |highlight-groups| item to be overridden by {hl-to} group in
	the window.

	Note: highlight namespaces take precedence over 'winhighlight'.
	See |nvim_win_set_hl_ns()| and |nvim_set_hl()|.
nvim_win_set_hl_ns help
nvim_win_set_hl_ns({window}, {ns_id})                   *nvim_win_set_hl_ns()*
    Set highlight namespace for a window. This will use highlights defined
    with |nvim_set_hl()| for this namespace, but fall back to global
    highlights (ns=0) when missing.

    This takes precedence over the 'winhighlight' option.

    Parameters: ~
      • {ns_id}  the namespace to use

Snippet to test:

local ns = vim.api.nvim_create_namespace("UserTestHighlight")
vim.api.nvim_set_hl(ns, "Function", { fg = "#00FF66" })

vim.keymap.set("n", "<C-w>", function()
  vim.api.nvim_win_set_hl_ns(0, ns)
end)

vim.api.nvim_create_autocmd({ 'CursorMoved', 'TextChanged', }, {
  callback = function()
    vim.wo[0].winhl = "String:"
  end
})
issue.mp4

ccc.nvim is one of the plugin that is in conflict with the current plugin.

I think that sticking to the lua api is a good way to solve the problem

Plugin un-setting colorcolumn setting

I have the setting vim.o.colorcolumn = '100', which normally works and sets the value.

When running the plugin with lazy.nvim, and then running :set colorcolumn? to verify the value, the setting appears empty. Setting the value to 100 in the buffer makes the plugin work normally afterwards.

Uninstalling and then verifying the value of the setting, the setting has the correct value.

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.