Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Cannot use trouble due to lua error #465

Closed
3 tasks done
radu781 opened this issue Jun 1, 2024 · 9 comments · Fixed by #461
Closed
3 tasks done

bug: Cannot use trouble due to lua error #465

radu781 opened this issue Jun 1, 2024 · 9 comments · Fixed by #461
Labels
bug Something isn't working

Comments

@radu781
Copy link

radu781 commented Jun 1, 2024

Did you check docs and existing issues?

  • I have read all the trouble.nvim docs
  • I have searched the existing issues of trouble.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

NVIM v0.10.0-dev-2752+g35239e977

Operating system/version

Windows 10

Describe the bug

Cannot use trouble due to lua error, using latest trouble version, I had no issues with this until yesterday, maybe because of a version update

E5108: Error executing lua: ...k\packer\start\trouble.nvim/lua/trouble/sources/init.lua:40: attempt to index local 'source' (a nil value)
stack traceback:
        ...k\packer\start\trouble.nvim/lua/trouble/sources/init.lua:40: in function 'get'
        ...k\packer\start\trouble.nvim/lua/trouble/view/section.lua:33: in function 'new'
        ...pack\packer\start\trouble.nvim/lua/trouble/view/init.lua:59: in function 'new'
        ...\site\pack\packer\start\trouble.nvim/lua/trouble/api.lua:52: in function 'toggle'
        [string ":source (no file)"]:59: in function <[string ":source (no file)"]:59>

Steps To Reproduce

require("trouble").toggle("document_diagnostics")
require("trouble").toggle("workspace_diagnostics")

Expected Behavior

It's supposed to not error and show diagnostics for the current file or workspace

Repro

No response

@radu781 radu781 added the bug Something isn't working label Jun 1, 2024
@folke folke closed this as completed in 4b1914c Jun 1, 2024
@folke
Copy link
Owner

folke commented Jun 1, 2024

Trouble v3 was merged in main. Please check the docs.
Those are no longer valid modes. I just updated the code to show a proper error message in this case.

@antolu
Copy link

antolu commented Jul 19, 2024

Sorry for necroing this issue, but I'm getting the same error on LazyVim 12.x with default lualine and trouble configs. Does this mean I just should not use the latest of the main branches?

@folke
Copy link
Owner

folke commented Jul 19, 2024

Trouble v3 has been merged in main ages ago.
Update your plugins.

@antolu
Copy link

antolu commented Jul 19, 2024

I am on the latest of all plugins. This my lazy-lock.json:

{
  "CopilotChat.nvim": { "branch": "canary", "commit": "92bc7b5e564c23b12b2ed41dd7657fdafe39d95f" },
  "LazyVim": { "branch": "main", "commit": "0daa957b3c8e672c9608bda7cd737cd8090adf80" },
  "LuaSnip": { "branch": "master", "commit": "ce0a05ab4e2839e1c48d072c5236cce846a387bc" },
  "SchemaStore.nvim": { "branch": "main", "commit": "58a965eedbfe7c358938b0e535ed2d98a4520987" },
  "alpha-nvim": { "branch": "main", "commit": "41283fb402713fc8b327e60907f74e46166f4cfd" },
  "bufferline.nvim": { "branch": "main", "commit": "0b2fd861eee7595015b6561dade52fb060be10c4" },
  "catppuccin": { "branch": "main", "commit": "0b5df9c9e641b1212b21a0762ccad4434fd41322" },
  "chezmoi.nvim": { "branch": "main", "commit": "faf61465718424696269b2647077331b3e4605f1" },
  "chezmoi.vim": { "branch": "main", "commit": "10f2692791b5e512a2c1bb4dc560b42ca5bf71fd" },
  "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
  "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" },
  "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
  "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
  "cmp-pypi": { "branch": "main", "commit": "a73411e5935caa23c6feab34980bb435deadd482" },
  "conform.nvim": { "branch": "master", "commit": "acc7d93f4a080fec587a99fcb36cffa29adc4bad" },
  "copilot-cmp": { "branch": "master", "commit": "b6e5286b3d74b04256d0a7e3bd2908eabec34b44" },
  "copilot.lua": { "branch": "master", "commit": "86537b286f18783f8b67bccd78a4ef4345679625" },
  "dressing.nvim": { "branch": "master", "commit": "6741f1062d3dc6e4755367a7e9b347b553623f04" },
  "edgy.nvim": { "branch": "main", "commit": "0e8bbab4eba9dab6c237e4a2e146dc0466897be6" },
  "flit.nvim": { "branch": "main", "commit": "a9be4e76c30a128f1e51af448c8321bf8366bcd4" },
  "friendly-snippets": { "branch": "main", "commit": "00ebcaa159e817150bd83bfe2d51fa3b3377d5c4" },
  "harpoon": { "branch": "harpoon2", "commit": "0378a6c428a0bed6a2781d459d7943843f374bce" },
  "headlines.nvim": { "branch": "master", "commit": "618ef1b2502c565c82254ef7d5b04402194d9ce3" },
  "indent-blankline.nvim": { "branch": "master", "commit": "65e20ab94a26d0e14acac5049b8641336819dfc7" },
  "lazy.nvim": { "branch": "main", "commit": "8f6225751138329da339eb6554d40158768d23ff" },
  "lazydev.nvim": { "branch": "main", "commit": "02f1055a777264d4b65896051ec28d0f322f7932" },
  "leap.nvim": { "branch": "main", "commit": "a9a9faee45066f2796c9a0e0ef52bf571d144492" },
  "lualine.nvim": { "branch": "master", "commit": "544dd1583f9bb27b393f598475c89809c4d5e86b" },
  "luvit-meta": { "branch": "main", "commit": "ce76f6f6cdc9201523a5875a4471dcfe0186eb60" },
  "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" },
  "mason-lspconfig.nvim": { "branch": "main", "commit": "37a336b653f8594df75c827ed589f1c91d91ff6c" },
  "mason-nvim-dap.nvim": { "branch": "main", "commit": "4ba55f9755ebe8297d92c419b90a946123292ae6" },
  "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
  "mini.ai": { "branch": "main", "commit": "45587078f323eaf41b9f701bbc04f8d1ab008979" },
  "mini.diff": { "branch": "main", "commit": "d58f9cb13400aedc5b5a0ef70fcdf31871ba2ee6" },
  "mini.files": { "branch": "main", "commit": "acfc4e46f6722a0690ce640632c5b5515ddade70" },
  "mini.icons": { "branch": "main", "commit": "c291191e2a2a99f8aeea5e4d6406af54d11c9608" },
  "mini.move": { "branch": "main", "commit": "cde3747eec9bb3941296e6fa1d874e0da5a10256" },
  "mini.pairs": { "branch": "main", "commit": "927d19cbdd0e752ab1c7eed87072e71d2cd6ff51" },
  "neo-tree.nvim": { "branch": "main", "commit": "206241e451c12f78969ff5ae53af45616ffc9b72" },
  "neotest": { "branch": "master", "commit": "32ff2ac21135a372a42b38ae131e531e64833bd3" },
  "neotest-python": { "branch": "master", "commit": "2e83d2bc00acbcc1fd529dbf0a0e677cabfe6b50" },
  "noice.nvim": { "branch": "main", "commit": "1df01e495b3ac0e2f5f111eba759691a9c21bb72" },
  "none-ls.nvim": { "branch": "main", "commit": "4c6605b2ec5dfe4c9694ade0c730c234d1039019" },
  "nui.nvim": { "branch": "main", "commit": "61574ce6e60c815b0a0c4b5655b8486ba58089a1" },
  "nvim-cmp": { "branch": "main", "commit": "d818fd0624205b34e14888358037fb6f5dc51234" },
  "nvim-dap": { "branch": "master", "commit": "bc03b83c94d0375145ff5ac6a6dcf28c1241e06f" },
  "nvim-dap-python": { "branch": "master", "commit": "d777c2b32ed39f61209c09bede28d7491621a631" },
  "nvim-dap-ui": { "branch": "master", "commit": "a5606bc5958db86f8d92803bea7400ee26a8d7e4" },
  "nvim-dap-virtual-text": { "branch": "master", "commit": "484995d573c0f0563f6a66ebdd6c67b649489615" },
  "nvim-lint": { "branch": "master", "commit": "efc6fc83f0772283e064c53a8f9fb5645bde0bc0" },
  "nvim-lspconfig": { "branch": "master", "commit": "e26da408cf955afa8e9ddbadd510e84ea8976cd7" },
  "nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" },
  "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" },
  "nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" },
  "nvim-snippets": { "branch": "main", "commit": "56b4052f71220144689caaa2e5b66222ba5661eb" },
  "nvim-spectre": { "branch": "master", "commit": "9a28f926d3371b7ef02243cbbb653a0478d06e31" },
  "nvim-treesitter": { "branch": "master", "commit": "0ffe62722307f6755d2c7049837cb2cd6d7d275a" },
  "nvim-treesitter-context": { "branch": "master", "commit": "2aba92ceb1479485953007f4d5adf34d0b66917e" },
  "nvim-treesitter-textobjects": { "branch": "master", "commit": "34867c69838078df7d6919b130c0541c0b400c47" },
  "nvim-ts-autotag": { "branch": "main", "commit": "1624866a1379fc1861797f0ed05899a9c1d2ff61" },
  "onedark.nvim": { "branch": "master", "commit": "fae34f7c635797f4bf62fb00e7d0516efa8abe37" },
  "onehalf": { "branch": "master", "commit": "75eb2e97acd74660779fed8380989ee7891eec56" },
  "persistence.nvim": { "branch": "main", "commit": "40a137dd9240c9c6760c53df48d2b155f52c252b" },
  "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" },
  "project.nvim": { "branch": "main", "commit": "8c6bad7d22eef1b71144b401c9f74ed01526a4fb" },
  "refactoring.nvim": { "branch": "master", "commit": "8ef9cfb8199bed4be4d609cc4b5dbfb5416b3ca6" },
  "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" },
  "telescope.nvim": { "branch": "master", "commit": "bfcc7d5c6f12209139f175e6123a7b7de6d9c18a" },
  "todo-comments.nvim": { "branch": "main", "commit": "96fee098a90e7c09c9811aa7df71d773ba8b9b53" },
  "tokyonight.nvim": { "branch": "main", "commit": "1471dab694ad88351185758bb4275624d8b798ec" },
  "trouble.nvim": { "branch": "main", "commit": "bf99ea71a39e322336b7f8be965f86dbf5c65540" },
  "ts-comments.nvim": { "branch": "main", "commit": "80eec3b9663ac3c4743b584f361099b061d0a9e5" },
  "venv-selector.nvim": { "branch": "regexp", "commit": "47159757b334343fe60f16d52478f827ccefa09d" },
  "vim-repeat": { "branch": "master", "commit": "65846025c15494983dafe5e3b46c8f88ab2e9635" },
  "vim-tmux-navigator": { "branch": "master", "commit": "5b3c701686fb4e6629c100ed32e827edf8dad01e" },
  "vim-wakatime": { "branch": "master", "commit": "3cb40867cb5a3120f9bef76eff88edc7f1dc1a23" },
  "vimtex": { "branch": "master", "commit": "80c9bc179784c30192d482741a43f176c859daa1" },
  "which-key.nvim": { "branch": "main", "commit": "a72d2482914d0ae3c5d24505c7bb91b834cf67d8" },
  "yanky.nvim": { "branch": "main", "commit": "73215b77d22ebb179cef98e7e1235825431d10e4" }
}

and lazyvim.json

{
  "extras": [
    "lazyvim.plugins.extras.coding.copilot",
    "lazyvim.plugins.extras.coding.copilot-chat",
    "lazyvim.plugins.extras.coding.yanky",
    "lazyvim.plugins.extras.dap.core",
    "lazyvim.plugins.extras.editor.harpoon2",
    "lazyvim.plugins.extras.editor.leap",
    "lazyvim.plugins.extras.editor.mini-diff",
    "lazyvim.plugins.extras.editor.mini-files",
    "lazyvim.plugins.extras.editor.mini-move",
    "lazyvim.plugins.extras.editor.navic",
    "lazyvim.plugins.extras.editor.refactoring",
    "lazyvim.plugins.extras.lang.markdown",
    "lazyvim.plugins.extras.lang.python",
    "lazyvim.plugins.extras.lang.tex",
    "lazyvim.plugins.extras.lang.toml",
    "lazyvim.plugins.extras.lang.yaml",
    "lazyvim.plugins.extras.lsp.none-ls",
    "lazyvim.plugins.extras.test.core",
    "lazyvim.plugins.extras.ui.alpha",
    "lazyvim.plugins.extras.ui.edgy",
    "lazyvim.plugins.extras.ui.treesitter-context",
    "lazyvim.plugins.extras.util.chezmoi",
    "lazyvim.plugins.extras.util.project",
    "lazyvim.plugins.extras.vscode"
  ],
  "news": {
    "NEWS.md": "6077"
  },
  "version": 6
}

I don't think anything is too old...

@folke
Copy link
Owner

folke commented Jul 19, 2024

ok, I thought this was something else.
Those API calls are just not valid.
Check the docs.

@radu781
Copy link
Author

radu781 commented Jul 19, 2024

@antolu I use this:

local trouble = require("trouble")
vim.keymap.set("n", "<leader>ed", "<cmd>Trouble diagnostics toggle<CR>", { desc = "document diagnostics on opened buffers" })
vim.keymap.set("n", "gr", "<cmd>Trouble lsp_references toggle<CR>", { desc = "go to references" })

@folke
Copy link
Owner

folke commented Jul 19, 2024

That works fine for me?
What is the exact error you get?

Op's problem was because they used a non-existing source.

@antolu
Copy link

antolu commented Jul 19, 2024

Cheers guys. Realized now I have a slightly different error for the status line, not the toggle.

In case @folke is interested, it happens on launch of nvim, regardless if I do nvim [file] or nvim

Failed to run `config` for lualine.nvim

...hare/nvim/lazy/trouble.nvim/lua/trouble/sources/init.lua:40: attempt to index local 'source' (a nil value)

# stacktrace:
  - /trouble.nvim/lua/trouble/sources/init.lua:40 _in_ **get**
  - /trouble.nvim/lua/trouble/view/section.lua:33 _in_ **new**
  - /trouble.nvim/lua/trouble/api.lua:164 _in_ **statusline**
  - /LazyVim/lua/lazyvim/plugins/ui.lua:209 _in_ **values**

From LazyVim/lua/lazyvim/plugins/ui.lua

https://github.com/LazyVim/LazyVim/blob/0daa957b3c8e672c9608bda7cd737cd8090adf80/lua/lazyvim/plugins/ui.lua#L209C11-L219C42

Sorry guys for hijacking this thread with an unrelated issue.

@folke
Copy link
Owner

folke commented Jul 19, 2024

Please open an issue in the LazyVim repo with a repro that triggers this.
I really don't see how that can happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants