auto-save.nvim icon indicating copy to clipboard operation
auto-save.nvim copied to clipboard

Error with colors.lua

Open SymphonySimper opened this issue 2 years ago • 13 comments

Error detected while processing VimEnter Autocommands for "*":
Error executing lua callback: ...cker/start/auto-save.nvim/lua/auto-save/utils/colors.lua:6: bad argument #1 to 'lower' (string expected, got nil)
stack traceback:
        [C]: in function 'lower'
        ...cker/start/auto-save.nvim/lua/auto-save/utils/colors.lua:6: in function 'hex_to_rgb'
        ...cker/start/auto-save.nvim/lua/auto-save/utils/colors.lua:51: in function 'darken'
        .../pack/packer/start/auto-save.nvim/lua/auto-save/init.lua:112: in function <.../pack/packer/start/auto-save.nvim/lua/auto-save/init.lua:106>

Here is my config

local autosave = require("auto-save")

autosave.setup({
	enabled = true,
	execution_message = {
		cleaning_interval = 1000,
	},
	trigger_events = { "InsertLeave", "TextChanged" },
	write_all_buffers = true,
	debounce_delay = 135,
})

Here is my nvim config For my color scheme I use a modified base16 scheme (original | my scheme)

SymphonySimper avatar Jul 31 '22 13:07 SymphonySimper

Yup same issue with me....

mas-wig avatar Jul 31 '22 16:07 mas-wig

Same issue!

coder3101 avatar Jul 31 '22 16:07 coder3101

Same issue here, I have pin-pointed the issue to this line.

I have found that parameter bg can be nil, but apprently, neither blend or hex_to_rgb in that file check the validity of parameters.

jdhao avatar Jul 31 '22 17:07 jdhao

I suggest the author focus more on the quality than excessive refactoring without any kind of check.

jdhao avatar Jul 31 '22 17:07 jdhao

@jdhao I did check, I always test things locally before pushing (i.e. adding the repo nvim's runtime path to test my changes).

Everything was working fine on mind.

pocco81 avatar Jul 31 '22 17:07 pocco81

@SymphonySimper I'll fix it :)

pocco81 avatar Jul 31 '22 17:07 pocco81

@Pocco81 Thank you for being responsive! We appreciate your time and energy in maintaining and continuous improvement on this project:) I'll eagerly wait for the fix

kohane27 avatar Aug 01 '22 04:08 kohane27

same error

Error executing lua callback: .../paqs/start/autosave.nvim/lua/auto-save/utils/colors.lua:6: bad argument #1 to 'lower' (string expected, got nil)
stack traceback:
        [C]: in function 'lower'
        .../paqs/start/autosave.nvim/lua/auto-save/utils/colors.lua:6: in function 'hex_to_rgb'
        .../paqs/start/autosave.nvim/lua/auto-save/utils/colors.lua:51: in function 'darken'
        ...ite/pack/paqs/start/autosave.nvim/lua/auto-save/init.lua:112: in function <...ite/pack/paqs/start/autosave.nvim/lua/auto-save/init.lua:106>

dn-kolesnikov avatar Aug 01 '22 06:08 dn-kolesnikov

Same here~

LintaoAmons avatar Aug 02 '22 07:08 LintaoAmons

Hi, for those who want a workaround here is how I fixed it (I did not tried to understand the source code and only wanted to make the error disappear).

Edit the colors.lua file, for example in nvim :e ~/.local/share/nvim/site/pack/packer/start/auto-save.nvim/lua/auto-save/utils/colors.lua.

Then simply add the following after the local M = {} declaration.

M.bg = "#ffffff"
M.fg = "#ffffff"

bgaillard avatar Aug 03 '22 12:08 bgaillard

Please everyone interested in the fix test the latest commits pushed to the dev branch.

Also, just to clarify what's been happening:

the problem is with the dim functionality that I added to the plugin after the rewrite. This feature dims the color of the autosave text to make it less visually obtrusive (since you'll be seeing this a lot). For example, by setting execution_message = { dim = 0.50 } you'll get:

image

This feature can be completely disabled by setting dim = 0 (this will also make the issue on matter disappear, but please! try the latest fix and let me know if it works. I think it's a really neat feature to have :)

Current solution

The patches I pushed to the dev branch are working for me (tested both with a precompiled colorscheme and a normal one by running autosave at startup and by just adding it to nvim's runtime).

Let me know if they work for you! If not then I have 3 other solutions I can test out.

pocco81 avatar Aug 03 '22 13:08 pocco81

I'm still getting the exact same error

Error executing vim.schedule lua callback: ...cker/start/auto-save.nvim/lua/auto-save/utils/colors.lua:6: bad argument #1 to 'lower' (string expected, got nil)
stack traceback:
        [C]: in function 'lower'
        ...cker/start/auto-save.nvim/lua/auto-save/utils/colors.lua:6: in function 'hex_to_rgb'
        ...cker/start/auto-save.nvim/lua/auto-save/utils/colors.lua:51: in function 'darken'
        .../pack/packer/start/auto-save.nvim/lua/auto-save/init.lua:114: in function <.../pack/packer/start/auto-save.nvim/lua/auto-save/init.lua:108>

Setting dim = 0 doesn't seem to work either

local autosave = require("auto-save")

autosave.setup({
	enabled = true,
	execution_message = {
		cleaning_interval = 1000,
		dim = 0,
	},
	trigger_events = { "InsertLeave", "TextChanged" },
	write_all_buffers = true,
	debounce_delay = 135,
})

Packer config

use({ "Pocco81/auto-save.nvim", branch = "dev" })

SymphonySimper avatar Aug 03 '22 14:08 SymphonySimper

@SymphonySimper I'm gonna try with your conf.

pocco81 avatar Aug 03 '22 15:08 pocco81

我仍然收到完全相同的错误

Error executing vim.schedule lua callback: ...cker/start/auto-save.nvim/lua/auto-save/utils/colors.lua:6: bad argument #1 to 'lower' (string expected, got nil)
stack traceback:
        [C]: in function 'lower'
        ...cker/start/auto-save.nvim/lua/auto-save/utils/colors.lua:6: in function 'hex_to_rgb'
        ...cker/start/auto-save.nvim/lua/auto-save/utils/colors.lua:51: in function 'darken'
        .../pack/packer/start/auto-save.nvim/lua/auto-save/init.lua:114: in function <.../pack/packer/start/auto-save.nvim/lua/auto-save/init.lua:108>

设置 dim = 0 似乎也不起作用

local autosave = require("auto-save")

autosave.setup({
	enabled = true,
	execution_message = {
		cleaning_interval = 1000,
		dim = 0,
	},
	trigger_events = { "InsertLeave", "TextChanged" },
	write_all_buffers = true,
	debounce_delay = 135,
})

打包程序配置

use({ "Pocco81/auto-save.nvim", branch = "dev" })

I tried to set dim = 0 in source code. After that, auto-save didn't throw any errors. From my perspective, auto-save is run after users require it, but it was using the default configurations, dim = 0.18. Because setup works after the plugin runs.

XXiaoA avatar Aug 04 '22 08:08 XXiaoA

Adding that I have this issue as well.

rockorager avatar Aug 06 '22 14:08 rockorager

Adding that I have this issue as well.

You could try my PR, and then set dim = 0. I think it will be useful

XXiaoA avatar Aug 06 '22 15:08 XXiaoA

Adding that I have this issue as well.

You could try my PR, and then set dim = 0. I think it will be useful

Hmm, strangely your PR doesn't fix it for me, even with setting dim = 0.

EDIT: Nevermind, it did! I hadn't updated require("autosave") to require("auto-save") yet

rockorager avatar Aug 06 '22 16:08 rockorager

I am just wondering how long until this is fixed? 🤔

coder3101 avatar Aug 06 '22 16:08 coder3101

Found the issue, will fire a PR once I understand how dim is supposed to work :P

kilpkonn avatar Aug 06 '22 18:08 kilpkonn

@coder3101 how about now? :)

pocco81 avatar Aug 06 '22 18:08 pocco81

@coder3101 how about now? :)

Still happens for me. :( I've opened PR against your dev branch with a fix that works for me, hope you can check it out

kilpkonn avatar Aug 06 '22 19:08 kilpkonn

In case anyone was curious, setting dim = 0 removes any errors and allows auto-save to run as usual on my end (using the master branch, re-installed the plugin just now).

turibiusrozario avatar Aug 06 '22 21:08 turibiusrozario

The error has gone away. But I got another error: (I use nvim 0.7)

Error executing vim.schedule lua callback: ...share/nvim/plugged/auto-save.nvim/lua/auto-save/init.lua:111: attempt to compare number with nil stack traceback: ...share/nvim/plugged/auto-save.nvim/lua/auto-save/init.lua:111: in function <...share/nvim/plugged/auto-save.nvim/lua/auto-save/init.lua:110>

arturo-salinas avatar Aug 09 '22 07:08 arturo-salinas

2022-08-09-16-37-44

I'm having the same issue as well.

kohane27 avatar Aug 09 '22 08:08 kohane27

@arturo-salinas and @kohane27 may I see your auto-save confs?

pocco81 avatar Aug 09 '22 13:08 pocco81

lua << EOF local autosave = require("auto-save")

autosave.setup( { enabled = true, execution_message = "AutoSave: saved at " .. vim.fn.strftime("%H:%M:%S"), events = {"InsertLeave", "TextChanged"}, conditions = { exists = true, filename_is_not = {}, filetype_is_not = {}, modifiable = true }, write_all_buffers = false, on_off_commands = true, clean_command_line_interval = 0, debounce_delay = 135 } ) EOF

arturo-salinas avatar Aug 09 '22 20:08 arturo-salinas

autosave.setup({
  enabled = false,
  execution_message = "",
  events = { "InsertLeave", "TextChanged" },
  conditions = {
    exists = true,
    filename_is_not = { "packer_init.lua" },
    filetype_is_not = {
      "lua",
      "javascript",
      "typescript",
      "javascriptreact",
      "typescriptreact",
      "tsx",
      "jsx",
      "svelte",
      "vue",
    },
    modifiable = true,
  },
  write_all_buffers = false,
  on_off_commands = false,
  clean_command_line_interval = 0,
  debounce_delay = 170,
})

My bad. I didn't realize that there's breaking changes in the config setup (#43). Once I just used autosave.setup({}) autosave works perfectly. Thank you again for creating and maintaining auto-save!

kohane27 avatar Aug 10 '22 00:08 kohane27

No problem @kohane27 :)

And for @arturo-salinas, please don't forget to check the default config. The execution_message setting receives a table not a string.

pocco81 avatar Aug 10 '22 11:08 pocco81

yes! I do not have any problem now. Thank you!

arturo-salinas avatar Aug 10 '22 22:08 arturo-salinas