mrjones2014 / legendary.nvim

🗺️ A legend for your keymaps, commands, and autocmds, integrates with which-key.nvim, lazy.nvim, and more.
MIT License
1.1k stars 19 forks source link

[Bug]: sqlite error when description contains `'` #472

Closed gbcreation closed 6 days ago

gbcreation commented 1 week ago

Similar Issues

Neovim Version

NVIM v0.10.1
Build type: Release
LuaJIT 2.1.1723675123

Steps to Reproduce

Configure the nvim-surround plugin with Lazy.nvim like this:

return {
    'kylechui/nvim-surround',
    version = "*", -- Use for stability; omit to use `main` branch for the latest features
    keys = {
        { "<leader>'", '<Cmd>normal cs"\'<CR>', desc = 'Change surrounding " to \'' },
        { '<leader>"', '<Cmd>normal cs\'"<CR>', desc = 'Change surrounding \' to "' },
    },
    config = function ()
        require('nvim-surround').setup({ })
    end
}

The lazy_nvim extension and the frecency sorting enabled.

Expected Behavior

No error when selecting the keymaps in the Legendary list.

Actual Behavior

The following error occurs:

Error executing vim.schedule lua callback: ...erts/.local/share/nvim/lazy/sqlite.lua/lua/sqlite/db.lua:223: ...ts/.local/share/nvim/lazy/sqlite.lua/lua/sqlite/stmt.lua:35: sqlite.lua: sql stat
ement parse, , stmt: `select * from item_count where item_id = "'Change surrounding " to \''"`, err: `(`near "to": syntax error`)`

Minimal Configuration to Reproduce

local root = vim.fn.fnamemodify('./.repro', ':p')

-- set stdpaths to use .repro
for _, name in ipairs({ 'config', 'data', 'state', 'cache' }) do
  vim.env[('XDG_%s_HOME'):format(name:upper())] = root .. '/' .. name
end

-- bootstrap lazy
local lazypath = root .. '/plugins/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    'git',
    'clone',
    '--filter=blob:none',
    '--single-branch',
    'https://github.com/folke/lazy.nvim.git',
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  -- do not remove the colorscheme! it makes testing nicer
  'folke/tokyonight.nvim',
  {
    'mrjones2014/legendary.nvim',
    dependencies = {
      -- place your `vim.ui.select()` handler plugin here
      -- for example:
      -- 'nvim-telescope/telescope.nvim',
      -- 'stevearc/dressing.nvim',
    },
  },
  -- add any other pugins here
}

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

require('dressing').setup()

require('legendary').setup({
  -- add any options here
})

-- add anything else here
vim.opt.termguicolors = true
-- do not remove the colorscheme! it makes testing nicer
vim.cmd([[colorscheme tokyonight]])

Output from :LegendaryLog

:LegendaryLog output (click to expand) ``` ```

Additional Details and/or Screenshots

No response

mrjones2014 commented 1 week ago

Can you test if #473 fixes your issue? Fixes it for me. Unfortunately since I had to change the ID generation algorithm, your existing frecency data will be invalid, so feel free to run :LegendaryFrecencyReset

gbcreation commented 1 week ago

It fixes the issue, but every time I open Legendary, this error occurs:

Failed to sort items: "...nvim/lazy/legendary.nvim/lua/legendary/data/itemlist.lua:167: attempt to call field 'sql_escape' (a nil value)"
gbcreation commented 1 week ago

Actually, this error occurred because I run the :LegendaryFrecencyReset command and did not restarted nvim. After restarting, all is good! :+1:

Thank you very much for the fix.