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

How to set this with cmp and lua based config? #31

Closed
thepenguinthatwants opened this issue Jan 13, 2022 · 6 comments
Closed

How to set this with cmp and lua based config? #31

thepenguinthatwants opened this issue Jan 13, 2022 · 6 comments

Comments

@thepenguinthatwants
Copy link

thepenguinthatwants commented Jan 13, 2022

I created
~/.config/nvim/ftplugin/sql.vim file
and added

" hrsh7th/nvim-cmp
autocmd FileType sql,mysql,plsql lua require('cmp').setup.buffer({ sources = {{ name = 'vim-dadbod-completion' }} })

But it doesn't seem to do anything. Wondering what's the recommended way to add this?

@kristijanhusak
Copy link
Owner

you should not use autocmd in the ftplugin file. This should be sufficient in there:

lua require('cmp').setup.buffer({ sources = {{ name = 'vim-dadbod-completion' }} })

@thepenguinthatwants
Copy link
Author

Thanks for the reply and it works!!

@zer09
Copy link

zer09 commented Mar 11, 2022

@kristijanhusak sorry to chime in, but I cant make this work I am using Packer for the package manager and have this

 -- Sql
use "tpope/vim-dadbod"
use { "kristijanhusak/vim-dadbod-completion" }
use { "kristijanhusak/vim-dadbod-ui" }

and this

vim.cmd([[
  augroup DadbodSql
    au!
    autocmd FileType sql,mysql,plsql lua require('cmp').setup.buffer({ sources = {{ name = 'vim-dadbod-completion' }} })
  augroup END
]])

-- also tried this without vim.cmd
require('cmp').setup.buffer({ sources = {{ name = 'vim-dadbod-completion' }} })

It works on DBUI, but I cant make it work on directly on sql files

@kristijanhusak
Copy link
Owner

@zer09
Copy link

zer09 commented Mar 13, 2022

Yes, but it will only autocomplete if I open the buffer using the New query from the DBUI.
I have existing sql file scripts, it just kinda works I mean not working properly. example there is no completion for the table name or it just keep suggesting this two irrelevant tables. to get the completion for the columns I need to type the table name followed by the dot before it will suggest the columns.

But using dbui it works perferctly fine

@kristijanhusak
Copy link
Owner

I need to check. Can you please open up separate issue for that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants