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

SQL Server field completion doesn't work #73

Open
Sh00Fly opened this issue Oct 2, 2024 · 0 comments
Open

SQL Server field completion doesn't work #73

Sh00Fly opened this issue Oct 2, 2024 · 0 comments

Comments

@Sh00Fly
Copy link

Sh00Fly commented Oct 2, 2024

Hi,
I just setup vim-dadbod-completion, and it works to complete keywords and table names, but doesn't complete field names.
If I try to type in TableName. I get the following error as soon as I hit "."

[dadbod completion] Fetching columns for table DBVersion...
Error executing lua callback: TextChangedI Autocommands for "*"..function vim_dadbod_completion#omni[103]..<SNR>80_get_table_scope_columns[13]..vim_dadbod_completion#job#run, line 2: Vim(let):E475: Invalid value for argument cmd: 'env' is not executable
stack traceback:
	[C]: in function 'vim_dadbod_completion#omni'
	...lazy/vim-dadbod-completion/lua/vim_dadbod_completion.lua:48: in function 'complete'
	...AppData/Local/nvim-data/lazy/nvim-cmp/lua/cmp/source.lua:326: in function 'complete'
	...n/AppData/Local/nvim-data/lazy/nvim-cmp/lua/cmp/core.lua:299: in function 'complete'
	...n/AppData/Local/nvim-data/lazy/nvim-cmp/lua/cmp/core.lua:169: in function 'callback'
	...n/AppData/Local/nvim-data/lazy/nvim-cmp/lua/cmp/core.lua:229: in function 'autoindent'
	...n/AppData/Local/nvim-data/lazy/nvim-cmp/lua/cmp/core.lua:161: in function 'on_change'
	...n/AppData/Local/nvim-data/lazy/nvim-cmp/lua/cmp/init.lua:346: in function 'callback'
	.../Local/nvim-data/lazy/nvim-cmp/lua/cmp/utils/autocmd.lua:49: in function 'emit'
	.../Local/nvim-data/lazy/nvim-cmp/lua/cmp/utils/autocmd.lua:23: in function <.../Local/nvim-data/lazy/nvim-cmp/lua/cmp/utils/autocmd.lua:22>

Here is my lazy.nvim config:

return {
    {
        "kristijanhusak/vim-dadbod-ui",
        dependencies = {
            { "tpope/vim-dadbod",  },
            { "kristijanhusak/vim-dadbod-completion",
                ft = { "sql", "mysql", "plsql" },
                lazy = true,
            },
        },
        cmd = {
            "DBUI",
            "DBUIToggle",
            "DBUIAddConnection",
            "DBUIFindBuffer",
        },
        init = function()
        -- Your DBUI configuration
        vim.g.db_ui_use_nerd_fonts = 1
        end,
    },
}

And here is my completion setup:

-- Autocompletion Configuration
return {
    "hrsh7th/nvim-cmp",
    dependencies = {
        { "L3MON4D3/LuaSnip",
            dependencies = {
                {  "rafamadriz/friendly-snippets", },
            },
            config = function()
                require("luasnip.loaders.from_vscode").lazy_load() -- loads friendly-snippets
                require("luasnip").config.setup({})
            end,
        },
        { "saadparwaiz1/cmp_luasnip", },
        { "hrsh7th/cmp-nvim-lsp", },
        { "onsails/lspkind.nvim", },
        { "hrsh7th/cmp-buffer", }, 
        { "hrsh7th/cmp-path", },
        { "hrsh7th/cmp-cmdline", 
            config = function()
                local cmp = require("cmp")
                cmp.setup.cmdline(":", {
                    mapping = cmp.mapping.preset.cmdline(),
                    sources = cmp.config.sources({
                        { name = "path" },
                    }, {
                        {
                            name = "cmdline",
                            option = {
                                ignore_cmds = { "Man", "!" },
                            },
                        },
                    }),
                })
                cmp.setup.cmdline("/", {
                    mapping = cmp.mapping.preset.cmdline(),
                    sources = {
                        { name = "buffer" },
                    },
                })
            end,
        },
    },
    config = function()
        local cmp = require("cmp")
        local luasnip = require("luasnip")
        local lspkind = require("lspkind")

        cmp.setup({
            completion = {
                completeopt = "menu, menuone, preview, noselect",
            },
            snippet = {
                expand = function(args)
                    luasnip.lsp_expand(args.body)
                end,
            },
            mapping = cmp.mapping.preset.insert({
                ["<C-n>"] = cmp.mapping.select_next_item(),
                ["<C-p>"] = cmp.mapping.select_prev_item(),
                ["<C-d>"] = cmp.mapping.scroll_docs(-4),
                ["<C-f>"] = cmp.mapping.scroll_docs(4),
                ["<C-S-k>"] = cmp.mapping.complete({}), 
                ["<C-e>"] = cmp.mapping.abort(),
                ["<CR>"] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }),
                ["<Tab>"] = cmp.mapping(function(fallback)
                    if cmp.visible() then
                        cmp.select_next_item()
                    elseif luasnip.expand_or_locally_jumpable() then
                        luasnip.expand_or_jump()
                    else
                        fallback()
                    end
                end, { "i", "s" }),
                ["<S-Tab>"] = cmp.mapping(function(fallback)
                    if cmp.visible() then
                        cmp.select_prev_item()
                    elseif luasnip.locally_jumpable(-1) then
                        luasnip.jump(-1)
                    else
                        fallback()
                    end
                end, { "i", "s" }),
            }),
            sources = cmp.config.sources({
                { name = "nvim_lsp" },
                { name = "luasnip" },
                { name = "buffer" },
                { name = "path" },
                -- { name = "cmdline" },
            }),
            formatting = {
                expandable_indicator = true,
                format = lspkind.cmp_format({
                    mode = "symbol_text",
                    menu = {
                        buffer = "[Buffer]",
                        nvim_lsp = "[LSP]",
                        luasnip = "[LuaSnip]",
                        nvim_lua = "[Lua]",
                        latex_symbols = "[Latex]",
                    },
                    maxwidth = 50,
                    ellipsis_char = "...",
                }),
            },
            -- setup vim-dadbod
            cmp.setup.filetype({ "sql" }, {
                sources = {
                    { name = "vim-dadbod-completion" },
                    { name = "buffer" },
                },
            }),
            experimental = {
                ghost_text = true,
            },
        })
    end,
}
---------------------------------------------------
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

1 participant