Skip to content

MattiasMTS/cmp-dbee

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cmp-dbee

ci

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

cmp_dbee.mp4

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:
  {
    "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:
   use({"hrsh7th/nvim-cmp", requires = {"MattiasMTS/cmp-dbee"}})
   use{
     "kndndrj/nvim-dbee",
      run = function()
        require("dbee").install()
      end,
   }

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •