Skip to content

Commit

Permalink
Merge branch 'master' into sqls-add-show-tables
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 authored Sep 14, 2024
2 parents fb76be6 + 213f207 commit c7f29ce
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.org
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* Add basic support for [[https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_pullDiagnostics][pull diagnostics]] requests.
* Add ~lsp-flush-delayed-changes-before-next-message~ customization point to enforce throttling document change notifications.
* Add ~lsp-sql-show-tables~ command.
* Fix bug in ~rust-analyzer.check.features~ configuration via ~lsp-rust-checkonsave-features~ Emacs setting: we were defaulting to ~[]~, but ~rust-analyzer~ defaults to inheriting the value from ~rust-analyzer.cargo.features~. The bug resulted in code hidden behind features not getting type checked when those features were enabled by setting ~rust-analyzer.cargo.features~ via the ~lsp-rust-features~ Emacs setting.

** 9.0.0
* Add language server config for QML (Qt Modeling Language) using qmlls.
Expand Down
24 changes: 21 additions & 3 deletions clients/lsp-rust.el
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ the latest build duration."

(defcustom lsp-rust-features []
"List of features to activate.
Corresponds to the `rust-analyzer` setting `rust-analyzer.cargo.features`.
Set this to `\"all\"` to pass `--all-features` to cargo."
:type 'lsp-string-vector
:group 'lsp-rust-rls
Expand Down Expand Up @@ -596,9 +597,15 @@ The command should include `--message=format=json` or similar option."
:group 'lsp-rust-analyzer
:package-version '(lsp-mode . "8.0.2"))

(defcustom lsp-rust-analyzer-checkonsave-features []
(defcustom lsp-rust-analyzer-checkonsave-features nil
"List of features to activate.
Set this to `\"all\"` to pass `--all-features` to cargo."
Corresponds to the `rust-analyzer` setting `rust-analyzer.check.features`.
When set to `nil` (default), the value of `lsp-rust-features' is inherited.
Set this to `\"all\"` to pass `--all-features` to cargo.
Note: setting this to `nil` means \"unset\", whereas setting this
to `[]` (empty vector) means \"set to empty list of features\",
which overrides any value that would otherwise be inherited from
`lsp-rust-features'."
:type 'lsp-string-vector
:group 'lsp-rust-rust-analyzer
:package-version '(lsp-mode . "8.0.2"))
Expand Down Expand Up @@ -1666,11 +1673,22 @@ https://github.com/rust-lang/rust-analyzer/blob/master/docs/dev/lsp-extensions.m
:merge (:glob ,(lsp-json-bool lsp-rust-analyzer-imports-merge-glob))
:prefix ,lsp-rust-analyzer-import-prefix)
:lruCapacity ,lsp-rust-analyzer-lru-capacity
;; This `checkOnSave` is called `check` in the `rust-analyzer` docs, not
;; `checkOnSave`, but the `rust-analyzer` source code shows that both names
;; work. The `checkOnSave` name has been supported by `rust-analyzer` for a
;; long time, whereas the `check` name was introduced here in 2023:
;; https://github.com/rust-lang/rust-analyzer/commit/d2bb62b6a81d26f1e41712e04d4ac760f860d3b3
:checkOnSave ( :enable ,(lsp-json-bool lsp-rust-analyzer-cargo-watch-enable)
:command ,lsp-rust-analyzer-cargo-watch-command
:extraArgs ,lsp-rust-analyzer-cargo-watch-args
:allTargets ,(lsp-json-bool lsp-rust-analyzer-check-all-targets)
:features ,lsp-rust-analyzer-checkonsave-features
;; We need to distinguish between setting this to the empty
;; vector, and not setting it at all, which `rust-analyzer`
;; interprets as "inherit from
;; `rust-analyzer.cargo.features`". We use `nil` to mean
;; "unset".
,@(when (vectorp lsp-rust-analyzer-checkonsave-features)
`(:features ,lsp-rust-analyzer-checkonsave-features))
:overrideCommand ,lsp-rust-analyzer-cargo-override-command)
:highlightRelated ( :breakPoints (:enable ,(lsp-json-bool lsp-rust-analyzer-highlight-breakpoints))
:closureCaptures (:enable ,(lsp-json-bool lsp-rust-analyzer-highlight-closure-captures))
Expand Down
2 changes: 1 addition & 1 deletion clients/lsp-tex.el
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection lsp-clients-digestif-executable)
:major-modes '(plain-tex-mode latex-mode context-mode texinfo-mode LaTex-mode)
:major-modes '(plain-tex-mode latex-mode context-mode texinfo-mode LaTeX-mode)
:priority (if (eq lsp-tex-server 'digestif) 1 -1)
:server-id 'digestif))

Expand Down
32 changes: 30 additions & 2 deletions docs/manual-language-docs/lsp-sqls.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ root_file: docs/manual-language-docs/lsp-sqls.md
```

Alternatively, you can leave `lsp-sqls-workspace-config-path` to the default "workspace" value, and put a json file in `<project>/.sqls/config.json` containing
## Storing Configuration in `<project>/.sqls/config.json`

Alternatively, you can store your configuration in the project root at `<project>/.sqls/config.json`:

```
{
"sqls": {
Expand All @@ -29,4 +32,29 @@ Alternatively, you can leave `lsp-sqls-workspace-config-path` to the default "wo
}
```

Now lsp should start in sql-mode buffers, and you can pick a server connection with `M-x lsp-execute-code-action` and "Switch Connections" (or directly with `M-x lsp-sql-switch-connection`). You can change database with `M-x lsp-execute-code-action` and "Switch Database" (or `M-x lsp-sql-switch-database`).
In this case, you need to set `lsp-sqls-workspace-config-path` to "root":

```emacs-lisp
(setq lsp-sqls-workspace-config-path "root")
```

## Storing Configuration in the Current Directory

If you want to configure it for the current directory, you can create a `.sqls/config.json` file:

```
.sqls/config.json
target.sql
```

For this setup, ensure that `lsp-sqls-workspace-config-path` is set to "workspace":

```emacs-lisp
(setq lsp-sqls-workspace-config-path "workspace")
```

# Switching Connections and Databases

Now, lsp should start in sql-mode buffers. You can choose a server connection using `M-x lsp-execute-code-action` and then selecting "Switch Connections", or directly with `M-x lsp-sql-switch-connection`.

To change the database, use `M-x lsp-execute-code-action` and select "Switch Database" (or `M-x lsp-sql-switch-database`).

0 comments on commit c7f29ce

Please sign in to comment.