Comments (10)
I'm also using Lazy. You can try my setup. Here's how I set up dadbod related stuff: https://github.com/kristijanhusak/neovim-config/blob/master/nvim/lua/partials/plugins/db.lua
And this is where I set up cmp for it: https://github.com/kristijanhusak/neovim-config/blob/master/nvim/lua/partials/plugins/completion.lua#L93-L106
from vim-dadbod-completion.
Thanks! It was not having the "cmd" line in my case. Apart from changing vsnip to luasnip copy pasting the second worked like a charm as well.
Reference solution for anyone else using LazyVim that finds this issue.
Thanks for the help and the great applications! @kristijanhusak
Keep up the great work!
-- plugins/cmp.lua
return {
{
"hrsh7th/nvim-cmp",
lazy = true,
opts = function(_, opts)
local cmp = require("cmp")
opts.completion = {
completeopt = "menu,menuone,noinsert",
}
opts.window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
}
return opts
end,
},
}
-- plugins/dadbod.lua
return {
{
"kristijanhusak/vim-dadbod-ui",
dependencies = {
{ "tpope/vim-dadbod", lazy = true },
{ "kristijanhusak/vim-dadbod-completion", lazy = true, ft = { "sql", "mysql", "plsql" } },
},
cmd = { "DBUI", "DBUIFindBuffer" },
},
}
-- config/autocmds.lua
local autocomplete_group = vim.api.nvim_create_augroup("vimrc_autocompletion", { clear = true })
local cmp = require("cmp")
vim.api.nvim_create_autocmd("FileType", {
pattern = { "sql", "mysql", "plsql" },
callback = function()
cmp.setup.buffer({
sources = {
{ name = "vim-dadbod-completion" },
{ name = "buffer" },
{ name = "luasnip" },
},
})
end,
group = autocomplete_group,
})
from vim-dadbod-completion.
I have also had this issue.
return {
{
"tpope/vim-dadbod",
dependencies = {
"kristijanhusak/vim-dadbod-ui",
},
},
{
"kristijanhusak/vim-dadbod-ui",
},
-- {
-- "kristijanhusak/vim-dadbod-completion",
-- },
}
Commenting and uncommenting this line toggles the issue.
I am using LazyVim and my nvim-cmp config is completely default apart from a slight style choice.
return {
{
"hrsh7th/nvim-cmp",
lazy = true,
opts = function(_, opts)
local cmp = require("cmp")
opts.completion = {
completeopt = "menu,menuone,noinsert",
}
opts.window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
}
return opts
end,
},
}
I would love this behavior inside of SQL editors but this just disables it globally for me.
I notice a strange behavior where it seems that nvim-cmp loading gets placed "behind" dadbod-completion when it is active.
-- `:Lazy profile` with dadbod-completion
➜ after 5.14ms
★ after/plugin/vim_dadbod_completion.lua 5.06ms
‒ nvim-cmp 4.53ms
● crates.nvim 2.32ms
● copilot-cmp 0.53ms
➜ copilot.lua 0.46ms
★ copilot.lua/plugin/copilot.lua 0.03ms
● cmp-nvim-lsp 0.04ms
● cmp-buffer 0.08ms
● cmp-path 0.06ms
● cmp_luasnip 0.07ms
● nvim-cmp/plugin/cmp.lua 0.26ms
★ after/plugin/vim_dadbod_completion.vim 0.02ms
and removed from "InsertEnter" where I normally see it.
I'm not sure if the extension is taking ownership and overwriting the "event" somewhere. But something along those lines is what the behavior seems to suggest.
-- `:Lazy profile` without dadbod-completion
InsertEnter 21.42ms
➜ nvim-cmp 21.31ms
★ crates.nvim 10.62ms
‒ after/plugin/cmp_crates.lua 0.69ms
★ copilot-cmp 3ms
‒ copilot.lua 2.67ms
● copilot.lua/plugin/copilot.lua 0.18ms
★ cmp-buffer 5.08ms
‒ after/plugin/cmp_buffer.lua 4.95ms
★ cmp-path 0.57ms
‒ after/plugin/cmp_path.lua 0.47ms
★ cmp_luasnip 0.66ms
‒ after/plugin/cmp_luasnip.lua 0.6ms
★ nvim-cmp/plugin/cmp.lua 0.27ms
from vim-dadbod-completion.
I noticed that my dependencies might have caused some confusion. dadbod requiring ui instead of the other way around.
I will invert these tomorrow and see if that fixes the issue on my end.
I tried reviewing all of the places where this extension interacts with cmp and nothing stood out as being a potential cause.
I will let you know if this corrects the behavior or if I find anything else.
from vim-dadbod-completion.
@kristijanhusak Thank you very much for the help. For me the solution was a little weird. I kept my code just the same, but the only thing I added was local cmp = require("cmp")
(could be before or after the autocommand). That is, my code is this at the moment:
vim.api.nvim_create_autocmd("FileType", {
pattern = { "sql", "mysql", "plsql" },
command = ":lua require('cmp').setup.buffer({ sources = {{ name = 'vim-dadbod-completion' }} })",
})
local cmp = require("cmp")
I don't understand why requiring cmp
as a local config variable solves anything. Doing this alone for example won't work:
vim.api.nvim_create_autocmd("FileType", {
pattern = { "sql", "mysql", "plsql" },
callback = function()
require("cmp").setup.buffer({
sources = {
{ name = "vim-dadbod-completion" },
{ name = "buffer" },
{ name = "luasnip" },
},
})
end,
})
To make it work I MUST require cmp
at some point in the code, for example:
vim.api.nvim_create_autocmd("FileType", {
pattern = { "sql", "mysql", "plsql" },
callback = function()
require("cmp").setup.buffer({
sources = {
{ name = "vim-dadbod-completion" },
{ name = "buffer" },
{ name = "luasnip" },
},
})
end,
})
require("cmp") -- must have this
Maybe it is because LunarVim is doing something funny with cmp? I don't feel it is because of that, but at least this fixed my issue. Maybe doing require("cmp")
initializes some stuff? But then why wont the require within the callback do the same?
Either way, thanks for the great plugins @kristijanhusak. They work really well.
from vim-dadbod-completion.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
from vim-dadbod-completion.
I'm closing this since it seems that everyone managed to solve the configuration issue.
from vim-dadbod-completion.
Related Issues (20)
- "Error executing lua" after updating plugin with support for cmp HOT 2
- Completion options when using schema.table aliases lists non-existent columns - pgsql + nvim-cmp HOT 6
- Customize menu for nvim-cmp source display HOT 3
- nvim-cmp source name "vim-dadbod-completion" causes error when trying to set the source name. HOT 1
- How to set this with cmp and lua based config? HOT 6
- Completion from multiple databases HOT 4
- Completion wont work on local sql files HOT 3
- Support for coq.nvim HOT 1
- Caching Behavior Preventing Completion of New Tables HOT 2
- autocompletion with nvim-cmp now emits E730: using List as a String HOT 5
- Formatter like coc-sql HOT 1
- add support for mongo completion HOT 1
- Completions getting inserted wrapped in "" HOT 2
- Suggestions of tables work, suggestions of columns do not. HOT 1
- suggestions for columns fetched but not being suggested HOT 7
- Deprecated HOT 8
- Prefer DB specific recommendations HOT 1
- Option to not echom "Connecting to db..." HOT 3
- Autocompletion Issue in Large MSSQL Databases HOT 14
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 vim-dadbod-completion.