GoSQLX – Neovim LSP Setup

Prerequisites

Configuration

Add the following to your Neovim configuration (e.g. init.lua):

local lspconfig = require('lspconfig')
local configs = require('lspconfig.configs')

-- Register GoSQLX as a custom LSP server
if not configs.gosqlx then
  configs.gosqlx = {
    default_config = {
      cmd = { 'gosqlx', 'lsp' },
      filetypes = { 'sql', 'mysql', 'pgsql' },
      root_dir = lspconfig.util.root_pattern('.git', '.gosqlx.yaml'),
      settings = {},
    },
  }
end

lspconfig.gosqlx.setup{}

With Custom Options

lspconfig.gosqlx.setup{
  cmd = { 'gosqlx', 'lsp' },
  settings = {
    gosqlx = {
      dialect = 'postgresql',
      format = {
        indentSize = 2,
        uppercaseKeywords = true,
      },
    },
  },
}

Verify

Open a .sql file and run:

:LspInfo

You should see gosqlx listed as an active client.