Skip to content

KevinNitroG/blink-sql.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

blink-sql.nvim

SQL reserved keywords

Installation

lazy.nvim

---@type LazySpec
return {
  "KevinNitroG/blink-sql.nvim",
  specs = {
    {
      "Saghen/blink.cmp",
      ---@module 'blink.cmp'
      ---@type blink.cmp.Config
      opts = {
        sources = {
          providers = {
            sql = {
              name = "sql",
              module = "blink-sql",
              ---@module 'blink-sql'
              ---@type BlinkSql.Opts
              opts = nil,
            },
          },
        },
      },
    },
  },
  dependencies = {
    "Saghen/blink.cmp",
  },
}

Tweak

---@type table<string, table<string, true>>
local allowed_filetypes_nodes = {
  go = {
    raw_string_literal = true,
    string_literal = true,
    template_string = true,
    interpreted_string_literal = true,
  },
}

---@type LazySpec
return {
  "KevinNitroG/blink-sql.nvim",
  specs = {
    {
      "Saghen/blink.cmp",
      ---@module 'blink.cmp'
      ---@type blink.cmp.Config
      opts = {
        sources = {
          providers = {
            sql = {
              name = "sql",
              module = "blink-sql",
              score_offset = function(ctx)
                if vim.bo[ctx.bufnr].filetype:match("sql") then
                  return 0
                end
                return -5
              end,
              max_items = function(ctx)
                if vim.bo[ctx.bufnr].filetype:match("sql") then
                  return 10
                end
                return 50
              end,
              should_show_items = function(ctx)
                local filetype = vim.bo[ctx.bufnr].filetype
                if filetype:match("sql") then
                  return true
                end
                local ok, node = pcall(vim.treesitter.get_node)
                if not ok or not node then
                  return false
                end
                local allowed_filetype_nodes = allowed_filetypes_nodes[filetype]
                return allowed_filetype_nodes and allowed_filetype_nodes[node:type()] or false
              end,
            },
            lsp = {
              fallbacks = {
                "sql",
              },
            },
          },
          default = {
            "sql",
          },
        },
      },
      opts_extend = {
        "sources.default",
        "sources.providers.lsp.fallbacks",
      },
    },
  },
  dependencies = "Saghen/blink.cmp",
}

Source

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Languages