Comments (9)
Found the root cause of my problems. I was installing extras with a file defined in ~/.config/nvim/lua/plugins/extras.lua. When I moved importing to ~/.config/nvim/lua/config/lazy.lua, now I'm able to change configuration of nvim-dap.
This is not super user friendly as I followed the example where plugin modules are imported in plugins/ folder. To reproduce:
~/.config/nvim/lua/plugins/extras.lua
return {
{ import = "lazyvim.plugins.extras.lang.clangd" },
}
(this configuration change doesn't get applied)
~/.config/nvim/lua/plugins/clangd-extra.lua
return {
{
"mfussenegger/nvim-dap",
opts = function()
local dap = require("dap")
dap.adapters["cppdbg"] = {
id = "cppdbg",
type = "executable",
command = "/usr/bin/vscode-cpptools/OpenDebugAD7",
}
for _, lang in ipairs({ "c", "cpp" }) do
dap.configurations[lang] = {
{
type = "cppdbg",
request = "launch",
name = "Launch file",
program = function()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
end,
cwd = "${workspaceFolder}",
},
{
name = "Attach to gdbserver :1234",
type = "cppdbg",
request = "launch",
MIMode = "gdb",
miDebuggerServerAddress = "localhost:1234",
miDebuggerPath = "/usr/bin/gdb",
cwd = "${workspaceFolder}",
program = function()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
end,
},
}
end
end,
},
}
from lazyvim.
It mentions it in the docs for each extra that it should be imported either via :LazyExtras
or /lua/config/lazy.lua
manually.
You can enable the extra with the :LazyExtras command. Plugins marked as optional will only be configured if they are installed.
Alternatively, you can add it to your lazy.nvim imports
-- lua/config/lazy.lua
require("lazy").setup({
spec = {
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
{ import = "lazyvim.plugins.extras.lang.clangd" },
{ import = "plugins" },
},
})
Could you kindly close the issue if your problem is resolved?
from lazyvim.
The example.lua suggests otherwise and it seems it only doesn't work if opts
is a function()
(which is also not something you should assign to opts
according to documentation). If you think this is a user error, I will close the issue.
from lazyvim.
What do you mean the example.lua
suggests otherwise? I specifically quoted what is mentioned in the clangd docs itself, where it mentions how you can enable this Extra. Where did you see that opts
can't be a function? It can be a function that returns a table. From lazy.nvim
docs
opts should be a table (will be merged with parent specs), return a table (replaces parent specs) or should change a table.
The only difference here is that the table is created and then can be modified via the required dap
module, because that's how the nvim-dap
plugin works.
from lazyvim.
https://www.lazyvim.org/configuration/examples has examples of importing extras in plugins/
directory. I also wanted to have it in plugin/
folder to have all of my modifications in one place but it's not a big deal.
Where did you see that opts can't be a function?
More precisely, function that doesn't take arguments and doesn't return anything. But DAP is a special in this case as you described. From the same lazy.nvim
docs I could also assume function()
is not supported at all:
opts | table or fun(LazyPlugin, opts:table)
From my point of view, the fact that importing extras somewhere in plugins/
folder works in 50% of the cases (when opts
is a table or configured with function(_, opts)
), means there's area for improvement. Things should work in all cases or shouldn't work at all.
from lazyvim.
The difference that you notice when you import the Extras in your /lua/plugins/
folder is because lazy.nvim
parses files in alphabetical order. In your previous example you had the import in /lua/plugins/extras.lua
, but you had your custom spec of nvim-dap
in /lua/plugins/clangd-extra.lua
. So, the clangd-extra.lua
will get parsed first by lazy and then the extras.lua
file. In this case the latter overrides the former. You can check that with the following config
{
"mfussenegger/nvim-dap",
opts = function()
local dap = require("dap")
dap.configurations.c[1].name = "test"
end,
},
{ import = "lazyvim.plugins.extras.lang.clangd" },
It won't be like you want it to. Now if you put it like
{ import = "lazyvim.plugins.extras.lang.clangd" },
{
"mfussenegger/nvim-dap",
opts = function()
local dap = require("dap")
dap.configurations.c[1].name = "test"
end,
},
It will work as expected. This is why in the Extras documentation it says to put the import in your /lua/config/lazy.lua
, because that file and everything in it will get parsed before the files in /lua/plugins/
directory.
The safest way is to enable the Extras you want via the command LazyExtras
, because that takes into consideration the correct ordering of parsing the Extras files.
Anyway, this is not a LazyVim bug. If you'd like you could make a PR in the docs repo or create an issue with enhancement
label to clarify this in the LazyVim website.
from lazyvim.
What do you think about commenting out this or putting a warning in the comments not to include Extras like that? This is what lead me to the wrong assumptions in the first place.
from lazyvim.
Yes, I'm in favor of this because it seems to mislead new users. But I'm just a user like you with no access to this project. That's why I suggested for you to create an issue with enhancement
label or create a PR yourself in the docs repo that I linked above that comments out or even deletes the current section that you're referring to.
from lazyvim.
@ifonajs Did you reopen this issue by mistake or is there any particular problem you keep having?
from lazyvim.
Related Issues (20)
- bug: bad argument #1 to 'get_line_col' (string expected, got nil) HOT 3
- bug: The latest version of lualine will be lost when the file is opened HOT 7
- bug: `<leader>m` not working with `neo-tree` opened HOT 2
- bug: `vtsls` crashes when `lang.vue` extra is enabled without `lang.typescript` HOT 3
- bug(LazyExtras lang.yaml): error whenever buffer have array of objects HOT 3
- bug: outline.nvim extra keymap conflicts with trouble.nvim's symbols keymap
- bug: Overriding Copilot-Chat edgy config does not work HOT 4
- bug: Crashed when execute LazyHealth HOT 4
- feature: lazydocker HOT 1
- bug: `recommended` not working after removing specs for some plugins HOT 2
- feature: add supermaven HOT 5
- bug: Failed to run config for nvim-snippets HOT 1
- bug: Unable to restore the maximized Neo-tree window HOT 1
- bug: latex snippet fails to preview and expand HOT 10
- bug: cmp menu doesn't appear when typing punctuation characetrs HOT 2
- bug: lsp not working after installing vtsls. HOT 3
- feature: Ask for users permission before removing or adding new plugins over lazyvim update HOT 1
- bug: default indent adds wrong indentline in nested functions HOT 5
- bug: `gitsigns.nvim` makes Neovim randomly freeze when scrolling/switching buffers HOT 2
- bug: Not managed by LazyExtras HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lazyvim.