{"id":13479781,"url":"https://github.com/kristijanhusak/vim-dadbod-completion","last_synced_at":"2025-05-14T19:02:50.945Z","repository":{"id":37008800,"uuid":"254419339","full_name":"kristijanhusak/vim-dadbod-completion","owner":"kristijanhusak","description":"Database autocompletion powered by https://github.com/tpope/vim-dadbod","archived":false,"fork":false,"pushed_at":"2025-03-19T18:51:21.000Z","size":137,"stargazers_count":708,"open_issues_count":16,"forks_count":29,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-13T13:57:40.014Z","etag":null,"topics":["autocompletions","coc","database","deoplete","deoplete-source","neovim","neovim-plugin","nvim-cmp","vim","vim-dadbod","vim-plugin","vim-plugins"],"latest_commit_sha":null,"homepage":"","language":"Vim Script","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kristijanhusak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-09T16:09:28.000Z","updated_at":"2025-04-12T17:02:49.000Z","dependencies_parsed_at":"2024-01-16T06:28:07.554Z","dependency_job_id":"4540408b-419a-4974-8215-7390a0942948","html_url":"https://github.com/kristijanhusak/vim-dadbod-completion","commit_stats":{"total_commits":109,"total_committers":11,"mean_commits":9.909090909090908,"dds":"0.23853211009174313","last_synced_commit":"fc7321a17f4c55db11fae89a884ddf4724020bae"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kristijanhusak%2Fvim-dadbod-completion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kristijanhusak%2Fvim-dadbod-completion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kristijanhusak%2Fvim-dadbod-completion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kristijanhusak%2Fvim-dadbod-completion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kristijanhusak","download_url":"https://codeload.github.com/kristijanhusak/vim-dadbod-completion/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248724587,"owners_count":21151559,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["autocompletions","coc","database","deoplete","deoplete-source","neovim","neovim-plugin","nvim-cmp","vim","vim-dadbod","vim-plugin","vim-plugins"],"created_at":"2024-07-31T16:02:22.891Z","updated_at":"2025-04-13T13:57:44.777Z","avatar_url":"https://github.com/kristijanhusak.png","language":"Vim Script","funding_links":[],"categories":["Vim Script"],"sub_categories":[],"readme":"# vim-dadbod-completion\n\nDatabase auto completion powered by [vim-dadbod](https://github.com/tpope/vim-dadbod).\n\nSupports:\n* [coc.nvim](https://github.com/neoclide/coc.nvim)\n* [deoplete.nvim](https://github.com/Shougo/deoplete.nvim)\n* [nvim-compe](https://github.com/hrsh7th/nvim-compe)\n* [nvim-cmp](https://github.com/hrsh7th/nvim-cmp)\n* [ddc.vim](https://github.com/Shougo/ddc.vim)\n* [blink.cmp](https://github.com/Saghen/blink.cmp)\n* Built in `omnifunc`\n\n![coc-db](https://user-images.githubusercontent.com/1782860/78941173-717f6680-7ab7-11ea-91b3-18bf178b3735.gif)\n\n\nVideo presentation by TJ:\n\n[![Video presentation by TJ](https://i.ytimg.com/vi/ALGBuFLzDSA/hqdefault.jpg?sqp=-oaymwEcCNACELwBSFXyq4qpAw4IARUAAIhCGAFwAcABBg==\u0026rs=AOn4CLDmOFtUnDmQx5U_PKBqV819YujOBw)](https://www.youtube.com/watch?v=ALGBuFLzDSA)\n\n\n## Install\n\n**Dependencies**:\n* [vim-dadbod](https://github.com/tpope/vim-dadbod)\n\nFor [coc.nvim](https://github.com/neoclide/coc.nvim)\n```\n:CocInstall coc-db\n```\n\nFor `deoplete`, `completion-nvim`, `nvim-compe`, `ddc` and `omnifunc`, install it with your favorite plugin manager.\n\n```vim\nPlug 'tpope/vim-dadbod'\nPlug 'kristijanhusak/vim-dadbod-ui' \"Optional\nPlug 'kristijanhusak/vim-dadbod-completion'\n\n\" For built in omnifunc\nautocmd FileType sql setlocal omnifunc=vim_dadbod_completion#omni\n\n\" hrsh7th/nvim-compe\nlet g:compe.source.vim_dadbod_completion = v:true\n\n\" hrsh7th/nvim-cmp\n  autocmd FileType sql,mysql,plsql lua require('cmp').setup.buffer({ sources = {{ name = 'vim-dadbod-completion' }} })\n\n\" Shougo/ddc.vim\ncall ddc#custom#patch_filetype(['sql', 'mysql', 'plsql'], 'sources', 'dadbod-completion')\ncall ddc#custom#patch_filetype(['sql', 'mysql', 'plsql'], 'sourceOptions', {\n\\ 'dadbod-completion': {\n\\   'mark': 'DB',\n\\   'isVolatile': v:true,\n\\ },\n\\ })\n```\n\nConfiguration using [lazy.nvim](https://github.com/folke/lazy.nvim) with [vim-dadbod-ui](https://github.com/kristijanhusak/vim-dadbod-ui)\n```lua\nreturn {\n  {\n    'kristijanhusak/vim-dadbod-ui',\n    dependencies = {\n      { 'tpope/vim-dadbod', lazy = true },\n      { 'kristijanhusak/vim-dadbod-completion', ft = { 'sql', 'mysql', 'plsql' }, lazy = true },\n    },\n    cmd = {\n      'DBUI',\n      'DBUIToggle',\n      'DBUIAddConnection',\n      'DBUIFindBuffer',\n    },\n    init = function()\n      -- Your DBUI configuration\n      vim.g.db_ui_use_nerd_fonts = 1\n    end,\n  },\n  { -- optional saghen/blink.cmp completion source\n    'saghen/blink.cmp',\n    opts = {\n      sources = {\n        default = { \"lsp\", \"path\", \"snippets\", \"buffer\" },\n        per_filetype = {\n          sql = { 'snippets', 'dadbod', 'buffer' },\n        },\n        -- add vim-dadbod-completion to your completion providers\n        providers = {\n          dadbod = { name = \"Dadbod\", module = \"vim_dadbod_completion.blink\" },\n        },\n      },\n    },\n  }\n}\n```\n\n## Features\n* Autocomplete table names, with automatic quoting where needed. Works for all schemes that [vim-dadbod](https://github.com/tpope/vim-dadbod) supports.\n* Autocomplete table columns, context aware. Also knows to read aliases (`select * from mytable tbl where tbl.id = 1`). Currently works for `PostgreSQL`, `MySQL`, `Oracle`, `SQLite` (requires version `3.37.0 (2021-11-27)`) and `SQLserver/MSSQL`.\n* Out of the box integration with [vim-dadbod-ui](https://github.com/kristijanhusak/vim-dadbod-ui)\n\n## How it works\n* If an sql buffer is created by [vim-dadbod-ui](https://github.com/kristijanhusak/vim-dadbod-ui), it reads all the configuration from there. It should work out of the box.\n* If `vim-dadbod-ui` is not used, there are multiple ways to define the connection string, prioritized by this order:\n  * Window variable - example: `let w:db = 'postgresql://user:pass@localhost:5432/db_name'`\n  * Tab variable - example: `let t:db = 'postgresql://user:pass@localhost:5432/db_name'`\n  * Buffer variable - example: `let b:db = 'postgresql://user:pass@localhost:5432/db_name'`. You can also add `let b:db_table = 'table_name'` to limit column completions only to this table\n  * Global variable - example: `let g:db = 'postgresql://user:pass@localhost:5432/db_name'`\n  * `$DATABASE_URL` env variable, defined outside of Vim, or inside with `let $DATABASE_URL = 'postgresql://user:pass@localhost:5432/db_name'`\n\n## Settings\nDefault mark for completion items is `[DB]`. To change it, add this to vimrc:\n```\nlet g:vim_dadbod_completion_mark = 'MYMARK'\n```\n\n## Commands\nThis plugin caches the database tables and columns to leverage maximum performance. If you want to clear the cache at any point just run:\n\n```\n:DBCompletionClearCache\n```\n\n## Todo\n* [ ] Integration for column autocompletion with more database types\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkristijanhusak%2Fvim-dadbod-completion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkristijanhusak%2Fvim-dadbod-completion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkristijanhusak%2Fvim-dadbod-completion/lists"}