Home

Awesome

cmp-dbee

ci

<!--toc:start-->

Autocompletion plugin for 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

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

  {
    "hrsh7th/nvim-cmp",
    dependencies = {
      {
        "MattiasMTS/cmp-dbee",
        dependencies = {
          {"kndndrj/nvim-dbee"}
        },
        ft = "sql", -- optional but good to have
        opts = {}, -- needed
      },
    },
    opts = {
      sources = {
        { "cmp-dbee" },
      },
    },
  }
   use({"hrsh7th/nvim-cmp", requires = {"MattiasMTS/cmp-dbee"}})
   use{
     "kndndrj/nvim-dbee",
      run = function()
        require("dbee").install()
      end,
   }