From 393c31f241fc6c461b5d7b93f8aa35a297e80dcc Mon Sep 17 00:00:00 2001 From: Evan Reichard Date: Fri, 3 Apr 2026 09:57:45 -0400 Subject: [PATCH] fix(nvim): lsp sqls --- modules/home/common/default.nix | 2 +- .../terminal/nvim/config/lua/lsp-config.lua | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/modules/home/common/default.nix b/modules/home/common/default.nix index 72f274b..8ea89a4 100644 --- a/modules/home/common/default.nix +++ b/modules/home/common/default.nix @@ -5,6 +5,6 @@ jnv jq ncdu - rg + ripgrep ]; } diff --git a/modules/home/programs/terminal/nvim/config/lua/lsp-config.lua b/modules/home/programs/terminal/nvim/config/lua/lsp-config.lua index a8643db..4287ccf 100755 --- a/modules/home/programs/terminal/nvim/config/lua/lsp-config.lua +++ b/modules/home/programs/terminal/nvim/config/lua/lsp-config.lua @@ -97,6 +97,7 @@ local default_config = { capabilities = require("cmp_nvim_lsp").default_capabilities(), on_attach = on_attach, } + local setup_lsp = function(name, config) local final_config = vim.tbl_deep_extend("force", default_config, config or {}) @@ -159,10 +160,25 @@ setup_lsp("lua_ls", { setup_lsp("unison") -- SQL Configuration +-- NOTE: root_markers resolves root_dir but Neovim does NOT use root_dir as +-- the process cwd (cmd_cwd defaults to Neovim's cwd). We use cmd as a +-- function so we can read root_dir from the resolved config and build an +-- absolute path to .sqls.yml. setup_lsp("sqls", { on_attach = on_attach_no_formatting, - cmd = { nix_vars.sqls, "-config", ".sqls.yml" }, root_markers = { ".sqls.yml", ".git" }, + cmd = function(dispatchers, config) + local cmd = { nix_vars.sqls } + if config.root_dir then + local config_file = config.root_dir .. "/.sqls.yml" + if vim.fn.filereadable(config_file) == 1 then + cmd = { nix_vars.sqls, "-config", config_file } + end + end + return vim.lsp.rpc.start(cmd, dispatchers, { + cwd = config.root_dir, + }) + end, }) -- Nix LSP Configuration