https://github.com/mattiasmts/cmp-dbee
Autocompletion for nvim-dbee
https://github.com/mattiasmts/cmp-dbee
autocompletion database nvim nvim-cmp
Last synced: 3 days ago
JSON representation
Autocompletion for nvim-dbee
- Host: GitHub
- URL: https://github.com/mattiasmts/cmp-dbee
- Owner: MattiasMTS
- License: mit
- Created: 2024-01-06T22:43:59.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-19T07:45:20.000Z (2 months ago)
- Last Synced: 2025-02-09T03:51:13.314Z (13 days ago)
- Topics: autocompletion, database, nvim, nvim-cmp
- Language: Lua
- Homepage:
- Size: 75.2 KB
- Stars: 62
- Watchers: 3
- Forks: 9
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cmp-dbee
[](https://github.com/MattiasMTS/cmp-dbee/actions/workflows/ci.yml)
- [cmp-dbee](#cmp-dbee)
- [Showcase](#showcase)
- [Usage](#usage)
- [Suggestions](#suggestions)
- [Installation](#installation)
Autocompletion plugin for [nvim-dbee](https://github.com/kndndrj/nvim-dbee/) database client.
> Still very much a WIP plugin => expect some breaking changes.
Feel free to open any issues or PRs as you seem fit!
## Showcase
https://github.com/MattiasMTS/cmp-dbee/assets/86059470/1a0141dd-cb4d-47ce-b510-148d654d9503
## Usage
cmp-dbee is using a little bit of regex but mostly Treesitter to generate
suggestions.### Suggestions
TL;DR
- schemas
- leaf of schemas (tables, views, functions, etc)
- aliases
- CTEs
- columns: name and dtype (by referencing aliases)By default, schema + model suggestion is generated whenever a user hits "space".
At this point, the syntax for the SQL query isn't complete and the plugin
therefore uses a little bit of regex to "find/match" the selected schema.Ones the schemas has been found, the plugin suggests all the "leafs"
for the schema.CTEs and aliases are suggested based on the cursor position. I.e. if you've
two _complete_ (complete = ended with ';') queries in the buffer. Then, only
the aliases and ctes which the current cursor are nearest will be suggested.Column suggestion is provided by being explicit. I.e. you'd have to refer the
alias of a table if you want column completion. This is to reduce ambiguity
when there are other suggestions that compete. Column completion provide you
with the current name and the datatype of the column. As of now, only table
leafs provides columns. This might change in the future.## Installation
- Using **lazy**:
```lua
{
"hrsh7th/nvim-cmp",
dependencies = {
{
"MattiasMTS/cmp-dbee",
dependencies = {
{"kndndrj/nvim-dbee"}
},
ft = "sql", -- optional but good to have
opts = {}, -- needed
},
},
opts = {
sources = {
{ "cmp-dbee" },
},
},
}
```- Using **packer**:
```lua
use({"hrsh7th/nvim-cmp", requires = {"MattiasMTS/cmp-dbee"}})
use{
"kndndrj/nvim-dbee",
run = function()
require("dbee").install()
end,
}
```