From 4d8caa0f5adba069565ebf08b0013e0d9e193c07 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Tue, 17 Sep 2024 22:05:43 +0200 Subject: [PATCH 01/84] docs: generate --- doc/rustaceanvim.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/rustaceanvim.txt b/doc/rustaceanvim.txt index facf0e45..035696bc 100644 --- a/doc/rustaceanvim.txt +++ b/doc/rustaceanvim.txt @@ -423,8 +423,9 @@ LSP configuration utility *rustaceanvim.config.server* rustaceanvim.LoadRASettingsOpts *rustaceanvim.LoadRASettingsOpts* Fields: ~ - {settings_file_pattern} (string|nil) File name or pattern to search for. Defaults to 'rust-analyzer.json' - {default_settings} (table|nil) Default settings to merge the loaded settings into + {settings_file_pattern} (string|nil) + (deprecated) File name or pattern to search for. Defaults to 'rust-analyzer.json' + {default_settings} (table|nil) Default settings to merge the loaded settings into. *server.load_rust_analyzer_settings* From bb7ca76b4db6bab5cf25b0e8d940dea6ed733d1e Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Tue, 17 Sep 2024 22:08:56 +0200 Subject: [PATCH 02/84] chore: update flake.lock (#504) Co-authored-by: github-actions[bot] --- flake.lock | 164 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 119 insertions(+), 45 deletions(-) diff --git a/flake.lock b/flake.lock index 5dd678bb..daf6986b 100644 --- a/flake.lock +++ b/flake.lock @@ -96,16 +96,32 @@ "type": "github" } }, + "flake-compat_7": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1725234343, - "narHash": "sha256-+ebgonl3NbiKD2UD0x4BszCZQ6sTfL4xioaM49o5B3Y=", + "lastModified": 1726153070, + "narHash": "sha256-HO4zgY0ekfwO5bX0QH/3kJ/h4KvUDFZg8YpkNwIbg1U=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "567b938d64d4b4112ee253b9274472dc3a346eb6", + "rev": "bcef6817a8b2aa20a5a6dbb19b43e63c5bf8619a", "type": "github" }, "original": { @@ -137,11 +153,11 @@ "nixpkgs-lib": "nixpkgs-lib_3" }, "locked": { - "lastModified": 1725234343, - "narHash": "sha256-+ebgonl3NbiKD2UD0x4BszCZQ6sTfL4xioaM49o5B3Y=", + "lastModified": 1726153070, + "narHash": "sha256-HO4zgY0ekfwO5bX0QH/3kJ/h4KvUDFZg8YpkNwIbg1U=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "567b938d64d4b4112ee253b9274472dc3a346eb6", + "rev": "bcef6817a8b2aa20a5a6dbb19b43e63c5bf8619a", "type": "github" }, "original": { @@ -159,11 +175,11 @@ ] }, "locked": { - "lastModified": 1725234343, - "narHash": "sha256-+ebgonl3NbiKD2UD0x4BszCZQ6sTfL4xioaM49o5B3Y=", + "lastModified": 1726153070, + "narHash": "sha256-HO4zgY0ekfwO5bX0QH/3kJ/h4KvUDFZg8YpkNwIbg1U=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "567b938d64d4b4112ee253b9274472dc3a346eb6", + "rev": "bcef6817a8b2aa20a5a6dbb19b43e63c5bf8619a", "type": "github" }, "original": { @@ -199,11 +215,11 @@ "nixpkgs-lib": "nixpkgs-lib_4" }, "locked": { - "lastModified": 1696343447, - "narHash": "sha256-B2xAZKLkkeRFG5XcHHSXXcP7To9Xzr59KXeZiRf4vdQ=", + "lastModified": 1725234343, + "narHash": "sha256-+ebgonl3NbiKD2UD0x4BszCZQ6sTfL4xioaM49o5B3Y=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "c9afaba3dfa4085dbd2ccb38dfade5141e33d9d4", + "rev": "567b938d64d4b4112ee253b9274472dc3a346eb6", "type": "github" }, "original": { @@ -307,6 +323,31 @@ "type": "github" } }, + "git-hooks_4": { + "inputs": { + "flake-compat": "flake-compat_7", + "gitignore": "gitignore_5", + "nixpkgs": [ + "vimcats", + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable_4" + }, + "locked": { + "lastModified": 1725438226, + "narHash": "sha256-lL4hQ+g2qiZ02WfidLkrujaT23c6E2Wm7S0ZQhSB8Jk=", + "owner": "mrcjkb", + "repo": "git-hooks.nix", + "rev": "ec0f4d97f48a1f32bd87804e2390f03999790ec0", + "type": "github" + }, + "original": { + "owner": "mrcjkb", + "ref": "clippy", + "repo": "git-hooks.nix", + "type": "github" + } + }, "gitignore": { "inputs": { "nixpkgs": [ @@ -395,6 +436,28 @@ "type": "github" } }, + "gitignore_5": { + "inputs": { + "nixpkgs": [ + "vimcats", + "git-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "hercules-ci-effects": { "inputs": { "flake-parts": "flake-parts_5", @@ -443,11 +506,11 @@ "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1725686700, - "narHash": "sha256-wCjTrQhEcsU3Gb4wUzKZgJzD/Ydm+cwU+wzRUAhwua0=", + "lastModified": 1726291442, + "narHash": "sha256-V0heel8HhLtvFzBBSss7EKnBowhTYN+xO4DYCwsPSxw=", "owner": "nvim-neorocks", "repo": "neorocks", - "rev": "b4ecf2fc5d258e2d8754d573785209098877fa93", + "rev": "b628f6aef1453ebad58a970070c112855e93c044", "type": "github" }, "original": { @@ -466,11 +529,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1725621813, - "narHash": "sha256-PULZxwVju7sX7YTDiu2Gr15htFEEoMJ95ZZ6FGj+qa0=", + "lastModified": 1726189029, + "narHash": "sha256-A6rw8kgxTDmuGD6D8kooF9V++iAeXXgqay0vKG/zi/M=", "owner": "nix-community", "repo": "neovim-nightly-overlay", - "rev": "f751e2e0c00a9393410361b205f42658611ae89b", + "rev": "3b426df85fb2edc0da26673c464709e9c8b0c654", "type": "github" }, "original": { @@ -482,11 +545,11 @@ "neovim-src": { "flake": false, "locked": { - "lastModified": 1725578611, - "narHash": "sha256-sRezYqvmEjS/TIumXiwIN+ttuEPhNNtDnUY7wCpSCAs=", + "lastModified": 1726157817, + "narHash": "sha256-Vu2rOpAKlEFu+dGewEBsnAuHHxj8XbGqF52WGmu1NNY=", "owner": "neovim", "repo": "neovim", - "rev": "9570ad24f52442d75d677412cfe2fa83a7ff7a88", + "rev": "deac7df80a1491ae65b68a1a1047902bcd775adc", "type": "github" }, "original": { @@ -549,23 +612,33 @@ }, "nixpkgs-lib_4": { "locked": { - "dir": "lib", - "lastModified": 1696019113, - "narHash": "sha256-X3+DKYWJm93DRSdC5M6K5hLqzSya9BjibtBsuARoPco=", + "lastModified": 1725233747, + "narHash": "sha256-Ss8QWLXdr2JCBPcYChJhz4xJm+h/xjl4G0c0XlP6a74=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/356624c12086a18f2ea2825fed34523d60ccc4e3.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/356624c12086a18f2ea2825fed34523d60ccc4e3.tar.gz" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1720386169, + "narHash": "sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "f5892ddac112a1e9b3612c39af1b72987ee5783a", + "rev": "194846768975b7ad2c4988bdb82572c00222c0d7", "type": "github" }, "original": { - "dir": "lib", "owner": "NixOS", - "ref": "nixos-unstable", + "ref": "nixos-24.05", "repo": "nixpkgs", "type": "github" } }, - "nixpkgs-stable": { + "nixpkgs-stable_2": { "locked": { "lastModified": 1720386169, "narHash": "sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo=", @@ -581,7 +654,7 @@ "type": "github" } }, - "nixpkgs-stable_2": { + "nixpkgs-stable_3": { "locked": { "lastModified": 1720386169, "narHash": "sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo=", @@ -597,7 +670,7 @@ "type": "github" } }, - "nixpkgs-stable_3": { + "nixpkgs-stable_4": { "locked": { "lastModified": 1720386169, "narHash": "sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo=", @@ -631,11 +704,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1725503534, - "narHash": "sha256-hd1eRyPtTkRnAPYpnEfzugQwAifVYMmOR3z+MTTSw+g=", + "lastModified": 1726108120, + "narHash": "sha256-Ji5wO1lLG99grI0qCRb6FyRPpH9tfdfD1QP/r7IlgfM=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "fcb54ddcc974cff59bdfb7c1ac9e080299763d2d", + "rev": "111ed8812c10d7dc3017de46cbf509600c93f551", "type": "github" }, "original": { @@ -647,11 +720,11 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1725534445, - "narHash": "sha256-Yd0FK9SkWy+ZPuNqUgmVPXokxDgMJoGuNpMEtkfcf84=", + "lastModified": 1726206720, + "narHash": "sha256-tI7141IHDABMNgz4iXDo8agCp0SeTLbaIZ2DRndwcmk=", "owner": "nixos", "repo": "nixpkgs", - "rev": "9bb1e7571aadf31ddb4af77fc64b2d59580f9a39", + "rev": "673d99f1406cb09b8eb6feab4743ebdf70046557", "type": "github" }, "original": { @@ -663,11 +736,11 @@ }, "nixpkgs_5": { "locked": { - "lastModified": 1725534445, - "narHash": "sha256-Yd0FK9SkWy+ZPuNqUgmVPXokxDgMJoGuNpMEtkfcf84=", + "lastModified": 1726206720, + "narHash": "sha256-tI7141IHDABMNgz4iXDo8agCp0SeTLbaIZ2DRndwcmk=", "owner": "nixos", "repo": "nixpkgs", - "rev": "9bb1e7571aadf31ddb4af77fc64b2d59580f9a39", + "rev": "673d99f1406cb09b8eb6feab4743ebdf70046557", "type": "github" }, "original": { @@ -695,11 +768,11 @@ }, "nixpkgs_7": { "locked": { - "lastModified": 1697379843, - "narHash": "sha256-RcnGuJgC2K/UpTy+d32piEoBXq2M+nVFzM3ah/ZdJzg=", + "lastModified": 1725910328, + "narHash": "sha256-n9pCtzGZ0httmTwMuEbi5E78UQ4ZbQMr1pzi5N0LAG8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "12bdeb01ff9e2d3917e6a44037ed7df6e6c3df9d", + "rev": "5775c2583f1801df7b790bf7f7d710a19bac66f4", "type": "github" }, "original": { @@ -743,14 +816,15 @@ "vimcats": { "inputs": { "flake-parts": "flake-parts_6", + "git-hooks": "git-hooks_4", "nixpkgs": "nixpkgs_7" }, "locked": { - "lastModified": 1725500280, - "narHash": "sha256-Gk3wy8OvvW26bd+wVRjuHPch6DJOXJjW2TK7Jbe0hrw=", + "lastModified": 1726045206, + "narHash": "sha256-/ekQF2pE/juZ7AVge9bqodQLx4n0uaV4j2taD5U78R0=", "owner": "mrcjkb", "repo": "vimcats", - "rev": "eeba18f1205388f403b1b3cc5a71747e0ca0a2ba", + "rev": "fd213ad22ffbfff87899c872752a1c92814c93fa", "type": "github" }, "original": { From 5c0c44149e43b907dae2e0fe053284ad56226eb7 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Wed, 18 Sep 2024 18:54:11 +0200 Subject: [PATCH 03/84] feat(lsp): notify if rust-analyzer status is not healthy (#508) --- CHANGELOG.md | 6 ++++++ lua/rustaceanvim/server_status.lua | 3 +++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c598556..8ac5ca86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [5.6.0] - 2024-09-18 + +### Added + +- LSP: Notify if rust-analyzer is not healthy. + ## [5.5.0] - 2024-09-16 ### Changed diff --git a/lua/rustaceanvim/server_status.lua b/lua/rustaceanvim/server_status.lua index 21390451..14a8ef28 100644 --- a/lua/rustaceanvim/server_status.lua +++ b/lua/rustaceanvim/server_status.lua @@ -7,6 +7,9 @@ local _ran_once = {} ---@param result rustaceanvim.internal.RAInitializedStatus function M.handler(_, result, ctx, _) + if result and result.health and result.health ~= 'ok' then + vim.notify_once("rust-analyzer health is not OK. Run 'RustLsp logFile' for details", vim.log.levels.WARN) + end -- quiescent means the full set of results is ready. if not result.quiescent or _ran_once[ctx.client_id] then return From 4786724810d040c5b7607291323ac23da0d8a2ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Cruz?= Date: Thu, 19 Sep 2024 16:40:02 +0100 Subject: [PATCH 04/84] feat(lsp): more information on LSP errors (#509) --- CHANGELOG.md | 6 ++++++ lua/rustaceanvim/config/internal.lua | 1 + lua/rustaceanvim/server_status.lua | 18 ++++++++++++++---- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ac5ca86..a660020e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Added + +- LSP: Add more information to rust-analyzer unhealthy notifications + ## [5.6.0] - 2024-09-18 ### Added diff --git a/lua/rustaceanvim/config/internal.lua b/lua/rustaceanvim/config/internal.lua index 198e3bef..b7797af5 100644 --- a/lua/rustaceanvim/config/internal.lua +++ b/lua/rustaceanvim/config/internal.lua @@ -10,6 +10,7 @@ local RustaceanConfig ---@class rustaceanvim.internal.RAInitializedStatus : rustaceanvim.RAInitializedStatus ---@field health rustaceanvim.lsp_server_health_status ---@field quiescent boolean inactive? +---@field message string | nil --- ---@param dap_adapter rustaceanvim.dap.executable.Config | rustaceanvim.dap.server.Config | rustaceanvim.disable ---@return boolean diff --git a/lua/rustaceanvim/server_status.lua b/lua/rustaceanvim/server_status.lua index 14a8ef28..46d35314 100644 --- a/lua/rustaceanvim/server_status.lua +++ b/lua/rustaceanvim/server_status.lua @@ -7,11 +7,21 @@ local _ran_once = {} ---@param result rustaceanvim.internal.RAInitializedStatus function M.handler(_, result, ctx, _) - if result and result.health and result.health ~= 'ok' then - vim.notify_once("rust-analyzer health is not OK. Run 'RustLsp logFile' for details", vim.log.levels.WARN) - end -- quiescent means the full set of results is ready. - if not result.quiescent or _ran_once[ctx.client_id] then + if not result or not result.quiescent then + return + end + -- notify of LSP errors/warnings + if result.health and result.health ~= 'ok' then + local message = ([[ +rust-analyzer health status is [%s]: +%s +Run ':RustLsp logFile' for details. +]]):format(result.health, result.message or '[unknown error]') + vim.notify(message, vim.log.levels.WARN) + end + -- deduplicate messages. + if _ran_once[ctx.client_id] then return end -- rust-analyzer may provide incomplete/empty inlay hints by the time Neovim From 42a6d3342608dcbe0986919753385f3dea00ac14 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Thu, 19 Sep 2024 17:40:28 +0200 Subject: [PATCH 05/84] docs(changelog): prepare release --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a660020e..11b8d298 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,11 +6,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [5.7.0] ### Added -- LSP: Add more information to rust-analyzer unhealthy notifications +- LSP: More information in unhealthy rust-analyzer notifications. + Thanks [@edevil](https://github.com/edevil)! ## [5.6.0] - 2024-09-18 From ca76a28cd4477add00e3ad29765cae99d105cb96 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Fri, 20 Sep 2024 07:50:47 +0200 Subject: [PATCH 06/84] ci: release-please --- .../workflows/{release.yml => luarocks.yml} | 24 +++++++++---------- .github/workflows/release-please-config.json | 3 +++ .github/workflows/release-please.yml | 23 ++++++++++++++++++ .github/workflows/review-checklist.yml | 1 - 4 files changed, 37 insertions(+), 14 deletions(-) rename .github/workflows/{release.yml => luarocks.yml} (55%) create mode 100644 .github/workflows/release-please-config.json create mode 100644 .github/workflows/release-please.yml diff --git a/.github/workflows/release.yml b/.github/workflows/luarocks.yml similarity index 55% rename from .github/workflows/release.yml rename to .github/workflows/luarocks.yml index fddca06d..46a87fa9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/luarocks.yml @@ -1,8 +1,12 @@ -name: "Release" +--- +name: "Push to LuaRocks" on: push: tags: - "*" + release: + types: + - created pull_request: jobs: @@ -12,23 +16,17 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - name: Fail if changelog entry does not exist - if: startsWith(github.ref, 'refs/tags/') - run: grep -q "${{ github.ref_name }}" CHANGELOG.md + with: + fetch-depth: 0 # Required to count the commits + - name: Get Version + run: echo "LUAROCKS_VERSION=$(git describe --abbrev=0 --tags)" >> $GITHUB_ENV - name: LuaRocks Upload - uses: nvim-neorocks/luarocks-tag-release@v5 + uses: nvim-neorocks/luarocks-tag-release@v7 env: LUAROCKS_API_KEY: ${{ secrets.LUAROCKS_API_KEY }} with: - test_interpreters: "" + version: ${{ env.LUAROCKS_VERSION }} detailed_description: | This plugin automatically configures the rust-analyzer builtin LSP client and integrates with other Rust tools. See the README's #features section for more info. - - name: GitHub Release - if: startsWith(github.ref, 'refs/tags/') - uses: ncipollo/release-action@v1 - with: - bodyFile: "CHANGELOG.md" - allowUpdates: true - diff --git a/.github/workflows/release-please-config.json b/.github/workflows/release-please-config.json new file mode 100644 index 00000000..b7be3ef1 --- /dev/null +++ b/.github/workflows/release-please-config.json @@ -0,0 +1,3 @@ +{ + "bootstrap-sha": "42a6d3342608dcbe0986919753385f3dea00ac14" +} diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 00000000..b36c6eff --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,23 @@ +--- +permissions: + contents: write + pull-requests: write + +name: Release Please + +on: + workflow_dispatch: + push: + branches: + - master + +jobs: + release: + name: release + runs-on: ubuntu-latest + steps: + - uses: googleapis/release-please-action@v4 + with: + release-type: simple + token: ${{ secrets.PAT }} + config-file: .github/workflows/release-please-config.json diff --git a/.github/workflows/review-checklist.yml b/.github/workflows/review-checklist.yml index 8d31faf5..ee2e20ff 100644 --- a/.github/workflows/review-checklist.yml +++ b/.github/workflows/review-checklist.yml @@ -49,6 +49,5 @@ jobs: - [ ] Tests have been added. - [ ] Tested manually (Steps to reproduce in PR description). - [ ] Updated documentation. - - [ ] Updated [CHANGELOG.md](https://github.com/mrcjkb/rustaceanvim/blob/master/CHANGELOG.md) `, }) From d18acf9de01ada4fc6a19a1e94e18d39c4a0e5fd Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Fri, 20 Sep 2024 11:56:49 +0200 Subject: [PATCH 07/84] docs(changelog): remove keepachangelog headig --- CHANGELOG.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 11b8d298..7945eaa6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,9 +3,6 @@ All notable changes to this project will be documented in this file. -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - ## [5.7.0] ### Added From 05c701087d1b332d45926b9170647f2bbfd6ffe3 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Fri, 20 Sep 2024 11:58:32 +0200 Subject: [PATCH 08/84] docs(changelog): remove keepachangelog headig --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7945eaa6..7fabf01e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ # Changelog All notable changes to this project will be documented in this file. +This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [5.7.0] From b52bbc4bb0e50bf7da65b2695e1d602344877858 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Fri, 20 Sep 2024 12:33:18 +0200 Subject: [PATCH 09/84] feat(lsp): `` mapping for hover actions (#510) --- README.md | 12 ++++++++++++ lua/rustaceanvim/hover_actions.lua | 13 ++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 3f125923..0603833e 100644 --- a/README.md +++ b/README.md @@ -403,6 +403,18 @@ vim.keymap.set( By default, this plugin replaces Neovim's built-in hover handler with hover actions, so you can also use `vim.lsp.buf.hover()`. + You can invoke a hover action by switching to the hover window and entering `` + on the respective line, or with a keymap for the `RustHoverAction` mapping, + which accepts a `` prefix as the (1-based) index of the hover action to invoke. + + For example, if you set the following keymap: + + ```lua + vim.keymap.set('n', 'a', 'RustHoverAction') + ``` + + you can invoke the third hover action with `3a`. + ![](https://github.com/mrcjkb/rustaceanvim/assets/12857160/c7b6c730-4439-47b0-9a75-7ea4e6831f7a) diff --git a/lua/rustaceanvim/hover_actions.lua b/lua/rustaceanvim/hover_actions.lua index cfcd0e70..c9b09726 100644 --- a/lua/rustaceanvim/hover_actions.lua +++ b/lua/rustaceanvim/hover_actions.lua @@ -30,10 +30,8 @@ end -- run the command under the cursor, if the thing under the cursor is not the -- command then do nothing ---@param ctx table -local function run_command(ctx) - local winnr = vim.api.nvim_get_current_win() - local line = vim.api.nvim_win_get_cursor(winnr)[1] - +---@param line integer +local function run_command(ctx, line) if line > #_state.commands then return end @@ -132,8 +130,13 @@ function M.handler(_, result, ctx) -- run the command under the cursor vim.keymap.set('n', '', function() - run_command(ctx) + local line = vim.api.nvim_win_get_cursor(winnr)[1] + run_command(ctx, line) end, { buffer = bufnr, noremap = true, silent = true }) + vim.keymap.set('n', 'RustHoverAction', function() + local line = math.max(vim.v.count, 1) + run_command(ctx, line) + end, { buffer = vim.api.nvim_get_current_buf(), noremap = true, silent = true }) end local rl = require('rustaceanvim.rust_analyzer') From 6dece0cfb8c74a3ba9e78091cb1f85a033eacf4c Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Fri, 20 Sep 2024 12:41:12 +0200 Subject: [PATCH 10/84] ci(changelog): disable markdownlint --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fabf01e..099816a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ - + # Changelog All notable changes to this project will be documented in this file. From 9db87deb7b00d64466b56afff645756530db1c03 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Fri, 20 Sep 2024 12:43:45 +0200 Subject: [PATCH 11/84] fix: remove luajit requirement (#512) --- lua/rustaceanvim/dap.lua | 53 ++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/lua/rustaceanvim/dap.lua b/lua/rustaceanvim/dap.lua index 38673813..2ae16114 100644 --- a/lua/rustaceanvim/dap.lua +++ b/lua/rustaceanvim/dap.lua @@ -310,32 +310,33 @@ function M.start(args, verbose, callback, on_error) end vim.schedule(function() local executables = {} - for value in output:gmatch('([^\n]*)\n?') do - local is_json, artifact = pcall(vim.fn.json_decode, value) - if not is_json then - goto loop_end - end - - -- only process artifact if it's valid json object and it is a compiler artifact - if type(artifact) ~= 'table' or artifact.reason ~= 'compiler-artifact' then - goto loop_end - end - - local is_binary = vim.list_contains(artifact.target.crate_types, 'bin') - local is_build_script = vim.list_contains(artifact.target.kind, 'custom-build') - local is_test = ((artifact.profile.test == true) and (artifact.executable ~= nil)) - or vim.list_contains(artifact.target.kind, 'test') - -- only add executable to the list if we want a binary debug and it is a binary - -- or if we want a test debug and it is a test - if - (cargo_args[1] == 'build' and is_binary and not is_build_script) - or (cargo_args[1] == 'test' and is_test) - then - table.insert(executables, artifact.executable) - end - - ::loop_end:: - end + vim + .iter(output:gmatch('([^\n]*)\n?')) + ---@param value string + :map(function(value) + local is_json, artifact = pcall(vim.fn.json_decode, value) + return is_json, artifact + end) + ---@param is_json boolean + :filter(function(is_json, artifact) + -- only process artifact if it's valid json object and it is a compiler artifact + return is_json and type(artifact) == 'table' and artifact.reason == 'compiler-artifact' + end) + ---@param artifact table + :each(function(_, artifact) + local is_binary = vim.list_contains(artifact.target.crate_types, 'bin') + local is_build_script = vim.list_contains(artifact.target.kind, 'custom-build') + local is_test = ((artifact.profile.test == true) and (artifact.executable ~= nil)) + or vim.list_contains(artifact.target.kind, 'test') + -- only add executable to the list if we want a binary debug and it is a binary + -- or if we want a test debug and it is a test + if + (cargo_args[1] == 'build' and is_binary and not is_build_script) + or (cargo_args[1] == 'test' and is_test) + then + table.insert(executables, artifact.executable) + end + end) -- only 1 executable is allowed for debugging - error out if zero or many were found if #executables <= 0 then on_error('No compilation artifacts found.') From f9ecc0c3084186a60513b83139a643a5cbf3bdf7 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Fri, 20 Sep 2024 12:48:00 +0200 Subject: [PATCH 12/84] chore(master): release 5.8.0 (#511) --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 099816a9..3583e36e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [5.8.0](https://github.com/mrcjkb/rustaceanvim/compare/5.7.0...v5.8.0) (2024-09-20) + + +### Features + +* **lsp:** `` mapping for hover actions ([#510](https://github.com/mrcjkb/rustaceanvim/issues/510)) ([b52bbc4](https://github.com/mrcjkb/rustaceanvim/commit/b52bbc4bb0e50bf7da65b2695e1d602344877858)) + + +### Bug Fixes + +* remove luajit requirement ([#512](https://github.com/mrcjkb/rustaceanvim/issues/512)) ([9db87de](https://github.com/mrcjkb/rustaceanvim/commit/9db87deb7b00d64466b56afff645756530db1c03)) + ## [5.7.0] ### Added From 9a369055aebd0411a11600f7cfd5c9b39c751eaa Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Sat, 21 Sep 2024 09:50:41 +0200 Subject: [PATCH 13/84] fix(lsp): update deprecated API calls (#514) --- .../commands/code_action_group.lua | 2 +- lua/rustaceanvim/compat.lua | 18 +++++++++ lua/rustaceanvim/health.lua | 40 ++++++++----------- 3 files changed, 35 insertions(+), 25 deletions(-) create mode 100644 lua/rustaceanvim/compat.lua diff --git a/lua/rustaceanvim/commands/code_action_group.lua b/lua/rustaceanvim/commands/code_action_group.lua index 85180923..356e8ac3 100644 --- a/lua/rustaceanvim/commands/code_action_group.lua +++ b/lua/rustaceanvim/commands/code_action_group.lua @@ -376,7 +376,7 @@ M.state = { M.code_action_group = function() local context = {} - context.diagnostics = vim.lsp.diagnostic.get_line_diagnostics() + context.diagnostics = require('rustaceanvim.compat').get_line_diagnostics() local params = vim.lsp.util.make_range_params() params.context = context diff --git a/lua/rustaceanvim/compat.lua b/lua/rustaceanvim/compat.lua new file mode 100644 index 00000000..229d929e --- /dev/null +++ b/lua/rustaceanvim/compat.lua @@ -0,0 +1,18 @@ +---@mod rustaceanvim.compat compativility layer for +---API calls that are deprecated or removed in nvim nightly + +local compat = {} + +---@return lsp.Diagnostic[] +function compat.get_line_diagnostics() + if vim.lsp.diagnostic.from then + local opts = { + lnum = vim.api.nvim_win_get_cursor(0)[1] - 1, + } + return vim.lsp.diagnostic.from(vim.diagnostic.get(0, opts)) + end + ---@diagnostic disable-next-line: deprecated + return vim.lsp.diagnostic.get_line_diagnostics() +end + +return compat diff --git a/lua/rustaceanvim/health.lua b/lua/rustaceanvim/health.lua index 584f0a45..c0489fc3 100644 --- a/lua/rustaceanvim/health.lua +++ b/lua/rustaceanvim/health.lua @@ -2,15 +2,7 @@ local health = {} -local h = vim.health or require('health') ----@diagnostic disable-next-line: deprecated -local start = h.start or h.report_start ----@diagnostic disable-next-line: deprecated -local ok = h.ok or h.report_ok ----@diagnostic disable-next-line: deprecated -local error = h.error or h.report_error ----@diagnostic disable-next-line: deprecated -local warn = h.warn or h.report_warn +local h = vim.health ---@class rustaceanvim.LuaDependency ---@field module string The name of a module @@ -43,11 +35,11 @@ local lua_dependencies = { ---@param dep rustaceanvim.LuaDependency local function check_lua_dependency(dep) if pcall(require, dep.module) then - ok(dep.url .. ' installed.') + h.ok(dep.url .. ' installed.') return end if dep.optional() then - warn(('%s not installed. %s %s'):format(dep.module, dep.info, dep.url)) + h.warn(('%s not installed. %s %s'):format(dep.module, dep.info, dep.url)) else error(('Lua dependency %s not found: %s'):format(dep.module, dep.url)) end @@ -88,14 +80,14 @@ local function check_external_dependency(dep) local mb_version_len = version_or_err and (mb_version_newline_idx and mb_version_newline_idx - 1 or version_or_err:len()) version_or_err = version_or_err and version_or_err:sub(0, mb_version_len) or '(unknown version)' - ok(('%s: found %s'):format(dep.name, version_or_err)) + h.ok(('%s: found %s'):format(dep.name, version_or_err)) if dep.extra_checks_if_installed then dep.extra_checks_if_installed(binary) end return end if dep.optional() then - warn(([[ + h.warn(([[ %s: not found. Install %s for extended capabilities. %s @@ -114,13 +106,13 @@ end ---@param config rustaceanvim.Config local function check_config(config) - start('Checking config') + h.start('Checking config') if vim.g.rustaceanvim and not config.was_g_rustaceanvim_sourced then error('vim.g.rustaceanvim is set, but it was sourced after rustaceanvim was initialized.') end local valid, err = require('rustaceanvim.config.check').validate(config) if valid then - ok('No errors found in config.') + h.ok('No errors found in config.') else error(err or '' .. vim.g.rustaceanvim and '' or ' This looks like a plugin bug!') end @@ -136,23 +128,23 @@ local function is_dap_enabled() end local function check_for_conflicts() - start('Checking for conflicting plugins') + h.start('Checking for conflicting plugins') require('rustaceanvim.config.check').check_for_lspconfig_conflict(error) if package.loaded['rustaceanvim.neotest'] ~= nil and package.loaded['neotest-rust'] ~= nil then error('rustaceanvim.neotest and neotest-rust are both loaded. This is likely a conflict.') return end - ok('No conflicting plugins detected.') + h.ok('No conflicting plugins detected.') end local function check_tree_sitter() - start('Checking for tree-sitter parser') + h.start('Checking for tree-sitter parser') local has_tree_sitter_rust_parser = #vim.api.nvim_get_runtime_file('parser/rust.so', true) > 0 or #vim.api.nvim_get_runtime_file('parser/rust.dll', true) > 0 if has_tree_sitter_rust_parser then - ok('tree-sitter parser for Rust detected.') + h.ok('tree-sitter parser for Rust detected.') else - warn("No tree-sitter parser for Rust detected. Required by 'Rustc unpretty' command.") + h.warn("No tree-sitter parser for Rust detected. Required by 'Rustc unpretty' command.") end end @@ -160,12 +152,12 @@ function health.check() local types = require('rustaceanvim.types.internal') local config = require('rustaceanvim.config.internal') - start('Checking for Lua dependencies') + h.start('Checking for Lua dependencies') for _, dep in ipairs(lua_dependencies) do check_lua_dependency(dep) end - start('Checking external dependencies') + h.start('Checking external dependencies') local adapter = types.evaluate(config.dap.adapter) ---@cast adapter rustaceanvim.dap.executable.Config | rustaceanvim.dap.server.Config | boolean @@ -207,7 +199,7 @@ function health.check() extra_checks_if_not_installed = function() local bin = get_rust_analyzer_binary() if vim.fn.executable(bin) == 1 then - warn("rust-analyzer wrapper detected. Run 'rustup component add rust-analyzer' to install rust-analyzer.") + h.warn("rust-analyzer wrapper detected. Run 'rustup component add rust-analyzer' to install rust-analyzer.") end end, }, @@ -281,7 +273,7 @@ function health.check() }) end if adapter == false and is_dap_enabled() then - warn('No debug adapter detected. Make sure either lldb or codelldb is available on the path.') + h.warn('No debug adapter detected. Make sure either lldb or codelldb is available on the path.') end for _, dep in ipairs(external_dependencies) do check_external_dependency(dep) From 6511cb09310972f07c859836e5051e7434a19fc7 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Sat, 21 Sep 2024 13:31:57 +0200 Subject: [PATCH 14/84] chore(master): release 5.8.1 (#515) --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3583e36e..97a1e4a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [5.8.1](https://github.com/mrcjkb/rustaceanvim/compare/v5.8.0...v5.8.1) (2024-09-21) + + +### Bug Fixes + +* **lsp:** update deprecated API calls ([#514](https://github.com/mrcjkb/rustaceanvim/issues/514)) ([9a36905](https://github.com/mrcjkb/rustaceanvim/commit/9a369055aebd0411a11600f7cfd5c9b39c751eaa)) + ## [5.8.0](https://github.com/mrcjkb/rustaceanvim/compare/5.7.0...v5.8.0) (2024-09-20) From 1f79f553208172ed9a02435f668b8e0b5c652078 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Sun, 22 Sep 2024 02:20:03 +0200 Subject: [PATCH 15/84] chore: update flake.lock (#516) Co-authored-by: github-actions[bot] --- flake.lock | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/flake.lock b/flake.lock index daf6986b..140e7ed4 100644 --- a/flake.lock +++ b/flake.lock @@ -281,11 +281,11 @@ "nixpkgs-stable": "nixpkgs-stable_2" }, "locked": { - "lastModified": 1725513492, - "narHash": "sha256-tyMUA6NgJSvvQuzB7A1Sf8+0XCHyfSPRx/b00o6K0uo=", + "lastModified": 1726745158, + "narHash": "sha256-D5AegvGoEjt4rkKedmxlSEmC+nNLMBPWFxvmYnVLhjk=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "7570de7b9b504cfe92025dd1be797bf546f66528", + "rev": "4e743a6920eab45e8ba0fbe49dc459f1423a4b74", "type": "github" }, "original": { @@ -310,11 +310,11 @@ ] }, "locked": { - "lastModified": 1725513492, - "narHash": "sha256-tyMUA6NgJSvvQuzB7A1Sf8+0XCHyfSPRx/b00o6K0uo=", + "lastModified": 1726745158, + "narHash": "sha256-D5AegvGoEjt4rkKedmxlSEmC+nNLMBPWFxvmYnVLhjk=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "7570de7b9b504cfe92025dd1be797bf546f66528", + "rev": "4e743a6920eab45e8ba0fbe49dc459f1423a4b74", "type": "github" }, "original": { @@ -506,11 +506,11 @@ "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1726291442, - "narHash": "sha256-V0heel8HhLtvFzBBSss7EKnBowhTYN+xO4DYCwsPSxw=", + "lastModified": 1726896389, + "narHash": "sha256-Qxh7GmtsB94T9EzROLvXIr486c//1M+S8apU7KoTVA0=", "owner": "nvim-neorocks", "repo": "neorocks", - "rev": "b628f6aef1453ebad58a970070c112855e93c044", + "rev": "39308fea510539a516a2620f859dd2c8f96fc935", "type": "github" }, "original": { @@ -529,11 +529,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1726189029, - "narHash": "sha256-A6rw8kgxTDmuGD6D8kooF9V++iAeXXgqay0vKG/zi/M=", + "lastModified": 1726814269, + "narHash": "sha256-eXI81wCtybqgK05ky5/tmj4AZDKmtoNQcGZEX0vnoe8=", "owner": "nix-community", "repo": "neovim-nightly-overlay", - "rev": "3b426df85fb2edc0da26673c464709e9c8b0c654", + "rev": "25aca068d0bd63c6db17c29bd3641256ea62a2c1", "type": "github" }, "original": { @@ -545,11 +545,11 @@ "neovim-src": { "flake": false, "locked": { - "lastModified": 1726157817, - "narHash": "sha256-Vu2rOpAKlEFu+dGewEBsnAuHHxj8XbGqF52WGmu1NNY=", + "lastModified": 1726786786, + "narHash": "sha256-SMRChiJK6Td+TtiphiXP+fc8ZNElfmAeHTF2y2y9y9w=", "owner": "neovim", "repo": "neovim", - "rev": "deac7df80a1491ae65b68a1a1047902bcd775adc", + "rev": "f01c764cc6f82399edfa0d47a7bafbf7c95e2747", "type": "github" }, "original": { @@ -704,11 +704,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1726108120, - "narHash": "sha256-Ji5wO1lLG99grI0qCRb6FyRPpH9tfdfD1QP/r7IlgfM=", + "lastModified": 1726583932, + "narHash": "sha256-zACxiQx8knB3F8+Ze+1BpiYrI+CbhxyWpcSID9kVhkQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "111ed8812c10d7dc3017de46cbf509600c93f551", + "rev": "658e7223191d2598641d50ee4e898126768fe847", "type": "github" }, "original": { @@ -720,11 +720,11 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1726206720, - "narHash": "sha256-tI7141IHDABMNgz4iXDo8agCp0SeTLbaIZ2DRndwcmk=", + "lastModified": 1726745986, + "narHash": "sha256-xB35C2fpz7iyNcj9sn0a+wM2C4CQ6DGTn5VUHogstYs=", "owner": "nixos", "repo": "nixpkgs", - "rev": "673d99f1406cb09b8eb6feab4743ebdf70046557", + "rev": "268bb5090a3c6ac5e1615b38542a868b52ef8088", "type": "github" }, "original": { @@ -736,11 +736,11 @@ }, "nixpkgs_5": { "locked": { - "lastModified": 1726206720, - "narHash": "sha256-tI7141IHDABMNgz4iXDo8agCp0SeTLbaIZ2DRndwcmk=", + "lastModified": 1726871744, + "narHash": "sha256-V5LpfdHyQkUF7RfOaDPrZDP+oqz88lTJrMT1+stXNwo=", "owner": "nixos", "repo": "nixpkgs", - "rev": "673d99f1406cb09b8eb6feab4743ebdf70046557", + "rev": "a1d92660c6b3b7c26fb883500a80ea9d33321be2", "type": "github" }, "original": { @@ -790,11 +790,11 @@ "nixpkgs-stable": "nixpkgs-stable_3" }, "locked": { - "lastModified": 1725513492, - "narHash": "sha256-tyMUA6NgJSvvQuzB7A1Sf8+0XCHyfSPRx/b00o6K0uo=", + "lastModified": 1726745158, + "narHash": "sha256-D5AegvGoEjt4rkKedmxlSEmC+nNLMBPWFxvmYnVLhjk=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "7570de7b9b504cfe92025dd1be797bf546f66528", + "rev": "4e743a6920eab45e8ba0fbe49dc459f1423a4b74", "type": "github" }, "original": { From 360ac5c80f299f282cbb1967bbfe5aa1e1c6e66e Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Mon, 23 Sep 2024 20:31:00 +0200 Subject: [PATCH 16/84] feat(lsp): only notify on server status error by default (#519) --- doc/rustaceanvim.txt | 40 +++++++++++++++++++++------- lua/rustaceanvim/config/init.lua | 19 ++++++++----- lua/rustaceanvim/config/internal.lua | 2 ++ lua/rustaceanvim/server_status.lua | 18 ++++++++++++- 4 files changed, 63 insertions(+), 16 deletions(-) diff --git a/doc/rustaceanvim.txt b/doc/rustaceanvim.txt index 035696bc..ee053514 100644 --- a/doc/rustaceanvim.txt +++ b/doc/rustaceanvim.txt @@ -299,18 +299,16 @@ rustaceanvim.lsp.ClientOpts *rustaceanvim.lsp.ClientOpts* {load_vscode_settings?} (boolean) Whether to search (upward from the buffer) for rust-analyzer settings in .vscode/settings json. If found, loaded settings will override configured options. - Default: true - - See: ~ - |vim.lsp.ClientConfig| + Default: `true` + {status_notify_level?} (rustaceanvim.server.status_notify_level) + Server status warning level to notify at. + Default: 'error' -rustaceanvim.dap.Opts *rustaceanvim.dap.Opts* +rustaceanvim.server.status_notify_level*rustaceanvim.server.status_notify_level* - Fields: ~ - {autoload_configurations} (boolean) - Whether to autoload nvim-dap configurations when rust-analyzer has attached? - Default: `true`. + Type: ~ + "error"|"warning"|rustaceanvim.disable rustaceanvim.disable *rustaceanvim.disable* @@ -319,6 +317,30 @@ rustaceanvim.disable *rustaceanvim.disable* false +rustaceanvim.dap.Opts *rustaceanvim.dap.Opts* + + Fields: ~ + {autoload_configurations?} (boolean) + Whether to autoload nvim-dap configurations when rust-analyzer has attached? + Default: `true` + {adapter?} (rustaceanvim.dap.executable.Config|rustaceanvim.dap.server.Config|rustaceanvim.disable|fun():rustaceanvim.dap.executable.Config|rustaceanvim.dap.server.Config|rustaceanvim.disable) + Defaults to creating the `rt_lldb` adapter, which is a |rustaceanvim.dap.server.Config| + if `codelldb` is detected, and a |rustaceanvim.dap.executable.Config|` if `lldb` is detected. + Set to `false` to disable. + {configuration?} (rustaceanvim.dap.client.Config|rustaceanvim.disable|fun():rustaceanvim.dap.client.Config|rustaceanvim.disable) + Dap client configuration. Defaults to a function that looks for a `launch.json` file + or returns a |rustaceanvim.dap.executable.Config| that launches the `rt_lldb` adapter. + Set to `false` to disable. + {add_dynamic_library_paths?} (boolean|fun():boolean) + Accommodate dynamically-linked targets by passing library paths to lldb. + Default: `true`. + {auto_generate_source_map?} (fun():boolean|boolean) + Whether to auto-generate a source map for the standard library. + {load_rust_types?} (fun():boolean|boolean) + Whether to get Rust types via initCommands (rustlib/etc/lldb_commands, lldb only). + Default: `true`. + + rustaceanvim.dap.Command *rustaceanvim.dap.Command* Type: ~ diff --git a/lua/rustaceanvim/config/init.lua b/lua/rustaceanvim/config/init.lua index 48f5d79f..afe6f53a 100644 --- a/lua/rustaceanvim/config/init.lua +++ b/lua/rustaceanvim/config/init.lua @@ -189,19 +189,28 @@ vim.g.rustaceanvim = vim.g.rustaceanvim --- ---Whether to search (upward from the buffer) for rust-analyzer settings in .vscode/settings json. ---If found, loaded settings will override configured options. ----Default: true +---Default: `true` ---@field load_vscode_settings? boolean +--- +---Server status warning level to notify at. +---Default: 'error' +---@field status_notify_level? rustaceanvim.server.status_notify_level +--- ---@see vim.lsp.ClientConfig +---@alias rustaceanvim.server.status_notify_level 'error' | 'warning' | rustaceanvim.disable + +---@alias rustaceanvim.disable false + ---@class rustaceanvim.dap.Opts --- ---Whether to autoload nvim-dap configurations when rust-analyzer has attached? ----Default: `true`. ----@field autoload_configurations boolean +---Default: `true` +---@field autoload_configurations? boolean --- ---Defaults to creating the `rt_lldb` adapter, which is a |rustaceanvim.dap.server.Config| ---if `codelldb` is detected, and a |rustaceanvim.dap.executable.Config|` if `lldb` is detected. --- Set to `false` to disable. +---Set to `false` to disable. ---@field adapter? rustaceanvim.dap.executable.Config | rustaceanvim.dap.server.Config | rustaceanvim.disable | fun():(rustaceanvim.dap.executable.Config | rustaceanvim.dap.server.Config | rustaceanvim.disable) --- ---Dap client configuration. Defaults to a function that looks for a `launch.json` file @@ -220,8 +229,6 @@ vim.g.rustaceanvim = vim.g.rustaceanvim ---Default: `true`. ---@field load_rust_types? fun():boolean | boolean ----@alias rustaceanvim.disable false - ---@alias rustaceanvim.dap.Command string ---@class rustaceanvim.dap.executable.Config diff --git a/lua/rustaceanvim/config/internal.lua b/lua/rustaceanvim/config/internal.lua index b7797af5..f9dfbceb 100644 --- a/lua/rustaceanvim/config/internal.lua +++ b/lua/rustaceanvim/config/internal.lua @@ -295,6 +295,8 @@ local RustaceanDefaultConfig = { }, ---@type boolean Whether to search (upward from the buffer) for rust-analyzer settings in .vscode/settings json. load_vscode_settings = true, + ---@type rustaceanvim.server.status_notify_level + status_notify_level = 'error', }, --- debugging stuff diff --git a/lua/rustaceanvim/server_status.lua b/lua/rustaceanvim/server_status.lua index 46d35314..89ae9b32 100644 --- a/lua/rustaceanvim/server_status.lua +++ b/lua/rustaceanvim/server_status.lua @@ -5,6 +5,22 @@ local M = {} ---@type { [integer]: boolean } local _ran_once = {} +---@param health rustaceanvim.lsp_server_health_status +---@return boolean +local function is_notify_enabled_for(health) + if health and health == 'ok' then + return false + end + local notify_level = config.server.status_notify_level + if not notify_level then + return false + end + if notify_level == 'error' then + return health == 'error' + end + return true +end + ---@param result rustaceanvim.internal.RAInitializedStatus function M.handler(_, result, ctx, _) -- quiescent means the full set of results is ready. @@ -12,7 +28,7 @@ function M.handler(_, result, ctx, _) return end -- notify of LSP errors/warnings - if result.health and result.health ~= 'ok' then + if is_notify_enabled_for(result.health) then local message = ([[ rust-analyzer health status is [%s]: %s From dc0ab4e36f9944901ed8a59878f92c2f818799a7 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Mon, 23 Sep 2024 20:33:36 +0200 Subject: [PATCH 17/84] chore(master): release 5.9.0 (#520) --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97a1e4a4..0d12e287 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [5.9.0](https://github.com/mrcjkb/rustaceanvim/compare/v5.8.1...v5.9.0) (2024-09-23) + + +### Features + +* **lsp:** only notify on server status error by default ([#519](https://github.com/mrcjkb/rustaceanvim/issues/519)) ([360ac5c](https://github.com/mrcjkb/rustaceanvim/commit/360ac5c80f299f282cbb1967bbfe5aa1e1c6e66e)) + ## [5.8.1](https://github.com/mrcjkb/rustaceanvim/compare/v5.8.0...v5.8.1) (2024-09-21) From 7d6f244e9699292eab8a65b487a710256c47a57a Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Thu, 26 Sep 2024 13:28:14 +0200 Subject: [PATCH 18/84] chore: q-a discussion form template --- .github/DISCUSSION_TEMPLATE/q-a.yml | 98 +++++++++++++++++++++++++++ .github/ISSUE_TEMPLATE/bug_report.yml | 13 +++- 2 files changed, 108 insertions(+), 3 deletions(-) create mode 100644 .github/DISCUSSION_TEMPLATE/q-a.yml diff --git a/.github/DISCUSSION_TEMPLATE/q-a.yml b/.github/DISCUSSION_TEMPLATE/q-a.yml new file mode 100644 index 00000000..a1b33e23 --- /dev/null +++ b/.github/DISCUSSION_TEMPLATE/q-a.yml @@ -0,0 +1,98 @@ +--- +labels: [Question] +body: + - type: markdown + attributes: + value: | + Thanks for your interest in rustaceanvim 🦀 + Please follow these instructions, fill every question, and do every step. 🙏 + - type: checkboxes + id: checks + attributes: + label: Checked other resources + description: Please confirm and check all the following options. + options: + - label: This is not a bug report or feature request (Please use [issues](https://github.com/mrcjkb/rustaceanvim/issues/new/choose) for those). + required: true + - label: I have read the README. + required: true + - label: I have searched for a solution using `:h rustaceanvim`. + required: true + - label: I have searched [existing discussions](https://github.com/mrcjkb/rustaceanvim/discussions). + required: true + - label: I have searched the existing issues/discussions of other plugins related to this question (if applicable). + required: false + - label: I have searched the [existing rust-analyzer discussions](https://github.com/rust-lang/rust-analyzer/discussions) (if applicable). + required: false + - label: I have added a very descriptive title to this question. + required: true + - type: textarea + id: example + attributes: + label: Example Code + description: | + Please add a self-contained, [minimal, reproducible, example](https://stackoverflow.com/help/minimal-reproducible-example) with your use case. + You can use [the minimal config as a template](https://github.com/mrcjkb/rustaceanvim/blob/master/troubleshooting/minimal.lua). + + If a maintainer can copy it, run it, and see it right away, there's a much higher chance that you'll be able to get help. + + > [!IMPORTANT] + > + > - Reduce your code to the minimum required to reproduce the issue if possible. This makes it much easier for others to help you. + > - Avoid screenshots when possible, as they are hard to read and (more importantly) don't allow others to copy-and-paste your code. + + placeholder: | + vim.env.LAZY_STDPATH = '.repro' + load(vim.fn.system('curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua'))() + + require('lazy.minit').repro { + spec = { + { + 'mrcjkb/rustaceanvim', + version = '^5', + init = function() + -- Configure rustaceanvim here + vim.g.rustaceanvim = {} + end, + lazy = false, + }, + }, + } + -- do anything else you need to do to reproduce the issue + render: lua + validations: + required: true + - type: textarea + id: description + attributes: + label: Description + description: | + What is the problem, question, or error? + + Write a short description explaining what you are doing, what you expect to happen, and what is currently happening. + placeholder: | + * I'm trying to use the `rustaceanvim` plugin to do X. + * I expect to see Y. + * Instead, it does Z. + validations: + required: true + - type: input + attributes: + label: "Neovim version (nvim -v)" + placeholder: "v0.10.1" + validations: + required: true + - type: input + attributes: + label: "Operating system/version" + placeholder: "NixOS 24.05" + validations: + required: true + - type: textarea + attributes: + label: "Output of :checkhealth rustaceanvim" + render: "console" + placeholder: | + Please paste the output here, as it may contain important information for debugging. + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index a859de02..e53ea05b 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -25,13 +25,13 @@ body: - type: input attributes: label: "Neovim version (nvim -v)" - placeholder: "v0.9.5" + placeholder: "v0.10.1" validations: required: true - type: input attributes: label: "Operating system/version" - placeholder: "NixOS 23.11" + placeholder: "NixOS 24.05" validations: required: true - type: textarea @@ -53,6 +53,7 @@ body: > - To rule out another plugin causing the issue, please start with a [minimal config](https://github.com/mrcjkb/rustaceanvim/blob/master/troubleshooting/minimal.lua). > - Please refer to the readme's [troubleshooting guide](https://github.com/mrcjkb/rustaceanvim?tab=readme-ov-file#stethoscope-troubleshooting). > - Please provide exact (repeatable) steps, including project initialization (if applicable). + > - Avoid screenshots when possible, as they are hard to read and (more importantly) don't allow others to copy-and-paste your code. placeholder: | mkdir -p /tmp/minimal NVIM_DATA_MINIMAL=/tmp/minimal NVIM_APP_NAME="nvim-minimal" -u minimal.lua @@ -78,6 +79,12 @@ body: label: "The minimal config used to reproduce this issue." description: | Run with `nvim -u minimal.lua` + + > [!IMPORTANT] + > + > - Reduce your code to the minimum required to reproduce. + > - Avoid screenshots when possible, as they are hard to read and (more importantly) don't allow others to copy-and-paste your code. + placeholder: | vim.env.LAZY_STDPATH = '.repro' load(vim.fn.system('curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua'))() @@ -86,7 +93,7 @@ body: spec = { { 'mrcjkb/rustaceanvim', - version = '^4', + version = '^5', init = function() -- Configure rustaceanvim here vim.g.rustaceanvim = {} From 99995747f8c8d611504536e5374a808bc35b5fb2 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Thu, 26 Sep 2024 13:50:58 +0200 Subject: [PATCH 19/84] chore: tweak q-a discussion form template --- .github/DISCUSSION_TEMPLATE/q-a.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/DISCUSSION_TEMPLATE/q-a.yml b/.github/DISCUSSION_TEMPLATE/q-a.yml index a1b33e23..91c615c8 100644 --- a/.github/DISCUSSION_TEMPLATE/q-a.yml +++ b/.github/DISCUSSION_TEMPLATE/q-a.yml @@ -26,6 +26,20 @@ body: required: false - label: I have added a very descriptive title to this question. required: true + - type: textarea + id: description + attributes: + label: Description + description: | + What is the problem, question, or error? + + Write a short description explaining what you are doing, what you expect to happen, and what is currently happening. + placeholder: | + * I'm trying to use the `rustaceanvim` plugin to do X. + * I expect to see Y. + * Instead, it does Z. + validations: + required: true - type: textarea id: example attributes: @@ -62,20 +76,6 @@ body: render: lua validations: required: true - - type: textarea - id: description - attributes: - label: Description - description: | - What is the problem, question, or error? - - Write a short description explaining what you are doing, what you expect to happen, and what is currently happening. - placeholder: | - * I'm trying to use the `rustaceanvim` plugin to do X. - * I expect to see Y. - * Instead, it does Z. - validations: - required: true - type: input attributes: label: "Neovim version (nvim -v)" From 5e5817d95eb008b0e5183575508e1c3946273cff Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Fri, 27 Sep 2024 13:31:25 +0200 Subject: [PATCH 20/84] chore: tweak discussion/issue templates --- .github/DISCUSSION_TEMPLATE/q-a.yml | 4 ++++ .github/ISSUE_TEMPLATE/bug_report.yml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/.github/DISCUSSION_TEMPLATE/q-a.yml b/.github/DISCUSSION_TEMPLATE/q-a.yml index 91c615c8..20b83f74 100644 --- a/.github/DISCUSSION_TEMPLATE/q-a.yml +++ b/.github/DISCUSSION_TEMPLATE/q-a.yml @@ -14,6 +14,10 @@ body: options: - label: This is not a bug report or feature request (Please use [issues](https://github.com/mrcjkb/rustaceanvim/issues/new/choose) for those). required: true + - label: This is a question about rustaceanvim, not rust-analyzer or Neovim. + required: true + - label: This is [not a question about autocompletion](https://github.com/mrcjkb/rustaceanvim?tab=readme-ov-file#im-having-issues-with-autocompletion). + required: true - label: I have read the README. required: true - label: I have searched for a solution using `:h rustaceanvim`. diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index e53ea05b..b31dd462 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -22,6 +22,10 @@ body: required: false - label: I can reproduce the issue with stable Neovim (not a distribution or nightly) and the [minimal config](https://github.com/mrcjkb/rustaceanvim/blob/master/troubleshooting/minimal.lua). required: true + - label: This is an issue about rustaceanvim, not rust-analyzer or Neovim. + required: true + - label: This is [not an issue with autocompletion](https://github.com/mrcjkb/rustaceanvim?tab=readme-ov-file#im-having-issues-with-autocompletion). + required: true - type: input attributes: label: "Neovim version (nvim -v)" From 711e25fe11b6e72fbeda52d9d81b85a5aa3a81ab Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Fri, 27 Sep 2024 13:35:37 +0200 Subject: [PATCH 21/84] feat: add hint on how to configure/disable server status notifications --- lua/rustaceanvim/server_status.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/rustaceanvim/server_status.lua b/lua/rustaceanvim/server_status.lua index 89ae9b32..8e99f065 100644 --- a/lua/rustaceanvim/server_status.lua +++ b/lua/rustaceanvim/server_status.lua @@ -33,6 +33,8 @@ function M.handler(_, result, ctx, _) rust-analyzer health status is [%s]: %s Run ':RustLsp logFile' for details. +To configure or disable rust-analyzer server status notifications, +see ':h rustaceanvim.lsp.ClientOpts'. ]]):format(result.health, result.message or '[unknown error]') vim.notify(message, vim.log.levels.WARN) end From bd2538868298217b6f2fbb7d4dbfb26c04e5ce09 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Fri, 27 Sep 2024 13:37:21 +0200 Subject: [PATCH 22/84] docs(readme): add info on standalone diagnostics to faq --- "\r" | 104 ++++++++++++++++++++++++++++ .github/DISCUSSION_TEMPLATE/q-a.yml | 2 + README.md | 6 ++ 3 files changed, 112 insertions(+) create mode 100644 "\r" diff --git "a/\r" "b/\r" new file mode 100644 index 00000000..b4c81c4f --- /dev/null +++ "b/\r" @@ -0,0 +1,104 @@ +--- +labels: [Question] +body: + - type: markdown + attributes: + value: | + Thanks for your interest in rustaceanvim 🦀 + Please follow these instructions, fill every question, and do every step. 🙏 + - type: checkboxes + id: checks + attributes: + label: Checked other resources + description: Please confirm and check all the following options. + options: + - label: This is not a bug report or feature request (Please use [issues](https://github.com/mrcjkb/rustaceanvim/issues/new/choose) for those). + required: true + - label: This is a question about rustaceanvim, not rust-analyzer or Neovim. + required: true + - label: This is [not a question about autocompletion](https://github.com/mrcjkb/rustaceanvim?tab=readme-ov-file#im-having-issues-with-autocompletion). + required: true + - label: I have read the README. + required: true + - label: I have read the [FAQ](https://github.com/mrcjkb/rustaceanvim?tab=readme-ov-file#left_speech_bubble-faq). + required: true + - label: I have searched for a solution using `:h rustaceanvim`. + required: true + - label: I have searched [existing discussions](https://github.com/mrcjkb/rustaceanvim/discussions). + required: true + - label: I have searched the existing issues/discussions of other plugins related to this question (if applicable). + required: false + - label: I have searched the [existing rust-analyzer discussions](https://github.com/rust-lang/rust-analyzer/discussions) (if applicable). + required: false + - label: I have added a very descriptive title to this question. + required: true + - type: textarea + id: description + attributes: + label: Description + description: | + What is the problem, question, or error? + + Write a short description explaining what you are doing, what you expect to happen, and what is currently happening. + placeholder: | + * I'm trying to use the `rustaceanvim` plugin to do X. + * I expect to see Y. + * Instead, it does Z. + validations: + required: true + - type: textarea + id: example + attributes: + label: Example Code + description: | + Please add a self-contained, [minimal, reproducible, example](https://stackoverflow.com/help/minimal-reproducible-example) with your use case. + You can use [the minimal config as a template](https://github.com/mrcjkb/rustaceanvim/blob/master/troubleshooting/minimal.lua). + + If a maintainer can copy it, run it, and see it right away, there's a much higher chance that you'll be able to get help. + + > [!IMPORTANT] + > + > - Reduce your code to the minimum required to reproduce the issue if possible. This makes it much easier for others to help you. + > - Avoid screenshots when possible, as they are hard to read and (more importantly) don't allow others to copy-and-paste your code. + + placeholder: | + vim.env.LAZY_STDPATH = '.repro' + load(vim.fn.system('curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua'))() + + require('lazy.minit').repro { + spec = { + { + 'mrcjkb/rustaceanvim', + version = '^5', + init = function() + -- Configure rustaceanvim here + vim.g.rustaceanvim = {} + end, + lazy = false, + }, + }, + } + -- do anything else you need to do to reproduce the issue + render: lua + validations: + required: true + - type: input + attributes: + label: "Neovim version (nvim -v)" + placeholder: "v0.10.1" + validations: + required: true + - type: input + attributes: + label: "Operating system/version" + placeholder: "NixOS 24.05" + validations: + required: true + - type: textarea + attributes: + label: "Output of :checkhealth rustaceanvim" + render: "console" + placeholder: | + Please paste the output here, as it may contain important information for debugging. + validations: + required: true diff --git a/.github/DISCUSSION_TEMPLATE/q-a.yml b/.github/DISCUSSION_TEMPLATE/q-a.yml index 20b83f74..b4c81c4f 100644 --- a/.github/DISCUSSION_TEMPLATE/q-a.yml +++ b/.github/DISCUSSION_TEMPLATE/q-a.yml @@ -20,6 +20,8 @@ body: required: true - label: I have read the README. required: true + - label: I have read the [FAQ](https://github.com/mrcjkb/rustaceanvim?tab=readme-ov-file#left_speech_bubble-faq). + required: true - label: I have searched for a solution using `:h rustaceanvim`. required: true - label: I have searched [existing discussions](https://github.com/mrcjkb/rustaceanvim/discussions). diff --git a/README.md b/README.md index 0603833e..58418b5b 100644 --- a/README.md +++ b/README.md @@ -890,6 +890,12 @@ See [`:h rustaceanvim.mason`](./doc/mason.txt) for details about troubleshooting mason.nvim and nvim-lspconfig issues, or configuring rustaceanvim to use a rust-analyzer installation that is managed by mason.nvim. +#### I am not seeing diagnostics in a standalone file + +rust-analyzer has limited support for standalone files. +Many diagnostics come from Cargo. If you're not in a Cargo project, +you won't see any Cargo diagnostics. + ## :link: Related Projects - [`rouge8/neotest-rust`](https://github.com/rouge8/neotest-rust) From 431a2b145fb8774dec22a0d1b2c26f60438bff93 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Fri, 27 Sep 2024 13:41:04 +0200 Subject: [PATCH 23/84] chore(master): release 5.10.0 (#527) --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d12e287..cf40742c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [5.10.0](https://github.com/mrcjkb/rustaceanvim/compare/v5.9.0...v5.10.0) (2024-09-27) + + +### Features + +* add hint on how to configure/disable server status notifications ([711e25f](https://github.com/mrcjkb/rustaceanvim/commit/711e25fe11b6e72fbeda52d9d81b85a5aa3a81ab)) + ## [5.9.0](https://github.com/mrcjkb/rustaceanvim/compare/v5.8.1...v5.9.0) (2024-09-23) From 3921a5194185f6f0b19cc5b4ea775437c63effe3 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Fri, 27 Sep 2024 16:09:46 +0200 Subject: [PATCH 24/84] chore: remove .neoconf.json --- .neoconf.json | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 .neoconf.json diff --git a/.neoconf.json b/.neoconf.json deleted file mode 100644 index f42d8477..00000000 --- a/.neoconf.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "neodev": { - "library": { - "enabled": true, - "plugins": [ - "nvim-dap", - "toggleterm.nvim", - "neotest", - ] - } - }, - "neoconf": { - "plugins": { - "lua_ls": { - "enabled": true - } - } - }, -} From b7c8171b1a496e20a2906bf74d1a260f802932d3 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Fri, 27 Sep 2024 16:13:00 +0200 Subject: [PATCH 25/84] fix(windows): remove empty file causing git clone to fail --- "\r" | 104 ----------------------------------------------------------- 1 file changed, 104 deletions(-) delete mode 100644 "\r" diff --git "a/\r" "b/\r" deleted file mode 100644 index b4c81c4f..00000000 --- "a/\r" +++ /dev/null @@ -1,104 +0,0 @@ ---- -labels: [Question] -body: - - type: markdown - attributes: - value: | - Thanks for your interest in rustaceanvim 🦀 - Please follow these instructions, fill every question, and do every step. 🙏 - - type: checkboxes - id: checks - attributes: - label: Checked other resources - description: Please confirm and check all the following options. - options: - - label: This is not a bug report or feature request (Please use [issues](https://github.com/mrcjkb/rustaceanvim/issues/new/choose) for those). - required: true - - label: This is a question about rustaceanvim, not rust-analyzer or Neovim. - required: true - - label: This is [not a question about autocompletion](https://github.com/mrcjkb/rustaceanvim?tab=readme-ov-file#im-having-issues-with-autocompletion). - required: true - - label: I have read the README. - required: true - - label: I have read the [FAQ](https://github.com/mrcjkb/rustaceanvim?tab=readme-ov-file#left_speech_bubble-faq). - required: true - - label: I have searched for a solution using `:h rustaceanvim`. - required: true - - label: I have searched [existing discussions](https://github.com/mrcjkb/rustaceanvim/discussions). - required: true - - label: I have searched the existing issues/discussions of other plugins related to this question (if applicable). - required: false - - label: I have searched the [existing rust-analyzer discussions](https://github.com/rust-lang/rust-analyzer/discussions) (if applicable). - required: false - - label: I have added a very descriptive title to this question. - required: true - - type: textarea - id: description - attributes: - label: Description - description: | - What is the problem, question, or error? - - Write a short description explaining what you are doing, what you expect to happen, and what is currently happening. - placeholder: | - * I'm trying to use the `rustaceanvim` plugin to do X. - * I expect to see Y. - * Instead, it does Z. - validations: - required: true - - type: textarea - id: example - attributes: - label: Example Code - description: | - Please add a self-contained, [minimal, reproducible, example](https://stackoverflow.com/help/minimal-reproducible-example) with your use case. - You can use [the minimal config as a template](https://github.com/mrcjkb/rustaceanvim/blob/master/troubleshooting/minimal.lua). - - If a maintainer can copy it, run it, and see it right away, there's a much higher chance that you'll be able to get help. - - > [!IMPORTANT] - > - > - Reduce your code to the minimum required to reproduce the issue if possible. This makes it much easier for others to help you. - > - Avoid screenshots when possible, as they are hard to read and (more importantly) don't allow others to copy-and-paste your code. - - placeholder: | - vim.env.LAZY_STDPATH = '.repro' - load(vim.fn.system('curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua'))() - - require('lazy.minit').repro { - spec = { - { - 'mrcjkb/rustaceanvim', - version = '^5', - init = function() - -- Configure rustaceanvim here - vim.g.rustaceanvim = {} - end, - lazy = false, - }, - }, - } - -- do anything else you need to do to reproduce the issue - render: lua - validations: - required: true - - type: input - attributes: - label: "Neovim version (nvim -v)" - placeholder: "v0.10.1" - validations: - required: true - - type: input - attributes: - label: "Operating system/version" - placeholder: "NixOS 24.05" - validations: - required: true - - type: textarea - attributes: - label: "Output of :checkhealth rustaceanvim" - render: "console" - placeholder: | - Please paste the output here, as it may contain important information for debugging. - validations: - required: true From ebbd10006d2deeb71c46d58c4c69aa3d5c088310 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Fri, 27 Sep 2024 16:15:47 +0200 Subject: [PATCH 26/84] chore(master): release 5.10.1 (#529) --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf40742c..04e0a15d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [5.10.1](https://github.com/mrcjkb/rustaceanvim/compare/v5.10.0...v5.10.1) (2024-09-27) + + +### Bug Fixes + +* **windows:** remove empty file causing git clone to fail ([b7c8171](https://github.com/mrcjkb/rustaceanvim/commit/b7c8171b1a496e20a2906bf74d1a260f802932d3)) + ## [5.10.0](https://github.com/mrcjkb/rustaceanvim/compare/v5.9.0...v5.10.0) (2024-09-27) From 1e97a9e0ebacfdb3d3c4ba7b533cbbd13b0975a8 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Sun, 29 Sep 2024 02:21:02 +0200 Subject: [PATCH 27/84] chore: update flake.lock (#531) Co-authored-by: github-actions[bot] --- flake.lock | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/flake.lock b/flake.lock index 140e7ed4..95efbec3 100644 --- a/flake.lock +++ b/flake.lock @@ -506,11 +506,11 @@ "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1726896389, - "narHash": "sha256-Qxh7GmtsB94T9EzROLvXIr486c//1M+S8apU7KoTVA0=", + "lastModified": 1727501146, + "narHash": "sha256-0iPwQojksI+NGB2iAj/pqf0ckqUUDKyBNzinFrGHK1s=", "owner": "nvim-neorocks", "repo": "neorocks", - "rev": "39308fea510539a516a2620f859dd2c8f96fc935", + "rev": "c7c04e570ae09ed36a78e4ce6ca6728765236526", "type": "github" }, "original": { @@ -529,11 +529,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1726814269, - "narHash": "sha256-eXI81wCtybqgK05ky5/tmj4AZDKmtoNQcGZEX0vnoe8=", + "lastModified": 1727415632, + "narHash": "sha256-PApi0lMoKu8Ragc1pyrcgFyye1Xhfh4qsL+tMyvnYjw=", "owner": "nix-community", "repo": "neovim-nightly-overlay", - "rev": "25aca068d0bd63c6db17c29bd3641256ea62a2c1", + "rev": "6a21da1b53a9a5c6467694b9456b4447cbd69816", "type": "github" }, "original": { @@ -545,11 +545,11 @@ "neovim-src": { "flake": false, "locked": { - "lastModified": 1726786786, - "narHash": "sha256-SMRChiJK6Td+TtiphiXP+fc8ZNElfmAeHTF2y2y9y9w=", + "lastModified": 1727394046, + "narHash": "sha256-vhOhvCtNWeuqtjMnV87Xb2zgFDJJUrWcAofzQNYyiR8=", "owner": "neovim", "repo": "neovim", - "rev": "f01c764cc6f82399edfa0d47a7bafbf7c95e2747", + "rev": "a9287dd882e082a17fc7dcf004d3f991ed29001b", "type": "github" }, "original": { @@ -704,11 +704,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1726583932, - "narHash": "sha256-zACxiQx8knB3F8+Ze+1BpiYrI+CbhxyWpcSID9kVhkQ=", + "lastModified": 1727296349, + "narHash": "sha256-C3SRU3GMDNII9l16o4+nkybuxaDX4x5TBypwmmUBCo0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "658e7223191d2598641d50ee4e898126768fe847", + "rev": "fe866c653c24adf1520628236d4e70bbb2fdd949", "type": "github" }, "original": { @@ -720,11 +720,11 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1726745986, - "narHash": "sha256-xB35C2fpz7iyNcj9sn0a+wM2C4CQ6DGTn5VUHogstYs=", + "lastModified": 1727335715, + "narHash": "sha256-1uw3y94dA4l22LkqHRIsb7qr3rV5XdxQFqctINfx8Cc=", "owner": "nixos", "repo": "nixpkgs", - "rev": "268bb5090a3c6ac5e1615b38542a868b52ef8088", + "rev": "28b5b8af91ffd2623e995e20aee56510db49001a", "type": "github" }, "original": { @@ -736,11 +736,11 @@ }, "nixpkgs_5": { "locked": { - "lastModified": 1726871744, - "narHash": "sha256-V5LpfdHyQkUF7RfOaDPrZDP+oqz88lTJrMT1+stXNwo=", + "lastModified": 1727524699, + "narHash": "sha256-k6YxGj08voz9NvuKExojiGXAVd69M8COtqWSKr6sQS4=", "owner": "nixos", "repo": "nixpkgs", - "rev": "a1d92660c6b3b7c26fb883500a80ea9d33321be2", + "rev": "b5b2fecd0cadd82ef107c9583018f381ae70f222", "type": "github" }, "original": { @@ -790,11 +790,11 @@ "nixpkgs-stable": "nixpkgs-stable_3" }, "locked": { - "lastModified": 1726745158, - "narHash": "sha256-D5AegvGoEjt4rkKedmxlSEmC+nNLMBPWFxvmYnVLhjk=", + "lastModified": 1727514110, + "narHash": "sha256-0YRcOxJG12VGDFH8iS8pJ0aYQQUAgo/r3ZAL+cSh9nk=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "4e743a6920eab45e8ba0fbe49dc459f1423a4b74", + "rev": "85f7a7177c678de68224af3402ab8ee1bcee25c8", "type": "github" }, "original": { From a07bb0d256d1f9693ae8fb96dbcc5350b18f2978 Mon Sep 17 00:00:00 2001 From: Munif Tanjim Date: Tue, 1 Oct 2024 18:51:39 +0600 Subject: [PATCH 28/84] feat(lsp): preserve cursor position for move_item command (#532) --- lua/rustaceanvim/commands/move_item.lua | 27 +++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lua/rustaceanvim/commands/move_item.lua b/lua/rustaceanvim/commands/move_item.lua index 524ef8e5..dc87519d 100644 --- a/lua/rustaceanvim/commands/move_item.lua +++ b/lua/rustaceanvim/commands/move_item.lua @@ -12,14 +12,41 @@ local function get_params(up) return params end +local function extract_cursor_position(text_edits) + local cursor = { text_edits[1].range.start.line } + local prev_te + for _, te in ipairs(text_edits) do + if te.newText and te.insertTextFormat == 2 then + if not cursor[2] then + if prev_te then + cursor[1] = cursor[1] + + math.max(0, te.range.start.line - prev_te.range['end'].line - 1) + - (prev_te.range.start.line == te.range.start.line and 1 or 0) + end + local pos_start = string.find(te.newText, '%$0') + local lines = vim.split(string.sub(te.newText, 1, pos_start), '\n') + local total_lines = #lines + cursor[1] = cursor[1] + total_lines + if pos_start then + cursor[2] = (total_lines == 1 and te.range.start.character or 0) + #lines[total_lines] - 1 + end + end + end + prev_te = te + end + return cursor +end + -- move it baby local function handler(_, result, ctx) if result == nil or #result == 0 then return end + local cursor = extract_cursor_position(result) local overrides = require('rustaceanvim.overrides') overrides.snippet_text_edits_to_text_edits(result) vim.lsp.util.apply_text_edits(result, ctx.bufnr, vim.lsp.get_client_by_id(ctx.client_id).offset_encoding) + vim.api.nvim_win_set_cursor(0, cursor) end local rl = require('rustaceanvim.rust_analyzer') From 56959fa07ef7aff93f14ea8f8bc195c67efd5a1e Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Tue, 1 Oct 2024 15:33:30 +0200 Subject: [PATCH 29/84] refactor: add some type annotations --- lua/rustaceanvim/commands/move_item.lua | 33 ++++++++++--------- .../executors/{meta.lua => _meta.lua} | 0 lua/rustaceanvim/hover_actions.lua | 1 + lua/rustaceanvim/lsp/_meta.lua | 6 ++++ lua/rustaceanvim/{lsp.lua => lsp/init.lua} | 0 lua/rustaceanvim/overrides.lua | 8 ++--- lua/rustaceanvim/server_status.lua | 1 + 7 files changed, 30 insertions(+), 19 deletions(-) rename lua/rustaceanvim/executors/{meta.lua => _meta.lua} (100%) create mode 100644 lua/rustaceanvim/lsp/_meta.lua rename lua/rustaceanvim/{lsp.lua => lsp/init.lua} (100%) diff --git a/lua/rustaceanvim/commands/move_item.lua b/lua/rustaceanvim/commands/move_item.lua index dc87519d..6035ad30 100644 --- a/lua/rustaceanvim/commands/move_item.lua +++ b/lua/rustaceanvim/commands/move_item.lua @@ -12,40 +12,43 @@ local function get_params(up) return params end +---@param text_edits rustaceanvim.lsp.TextEdit[] local function extract_cursor_position(text_edits) local cursor = { text_edits[1].range.start.line } - local prev_te - for _, te in ipairs(text_edits) do - if te.newText and te.insertTextFormat == 2 then + local prev_text_edit + for _, text_edit in ipairs(text_edits) do + if text_edit.newText and text_edit.insertTextFormat == 2 then if not cursor[2] then - if prev_te then + if prev_text_edit then cursor[1] = cursor[1] - + math.max(0, te.range.start.line - prev_te.range['end'].line - 1) - - (prev_te.range.start.line == te.range.start.line and 1 or 0) + + math.max(0, text_edit.range.start.line - prev_text_edit.range['end'].line - 1) + - (prev_text_edit.range.start.line == text_edit.range.start.line and 1 or 0) end - local pos_start = string.find(te.newText, '%$0') - local lines = vim.split(string.sub(te.newText, 1, pos_start), '\n') + local pos_start = string.find(text_edit.newText, '%$0') + local lines = vim.split(string.sub(text_edit.newText, 1, pos_start), '\n') local total_lines = #lines cursor[1] = cursor[1] + total_lines if pos_start then - cursor[2] = (total_lines == 1 and te.range.start.character or 0) + #lines[total_lines] - 1 + cursor[2] = (total_lines == 1 and text_edit.range.start.character or 0) + #lines[total_lines] - 1 end end end - prev_te = te + prev_text_edit = text_edit end return cursor end -- move it baby -local function handler(_, result, ctx) - if result == nil or #result == 0 then +---@param text_edits? rustaceanvim.lsp.TextEdit[] +---@param ctx lsp.HandlerContext +local function handler(_, text_edits, ctx) + if text_edits == nil or #text_edits == 0 then return end - local cursor = extract_cursor_position(result) + local cursor = extract_cursor_position(text_edits) local overrides = require('rustaceanvim.overrides') - overrides.snippet_text_edits_to_text_edits(result) - vim.lsp.util.apply_text_edits(result, ctx.bufnr, vim.lsp.get_client_by_id(ctx.client_id).offset_encoding) + overrides.snippet_text_edits_to_text_edits(text_edits) + vim.lsp.util.apply_text_edits(text_edits, ctx.bufnr, vim.lsp.get_client_by_id(ctx.client_id).offset_encoding) vim.api.nvim_win_set_cursor(0, cursor) end diff --git a/lua/rustaceanvim/executors/meta.lua b/lua/rustaceanvim/executors/_meta.lua similarity index 100% rename from lua/rustaceanvim/executors/meta.lua rename to lua/rustaceanvim/executors/_meta.lua diff --git a/lua/rustaceanvim/hover_actions.lua b/lua/rustaceanvim/hover_actions.lua index c9b09726..586ea0a8 100644 --- a/lua/rustaceanvim/hover_actions.lua +++ b/lua/rustaceanvim/hover_actions.lua @@ -59,6 +59,7 @@ local function parse_commands() return prompt end +---@param ctx lsp.HandlerContext function M.handler(_, result, ctx) if not (result and result.contents) then -- return { 'No information available' } diff --git a/lua/rustaceanvim/lsp/_meta.lua b/lua/rustaceanvim/lsp/_meta.lua new file mode 100644 index 00000000..4bce41a2 --- /dev/null +++ b/lua/rustaceanvim/lsp/_meta.lua @@ -0,0 +1,6 @@ +error('Cannot import a meta module') + +---@class rustaceanvim.lsp.TextEdit +---@field range lsp.Range +---@field newText? string +---@field insertTextFormat? integer diff --git a/lua/rustaceanvim/lsp.lua b/lua/rustaceanvim/lsp/init.lua similarity index 100% rename from lua/rustaceanvim/lsp.lua rename to lua/rustaceanvim/lsp/init.lua diff --git a/lua/rustaceanvim/overrides.lua b/lua/rustaceanvim/overrides.lua index 6bcff94c..fb0317d1 100644 --- a/lua/rustaceanvim/overrides.lua +++ b/lua/rustaceanvim/overrides.lua @@ -21,12 +21,12 @@ local function parse_snippet(input) return ok and tostring(parsed) or parse_snippet_fallback(input) end ----@param spe? table -function M.snippet_text_edits_to_text_edits(spe) - if type(spe) ~= 'table' then +---@param text_edits? rustaceanvim.lsp.TextEdit[] +function M.snippet_text_edits_to_text_edits(text_edits) + if type(text_edits) ~= 'table' then return end - for _, value in ipairs(spe) do + for _, value in ipairs(text_edits) do if value.newText and value.insertTextFormat then value.newText = parse_snippet(value.newText) end diff --git a/lua/rustaceanvim/server_status.lua b/lua/rustaceanvim/server_status.lua index 8e99f065..fb3d2177 100644 --- a/lua/rustaceanvim/server_status.lua +++ b/lua/rustaceanvim/server_status.lua @@ -22,6 +22,7 @@ local function is_notify_enabled_for(health) end ---@param result rustaceanvim.internal.RAInitializedStatus +---@param ctx lsp.HandlerContext function M.handler(_, result, ctx, _) -- quiescent means the full set of results is ready. if not result or not result.quiescent then From 6a0247daa1fad0f968f1b279da515dd38021401e Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Tue, 1 Oct 2024 15:45:59 +0200 Subject: [PATCH 30/84] refactor: extract_cursor_position --- lua/rustaceanvim/commands/move_item.lua | 31 ++++++++++++++----------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/lua/rustaceanvim/commands/move_item.lua b/lua/rustaceanvim/commands/move_item.lua index 6035ad30..457b57a4 100644 --- a/lua/rustaceanvim/commands/move_item.lua +++ b/lua/rustaceanvim/commands/move_item.lua @@ -12,25 +12,28 @@ local function get_params(up) return params end +---@param prev_text_edit rustaceanvim.lsp.TextEdit +---@param text_edit rustaceanvim.lsp.TextEdit +local function text_edit_line_range_diff(prev_text_edit, text_edit) + return math.max(0, text_edit.range.start.line - prev_text_edit.range['end'].line - 1) + - (prev_text_edit.range.start.line == text_edit.range.start.line and 1 or 0) +end + ---@param text_edits rustaceanvim.lsp.TextEdit[] local function extract_cursor_position(text_edits) local cursor = { text_edits[1].range.start.line } local prev_text_edit for _, text_edit in ipairs(text_edits) do - if text_edit.newText and text_edit.insertTextFormat == 2 then - if not cursor[2] then - if prev_text_edit then - cursor[1] = cursor[1] - + math.max(0, text_edit.range.start.line - prev_text_edit.range['end'].line - 1) - - (prev_text_edit.range.start.line == text_edit.range.start.line and 1 or 0) - end - local pos_start = string.find(text_edit.newText, '%$0') - local lines = vim.split(string.sub(text_edit.newText, 1, pos_start), '\n') - local total_lines = #lines - cursor[1] = cursor[1] + total_lines - if pos_start then - cursor[2] = (total_lines == 1 and text_edit.range.start.character or 0) + #lines[total_lines] - 1 - end + if text_edit.newText and text_edit.insertTextFormat == 2 and not cursor[2] then + cursor[1] = cursor[1] + (prev_text_edit and text_edit_line_range_diff(prev_text_edit, text_edit) or 0) + local snippet_pos_start = string.find(text_edit.newText, '%$0') + local lines = vim.split(string.sub(text_edit.newText, 1, snippet_pos_start), '\n') + local line_count = #lines + cursor[1] = cursor[1] + line_count + if snippet_pos_start then + local start_offset = line_count == 1 and text_edit.range.start.character or 0 + local last_line_length = #lines[line_count] - 1 + cursor[2] = start_offset + last_line_length end end prev_text_edit = text_edit From 29f42cc149f915d771c550b6dfe7c788d856cf04 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Tue, 1 Oct 2024 16:18:28 +0200 Subject: [PATCH 31/84] chore(master): release 5.11.0 (#533) --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 04e0a15d..1ff71204 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [5.11.0](https://github.com/mrcjkb/rustaceanvim/compare/v5.10.1...v5.11.0) (2024-10-01) + + +### Features + +* **lsp:** preserve cursor position for move_item command ([#532](https://github.com/mrcjkb/rustaceanvim/issues/532)) ([a07bb0d](https://github.com/mrcjkb/rustaceanvim/commit/a07bb0d256d1f9693ae8fb96dbcc5350b18f2978)) + ## [5.10.1](https://github.com/mrcjkb/rustaceanvim/compare/v5.10.0...v5.10.1) (2024-09-27) From d2d9e02ce2c9ffd3746c99925de40e9b3d872f9b Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Sun, 6 Oct 2024 02:18:29 +0200 Subject: [PATCH 32/84] chore: update flake.lock (#534) Co-authored-by: github-actions[bot] --- flake.lock | 88 +++++++++++++++++++++++++++--------------------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/flake.lock b/flake.lock index 95efbec3..deefbfde 100644 --- a/flake.lock +++ b/flake.lock @@ -117,11 +117,11 @@ "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1726153070, - "narHash": "sha256-HO4zgY0ekfwO5bX0QH/3kJ/h4KvUDFZg8YpkNwIbg1U=", + "lastModified": 1727826117, + "narHash": "sha256-K5ZLCyfO/Zj9mPFldf3iwS6oZStJcU4tSpiXTMYaaL0=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "bcef6817a8b2aa20a5a6dbb19b43e63c5bf8619a", + "rev": "3d04084d54bedc3d6b8b736c70ef449225c361b1", "type": "github" }, "original": { @@ -153,11 +153,11 @@ "nixpkgs-lib": "nixpkgs-lib_3" }, "locked": { - "lastModified": 1726153070, - "narHash": "sha256-HO4zgY0ekfwO5bX0QH/3kJ/h4KvUDFZg8YpkNwIbg1U=", + "lastModified": 1727826117, + "narHash": "sha256-K5ZLCyfO/Zj9mPFldf3iwS6oZStJcU4tSpiXTMYaaL0=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "bcef6817a8b2aa20a5a6dbb19b43e63c5bf8619a", + "rev": "3d04084d54bedc3d6b8b736c70ef449225c361b1", "type": "github" }, "original": { @@ -175,11 +175,11 @@ ] }, "locked": { - "lastModified": 1726153070, - "narHash": "sha256-HO4zgY0ekfwO5bX0QH/3kJ/h4KvUDFZg8YpkNwIbg1U=", + "lastModified": 1727826117, + "narHash": "sha256-K5ZLCyfO/Zj9mPFldf3iwS6oZStJcU4tSpiXTMYaaL0=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "bcef6817a8b2aa20a5a6dbb19b43e63c5bf8619a", + "rev": "3d04084d54bedc3d6b8b736c70ef449225c361b1", "type": "github" }, "original": { @@ -281,11 +281,11 @@ "nixpkgs-stable": "nixpkgs-stable_2" }, "locked": { - "lastModified": 1726745158, - "narHash": "sha256-D5AegvGoEjt4rkKedmxlSEmC+nNLMBPWFxvmYnVLhjk=", + "lastModified": 1728092656, + "narHash": "sha256-eMeCTJZ5xBeQ0f9Os7K8DThNVSo9gy4umZLDfF5q6OM=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "4e743a6920eab45e8ba0fbe49dc459f1423a4b74", + "rev": "1211305a5b237771e13fcca0c51e60ad47326a9a", "type": "github" }, "original": { @@ -310,11 +310,11 @@ ] }, "locked": { - "lastModified": 1726745158, - "narHash": "sha256-D5AegvGoEjt4rkKedmxlSEmC+nNLMBPWFxvmYnVLhjk=", + "lastModified": 1727805723, + "narHash": "sha256-b8flytpuc4Ey/g3mcvpS/ICORcD4h56QDZeP5LogevY=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "4e743a6920eab45e8ba0fbe49dc459f1423a4b74", + "rev": "2f5ae3fc91db865eff2c5a418da85a0fbe6238a3", "type": "github" }, "original": { @@ -506,11 +506,11 @@ "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1727501146, - "narHash": "sha256-0iPwQojksI+NGB2iAj/pqf0ckqUUDKyBNzinFrGHK1s=", + "lastModified": 1728105821, + "narHash": "sha256-8R1NGPbmS4nNiKLUL2hGxfgXcNwHQqWTZtUJylVCfdg=", "owner": "nvim-neorocks", "repo": "neorocks", - "rev": "c7c04e570ae09ed36a78e4ce6ca6728765236526", + "rev": "189645e30fd7f038c08df2ac665c4282ce810f87", "type": "github" }, "original": { @@ -529,11 +529,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1727415632, - "narHash": "sha256-PApi0lMoKu8Ragc1pyrcgFyye1Xhfh4qsL+tMyvnYjw=", + "lastModified": 1727852635, + "narHash": "sha256-eY0Y5ZDMo5IS+K42kMwAMCLsYHoAgPW3R4UxeGfzP0U=", "owner": "nix-community", "repo": "neovim-nightly-overlay", - "rev": "6a21da1b53a9a5c6467694b9456b4447cbd69816", + "rev": "377cf41246ee443c86c4ae48f66f5100038fe158", "type": "github" }, "original": { @@ -545,11 +545,11 @@ "neovim-src": { "flake": false, "locked": { - "lastModified": 1727394046, - "narHash": "sha256-vhOhvCtNWeuqtjMnV87Xb2zgFDJJUrWcAofzQNYyiR8=", + "lastModified": 1727825968, + "narHash": "sha256-7DbbGIAbJesqYEkZh2FaEo5wycZ/cRbvZP6k01Z5+ZM=", "owner": "neovim", "repo": "neovim", - "rev": "a9287dd882e082a17fc7dcf004d3f991ed29001b", + "rev": "2168d772b864fd05109fb4299e409d4bdc1df39d", "type": "github" }, "original": { @@ -576,14 +576,14 @@ }, "nixpkgs-lib": { "locked": { - "lastModified": 1725233747, - "narHash": "sha256-Ss8QWLXdr2JCBPcYChJhz4xJm+h/xjl4G0c0XlP6a74=", + "lastModified": 1727825735, + "narHash": "sha256-0xHYkMkeLVQAMa7gvkddbPqpxph+hDzdu1XdGPJR+Os=", "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/356624c12086a18f2ea2825fed34523d60ccc4e3.tar.gz" + "url": "https://github.com/NixOS/nixpkgs/archive/fb192fec7cc7a4c26d51779e9bab07ce6fa5597a.tar.gz" }, "original": { "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/356624c12086a18f2ea2825fed34523d60ccc4e3.tar.gz" + "url": "https://github.com/NixOS/nixpkgs/archive/fb192fec7cc7a4c26d51779e9bab07ce6fa5597a.tar.gz" } }, "nixpkgs-lib_2": { @@ -600,14 +600,14 @@ }, "nixpkgs-lib_3": { "locked": { - "lastModified": 1725233747, - "narHash": "sha256-Ss8QWLXdr2JCBPcYChJhz4xJm+h/xjl4G0c0XlP6a74=", + "lastModified": 1727825735, + "narHash": "sha256-0xHYkMkeLVQAMa7gvkddbPqpxph+hDzdu1XdGPJR+Os=", "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/356624c12086a18f2ea2825fed34523d60ccc4e3.tar.gz" + "url": "https://github.com/NixOS/nixpkgs/archive/fb192fec7cc7a4c26d51779e9bab07ce6fa5597a.tar.gz" }, "original": { "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/356624c12086a18f2ea2825fed34523d60ccc4e3.tar.gz" + "url": "https://github.com/NixOS/nixpkgs/archive/fb192fec7cc7a4c26d51779e9bab07ce6fa5597a.tar.gz" } }, "nixpkgs-lib_4": { @@ -704,11 +704,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1727296349, - "narHash": "sha256-C3SRU3GMDNII9l16o4+nkybuxaDX4x5TBypwmmUBCo0=", + "lastModified": 1727747005, + "narHash": "sha256-2PBox0LkPhxirg1asEIpvfFARjq5KLw0EHPCy4unjPs=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "fe866c653c24adf1520628236d4e70bbb2fdd949", + "rev": "9682b2197dabc185fcca802ac1ac21136e48fcc2", "type": "github" }, "original": { @@ -720,11 +720,11 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1727335715, - "narHash": "sha256-1uw3y94dA4l22LkqHRIsb7qr3rV5XdxQFqctINfx8Cc=", + "lastModified": 1728031656, + "narHash": "sha256-JXumn7X+suKEcehp4rchSvBzIboqyybQ5bLK4wk7gQU=", "owner": "nixos", "repo": "nixpkgs", - "rev": "28b5b8af91ffd2623e995e20aee56510db49001a", + "rev": "eeeb90a1dd3c9bea3afdbc76fd34d0fb2a727c7a", "type": "github" }, "original": { @@ -736,11 +736,11 @@ }, "nixpkgs_5": { "locked": { - "lastModified": 1727524699, - "narHash": "sha256-k6YxGj08voz9NvuKExojiGXAVd69M8COtqWSKr6sQS4=", + "lastModified": 1728093190, + "narHash": "sha256-CAZF2NRuHmqTtRTNAruWpHA43Gg2UvuCNEIzabP0l6M=", "owner": "nixos", "repo": "nixpkgs", - "rev": "b5b2fecd0cadd82ef107c9583018f381ae70f222", + "rev": "e2f08f4d8b3ecb5cf5c9fd9cb2d53bb3c71807da", "type": "github" }, "original": { @@ -790,11 +790,11 @@ "nixpkgs-stable": "nixpkgs-stable_3" }, "locked": { - "lastModified": 1727514110, - "narHash": "sha256-0YRcOxJG12VGDFH8iS8pJ0aYQQUAgo/r3ZAL+cSh9nk=", + "lastModified": 1728092656, + "narHash": "sha256-eMeCTJZ5xBeQ0f9Os7K8DThNVSo9gy4umZLDfF5q6OM=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "85f7a7177c678de68224af3402ab8ee1bcee25c8", + "rev": "1211305a5b237771e13fcca0c51e60ad47326a9a", "type": "github" }, "original": { From df23ea04d01bb5a812a6507b3714f542f6297bfa Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Mon, 7 Oct 2024 12:03:41 +0200 Subject: [PATCH 33/84] docs(vimdoc): correct typo --- doc/rustaceanvim.txt | 2 +- lua/rustaceanvim/config/init.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/rustaceanvim.txt b/doc/rustaceanvim.txt index ee053514..2c9e45a1 100644 --- a/doc/rustaceanvim.txt +++ b/doc/rustaceanvim.txt @@ -262,7 +262,7 @@ rustaceanvim.crate-graph.Opts *rustaceanvim.crate-graph.Opts* {enabled_graphviz_backends?} (string[]) Override the enabled graphviz backends list, used for input validation and autocompletion. {pipe?} (string) - Overide the pipe symbol in the shell command. + Override the pipe symbol in the shell command. Useful if using a shell that is not supported by this plugin. diff --git a/lua/rustaceanvim/config/init.lua b/lua/rustaceanvim/config/init.lua index afe6f53a..89150687 100644 --- a/lua/rustaceanvim/config/init.lua +++ b/lua/rustaceanvim/config/init.lua @@ -150,7 +150,7 @@ vim.g.rustaceanvim = vim.g.rustaceanvim ---Override the enabled graphviz backends list, used for input validation and autocompletion. ---@field enabled_graphviz_backends? string[] --- ----Overide the pipe symbol in the shell command. +---Override the pipe symbol in the shell command. ---Useful if using a shell that is not supported by this plugin. ---@field pipe? string From d1f56672638508a7bc971cde31a29df4018579a9 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Mon, 7 Oct 2024 19:58:52 +0200 Subject: [PATCH 34/84] build(nix): use luaAttr --- nix/plugin-overlay.nix | 10 +++++++--- result | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) create mode 120000 result diff --git a/nix/plugin-overlay.nix b/nix/plugin-overlay.nix index cc94f66d..4a87f7af 100755 --- a/nix/plugin-overlay.nix +++ b/nix/plugin-overlay.nix @@ -20,21 +20,25 @@ lua5_1 = prev.lua5_1.override { packageOverrides = rustaceanvim-luaPackage-override; }; + luajit = prev.luajit.override { + packageOverrides = rustaceanvim-luaPackage-override; + }; lua51Packages = final.lua5_1.pkgs; + luajitPackages = final.luajit.pkgs; in { inherit lua5_1 lua51Packages + luajit + luajitPackages ; vimPlugins = prev.vimPlugins // { rustaceanvim = final.neovimUtils.buildNeovimPlugin { - pname = name; - version = "scm-1"; - src = self; + luaAttr = final.luajitPackages.rustaceanvim; }; }; diff --git a/result b/result new file mode 120000 index 00000000..4cfeceb6 --- /dev/null +++ b/result @@ -0,0 +1 @@ +/nix/store/pgfwfqx5snjrd5ccdgg520bachxdjhnw-vimplugin-luajit2.1-rustaceanvim-scm-1-unstable-scm-1 \ No newline at end of file From 1c47bdd38150d9ba636fd234128e232dc618e832 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Sun, 13 Oct 2024 02:20:46 +0200 Subject: [PATCH 35/84] chore: update flake.lock (#536) Co-authored-by: github-actions[bot] --- flake.lock | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/flake.lock b/flake.lock index deefbfde..5eb8efa4 100644 --- a/flake.lock +++ b/flake.lock @@ -281,11 +281,11 @@ "nixpkgs-stable": "nixpkgs-stable_2" }, "locked": { - "lastModified": 1728092656, - "narHash": "sha256-eMeCTJZ5xBeQ0f9Os7K8DThNVSo9gy4umZLDfF5q6OM=", + "lastModified": 1728651332, + "narHash": "sha256-lm+asqDSTj0m6j1dtEte1/XG+uzZbwxS3tn7JLaBw84=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "1211305a5b237771e13fcca0c51e60ad47326a9a", + "rev": "06bb5971c139959d9a951f34e4264d32f5d998e7", "type": "github" }, "original": { @@ -310,11 +310,11 @@ ] }, "locked": { - "lastModified": 1727805723, - "narHash": "sha256-b8flytpuc4Ey/g3mcvpS/ICORcD4h56QDZeP5LogevY=", + "lastModified": 1728580416, + "narHash": "sha256-nKttjKg6lE7O5S+wlBOkXsUGdOgVxZ8SWaCOyodW5so=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "2f5ae3fc91db865eff2c5a418da85a0fbe6238a3", + "rev": "4ebefcac44b5116cf5741be858245db769ddedd1", "type": "github" }, "original": { @@ -506,11 +506,11 @@ "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1728105821, - "narHash": "sha256-8R1NGPbmS4nNiKLUL2hGxfgXcNwHQqWTZtUJylVCfdg=", + "lastModified": 1728710931, + "narHash": "sha256-guSpjhNm1DiKUUdmbVAzUy4YcsCa7HP5NimiUItisZ8=", "owner": "nvim-neorocks", "repo": "neorocks", - "rev": "189645e30fd7f038c08df2ac665c4282ce810f87", + "rev": "9001b52860c1dc78a6d156bda2f3592769539d2e", "type": "github" }, "original": { @@ -529,11 +529,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1727852635, - "narHash": "sha256-eY0Y5ZDMo5IS+K42kMwAMCLsYHoAgPW3R4UxeGfzP0U=", + "lastModified": 1728631701, + "narHash": "sha256-LPqpJVV8Ws4uDfzp/Huu6myMW33lmZbFGTMoZ9LyRCU=", "owner": "nix-community", "repo": "neovim-nightly-overlay", - "rev": "377cf41246ee443c86c4ae48f66f5100038fe158", + "rev": "a2de61747149100c904c01eb8915e1c6ecec0379", "type": "github" }, "original": { @@ -545,11 +545,11 @@ "neovim-src": { "flake": false, "locked": { - "lastModified": 1727825968, - "narHash": "sha256-7DbbGIAbJesqYEkZh2FaEo5wycZ/cRbvZP6k01Z5+ZM=", + "lastModified": 1728600525, + "narHash": "sha256-Q2QHD23/bkNdYTbXaRLaVYy/uUx3gw08NAehTfF5ZXs=", "owner": "neovim", "repo": "neovim", - "rev": "2168d772b864fd05109fb4299e409d4bdc1df39d", + "rev": "6f1601a1b94e6ea724d8436600c64760525d1d2b", "type": "github" }, "original": { @@ -704,11 +704,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1727747005, - "narHash": "sha256-2PBox0LkPhxirg1asEIpvfFARjq5KLw0EHPCy4unjPs=", + "lastModified": 1728538411, + "narHash": "sha256-f0SBJz1eZ2yOuKUr5CA9BHULGXVSn6miBuUWdTyhUhU=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "9682b2197dabc185fcca802ac1ac21136e48fcc2", + "rev": "b69de56fac8c2b6f8fd27f2eca01dcda8e0a4221", "type": "github" }, "original": { @@ -720,11 +720,11 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1728031656, - "narHash": "sha256-JXumn7X+suKEcehp4rchSvBzIboqyybQ5bLK4wk7gQU=", + "lastModified": 1728538411, + "narHash": "sha256-f0SBJz1eZ2yOuKUr5CA9BHULGXVSn6miBuUWdTyhUhU=", "owner": "nixos", "repo": "nixpkgs", - "rev": "eeeb90a1dd3c9bea3afdbc76fd34d0fb2a727c7a", + "rev": "b69de56fac8c2b6f8fd27f2eca01dcda8e0a4221", "type": "github" }, "original": { @@ -736,11 +736,11 @@ }, "nixpkgs_5": { "locked": { - "lastModified": 1728093190, - "narHash": "sha256-CAZF2NRuHmqTtRTNAruWpHA43Gg2UvuCNEIzabP0l6M=", + "lastModified": 1728538411, + "narHash": "sha256-f0SBJz1eZ2yOuKUr5CA9BHULGXVSn6miBuUWdTyhUhU=", "owner": "nixos", "repo": "nixpkgs", - "rev": "e2f08f4d8b3ecb5cf5c9fd9cb2d53bb3c71807da", + "rev": "b69de56fac8c2b6f8fd27f2eca01dcda8e0a4221", "type": "github" }, "original": { @@ -790,11 +790,11 @@ "nixpkgs-stable": "nixpkgs-stable_3" }, "locked": { - "lastModified": 1728092656, - "narHash": "sha256-eMeCTJZ5xBeQ0f9Os7K8DThNVSo9gy4umZLDfF5q6OM=", + "lastModified": 1728727368, + "narHash": "sha256-7FMyNISP7K6XDSIt1NJxkXZnEdV3HZUXvFoBaJ/qdOg=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "1211305a5b237771e13fcca0c51e60ad47326a9a", + "rev": "eb74e0be24a11a1531b5b8659535580554d30b28", "type": "github" }, "original": { From cb31013a983faec6339d3bf6aad782da8fc7e111 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Wed, 16 Oct 2024 01:43:13 +0200 Subject: [PATCH 36/84] feat(config): health check reports for .vscode/settings.json (#539) --- lua/rustaceanvim/config/json.lua | 49 ++++++++++++++++++++++++++++++-- lua/rustaceanvim/health.lua | 20 +++++++++++++ spec/json_spec.lua | 43 ++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+), 3 deletions(-) diff --git a/lua/rustaceanvim/config/json.lua b/lua/rustaceanvim/config/json.lua index 351e409f..e5423435 100644 --- a/lua/rustaceanvim/config/json.lua +++ b/lua/rustaceanvim/config/json.lua @@ -1,10 +1,37 @@ local M = {} -local function tbl_set(tbl, keys, value) +local warnings = {} +local errors = {} +local is_json_config_loaded = false + +---@param warning string +local function add_warning(warning) + table.insert(warnings, warning) +end + +---@param err string +local function add_error(err) + table.insert(errors, err) +end + +---@param field_name string | nil +---@param tbl unknown +---@param keys string[] +---@param value unknown +local function tbl_set(field_name, tbl, keys, value) local next = table.remove(keys, 1) + if type(tbl) ~= 'table' then + add_warning(([[ +Ignored field '%s' of invalid type '%s': %s +Please refer to the rust-analyzer documentation at +https://rust-analyzer.github.io/manual.html#%s +]]):format(field_name, type(value), vim.inspect(value), field_name)) + return + end if #keys > 0 then tbl[next] = tbl[next] or {} - tbl_set(tbl[next], keys, value) + field_name = (field_name and field_name .. '.' or '') .. next + tbl_set(field_name, tbl[next], keys, value) else tbl[next] = value end @@ -15,14 +42,17 @@ end ---@param json_value unknown local function override_tbl_values(tbl, json_key, json_value) local keys = vim.split(json_key, '%.') - tbl_set(tbl, keys, json_value) + tbl_set(nil, tbl, keys, json_value) end ---@param json_content string ---@return table function M.silent_decode(json_content) + warnings = {} + errors = {} local ok, json_tbl = pcall(vim.json.decode, json_content) if not ok or type(json_tbl) ~= 'table' then + add_error(('Failed to decode json: %s'):format(json_tbl or 'unknown error')) return {} end return json_tbl @@ -32,6 +62,7 @@ end ---@param json_tbl { [string]: unknown } ---@param key_predicate? fun(string): boolean function M.override_with_json_keys(tbl, json_tbl, key_predicate) + is_json_config_loaded = true for json_key, value in pairs(json_tbl) do if not key_predicate or key_predicate(json_key) then override_tbl_values(tbl, json_key, value) @@ -47,4 +78,16 @@ function M.override_with_rust_analyzer_json_keys(tbl, json_tbl) end) end +function M.is_json_config_loaded() + return is_json_config_loaded +end + +function M.get_warnings() + return warnings +end + +function M.get_errors() + return errors +end + return M diff --git a/lua/rustaceanvim/health.lua b/lua/rustaceanvim/health.lua index c0489fc3..851b66a4 100644 --- a/lua/rustaceanvim/health.lua +++ b/lua/rustaceanvim/health.lua @@ -148,6 +148,25 @@ local function check_tree_sitter() end end +local function check_json_config() + local json = require('rustaceanvim.config.json') + if json.is_json_config_loaded() then + local errors = json.get_errors() + if #errors > 0 then + h.warn('.vscode/settings.json failed to load.') + vim.iter(errors):each(h.error) + return + end + local warnings = json.get_warnings() + if #warnings == 0 then + h.ok('.vscode/settings.json loaded without errors.') + else + h.warn('.vscode/settings.json loaded with warnings.') + vim.iter(warnings):each(h.warn) + end + end +end + function health.check() local types = require('rustaceanvim.types.internal') local config = require('rustaceanvim.config.internal') @@ -281,6 +300,7 @@ function health.check() check_config(config) check_for_conflicts() check_tree_sitter() + check_json_config() end return health diff --git a/spec/json_spec.lua b/spec/json_spec.lua index 838d75ae..446b6122 100644 --- a/spec/json_spec.lua +++ b/spec/json_spec.lua @@ -42,4 +42,47 @@ describe('Decode rust-analyzer settings from json', function() }, }, tbl) end) + it('persists warnings on invalid config', function() + local invalid_json_content = [[ +{ + "rust-analyzer.checkOnSave.overrideCommand": [ + "cargo", + "check", + "-p", + "service_b", + "--message-format=json" + ], + "rust-analyzer.foo.enable": true, + "rust-analyzer.foo.bar.enable": true, + "rust-analyzer.foo.bar.baz.bat": "something deeply nested", + "some-other-key.foo.bar.baz.bat": "should not be included" +} +]] + local tbl = { + ['rust-analyzer'] = { + checkOnSave = true, + }, + } + local json_tbl = json.silent_decode(invalid_json_content) + json.override_with_rust_analyzer_json_keys(tbl, json_tbl) + assert.same({ + [[ +Ignored field 'rust-analyzer.checkOnSave' of invalid type 'table': { "cargo", "check", "-p", "service_b", "--message-format=json" } +Please refer to the rust-analyzer documentation at +https://rust-analyzer.github.io/manual.html#rust-analyzer.checkOnSave +]], + }, json.get_warnings()) + end) + it('persists warnings about config parse errors', function() + local unsupported_json_content = [[ +{ + // This is a json5 comment + "rust-analyzer.foo.enable": true, +} +]] + json.silent_decode(unsupported_json_content) + assert.same({ + 'Failed to decode json: Expected object key string but found invalid token at character 5', + }, json.get_errors()) + end) end) From 819c3197bc308d81ea9c8cf75b01f34eb3f0e03b Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Wed, 16 Oct 2024 01:44:17 +0200 Subject: [PATCH 37/84] chore(master): release 5.12.0 (#540) --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ff71204..1a3b1d1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [5.12.0](https://github.com/mrcjkb/rustaceanvim/compare/v5.11.0...v5.12.0) (2024-10-15) + + +### Features + +* **config:** health check reports for .vscode/settings.json ([#539](https://github.com/mrcjkb/rustaceanvim/issues/539)) ([cb31013](https://github.com/mrcjkb/rustaceanvim/commit/cb31013a983faec6339d3bf6aad782da8fc7e111)) + ## [5.11.0](https://github.com/mrcjkb/rustaceanvim/compare/v5.10.1...v5.11.0) (2024-10-01) From 4e78e8d8fe464fbc9e99632b65dd3ead75d9dda0 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Wed, 16 Oct 2024 01:45:33 +0200 Subject: [PATCH 38/84] docs(readme): add note on json5 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 58418b5b..04bb9277 100644 --- a/README.md +++ b/README.md @@ -818,6 +818,7 @@ the `server.default_settings` will be used. [^2]: See [this example](https://github.com/rust-analyzer/rust-project.json-example/blob/master/.vscode/settings.json) and the rust-analyzer [configuration manual](https://rust-analyzer.github.io/manual.html#configuration). + Note that JSON5 is currently not supported by Neovim. Another option is to use `:h exrc`. From 95715b28c87b4cb3a8a38e063e2aa5cd3a8024d7 Mon Sep 17 00:00:00 2001 From: sami Date: Thu, 17 Oct 2024 13:25:27 +0100 Subject: [PATCH 39/84] feat(lsp): target architecture switching command for `RustAnalyzer` (#541) --- doc/rustaceanvim.txt | 3 + lua/rustaceanvim/init.lua | 5 ++ lua/rustaceanvim/lsp/init.lua | 141 +++++++++++++++++++++++++++------- 3 files changed, 120 insertions(+), 29 deletions(-) diff --git a/doc/rustaceanvim.txt b/doc/rustaceanvim.txt index 2c9e45a1..aa81b141 100644 --- a/doc/rustaceanvim.txt +++ b/doc/rustaceanvim.txt @@ -24,6 +24,9 @@ Commands: ':RustAnalyzer stop' - Stop the LSP client. ':RustAnalyzer restart' - Restart the LSP client. ':RustAnalyzer reloadSettings' - Reload settings for the LSP client. + ':RustAnalyzer target ' - Set the target architecture for the LSP client. + +The ':RustAnalyzer target' command can take a valid rustc target, such as 'wasm32-unknown-unknown', or it can be left empty to set the LSP client to use the default target architecture for the operating system. The ':RustLsp[!]' command is available after the LSP client has initialized. It accepts the following subcommands: diff --git a/lua/rustaceanvim/init.lua b/lua/rustaceanvim/init.lua index 22050a46..bf7ee927 100644 --- a/lua/rustaceanvim/init.lua +++ b/lua/rustaceanvim/init.lua @@ -16,6 +16,11 @@ --- ':RustAnalyzer stop' - Stop the LSP client. --- ':RustAnalyzer restart' - Restart the LSP client. --- ':RustAnalyzer reloadSettings' - Reload settings for the LSP client. +--- ':RustAnalyzer target ' - Set the target architecture for the LSP client. + +--- The ':RustAnalyzer target' command can take a valid rustc target, +--- such as 'wasm32-unknown-unknown', or it can be left empty to set the LSP client +--- to use the default target architecture for the operating system. --- ---The ':RustLsp[!]' command is available after the LSP client has initialized. ---It accepts the following subcommands: diff --git a/lua/rustaceanvim/lsp/init.lua b/lua/rustaceanvim/lsp/init.lua index 4770d451..acba95aa 100644 --- a/lua/rustaceanvim/lsp/init.lua +++ b/lua/rustaceanvim/lsp/init.lua @@ -7,6 +7,9 @@ local server_status = require('rustaceanvim.server_status') local cargo = require('rustaceanvim.cargo') local os = require('rustaceanvim.os') +---Local rustc targets cache +local rustc_targets_cache = nil + local function override_apply_text_edits() local old_func = vim.lsp.util.apply_text_edits ---@diagnostic disable-next-line @@ -93,6 +96,71 @@ local function configure_file_watcher(server_cfg) end end +---Handles retrieving rustc target archs and running on_valid callback +---to perform certain actions using the retrieved targets. +---@param on_valid function(rustc_targets) +local function validate_rustc_target(on_valid) + local on_exit = function(result) + -- use cache if available. + if rustc_targets_cache then + return on_valid(rustc_targets_cache) + end + + if result.code ~= 0 then + error('Failed to retrieve rustc targets: ' .. result.stderr) + end + + rustc_targets_cache = {} + for line in result.stdout:gmatch('[^\r\n]+') do + rustc_targets_cache[line] = true + end + + return on_valid(rustc_targets_cache) + end + + -- Call vim.system with on_exit callback to avoid blocking Neovim's event loop. + vim.system({ 'rustc', '--print', 'target-list' }, { text = true }, on_exit) +end + +---LSP restart internal implementations +---@param bufnr? number +---@param callback? function(client) Optional callback to run for each client before restarting. +---@return number|nil client_id +local function restart(bufnr, callback) + bufnr = bufnr or vim.api.nvim_get_current_buf() + local clients = M.stop(bufnr) + local timer, _, _ = vim.uv.new_timer() + if not timer then + vim.notify('Failed to init timer for LSP client restart.', vim.log.levels.ERROR) + return + end + local attempts_to_live = 50 + local stopped_client_count = 0 + timer:start(200, 100, function() + for _, client in ipairs(clients) do + if client:is_stopped() then + stopped_client_count = stopped_client_count + 1 + vim.schedule(function() + -- Execute the callback, if provided, for additional actions before restarting + if callback then + callback(client) + end + M.start(bufnr) + end) + end + end + if stopped_client_count >= #clients then + timer:stop() + attempts_to_live = 0 + elseif attempts_to_live <= 0 then + vim.notify('rustaceanvim.lsp: Could not restart all LSP clients.', vim.log.levels.ERROR) + timer:stop() + attempts_to_live = 0 + end + attempts_to_live = attempts_to_live - 1 + end) +end + ---@class rustaceanvim.lsp.StartConfig: rustaceanvim.lsp.ClientConfig ---@field root_dir string | nil ---@field init_options? table @@ -249,39 +317,50 @@ M.reload_settings = function(bufnr) return clients end +---Updates the target architecture setting for the LSP client associated with the given buffer. +---@param bufnr? number The buffer number, defaults to the current buffer +---@param target? string The target architecture. Defaults to nil(the current buffer's target if not provided). +M.set_target_arch = function(bufnr, target) + local on_update_target = function(client) + -- Get current user's rust-analyzer target + local current_target = vim.tbl_get(client, 'config', 'settings', 'rust-analyzer', 'cargo', 'target') + + if not target then + if not current_target then + vim.notify('Using default OS target architecture.', vim.log.levels.INFO) + else + vim.notify('Target architecture is already set to the default OS target.', vim.log.levels.INFO) + end + return + end + + ---on_valid callback handles the main functionality in changing system's arch + ---by checking if rustc targets contains user's target or if user's provided target is nil. + ---Notifies user on unrecognized target arch request + local on_valid = function(rustc_tgs) + if target == nil or rustc_tgs[target] then + client.settings['rust-analyzer'].cargo.target = target + client.notify('workspace/didChangeConfiguration', { settings = client.config.settings }) + vim.notify('Target architecture updated successfully to: ' .. target, vim.log.levels.INFO) + return + else + vim.notify('Invalid target architecture provided: ' .. tostring(target), vim.log.levels.ERROR) + return + end + end + + return validate_rustc_target(on_valid) + end + + restart(bufnr, on_update_target) +end + ---Restart the LSP client. ---Fails silently if the buffer's filetype is not one of the filetypes specified in the config. ---@param bufnr? number The buffer number (optional), defaults to the current buffer ---@return number|nil client_id The LSP client ID after restart M.restart = function(bufnr) - bufnr = bufnr or vim.api.nvim_get_current_buf() - local clients = M.stop(bufnr) - local timer, _, _ = vim.uv.new_timer() - if not timer then - -- TODO: Log error when logging is implemented - return - end - local attempts_to_live = 50 - local stopped_client_count = 0 - timer:start(200, 100, function() - for _, client in ipairs(clients) do - if client:is_stopped() then - stopped_client_count = stopped_client_count + 1 - vim.schedule(function() - M.start(bufnr) - end) - end - end - if stopped_client_count >= #clients then - timer:stop() - attempts_to_live = 0 - elseif attempts_to_live <= 0 then - vim.notify('rustaceanvim.lsp: Could not restart all LSP clients.', vim.log.levels.ERROR) - timer:stop() - attempts_to_live = 0 - end - attempts_to_live = attempts_to_live - 1 - end) + M.restart(bufnr) end ---@enum RustAnalyzerCmd @@ -290,11 +369,13 @@ local RustAnalyzerCmd = { stop = 'stop', restart = 'restart', reload_settings = 'reloadSettings', + target = 'target', } local function rust_analyzer_cmd(opts) local fargs = opts.fargs local cmd = fargs[1] + local arch = fargs[2] ---@cast cmd RustAnalyzerCmd if cmd == RustAnalyzerCmd.start then M.start() @@ -304,12 +385,14 @@ local function rust_analyzer_cmd(opts) M.restart() elseif cmd == RustAnalyzerCmd.reload_settings then M.reload_settings() + elseif cmd == RustAnalyzerCmd.target then + M.set_target_arch(nil, arch) end end vim.api.nvim_create_user_command('RustAnalyzer', rust_analyzer_cmd, { nargs = '+', - desc = 'Starts or stops the rust-analyzer LSP client', + desc = 'Starts, stops the rust-analyzer LSP client or changes the target', complete = function(arg_lead, cmdline, _) local clients = rust_analyzer.get_active_rustaceanvim_clients() ---@type RustAnalyzerCmd[] From 49101dbbd405f85658072063e4f0b0f41924d149 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Thu, 17 Oct 2024 14:26:47 +0200 Subject: [PATCH 40/84] refactor: some minor cleanup + vimdoc generation --- doc/rustaceanvim.txt | 5 +- lua/rustaceanvim/lsp/init.lua | 78 +++++++++++++++--------------- lua/rustaceanvim/rust_analyzer.lua | 2 +- 3 files changed, 43 insertions(+), 42 deletions(-) diff --git a/doc/rustaceanvim.txt b/doc/rustaceanvim.txt index aa81b141..98058101 100644 --- a/doc/rustaceanvim.txt +++ b/doc/rustaceanvim.txt @@ -25,8 +25,9 @@ Commands: ':RustAnalyzer restart' - Restart the LSP client. ':RustAnalyzer reloadSettings' - Reload settings for the LSP client. ':RustAnalyzer target ' - Set the target architecture for the LSP client. - -The ':RustAnalyzer target' command can take a valid rustc target, such as 'wasm32-unknown-unknown', or it can be left empty to set the LSP client to use the default target architecture for the operating system. + The ':RustAnalyzer target' command can take a valid rustc target, + such as 'wasm32-unknown-unknown', or it can be left empty to set the LSP client + to use the default target architecture for the operating system. The ':RustLsp[!]' command is available after the LSP client has initialized. It accepts the following subcommands: diff --git a/lua/rustaceanvim/lsp/init.lua b/lua/rustaceanvim/lsp/init.lua index acba95aa..bf78d3dc 100644 --- a/lua/rustaceanvim/lsp/init.lua +++ b/lua/rustaceanvim/lsp/init.lua @@ -20,7 +20,7 @@ local function override_apply_text_edits() end end ----@param client lsp.Client +---@param client vim.lsp.Client ---@param root_dir string ---@return boolean local function is_in_workspace(client, root_dir) @@ -96,35 +96,41 @@ local function configure_file_watcher(server_cfg) end end ----Handles retrieving rustc target archs and running on_valid callback +---Handles retrieving rustc target architectures and running the passed in callback ---to perform certain actions using the retrieved targets. ----@param on_valid function(rustc_targets) -local function validate_rustc_target(on_valid) - local on_exit = function(result) - -- use cache if available. - if rustc_targets_cache then - return on_valid(rustc_targets_cache) - end +---@param callback fun(targets: string[]) +local function with_rustc_target_architectures(callback) + vim.system( + { 'rustc', '--print', 'target-list' }, + { text = true }, + ---@param result vim.SystemCompleted + function(result) + if rustc_targets_cache then + return callback(rustc_targets_cache) + end - if result.code ~= 0 then - error('Failed to retrieve rustc targets: ' .. result.stderr) - end + if result.code ~= 0 then + error('Failed to retrieve rustc targets: ' .. result.stderr) + end - rustc_targets_cache = {} - for line in result.stdout:gmatch('[^\r\n]+') do - rustc_targets_cache[line] = true + rustc_targets_cache = vim.iter(result.stdout:gmatch('[^\r\n]+')):fold( + {}, + ---@param acc table + ---@param target string + function(acc, target) + acc[target] = true + return acc + end + ) + + return callback(rustc_targets_cache) end - - return on_valid(rustc_targets_cache) - end - - -- Call vim.system with on_exit callback to avoid blocking Neovim's event loop. - vim.system({ 'rustc', '--print', 'target-list' }, { text = true }, on_exit) + ) end ---LSP restart internal implementations ---@param bufnr? number ----@param callback? function(client) Optional callback to run for each client before restarting. +---@param callback? fun(client: vim.lsp.Client) Optional callback to run for each client before restarting. ---@return number|nil client_id local function restart(bufnr, callback) bufnr = bufnr or vim.api.nvim_get_current_buf() @@ -282,18 +288,18 @@ end ---Stop the LSP client. ---@param bufnr? number The buffer number, defaults to the current buffer ----@return table[] clients A list of clients that will be stopped +---@return vim.lsp.Client[] clients A list of clients that will be stopped M.stop = function(bufnr) bufnr = bufnr or vim.api.nvim_get_current_buf() local clients = rust_analyzer.get_active_rustaceanvim_clients(bufnr) vim.lsp.stop_client(clients) if type(clients) == 'table' then - ---@cast clients lsp.Client[] + ---@cast clients vim.lsp.Client[] for _, client in ipairs(clients) do server_status.reset_client_state(client.id) end else - ---@cast clients lsp.Client + ---@cast clients vim.lsp.Client server_status.reset_client_state(clients.id) end return clients @@ -301,11 +307,11 @@ end ---Reload settings for the LSP client. ---@param bufnr? number The buffer number, defaults to the current buffer ----@return table[] clients A list of clients that will be have their settings reloaded +---@return vim.lsp.Client[] clients A list of clients that will be have their settings reloaded M.reload_settings = function(bufnr) bufnr = bufnr or vim.api.nvim_get_current_buf() local clients = rust_analyzer.get_active_rustaceanvim_clients(bufnr) - ---@cast clients lsp.Client[] + ---@cast clients vim.lsp.Client[] for _, client in ipairs(clients) do local settings = get_start_settings(vim.api.nvim_buf_get_name(bufnr), client.config.root_dir, config.server) ---@diagnostic disable-next-line: inject-field @@ -321,7 +327,8 @@ end ---@param bufnr? number The buffer number, defaults to the current buffer ---@param target? string The target architecture. Defaults to nil(the current buffer's target if not provided). M.set_target_arch = function(bufnr, target) - local on_update_target = function(client) + ---@param client vim.lsp.Client + restart(bufnr, function(client) -- Get current user's rust-analyzer target local current_target = vim.tbl_get(client, 'config', 'settings', 'rust-analyzer', 'cargo', 'target') @@ -334,11 +341,8 @@ M.set_target_arch = function(bufnr, target) return end - ---on_valid callback handles the main functionality in changing system's arch - ---by checking if rustc targets contains user's target or if user's provided target is nil. - ---Notifies user on unrecognized target arch request - local on_valid = function(rustc_tgs) - if target == nil or rustc_tgs[target] then + with_rustc_target_architectures(function(rustc_targets) + if target == nil or rustc_targets[target] then client.settings['rust-analyzer'].cargo.target = target client.notify('workspace/didChangeConfiguration', { settings = client.config.settings }) vim.notify('Target architecture updated successfully to: ' .. target, vim.log.levels.INFO) @@ -347,12 +351,8 @@ M.set_target_arch = function(bufnr, target) vim.notify('Invalid target architecture provided: ' .. tostring(target), vim.log.levels.ERROR) return end - end - - return validate_rustc_target(on_valid) - end - - restart(bufnr, on_update_target) + end) + end) end ---Restart the LSP client. diff --git a/lua/rustaceanvim/rust_analyzer.lua b/lua/rustaceanvim/rust_analyzer.lua index 47a82897..1ecdec06 100644 --- a/lua/rustaceanvim/rust_analyzer.lua +++ b/lua/rustaceanvim/rust_analyzer.lua @@ -55,7 +55,7 @@ end ---@param file_path string Search for clients with a root_dir matching this file path ---@param method string LSP method name ----@return lsp.Client|nil +---@return vim.lsp.Client|nil M.get_client_for_file = function(file_path, method) for _, client in ipairs(M.get_active_rustaceanvim_clients(nil, { method = method })) do local root_dir = client.config.root_dir From 1a965f4c1361d08d4d7a3ad3399aa33c8b964b2b Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Thu, 17 Oct 2024 14:50:13 +0200 Subject: [PATCH 41/84] chore: fix caching in last refactor --- "\r" | 405 ++++++++++++++++++++++++++++++++++ lua/rustaceanvim/lsp/init.lua | 9 +- 2 files changed, 408 insertions(+), 6 deletions(-) create mode 100644 "\r" diff --git "a/\r" "b/\r" new file mode 100644 index 00000000..2147c385 --- /dev/null +++ "b/\r" @@ -0,0 +1,405 @@ +local M = {} +---@type rustaceanvim.Config +local config = require('rustaceanvim.config.internal') +local types = require('rustaceanvim.types.internal') +local rust_analyzer = require('rustaceanvim.rust_analyzer') +local server_status = require('rustaceanvim.server_status') +local cargo = require('rustaceanvim.cargo') +local os = require('rustaceanvim.os') + +---Local rustc targets cache +local rustc_targets_cache = nil + +local function override_apply_text_edits() + local old_func = vim.lsp.util.apply_text_edits + ---@diagnostic disable-next-line + vim.lsp.util.apply_text_edits = function(edits, bufnr, offset_encoding) + local overrides = require('rustaceanvim.overrides') + overrides.snippet_text_edits_to_text_edits(edits) + old_func(edits, bufnr, offset_encoding) + end +end + +---@param client vim.lsp.Client +---@param root_dir string +---@return boolean +local function is_in_workspace(client, root_dir) + if not client.workspace_folders then + return false + end + + for _, dir in ipairs(client.workspace_folders) do + if (root_dir .. '/'):sub(1, #dir.name + 1) == dir.name .. '/' then + return true + end + end + + return false +end + +---Searches upward for a .vscode/settings.json that contains rust-analyzer +---settings and returns them. +---@param bufname string +---@return table server_settings or an empty table if no settings were found +local function find_vscode_settings(bufname) + local settings = {} + local found_dirs = vim.fs.find({ '.vscode' }, { upward = true, path = vim.fs.dirname(bufname), type = 'directory' }) + if vim.tbl_isempty(found_dirs) then + return settings + end + local vscode_dir = found_dirs[1] + local results = vim.fn.glob(vim.fs.joinpath(vscode_dir, 'settings.json'), true, true) + if vim.tbl_isempty(results) then + return settings + end + local content = os.read_file(results[1]) + return content and require('rustaceanvim.config.json').silent_decode(content) or {} +end + +---Generate the settings from config and vscode settings if found. +---settings and returns them. +---@param bufname string +---@param root_dir string | nil +---@param client_config table +---@return table server_settings or an empty table if no settings were found +local function get_start_settings(bufname, root_dir, client_config) + local settings = client_config.settings + local evaluated_settings = type(settings) == 'function' and settings(root_dir, client_config.default_settings) + or settings + + if config.server.load_vscode_settings then + local json_settings = find_vscode_settings(bufname) + require('rustaceanvim.config.json').override_with_rust_analyzer_json_keys(evaluated_settings, json_settings) + end + + return evaluated_settings +end + +---HACK: Workaround for https://github.com/neovim/neovim/pull/28690 +--- to solve #423. +--- Checks if Neovim's file watcher is enabled, and if it isn't, +--- configures rust-analyzer to enable server-side file watching (if not configured otherwise). +--- +---@param server_cfg rustaceanvim.lsp.StartConfig LSP start settings +local function configure_file_watcher(server_cfg) + local is_client_file_watcher_enabled = + vim.tbl_get(server_cfg.capabilities, 'workspace', 'didChangeWatchedFiles', 'dynamicRegistration') + local file_watcher_setting = vim.tbl_get(server_cfg.settings, 'rust-analyzer', 'files', 'watcher') + if is_client_file_watcher_enabled and not file_watcher_setting then + server_cfg.settings = vim.tbl_deep_extend('force', server_cfg.settings, { + ['rust-analyzer'] = { + files = { + watcher = 'server', + }, + }, + }) + end +end + +---Handles retrieving rustc target architectures and running the passed in callback +---to perform certain actions using the retrieved targets. +---@param callback fun(targets: string[]) +local function with_rustc_target_architectures(callback) + if rustc_targets_cache then + return callback(rustc_targets_cache) + end + vim.system( + { 'rustc', '--print', 'target-list' }, + { text = true }, + ---@param result vim.SystemCompleted + function(result) + if result.code ~= 0 then + error('Failed to retrieve rustc targets: ' .. result.stderr) + end + rustc_targets_cache = vim.iter(result.stdout:gmatch('[^\r\n]+')):fold( + {}, + ---@param acc table + ---@param target string + function(acc, target) + acc[target] = true + return acc + end + ) + return callback(rustc_targets_cache) + end + ) +end + +---LSP restart internal implementations +---@param bufnr? number +---@param callback? fun(client: vim.lsp.Client) Optional callback to run for each client before restarting. +---@return number|nil client_id +local function restart(bufnr, callback) + bufnr = bufnr or vim.api.nvim_get_current_buf() + local clients = M.stop(bufnr) + local timer, _, _ = vim.uv.new_timer() + if not timer then + vim.notify('Failed to init timer for LSP client restart.', vim.log.levels.ERROR) + return + end + local attempts_to_live = 50 + local stopped_client_count = 0 + timer:start(200, 100, function() + for _, client in ipairs(clients) do + if client:is_stopped() then + stopped_client_count = stopped_client_count + 1 + vim.schedule(function() + -- Execute the callback, if provided, for additional actions before restarting + if callback then + callback(client) + end + M.start(bufnr) + end) + end + end + if stopped_client_count >= #clients then + timer:stop() + attempts_to_live = 0 + elseif attempts_to_live <= 0 then + vim.notify('rustaceanvim.lsp: Could not restart all LSP clients.', vim.log.levels.ERROR) + timer:stop() + attempts_to_live = 0 + end + attempts_to_live = attempts_to_live - 1 + end) +end + +---@class rustaceanvim.lsp.StartConfig: rustaceanvim.lsp.ClientConfig +---@field root_dir string | nil +---@field init_options? table +---@field settings table +---@field cmd string[] +---@field name string +---@field filetypes string[] +---@field capabilities table +---@field handlers lsp.Handler[] +---@field on_init function +---@field on_attach function +---@field on_exit function + +--- Start or attach the LSP client +---@param bufnr? number The buffer number (optional), defaults to the current buffer +---@return integer|nil client_id The LSP client ID +M.start = function(bufnr) + bufnr = bufnr or vim.api.nvim_get_current_buf() + local bufname = vim.api.nvim_buf_get_name(bufnr) + local client_config = config.server + ---@type rustaceanvim.lsp.StartConfig + local lsp_start_config = vim.tbl_deep_extend('force', {}, client_config) + local root_dir = cargo.get_config_root_dir(client_config, bufname) + if not root_dir then + --- No project root found. Start in detached/standalone mode. + root_dir = vim.fs.dirname(bufname) + lsp_start_config.init_options = { detachedFiles = { bufname } } + end + root_dir = os.normalize_path_on_windows(root_dir) + lsp_start_config.root_dir = root_dir + + lsp_start_config.settings = get_start_settings(bufname, root_dir, client_config) + configure_file_watcher(lsp_start_config) + + -- rust-analyzer treats settings in initializationOptions specially -- in particular, workspace_discoverConfig + -- so copy them to init_options (the vim name) + -- so they end up in initializationOptions (the LSP name) + -- ... and initialization_options (the rust name) in rust-analyzer's main.rs + lsp_start_config.init_options = vim.tbl_deep_extend( + 'force', + lsp_start_config.init_options or {}, + vim.tbl_get(lsp_start_config.settings, 'rust-analyzer') + ) + + -- Check if a client is already running and add the workspace folder if necessary. + for _, client in pairs(rust_analyzer.get_active_rustaceanvim_clients()) do + if root_dir and not is_in_workspace(client, root_dir) then + local workspace_folder = { uri = vim.uri_from_fname(root_dir), name = root_dir } + local params = { + event = { + added = { workspace_folder }, + removed = {}, + }, + } + client.rpc.notify('workspace/didChangeWorkspaceFolders', params) + if not client.workspace_folders then + client.workspace_folders = {} + end + table.insert(client.workspace_folders, workspace_folder) + vim.lsp.buf_attach_client(bufnr, client.id) + return + end + end + + local rust_analyzer_cmd = types.evaluate(client_config.cmd) + if #rust_analyzer_cmd == 0 or vim.fn.executable(rust_analyzer_cmd[1]) ~= 1 then + vim.notify('rust-analyzer binary not found.', vim.log.levels.ERROR) + return + end + ---@cast rust_analyzer_cmd string[] + lsp_start_config.cmd = rust_analyzer_cmd + lsp_start_config.name = 'rust-analyzer' + lsp_start_config.filetypes = { 'rust' } + + local custom_handlers = {} + custom_handlers['experimental/serverStatus'] = server_status.handler + + if config.tools.hover_actions.replace_builtin_hover then + custom_handlers['textDocument/hover'] = require('rustaceanvim.hover_actions').handler + end + + lsp_start_config.handlers = vim.tbl_deep_extend('force', custom_handlers, lsp_start_config.handlers or {}) + + local commands = require('rustaceanvim.commands') + local old_on_init = lsp_start_config.on_init + lsp_start_config.on_init = function(...) + override_apply_text_edits() + commands.create_rust_lsp_command() + if type(old_on_init) == 'function' then + old_on_init(...) + end + end + + local old_on_attach = lsp_start_config.on_attach + lsp_start_config.on_attach = function(...) + if type(old_on_attach) == 'function' then + old_on_attach(...) + end + if config.dap.autoload_configurations then + -- When switching projects, there might be new debuggables (#466) + require('rustaceanvim.commands.debuggables').add_dap_debuggables() + end + end + + local old_on_exit = lsp_start_config.on_exit + lsp_start_config.on_exit = function(...) + override_apply_text_edits() + -- on_exit runs in_fast_event + vim.schedule(function() + commands.delete_rust_lsp_command() + end) + if type(old_on_exit) == 'function' then + old_on_exit(...) + end + end + + return vim.lsp.start(lsp_start_config) +end + +---Stop the LSP client. +---@param bufnr? number The buffer number, defaults to the current buffer +---@return vim.lsp.Client[] clients A list of clients that will be stopped +M.stop = function(bufnr) + bufnr = bufnr or vim.api.nvim_get_current_buf() + local clients = rust_analyzer.get_active_rustaceanvim_clients(bufnr) + vim.lsp.stop_client(clients) + if type(clients) == 'table' then + ---@cast clients vim.lsp.Client[] + for _, client in ipairs(clients) do + server_status.reset_client_state(client.id) + end + else + ---@cast clients vim.lsp.Client + server_status.reset_client_state(clients.id) + end + return clients +end + +---Reload settings for the LSP client. +---@param bufnr? number The buffer number, defaults to the current buffer +---@return vim.lsp.Client[] clients A list of clients that will be have their settings reloaded +M.reload_settings = function(bufnr) + bufnr = bufnr or vim.api.nvim_get_current_buf() + local clients = rust_analyzer.get_active_rustaceanvim_clients(bufnr) + ---@cast clients vim.lsp.Client[] + for _, client in ipairs(clients) do + local settings = get_start_settings(vim.api.nvim_buf_get_name(bufnr), client.config.root_dir, config.server) + ---@diagnostic disable-next-line: inject-field + client.settings = settings + client.notify('workspace/didChangeConfiguration', { + settings = client.settings, + }) + end + return clients +end + +---Updates the target architecture setting for the LSP client associated with the given buffer. +---@param bufnr? number The buffer number, defaults to the current buffer +---@param target? string The target architecture. Defaults to nil(the current buffer's target if not provided). +M.set_target_arch = function(bufnr, target) + ---@param client vim.lsp.Client + restart(bufnr, function(client) + -- Get current user's rust-analyzer target + local current_target = vim.tbl_get(client, 'config', 'settings', 'rust-analyzer', 'cargo', 'target') + + if not target then + if not current_target then + vim.notify('Using default OS target architecture.', vim.log.levels.INFO) + else + vim.notify('Target architecture is already set to the default OS target.', vim.log.levels.INFO) + end + return + end + + with_rustc_target_architectures(function(rustc_targets) + if target == nil or rustc_targets[target] then + client.settings['rust-analyzer'].cargo.target = target + client.notify('workspace/didChangeConfiguration', { settings = client.config.settings }) + vim.notify('Target architecture updated successfully to: ' .. target, vim.log.levels.INFO) + return + else + vim.notify('Invalid target architecture provided: ' .. tostring(target), vim.log.levels.ERROR) + return + end + end) + end) +end + +---Restart the LSP client. +---Fails silently if the buffer's filetype is not one of the filetypes specified in the config. +---@param bufnr? number The buffer number (optional), defaults to the current buffer +---@return number|nil client_id The LSP client ID after restart +M.restart = function(bufnr) + M.restart(bufnr) +end + +---@enum RustAnalyzerCmd +local RustAnalyzerCmd = { + start = 'start', + stop = 'stop', + restart = 'restart', + reload_settings = 'reloadSettings', + target = 'target', +} + +local function rust_analyzer_cmd(opts) + local fargs = opts.fargs + local cmd = fargs[1] + local arch = fargs[2] + ---@cast cmd RustAnalyzerCmd + if cmd == RustAnalyzerCmd.start then + M.start() + elseif cmd == RustAnalyzerCmd.stop then + M.stop() + elseif cmd == RustAnalyzerCmd.restart then + M.restart() + elseif cmd == RustAnalyzerCmd.reload_settings then + M.reload_settings() + elseif cmd == RustAnalyzerCmd.target then + M.set_target_arch(nil, arch) + end +end + +vim.api.nvim_create_user_command('RustAnalyzer', rust_analyzer_cmd, { + nargs = '+', + desc = 'Starts, stops the rust-analyzer LSP client or changes the target', + complete = function(arg_lead, cmdline, _) + local clients = rust_analyzer.get_active_rustaceanvim_clients() + ---@type RustAnalyzerCmd[] + local commands = #clients == 0 and { 'start' } or { 'stop', 'restart', 'reloadSettings' } + if cmdline:match('^RustAnalyzer%s+%w*$') then + return vim.tbl_filter(function(command) + return command:find(arg_lead) ~= nil + end, commands) + end + end, +}) + +return M diff --git a/lua/rustaceanvim/lsp/init.lua b/lua/rustaceanvim/lsp/init.lua index bf78d3dc..2147c385 100644 --- a/lua/rustaceanvim/lsp/init.lua +++ b/lua/rustaceanvim/lsp/init.lua @@ -100,19 +100,17 @@ end ---to perform certain actions using the retrieved targets. ---@param callback fun(targets: string[]) local function with_rustc_target_architectures(callback) + if rustc_targets_cache then + return callback(rustc_targets_cache) + end vim.system( { 'rustc', '--print', 'target-list' }, { text = true }, ---@param result vim.SystemCompleted function(result) - if rustc_targets_cache then - return callback(rustc_targets_cache) - end - if result.code ~= 0 then error('Failed to retrieve rustc targets: ' .. result.stderr) end - rustc_targets_cache = vim.iter(result.stdout:gmatch('[^\r\n]+')):fold( {}, ---@param acc table @@ -122,7 +120,6 @@ local function with_rustc_target_architectures(callback) return acc end ) - return callback(rustc_targets_cache) end ) From ccff14065096c8978c431944f0f0db16db952c7b Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Thu, 17 Oct 2024 14:54:18 +0200 Subject: [PATCH 42/84] fix: remove corrupt file that breaks git clone on windows --- "\r" | 405 ----------------------------------------------------------- 1 file changed, 405 deletions(-) delete mode 100644 "\r" diff --git "a/\r" "b/\r" deleted file mode 100644 index 2147c385..00000000 --- "a/\r" +++ /dev/null @@ -1,405 +0,0 @@ -local M = {} ----@type rustaceanvim.Config -local config = require('rustaceanvim.config.internal') -local types = require('rustaceanvim.types.internal') -local rust_analyzer = require('rustaceanvim.rust_analyzer') -local server_status = require('rustaceanvim.server_status') -local cargo = require('rustaceanvim.cargo') -local os = require('rustaceanvim.os') - ----Local rustc targets cache -local rustc_targets_cache = nil - -local function override_apply_text_edits() - local old_func = vim.lsp.util.apply_text_edits - ---@diagnostic disable-next-line - vim.lsp.util.apply_text_edits = function(edits, bufnr, offset_encoding) - local overrides = require('rustaceanvim.overrides') - overrides.snippet_text_edits_to_text_edits(edits) - old_func(edits, bufnr, offset_encoding) - end -end - ----@param client vim.lsp.Client ----@param root_dir string ----@return boolean -local function is_in_workspace(client, root_dir) - if not client.workspace_folders then - return false - end - - for _, dir in ipairs(client.workspace_folders) do - if (root_dir .. '/'):sub(1, #dir.name + 1) == dir.name .. '/' then - return true - end - end - - return false -end - ----Searches upward for a .vscode/settings.json that contains rust-analyzer ----settings and returns them. ----@param bufname string ----@return table server_settings or an empty table if no settings were found -local function find_vscode_settings(bufname) - local settings = {} - local found_dirs = vim.fs.find({ '.vscode' }, { upward = true, path = vim.fs.dirname(bufname), type = 'directory' }) - if vim.tbl_isempty(found_dirs) then - return settings - end - local vscode_dir = found_dirs[1] - local results = vim.fn.glob(vim.fs.joinpath(vscode_dir, 'settings.json'), true, true) - if vim.tbl_isempty(results) then - return settings - end - local content = os.read_file(results[1]) - return content and require('rustaceanvim.config.json').silent_decode(content) or {} -end - ----Generate the settings from config and vscode settings if found. ----settings and returns them. ----@param bufname string ----@param root_dir string | nil ----@param client_config table ----@return table server_settings or an empty table if no settings were found -local function get_start_settings(bufname, root_dir, client_config) - local settings = client_config.settings - local evaluated_settings = type(settings) == 'function' and settings(root_dir, client_config.default_settings) - or settings - - if config.server.load_vscode_settings then - local json_settings = find_vscode_settings(bufname) - require('rustaceanvim.config.json').override_with_rust_analyzer_json_keys(evaluated_settings, json_settings) - end - - return evaluated_settings -end - ----HACK: Workaround for https://github.com/neovim/neovim/pull/28690 ---- to solve #423. ---- Checks if Neovim's file watcher is enabled, and if it isn't, ---- configures rust-analyzer to enable server-side file watching (if not configured otherwise). ---- ----@param server_cfg rustaceanvim.lsp.StartConfig LSP start settings -local function configure_file_watcher(server_cfg) - local is_client_file_watcher_enabled = - vim.tbl_get(server_cfg.capabilities, 'workspace', 'didChangeWatchedFiles', 'dynamicRegistration') - local file_watcher_setting = vim.tbl_get(server_cfg.settings, 'rust-analyzer', 'files', 'watcher') - if is_client_file_watcher_enabled and not file_watcher_setting then - server_cfg.settings = vim.tbl_deep_extend('force', server_cfg.settings, { - ['rust-analyzer'] = { - files = { - watcher = 'server', - }, - }, - }) - end -end - ----Handles retrieving rustc target architectures and running the passed in callback ----to perform certain actions using the retrieved targets. ----@param callback fun(targets: string[]) -local function with_rustc_target_architectures(callback) - if rustc_targets_cache then - return callback(rustc_targets_cache) - end - vim.system( - { 'rustc', '--print', 'target-list' }, - { text = true }, - ---@param result vim.SystemCompleted - function(result) - if result.code ~= 0 then - error('Failed to retrieve rustc targets: ' .. result.stderr) - end - rustc_targets_cache = vim.iter(result.stdout:gmatch('[^\r\n]+')):fold( - {}, - ---@param acc table - ---@param target string - function(acc, target) - acc[target] = true - return acc - end - ) - return callback(rustc_targets_cache) - end - ) -end - ----LSP restart internal implementations ----@param bufnr? number ----@param callback? fun(client: vim.lsp.Client) Optional callback to run for each client before restarting. ----@return number|nil client_id -local function restart(bufnr, callback) - bufnr = bufnr or vim.api.nvim_get_current_buf() - local clients = M.stop(bufnr) - local timer, _, _ = vim.uv.new_timer() - if not timer then - vim.notify('Failed to init timer for LSP client restart.', vim.log.levels.ERROR) - return - end - local attempts_to_live = 50 - local stopped_client_count = 0 - timer:start(200, 100, function() - for _, client in ipairs(clients) do - if client:is_stopped() then - stopped_client_count = stopped_client_count + 1 - vim.schedule(function() - -- Execute the callback, if provided, for additional actions before restarting - if callback then - callback(client) - end - M.start(bufnr) - end) - end - end - if stopped_client_count >= #clients then - timer:stop() - attempts_to_live = 0 - elseif attempts_to_live <= 0 then - vim.notify('rustaceanvim.lsp: Could not restart all LSP clients.', vim.log.levels.ERROR) - timer:stop() - attempts_to_live = 0 - end - attempts_to_live = attempts_to_live - 1 - end) -end - ----@class rustaceanvim.lsp.StartConfig: rustaceanvim.lsp.ClientConfig ----@field root_dir string | nil ----@field init_options? table ----@field settings table ----@field cmd string[] ----@field name string ----@field filetypes string[] ----@field capabilities table ----@field handlers lsp.Handler[] ----@field on_init function ----@field on_attach function ----@field on_exit function - ---- Start or attach the LSP client ----@param bufnr? number The buffer number (optional), defaults to the current buffer ----@return integer|nil client_id The LSP client ID -M.start = function(bufnr) - bufnr = bufnr or vim.api.nvim_get_current_buf() - local bufname = vim.api.nvim_buf_get_name(bufnr) - local client_config = config.server - ---@type rustaceanvim.lsp.StartConfig - local lsp_start_config = vim.tbl_deep_extend('force', {}, client_config) - local root_dir = cargo.get_config_root_dir(client_config, bufname) - if not root_dir then - --- No project root found. Start in detached/standalone mode. - root_dir = vim.fs.dirname(bufname) - lsp_start_config.init_options = { detachedFiles = { bufname } } - end - root_dir = os.normalize_path_on_windows(root_dir) - lsp_start_config.root_dir = root_dir - - lsp_start_config.settings = get_start_settings(bufname, root_dir, client_config) - configure_file_watcher(lsp_start_config) - - -- rust-analyzer treats settings in initializationOptions specially -- in particular, workspace_discoverConfig - -- so copy them to init_options (the vim name) - -- so they end up in initializationOptions (the LSP name) - -- ... and initialization_options (the rust name) in rust-analyzer's main.rs - lsp_start_config.init_options = vim.tbl_deep_extend( - 'force', - lsp_start_config.init_options or {}, - vim.tbl_get(lsp_start_config.settings, 'rust-analyzer') - ) - - -- Check if a client is already running and add the workspace folder if necessary. - for _, client in pairs(rust_analyzer.get_active_rustaceanvim_clients()) do - if root_dir and not is_in_workspace(client, root_dir) then - local workspace_folder = { uri = vim.uri_from_fname(root_dir), name = root_dir } - local params = { - event = { - added = { workspace_folder }, - removed = {}, - }, - } - client.rpc.notify('workspace/didChangeWorkspaceFolders', params) - if not client.workspace_folders then - client.workspace_folders = {} - end - table.insert(client.workspace_folders, workspace_folder) - vim.lsp.buf_attach_client(bufnr, client.id) - return - end - end - - local rust_analyzer_cmd = types.evaluate(client_config.cmd) - if #rust_analyzer_cmd == 0 or vim.fn.executable(rust_analyzer_cmd[1]) ~= 1 then - vim.notify('rust-analyzer binary not found.', vim.log.levels.ERROR) - return - end - ---@cast rust_analyzer_cmd string[] - lsp_start_config.cmd = rust_analyzer_cmd - lsp_start_config.name = 'rust-analyzer' - lsp_start_config.filetypes = { 'rust' } - - local custom_handlers = {} - custom_handlers['experimental/serverStatus'] = server_status.handler - - if config.tools.hover_actions.replace_builtin_hover then - custom_handlers['textDocument/hover'] = require('rustaceanvim.hover_actions').handler - end - - lsp_start_config.handlers = vim.tbl_deep_extend('force', custom_handlers, lsp_start_config.handlers or {}) - - local commands = require('rustaceanvim.commands') - local old_on_init = lsp_start_config.on_init - lsp_start_config.on_init = function(...) - override_apply_text_edits() - commands.create_rust_lsp_command() - if type(old_on_init) == 'function' then - old_on_init(...) - end - end - - local old_on_attach = lsp_start_config.on_attach - lsp_start_config.on_attach = function(...) - if type(old_on_attach) == 'function' then - old_on_attach(...) - end - if config.dap.autoload_configurations then - -- When switching projects, there might be new debuggables (#466) - require('rustaceanvim.commands.debuggables').add_dap_debuggables() - end - end - - local old_on_exit = lsp_start_config.on_exit - lsp_start_config.on_exit = function(...) - override_apply_text_edits() - -- on_exit runs in_fast_event - vim.schedule(function() - commands.delete_rust_lsp_command() - end) - if type(old_on_exit) == 'function' then - old_on_exit(...) - end - end - - return vim.lsp.start(lsp_start_config) -end - ----Stop the LSP client. ----@param bufnr? number The buffer number, defaults to the current buffer ----@return vim.lsp.Client[] clients A list of clients that will be stopped -M.stop = function(bufnr) - bufnr = bufnr or vim.api.nvim_get_current_buf() - local clients = rust_analyzer.get_active_rustaceanvim_clients(bufnr) - vim.lsp.stop_client(clients) - if type(clients) == 'table' then - ---@cast clients vim.lsp.Client[] - for _, client in ipairs(clients) do - server_status.reset_client_state(client.id) - end - else - ---@cast clients vim.lsp.Client - server_status.reset_client_state(clients.id) - end - return clients -end - ----Reload settings for the LSP client. ----@param bufnr? number The buffer number, defaults to the current buffer ----@return vim.lsp.Client[] clients A list of clients that will be have their settings reloaded -M.reload_settings = function(bufnr) - bufnr = bufnr or vim.api.nvim_get_current_buf() - local clients = rust_analyzer.get_active_rustaceanvim_clients(bufnr) - ---@cast clients vim.lsp.Client[] - for _, client in ipairs(clients) do - local settings = get_start_settings(vim.api.nvim_buf_get_name(bufnr), client.config.root_dir, config.server) - ---@diagnostic disable-next-line: inject-field - client.settings = settings - client.notify('workspace/didChangeConfiguration', { - settings = client.settings, - }) - end - return clients -end - ----Updates the target architecture setting for the LSP client associated with the given buffer. ----@param bufnr? number The buffer number, defaults to the current buffer ----@param target? string The target architecture. Defaults to nil(the current buffer's target if not provided). -M.set_target_arch = function(bufnr, target) - ---@param client vim.lsp.Client - restart(bufnr, function(client) - -- Get current user's rust-analyzer target - local current_target = vim.tbl_get(client, 'config', 'settings', 'rust-analyzer', 'cargo', 'target') - - if not target then - if not current_target then - vim.notify('Using default OS target architecture.', vim.log.levels.INFO) - else - vim.notify('Target architecture is already set to the default OS target.', vim.log.levels.INFO) - end - return - end - - with_rustc_target_architectures(function(rustc_targets) - if target == nil or rustc_targets[target] then - client.settings['rust-analyzer'].cargo.target = target - client.notify('workspace/didChangeConfiguration', { settings = client.config.settings }) - vim.notify('Target architecture updated successfully to: ' .. target, vim.log.levels.INFO) - return - else - vim.notify('Invalid target architecture provided: ' .. tostring(target), vim.log.levels.ERROR) - return - end - end) - end) -end - ----Restart the LSP client. ----Fails silently if the buffer's filetype is not one of the filetypes specified in the config. ----@param bufnr? number The buffer number (optional), defaults to the current buffer ----@return number|nil client_id The LSP client ID after restart -M.restart = function(bufnr) - M.restart(bufnr) -end - ----@enum RustAnalyzerCmd -local RustAnalyzerCmd = { - start = 'start', - stop = 'stop', - restart = 'restart', - reload_settings = 'reloadSettings', - target = 'target', -} - -local function rust_analyzer_cmd(opts) - local fargs = opts.fargs - local cmd = fargs[1] - local arch = fargs[2] - ---@cast cmd RustAnalyzerCmd - if cmd == RustAnalyzerCmd.start then - M.start() - elseif cmd == RustAnalyzerCmd.stop then - M.stop() - elseif cmd == RustAnalyzerCmd.restart then - M.restart() - elseif cmd == RustAnalyzerCmd.reload_settings then - M.reload_settings() - elseif cmd == RustAnalyzerCmd.target then - M.set_target_arch(nil, arch) - end -end - -vim.api.nvim_create_user_command('RustAnalyzer', rust_analyzer_cmd, { - nargs = '+', - desc = 'Starts, stops the rust-analyzer LSP client or changes the target', - complete = function(arg_lead, cmdline, _) - local clients = rust_analyzer.get_active_rustaceanvim_clients() - ---@type RustAnalyzerCmd[] - local commands = #clients == 0 and { 'start' } or { 'stop', 'restart', 'reloadSettings' } - if cmdline:match('^RustAnalyzer%s+%w*$') then - return vim.tbl_filter(function(command) - return command:find(arg_lead) ~= nil - end, commands) - end - end, -}) - -return M From 6eb1c41463a0ad02a4fe799321cc7f651b87e576 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Thu, 17 Oct 2024 17:32:09 +0200 Subject: [PATCH 43/84] chore(master): release 5.13.0 (#546) --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a3b1d1c..1655047e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [5.13.0](https://github.com/mrcjkb/rustaceanvim/compare/v5.12.0...v5.13.0) (2024-10-17) + + +### Features + +* **lsp:** target architecture switching command for `RustAnalyzer` ([#541](https://github.com/mrcjkb/rustaceanvim/issues/541)) ([95715b2](https://github.com/mrcjkb/rustaceanvim/commit/95715b28c87b4cb3a8a38e063e2aa5cd3a8024d7)) + + +### Bug Fixes + +* remove corrupt file that breaks git clone on windows ([ccff140](https://github.com/mrcjkb/rustaceanvim/commit/ccff14065096c8978c431944f0f0db16db952c7b)) + ## [5.12.0](https://github.com/mrcjkb/rustaceanvim/compare/v5.11.0...v5.12.0) (2024-10-15) From f2a7a51b506d6f896697b66c8de0c813d93d599e Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Sun, 20 Oct 2024 02:23:36 +0200 Subject: [PATCH 44/84] chore: update flake.lock (#549) Co-authored-by: github-actions[bot] --- flake.lock | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/flake.lock b/flake.lock index 5eb8efa4..ad6a23e6 100644 --- a/flake.lock +++ b/flake.lock @@ -281,11 +281,11 @@ "nixpkgs-stable": "nixpkgs-stable_2" }, "locked": { - "lastModified": 1728651332, - "narHash": "sha256-lm+asqDSTj0m6j1dtEte1/XG+uzZbwxS3tn7JLaBw84=", + "lastModified": 1729104314, + "narHash": "sha256-pZRZsq5oCdJt3upZIU4aslS9XwFJ+/nVtALHIciX/BI=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "06bb5971c139959d9a951f34e4264d32f5d998e7", + "rev": "3c3e88f0f544d6bb54329832616af7eb971b6be6", "type": "github" }, "original": { @@ -310,11 +310,11 @@ ] }, "locked": { - "lastModified": 1728580416, - "narHash": "sha256-nKttjKg6lE7O5S+wlBOkXsUGdOgVxZ8SWaCOyodW5so=", + "lastModified": 1729104314, + "narHash": "sha256-pZRZsq5oCdJt3upZIU4aslS9XwFJ+/nVtALHIciX/BI=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "4ebefcac44b5116cf5741be858245db769ddedd1", + "rev": "3c3e88f0f544d6bb54329832616af7eb971b6be6", "type": "github" }, "original": { @@ -506,11 +506,11 @@ "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1728710931, - "narHash": "sha256-guSpjhNm1DiKUUdmbVAzUy4YcsCa7HP5NimiUItisZ8=", + "lastModified": 1729315397, + "narHash": "sha256-j/juRj9MDCOMYcCGXTogUigGYDPjwwYuxnuyBul78tk=", "owner": "nvim-neorocks", "repo": "neorocks", - "rev": "9001b52860c1dc78a6d156bda2f3592769539d2e", + "rev": "bd4927a47d96bc2eb88f11079075ce4db5be8a4f", "type": "github" }, "original": { @@ -529,11 +529,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1728631701, - "narHash": "sha256-LPqpJVV8Ws4uDfzp/Huu6myMW33lmZbFGTMoZ9LyRCU=", + "lastModified": 1729147490, + "narHash": "sha256-F0/iQVbbIFctMPwK4JEd4fxVzNwaq7NnD5oen59S24s=", "owner": "nix-community", "repo": "neovim-nightly-overlay", - "rev": "a2de61747149100c904c01eb8915e1c6ecec0379", + "rev": "e2047498667aeb24e8493ff430a20cff713915f4", "type": "github" }, "original": { @@ -545,11 +545,11 @@ "neovim-src": { "flake": false, "locked": { - "lastModified": 1728600525, - "narHash": "sha256-Q2QHD23/bkNdYTbXaRLaVYy/uUx3gw08NAehTfF5ZXs=", + "lastModified": 1729121305, + "narHash": "sha256-c94xkA/RuszC4PfmB+MWqOo2vbO66GTO6XKer0mbltA=", "owner": "neovim", "repo": "neovim", - "rev": "6f1601a1b94e6ea724d8436600c64760525d1d2b", + "rev": "852954ff6d96adce0158f74ca494fdcef3aa1921", "type": "github" }, "original": { @@ -704,11 +704,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1728538411, - "narHash": "sha256-f0SBJz1eZ2yOuKUr5CA9BHULGXVSn6miBuUWdTyhUhU=", + "lastModified": 1728863046, + "narHash": "sha256-DZBO2465PL5V89e8hFSJewyH4QbCPpW3ssws7ckT/0A=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "b69de56fac8c2b6f8fd27f2eca01dcda8e0a4221", + "rev": "d4f247e89f6e10120f911e2e2d2254a050d0f732", "type": "github" }, "original": { @@ -720,11 +720,11 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1728538411, - "narHash": "sha256-f0SBJz1eZ2yOuKUr5CA9BHULGXVSn6miBuUWdTyhUhU=", + "lastModified": 1729265718, + "narHash": "sha256-4HQI+6LsO3kpWTYuVGIzhJs1cetFcwT7quWCk/6rqeo=", "owner": "nixos", "repo": "nixpkgs", - "rev": "b69de56fac8c2b6f8fd27f2eca01dcda8e0a4221", + "rev": "ccc0c2126893dd20963580b6478d1a10a4512185", "type": "github" }, "original": { @@ -736,11 +736,11 @@ }, "nixpkgs_5": { "locked": { - "lastModified": 1728538411, - "narHash": "sha256-f0SBJz1eZ2yOuKUr5CA9BHULGXVSn6miBuUWdTyhUhU=", + "lastModified": 1729265718, + "narHash": "sha256-4HQI+6LsO3kpWTYuVGIzhJs1cetFcwT7quWCk/6rqeo=", "owner": "nixos", "repo": "nixpkgs", - "rev": "b69de56fac8c2b6f8fd27f2eca01dcda8e0a4221", + "rev": "ccc0c2126893dd20963580b6478d1a10a4512185", "type": "github" }, "original": { @@ -790,11 +790,11 @@ "nixpkgs-stable": "nixpkgs-stable_3" }, "locked": { - "lastModified": 1728727368, - "narHash": "sha256-7FMyNISP7K6XDSIt1NJxkXZnEdV3HZUXvFoBaJ/qdOg=", + "lastModified": 1729104314, + "narHash": "sha256-pZRZsq5oCdJt3upZIU4aslS9XwFJ+/nVtALHIciX/BI=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "eb74e0be24a11a1531b5b8659535580554d30b28", + "rev": "3c3e88f0f544d6bb54329832616af7eb971b6be6", "type": "github" }, "original": { From f9b22ae03946a1938288400841cb62ec53077973 Mon Sep 17 00:00:00 2001 From: Arthur Cahu <81474071+arthur-cahu@users.noreply.github.com> Date: Tue, 22 Oct 2024 00:22:03 +0200 Subject: [PATCH 45/84] docs(mason): more generic config snippet (#550) --- doc/mason.txt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/doc/mason.txt b/doc/mason.txt index a30f1510..a2c2359a 100644 --- a/doc/mason.txt +++ b/doc/mason.txt @@ -14,11 +14,15 @@ the `server.cmd` setting (see |rustaceanvim.config| and |RustaceanLspClientOpts| server = { cmd = function() local mason_registry = require('mason-registry') - local ra_binary = mason_registry.is_installed('rust-analyzer') - -- This may need to be tweaked, depending on the operating system. - and mason_registry.get_package('rust-analyzer'):get_install_path() .. "/rust-analyzer" - or "rust-analyzer" - return { ra_binary } -- You can add args to the list, such as '--log-file' + if mason_registry.is_installed('rust-analyzer') then + -- This may need to be tweaked depending on the operating system. + local ra = mason_registry.get_package('rust-analyzer') + local ra_filename = ra:get_receipt():get().links.bin['rust-analyzer'] + return { ('%s/%s'):format(ra:get_install_path(), ra_filename or 'rust-analyzer') } + else + -- global installation + return { 'rust-analyzer' } + end end, }, } From f0e11ea356e269e2719811f5388a04ff7b215f7f Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Sun, 27 Oct 2024 02:15:40 +0200 Subject: [PATCH 46/84] chore: update flake.lock (#553) Co-authored-by: github-actions[bot] --- flake.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/flake.lock b/flake.lock index ad6a23e6..e1e6ec3a 100644 --- a/flake.lock +++ b/flake.lock @@ -506,11 +506,11 @@ "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1729315397, - "narHash": "sha256-j/juRj9MDCOMYcCGXTogUigGYDPjwwYuxnuyBul78tk=", + "lastModified": 1729920196, + "narHash": "sha256-wjo8ZF3hAGWm0L8S90VLsvSObdSZTsCzg7PyR26+WoU=", "owner": "nvim-neorocks", "repo": "neorocks", - "rev": "bd4927a47d96bc2eb88f11079075ce4db5be8a4f", + "rev": "df27c6f473c2945b148d3243000466f546939d72", "type": "github" }, "original": { @@ -720,11 +720,11 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1729265718, - "narHash": "sha256-4HQI+6LsO3kpWTYuVGIzhJs1cetFcwT7quWCk/6rqeo=", + "lastModified": 1729850857, + "narHash": "sha256-WvLXzNNnnw+qpFOmgaM3JUlNEH+T4s22b5i2oyyCpXE=", "owner": "nixos", "repo": "nixpkgs", - "rev": "ccc0c2126893dd20963580b6478d1a10a4512185", + "rev": "41dea55321e5a999b17033296ac05fe8a8b5a257", "type": "github" }, "original": { @@ -736,11 +736,11 @@ }, "nixpkgs_5": { "locked": { - "lastModified": 1729265718, - "narHash": "sha256-4HQI+6LsO3kpWTYuVGIzhJs1cetFcwT7quWCk/6rqeo=", + "lastModified": 1729850857, + "narHash": "sha256-WvLXzNNnnw+qpFOmgaM3JUlNEH+T4s22b5i2oyyCpXE=", "owner": "nixos", "repo": "nixpkgs", - "rev": "ccc0c2126893dd20963580b6478d1a10a4512185", + "rev": "41dea55321e5a999b17033296ac05fe8a8b5a257", "type": "github" }, "original": { From 6c4c8d82db26b9deab655ca4f75f526652a0de8a Mon Sep 17 00:00:00 2001 From: Samuel Onoja Date: Mon, 28 Oct 2024 17:46:42 +0100 Subject: [PATCH 47/84] perf: optimize target_arch switching (#548) --- lua/rustaceanvim/lsp/init.lua | 75 +++++++----------------------- lua/rustaceanvim/rust_analyzer.lua | 37 +++++++++++++-- lua/rustaceanvim/rustc.lua | 39 ++++++++++++++++ 3 files changed, 89 insertions(+), 62 deletions(-) create mode 100644 lua/rustaceanvim/rustc.lua diff --git a/lua/rustaceanvim/lsp/init.lua b/lua/rustaceanvim/lsp/init.lua index 2147c385..38a89cae 100644 --- a/lua/rustaceanvim/lsp/init.lua +++ b/lua/rustaceanvim/lsp/init.lua @@ -6,9 +6,7 @@ local rust_analyzer = require('rustaceanvim.rust_analyzer') local server_status = require('rustaceanvim.server_status') local cargo = require('rustaceanvim.cargo') local os = require('rustaceanvim.os') - ----Local rustc targets cache -local rustc_targets_cache = nil +local rustc = require('rustaceanvim.rustc') local function override_apply_text_edits() local old_func = vim.lsp.util.apply_text_edits @@ -96,42 +94,14 @@ local function configure_file_watcher(server_cfg) end end ----Handles retrieving rustc target architectures and running the passed in callback ----to perform certain actions using the retrieved targets. ----@param callback fun(targets: string[]) -local function with_rustc_target_architectures(callback) - if rustc_targets_cache then - return callback(rustc_targets_cache) - end - vim.system( - { 'rustc', '--print', 'target-list' }, - { text = true }, - ---@param result vim.SystemCompleted - function(result) - if result.code ~= 0 then - error('Failed to retrieve rustc targets: ' .. result.stderr) - end - rustc_targets_cache = vim.iter(result.stdout:gmatch('[^\r\n]+')):fold( - {}, - ---@param acc table - ---@param target string - function(acc, target) - acc[target] = true - return acc - end - ) - return callback(rustc_targets_cache) - end - ) -end - ---LSP restart internal implementations ----@param bufnr? number +---@param bufnr? number The buffer number, defaults to the current buffer +---@param exclude_rustc_target? string Cargo target triple (e.g., 'x86_64-unknown-linux-gnu') to filter rust-analyzer clients ---@param callback? fun(client: vim.lsp.Client) Optional callback to run for each client before restarting. ---@return number|nil client_id -local function restart(bufnr, callback) +local function restart(bufnr, exclude_rustc_target, callback) bufnr = bufnr or vim.api.nvim_get_current_buf() - local clients = M.stop(bufnr) + local clients = M.stop(bufnr, exclude_rustc_target) local timer, _, _ = vim.uv.new_timer() if not timer then vim.notify('Failed to init timer for LSP client restart.', vim.log.levels.ERROR) @@ -285,10 +255,11 @@ end ---Stop the LSP client. ---@param bufnr? number The buffer number, defaults to the current buffer +---@param exclude_rustc_target? string Cargo target triple (e.g., 'x86_64-unknown-linux-gnu') to filter rust-analyzer clients ---@return vim.lsp.Client[] clients A list of clients that will be stopped -M.stop = function(bufnr) +M.stop = function(bufnr, exclude_rustc_target) bufnr = bufnr or vim.api.nvim_get_current_buf() - local clients = rust_analyzer.get_active_rustaceanvim_clients(bufnr) + local clients = rust_analyzer.get_active_rustaceanvim_clients(bufnr, { exclude_rustc_target = exclude_rustc_target }) vim.lsp.stop_client(clients) if type(clients) == 'table' then ---@cast clients vim.lsp.Client[] @@ -322,24 +293,13 @@ end ---Updates the target architecture setting for the LSP client associated with the given buffer. ---@param bufnr? number The buffer number, defaults to the current buffer ----@param target? string The target architecture. Defaults to nil(the current buffer's target if not provided). +---@param target? string Cargo target triple (e.g., 'x86_64-unknown-linux-gnu') to filter rust-analyzer clients M.set_target_arch = function(bufnr, target) + target = target or rustc.DEFAULT_RUSTC_TARGET ---@param client vim.lsp.Client - restart(bufnr, function(client) - -- Get current user's rust-analyzer target - local current_target = vim.tbl_get(client, 'config', 'settings', 'rust-analyzer', 'cargo', 'target') - - if not target then - if not current_target then - vim.notify('Using default OS target architecture.', vim.log.levels.INFO) - else - vim.notify('Target architecture is already set to the default OS target.', vim.log.levels.INFO) - end - return - end - - with_rustc_target_architectures(function(rustc_targets) - if target == nil or rustc_targets[target] then + restart(bufnr, target, function(client) + rustc.with_rustc_target_architectures(function(rustc_targets) + if rustc_targets[target] then client.settings['rust-analyzer'].cargo.target = target client.notify('workspace/didChangeConfiguration', { settings = client.config.settings }) vim.notify('Target architecture updated successfully to: ' .. target, vim.log.levels.INFO) @@ -354,10 +314,9 @@ end ---Restart the LSP client. ---Fails silently if the buffer's filetype is not one of the filetypes specified in the config. ----@param bufnr? number The buffer number (optional), defaults to the current buffer ---@return number|nil client_id The LSP client ID after restart -M.restart = function(bufnr) - M.restart(bufnr) +M.restart = function() + return restart() end ---@enum RustAnalyzerCmd @@ -372,7 +331,6 @@ local RustAnalyzerCmd = { local function rust_analyzer_cmd(opts) local fargs = opts.fargs local cmd = fargs[1] - local arch = fargs[2] ---@cast cmd RustAnalyzerCmd if cmd == RustAnalyzerCmd.start then M.start() @@ -383,7 +341,8 @@ local function rust_analyzer_cmd(opts) elseif cmd == RustAnalyzerCmd.reload_settings then M.reload_settings() elseif cmd == RustAnalyzerCmd.target then - M.set_target_arch(nil, arch) + local target_arch = fargs[2] + M.set_target_arch(target_arch) end end diff --git a/lua/rustaceanvim/rust_analyzer.lua b/lua/rustaceanvim/rust_analyzer.lua index 1ecdec06..219600fa 100644 --- a/lua/rustaceanvim/rust_analyzer.lua +++ b/lua/rustaceanvim/rust_analyzer.lua @@ -1,22 +1,51 @@ ---@mod rustaceanvim.rust_analyzer Functions for interacting with rust-analyzer local os = require('rustaceanvim.os') +local rustc = require('rustaceanvim.rustc') ---@class rustaceanvim.rust-analyzer.ClientAdapter local M = {} +M.load_os_rustc_target = function() + vim.system({ 'rustc', '-Vv' }, { text = true }, function(result) + if result.code == 0 then + for line in result.stdout:gmatch('[^\r\n]+') do + local host = line:match('^host:%s*(.+)$') + if host then + M.os_rustc_target = host + break + end + end + end + end) +end + +---@class rustaceanvim.lsp.get_clients.Filter: vim.lsp.get_clients.Filter +---@field exclude_rustc_target? string Cargo target triple (e.g., 'x86_64-unknown-linux-gnu') to filter rust-analyzer clients + ---@param bufnr number | nil 0 for the current buffer, `nil` for no buffer filter ----@param filter? vim.lsp.get_clients.Filter +---@param filter? rustaceanvim.lsp.get_clients.Filter ---@return vim.lsp.Client[] M.get_active_rustaceanvim_clients = function(bufnr, filter) ---@type vim.lsp.get_clients.Filter - filter = vim.tbl_deep_extend('force', filter or {}, { + local client_filter = vim.tbl_deep_extend('force', filter or {}, { name = 'rust-analyzer', }) if bufnr then - filter.bufnr = bufnr + client_filter.bufnr = bufnr + end + local clients = vim.lsp.get_clients(client_filter) + if filter and filter.exclude_rustc_target then + clients = vim.tbl_filter(function(client) + local cargo_target = vim.tbl_get(client, 'config', 'settings', 'rust-analyzer', 'cargo', 'target') + if filter.exclude_rustc_target == rustc.DEFAULT_RUSTC_TARGET and cargo_target == nil then + return false + end + return cargo_target ~= filter.exclude_rustc_target + end, clients) end - return vim.lsp.get_clients(filter) + + return clients end ---@param method string LSP method name diff --git a/lua/rustaceanvim/rustc.lua b/lua/rustaceanvim/rustc.lua new file mode 100644 index 00000000..f9c43e3f --- /dev/null +++ b/lua/rustaceanvim/rustc.lua @@ -0,0 +1,39 @@ +local M = {} + +--- Default target value for rustc when no specific target is provided. +--- Used as a fallback to let rustc determine the appropriate target based on the OS. +M.DEFAULT_RUSTC_TARGET = 'OS' + +---Local rustc targets cache +local rustc_targets_cache = nil + +---Handles retrieving rustc target architectures and running the passed in callback +---to perform certain actions using the retrieved targets. +---@param callback fun(targets: string[]) +M.with_rustc_target_architectures = function(callback) + if rustc_targets_cache then + return callback(rustc_targets_cache) + end + vim.system( + { 'rustc', '--print', 'target-list' }, + { text = true }, + ---@param result vim.SystemCompleted + function(result) + if result.code ~= 0 then + error('Failed to retrieve rustc targets: ' .. result.stderr) + end + rustc_targets_cache = vim.iter(result.stdout:gmatch('[^\r\n]+')):fold( + {}, + ---@param acc table + ---@param target string + function(acc, target) + acc[target] = true + return acc + end + ) + return callback(rustc_targets_cache) + end + ) +end + +return M From 1bc24e40d553b2988e0a7b25435a8d283cb71b1c Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Mon, 28 Oct 2024 17:47:29 +0100 Subject: [PATCH 48/84] chore: some post-pr tweaks --- lua/rustaceanvim/lsp/init.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lua/rustaceanvim/lsp/init.lua b/lua/rustaceanvim/lsp/init.lua index 38a89cae..14ca7b95 100644 --- a/lua/rustaceanvim/lsp/init.lua +++ b/lua/rustaceanvim/lsp/init.lua @@ -96,12 +96,12 @@ end ---LSP restart internal implementations ---@param bufnr? number The buffer number, defaults to the current buffer ----@param exclude_rustc_target? string Cargo target triple (e.g., 'x86_64-unknown-linux-gnu') to filter rust-analyzer clients +---@param filter? rustaceanvim.lsp.get_clients.Filter ---@param callback? fun(client: vim.lsp.Client) Optional callback to run for each client before restarting. ---@return number|nil client_id -local function restart(bufnr, exclude_rustc_target, callback) +local function restart(bufnr, filter, callback) bufnr = bufnr or vim.api.nvim_get_current_buf() - local clients = M.stop(bufnr, exclude_rustc_target) + local clients = M.stop(bufnr, filter) local timer, _, _ = vim.uv.new_timer() if not timer then vim.notify('Failed to init timer for LSP client restart.', vim.log.levels.ERROR) @@ -255,11 +255,11 @@ end ---Stop the LSP client. ---@param bufnr? number The buffer number, defaults to the current buffer ----@param exclude_rustc_target? string Cargo target triple (e.g., 'x86_64-unknown-linux-gnu') to filter rust-analyzer clients +---@param filter? rustaceanvim.lsp.get_clients.Filter ---@return vim.lsp.Client[] clients A list of clients that will be stopped -M.stop = function(bufnr, exclude_rustc_target) +M.stop = function(bufnr, filter) bufnr = bufnr or vim.api.nvim_get_current_buf() - local clients = rust_analyzer.get_active_rustaceanvim_clients(bufnr, { exclude_rustc_target = exclude_rustc_target }) + local clients = rust_analyzer.get_active_rustaceanvim_clients(bufnr, filter) vim.lsp.stop_client(clients) if type(clients) == 'table' then ---@cast clients vim.lsp.Client[] @@ -293,11 +293,11 @@ end ---Updates the target architecture setting for the LSP client associated with the given buffer. ---@param bufnr? number The buffer number, defaults to the current buffer ----@param target? string Cargo target triple (e.g., 'x86_64-unknown-linux-gnu') to filter rust-analyzer clients +---@param target? string Cargo target triple (e.g., 'x86_64-unknown-linux-gnu') to set M.set_target_arch = function(bufnr, target) target = target or rustc.DEFAULT_RUSTC_TARGET ---@param client vim.lsp.Client - restart(bufnr, target, function(client) + restart(bufnr, { exclude_rustc_target = target }, function(client) rustc.with_rustc_target_architectures(function(rustc_targets) if rustc_targets[target] then client.settings['rust-analyzer'].cargo.target = target From e1f9464d9e1addeccb170eb7968471966965f5a3 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Mon, 28 Oct 2024 17:53:47 +0100 Subject: [PATCH 49/84] chore(master): release 5.13.1 (#555) --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1655047e..6c9fb449 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [5.13.1](https://github.com/mrcjkb/rustaceanvim/compare/v5.13.0...v5.13.1) (2024-10-28) + + +### Performance Improvements + +* optimize target_arch switching ([#548](https://github.com/mrcjkb/rustaceanvim/issues/548)) ([6c4c8d8](https://github.com/mrcjkb/rustaceanvim/commit/6c4c8d82db26b9deab655ca4f75f526652a0de8a)) + ## [5.13.0](https://github.com/mrcjkb/rustaceanvim/compare/v5.12.0...v5.13.0) (2024-10-17) From 7405d2d84ce96e460d548cf7e8def332ac6e19f0 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Thu, 31 Oct 2024 16:20:28 +0100 Subject: [PATCH 50/84] docs(readme): add hover action keymap to quick setup section --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 04bb9277..381fc15b 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,13 @@ vim.keymap.set( -- or vim.lsp.buf.codeAction() if you don't want grouping. end, { silent = true, buffer = bufnr } +vim.keymap.set( + "n", + "K", -- Override Neovim's built-in hover keymap with rustaceanvim's hover actions + function() + vim.cmd.RustLsp({'hover', 'action'}) + end, + { silent = true, buffer = bufnr } ) ``` From 42c4b0f385aca9175d429936a7690f1ff3ed41ad Mon Sep 17 00:00:00 2001 From: VegOwOtenks <90334612+Hyalunar@users.noreply.github.com> Date: Sat, 2 Nov 2024 12:21:14 +0100 Subject: [PATCH 51/84] docs(readme): Added ')' to avoid lua syntax error (#558) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 381fc15b..50154e7b 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,7 @@ vim.keymap.set( -- or vim.lsp.buf.codeAction() if you don't want grouping. end, { silent = true, buffer = bufnr } +) vim.keymap.set( "n", "K", -- Override Neovim's built-in hover keymap with rustaceanvim's hover actions From 7b794c1875de6184662348380c3b62fc38b207ee Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Sun, 3 Nov 2024 01:16:15 +0100 Subject: [PATCH 52/84] chore: update flake.lock (#559) Co-authored-by: github-actions[bot] --- flake.lock | 64 +++++++++++++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/flake.lock b/flake.lock index e1e6ec3a..6eda420c 100644 --- a/flake.lock +++ b/flake.lock @@ -117,11 +117,11 @@ "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1727826117, - "narHash": "sha256-K5ZLCyfO/Zj9mPFldf3iwS6oZStJcU4tSpiXTMYaaL0=", + "lastModified": 1730504689, + "narHash": "sha256-hgmguH29K2fvs9szpq2r3pz2/8cJd2LPS+b4tfNFCwE=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "3d04084d54bedc3d6b8b736c70ef449225c361b1", + "rev": "506278e768c2a08bec68eb62932193e341f55c90", "type": "github" }, "original": { @@ -153,11 +153,11 @@ "nixpkgs-lib": "nixpkgs-lib_3" }, "locked": { - "lastModified": 1727826117, - "narHash": "sha256-K5ZLCyfO/Zj9mPFldf3iwS6oZStJcU4tSpiXTMYaaL0=", + "lastModified": 1730504689, + "narHash": "sha256-hgmguH29K2fvs9szpq2r3pz2/8cJd2LPS+b4tfNFCwE=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "3d04084d54bedc3d6b8b736c70ef449225c361b1", + "rev": "506278e768c2a08bec68eb62932193e341f55c90", "type": "github" }, "original": { @@ -281,11 +281,11 @@ "nixpkgs-stable": "nixpkgs-stable_2" }, "locked": { - "lastModified": 1729104314, - "narHash": "sha256-pZRZsq5oCdJt3upZIU4aslS9XwFJ+/nVtALHIciX/BI=", + "lastModified": 1730302582, + "narHash": "sha256-W1MIJpADXQCgosJZT8qBYLRuZls2KSiKdpnTVdKBuvU=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "3c3e88f0f544d6bb54329832616af7eb971b6be6", + "rev": "af8a16fe5c264f5e9e18bcee2859b40a656876cf", "type": "github" }, "original": { @@ -506,11 +506,11 @@ "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1729920196, - "narHash": "sha256-wjo8ZF3hAGWm0L8S90VLsvSObdSZTsCzg7PyR26+WoU=", + "lastModified": 1730525028, + "narHash": "sha256-50Brt47i3P1DE/3mXw5NQZnW2ObI86xMwWOT7V+a1ck=", "owner": "nvim-neorocks", "repo": "neorocks", - "rev": "df27c6f473c2945b148d3243000466f546939d72", + "rev": "d7d0bac66ca4712d40bf8ad30a79ba2353bcde7a", "type": "github" }, "original": { @@ -529,11 +529,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1729147490, - "narHash": "sha256-F0/iQVbbIFctMPwK4JEd4fxVzNwaq7NnD5oen59S24s=", + "lastModified": 1730088025, + "narHash": "sha256-FIdIaN7f6karwtDV65VXTV8VThNrR63nwykfgXpm4p4=", "owner": "nix-community", "repo": "neovim-nightly-overlay", - "rev": "e2047498667aeb24e8493ff430a20cff713915f4", + "rev": "f35afbe60a4ff71fd65fec3839fc38943f961951", "type": "github" }, "original": { @@ -576,14 +576,14 @@ }, "nixpkgs-lib": { "locked": { - "lastModified": 1727825735, - "narHash": "sha256-0xHYkMkeLVQAMa7gvkddbPqpxph+hDzdu1XdGPJR+Os=", + "lastModified": 1730504152, + "narHash": "sha256-lXvH/vOfb4aGYyvFmZK/HlsNsr/0CVWlwYvo2rxJk3s=", "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/fb192fec7cc7a4c26d51779e9bab07ce6fa5597a.tar.gz" + "url": "https://github.com/NixOS/nixpkgs/archive/cc2f28000298e1269cea6612cd06ec9979dd5d7f.tar.gz" }, "original": { "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/fb192fec7cc7a4c26d51779e9bab07ce6fa5597a.tar.gz" + "url": "https://github.com/NixOS/nixpkgs/archive/cc2f28000298e1269cea6612cd06ec9979dd5d7f.tar.gz" } }, "nixpkgs-lib_2": { @@ -600,14 +600,14 @@ }, "nixpkgs-lib_3": { "locked": { - "lastModified": 1727825735, - "narHash": "sha256-0xHYkMkeLVQAMa7gvkddbPqpxph+hDzdu1XdGPJR+Os=", + "lastModified": 1730504152, + "narHash": "sha256-lXvH/vOfb4aGYyvFmZK/HlsNsr/0CVWlwYvo2rxJk3s=", "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/fb192fec7cc7a4c26d51779e9bab07ce6fa5597a.tar.gz" + "url": "https://github.com/NixOS/nixpkgs/archive/cc2f28000298e1269cea6612cd06ec9979dd5d7f.tar.gz" }, "original": { "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/fb192fec7cc7a4c26d51779e9bab07ce6fa5597a.tar.gz" + "url": "https://github.com/NixOS/nixpkgs/archive/cc2f28000298e1269cea6612cd06ec9979dd5d7f.tar.gz" } }, "nixpkgs-lib_4": { @@ -720,11 +720,11 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1729850857, - "narHash": "sha256-WvLXzNNnnw+qpFOmgaM3JUlNEH+T4s22b5i2oyyCpXE=", + "lastModified": 1730272153, + "narHash": "sha256-B5WRZYsRlJgwVHIV6DvidFN7VX7Fg9uuwkRW9Ha8z+w=", "owner": "nixos", "repo": "nixpkgs", - "rev": "41dea55321e5a999b17033296ac05fe8a8b5a257", + "rev": "2d2a9ddbe3f2c00747398f3dc9b05f7f2ebb0f53", "type": "github" }, "original": { @@ -736,11 +736,11 @@ }, "nixpkgs_5": { "locked": { - "lastModified": 1729850857, - "narHash": "sha256-WvLXzNNnnw+qpFOmgaM3JUlNEH+T4s22b5i2oyyCpXE=", + "lastModified": 1730272153, + "narHash": "sha256-B5WRZYsRlJgwVHIV6DvidFN7VX7Fg9uuwkRW9Ha8z+w=", "owner": "nixos", "repo": "nixpkgs", - "rev": "41dea55321e5a999b17033296ac05fe8a8b5a257", + "rev": "2d2a9ddbe3f2c00747398f3dc9b05f7f2ebb0f53", "type": "github" }, "original": { @@ -790,11 +790,11 @@ "nixpkgs-stable": "nixpkgs-stable_3" }, "locked": { - "lastModified": 1729104314, - "narHash": "sha256-pZRZsq5oCdJt3upZIU4aslS9XwFJ+/nVtALHIciX/BI=", + "lastModified": 1730302582, + "narHash": "sha256-W1MIJpADXQCgosJZT8qBYLRuZls2KSiKdpnTVdKBuvU=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "3c3e88f0f544d6bb54329832616af7eb971b6be6", + "rev": "af8a16fe5c264f5e9e18bcee2859b40a656876cf", "type": "github" }, "original": { From 1c174224784973d782767197d73aecd9a0825753 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Thu, 7 Nov 2024 19:16:59 +0100 Subject: [PATCH 53/84] docs(readme): typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 50154e7b..235ab875 100644 --- a/README.md +++ b/README.md @@ -154,7 +154,7 @@ vim.keymap.set( "n", "K", -- Override Neovim's built-in hover keymap with rustaceanvim's hover actions function() - vim.cmd.RustLsp({'hover', 'action'}) + vim.cmd.RustLsp({'hover', 'actions'}) end, { silent = true, buffer = bufnr } ) From 59f15efe7fcc6be5de57319764911849597f92a3 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Sat, 9 Nov 2024 18:11:11 +0100 Subject: [PATCH 54/84] fix: work around bug in Nushell on Windows (#564) --- lua/rustaceanvim/shell.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/rustaceanvim/shell.lua b/lua/rustaceanvim/shell.lua index 559284ab..cdd84dd3 100644 --- a/lua/rustaceanvim/shell.lua +++ b/lua/rustaceanvim/shell.lua @@ -44,7 +44,7 @@ end ---@param path string ---@return string function M.make_cd_command(path) - return ('cd "%s"'):format(path) + return ("cd '%s'"):format(path) end ---@param command string From 244443311f1c4e34ec1ea7f219a4b682b6ec066e Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Sat, 9 Nov 2024 18:22:13 +0100 Subject: [PATCH 55/84] chore(master): release 5.13.2 (#565) --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c9fb449..7baea00a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [5.13.2](https://github.com/mrcjkb/rustaceanvim/compare/v5.13.1...v5.13.2) (2024-11-09) + + +### Bug Fixes + +* work around bug in Nushell on Windows ([#564](https://github.com/mrcjkb/rustaceanvim/issues/564)) ([59f15ef](https://github.com/mrcjkb/rustaceanvim/commit/59f15efe7fcc6be5de57319764911849597f92a3)) + ## [5.13.1](https://github.com/mrcjkb/rustaceanvim/compare/v5.13.0...v5.13.1) (2024-10-28) From 7a8665bdf891ec00277704fd4a5b719587ca9082 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Sun, 10 Nov 2024 20:39:07 +0100 Subject: [PATCH 56/84] feat(lsp): allow overriding server command via `rust-analzyer.server.path` setting (#567) --- lua/rustaceanvim/lsp/init.lua | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lua/rustaceanvim/lsp/init.lua b/lua/rustaceanvim/lsp/init.lua index 14ca7b95..07e9294e 100644 --- a/lua/rustaceanvim/lsp/init.lua +++ b/lua/rustaceanvim/lsp/init.lua @@ -199,8 +199,19 @@ M.start = function(bufnr) end local rust_analyzer_cmd = types.evaluate(client_config.cmd) - if #rust_analyzer_cmd == 0 or vim.fn.executable(rust_analyzer_cmd[1]) ~= 1 then - vim.notify('rust-analyzer binary not found.', vim.log.levels.ERROR) + -- special case: rust-analyzer has a `rust-analyzer.server.path` config option + -- that allows you to override the path via .vscode/settings.json + local server_path = vim.tbl_get(lsp_start_config.settings, 'rust-analyzer', 'server', 'path') + if type(server_path) == 'string' then + rust_analyzer_cmd[1] = server_path + -- + end + if #rust_analyzer_cmd == 0 then + vim.notify('rust-analyzer command is not set!', vim.log.levels.ERROR) + return + end + if vim.fn.executable(rust_analyzer_cmd[1]) ~= 1 then + vim.notify(('%s is not executable'):format(rust_analyzer_cmd[1]), vim.log.levels.ERROR) return end ---@cast rust_analyzer_cmd string[] From 6116eeafb3cd906b8edccfc3c103fbde8f8cf4cd Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Sun, 10 Nov 2024 20:49:39 +0100 Subject: [PATCH 57/84] chore(master): release 5.14.0 (#568) --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7baea00a..12a0fe20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [5.14.0](https://github.com/mrcjkb/rustaceanvim/compare/v5.13.2...v5.14.0) (2024-11-10) + + +### Features + +* **lsp:** allow overriding server command via `rust-analzyer.server.path` setting ([#567](https://github.com/mrcjkb/rustaceanvim/issues/567)) ([7a8665b](https://github.com/mrcjkb/rustaceanvim/commit/7a8665bdf891ec00277704fd4a5b719587ca9082)) + ## [5.13.2](https://github.com/mrcjkb/rustaceanvim/compare/v5.13.1...v5.13.2) (2024-11-09) From 35d1dbcf8b5d828a17601dfc4d5e76fcc34d4048 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Mon, 11 Nov 2024 00:03:42 +0100 Subject: [PATCH 58/84] chore: delete result symlink --- result | 1 - 1 file changed, 1 deletion(-) delete mode 120000 result diff --git a/result b/result deleted file mode 120000 index 4cfeceb6..00000000 --- a/result +++ /dev/null @@ -1 +0,0 @@ -/nix/store/pgfwfqx5snjrd5ccdgg520bachxdjhnw-vimplugin-luajit2.1-rustaceanvim-scm-1-unstable-scm-1 \ No newline at end of file From a187a1395edceb1b60b6632fb0cdf7bc0a79fa27 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 10 Nov 2024 00:13:26 +0000 Subject: [PATCH 59/84] flake.lock: Update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flake lock file updates: • Updated input 'neorocks': 'github:nvim-neorocks/neorocks/d7d0bac66ca4712d40bf8ad30a79ba2353bcde7a?narHash=sha256-50Brt47i3P1DE/3mXw5NQZnW2ObI86xMwWOT7V%2Ba1ck%3D' (2024-11-02) → 'github:nvim-neorocks/neorocks/c1b3c1188de859d12a610a1c46d03558cc763634?narHash=sha256-oyDV65S7QY7uhzb2sADIvwPPkw2vwhqV8CIv0WAt1Kg%3D' (2024-11-09) • Updated input 'neorocks/git-hooks': 'github:cachix/git-hooks.nix/af8a16fe5c264f5e9e18bcee2859b40a656876cf?narHash=sha256-W1MIJpADXQCgosJZT8qBYLRuZls2KSiKdpnTVdKBuvU%3D' (2024-10-30) → 'github:cachix/git-hooks.nix/d70155fdc00df4628446352fc58adc640cd705c2?narHash=sha256-fWPHyhYE6xvMI1eGY3pwBTq85wcy1YXqdzTZF%2B06nOg%3D' (2024-11-05) • Updated input 'neorocks/git-hooks/nixpkgs': 'github:NixOS/nixpkgs/9693852a2070b398ee123a329e68f0dab5526681?narHash=sha256-jHJSUH619zBQ6WdC21fFAlDxHErKVDJ5fpN0Hgx4sjs%3D' (2024-06-22) → 'github:NixOS/nixpkgs/a04d33c0c3f1a59a2c1cb0c6e34cd24500e5a1dc?narHash=sha256-8AKquNnnSaJRXZxc5YmF/WfmxiHX6MMZZasRP6RRQkE%3D' (2024-11-05) • Updated input 'neorocks/git-hooks/nixpkgs-stable': 'github:NixOS/nixpkgs/194846768975b7ad2c4988bdb82572c00222c0d7?narHash=sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo%3D' (2024-07-07) → 'github:NixOS/nixpkgs/d063c1dd113c91ab27959ba540c0d9753409edf3?narHash=sha256-edm8WG19kWozJ/GqyYx2VjW99EdhjKwbY3ZwdlPAAlo%3D' (2024-11-04) • Updated input 'neorocks/neovim-nightly': 'github:nix-community/neovim-nightly-overlay/f35afbe60a4ff71fd65fec3839fc38943f961951?narHash=sha256-FIdIaN7f6karwtDV65VXTV8VThNrR63nwykfgXpm4p4%3D' (2024-10-28) → 'github:nix-community/neovim-nightly-overlay/702364e6ec794961483eba5220ca531917d03784?narHash=sha256-8u8k3hnU5OxlXfhDLD3XEwAqv/M9Tb5USLCEPvXCPcM%3D' (2024-11-09) • Updated input 'neorocks/neovim-nightly/flake-parts': 'github:hercules-ci/flake-parts/3d04084d54bedc3d6b8b736c70ef449225c361b1?narHash=sha256-K5ZLCyfO/Zj9mPFldf3iwS6oZStJcU4tSpiXTMYaaL0%3D' (2024-10-01) → 'github:hercules-ci/flake-parts/506278e768c2a08bec68eb62932193e341f55c90?narHash=sha256-hgmguH29K2fvs9szpq2r3pz2/8cJd2LPS%2Bb4tfNFCwE%3D' (2024-11-01) • Updated input 'neorocks/neovim-nightly/git-hooks': 'github:cachix/git-hooks.nix/3c3e88f0f544d6bb54329832616af7eb971b6be6?narHash=sha256-pZRZsq5oCdJt3upZIU4aslS9XwFJ%2B/nVtALHIciX/BI%3D' (2024-10-16) → 'github:cachix/git-hooks.nix/d70155fdc00df4628446352fc58adc640cd705c2?narHash=sha256-fWPHyhYE6xvMI1eGY3pwBTq85wcy1YXqdzTZF%2B06nOg%3D' (2024-11-05) • Updated input 'neorocks/neovim-nightly/hercules-ci-effects': 'github:hercules-ci/hercules-ci-effects/dba4367b9a9d9615456c430a6d6af716f6e84cef?narHash=sha256-MHHrHasTngp7EYQOObHJ1a/IsRF%2BwodHqOckhH6uZbk%3D' (2024-08-29) → 'github:hercules-ci/hercules-ci-effects/b89ac4d66d618b915b1f0a408e2775fe3821d141?narHash=sha256-mnynlrPeiW0nUQ8KGZHb3WyxAxA3Ye/BH8gMjdoKP6E%3D' (2024-11-06) • Updated input 'neorocks/neovim-nightly/neovim-src': 'github:neovim/neovim/852954ff6d96adce0158f74ca494fdcef3aa1921?narHash=sha256-c94xkA/RuszC4PfmB%2BMWqOo2vbO66GTO6XKer0mbltA%3D' (2024-10-16) → 'github:neovim/neovim/ad3472e291694b6c589d8a664459b03962eaac95?narHash=sha256-0uH8SSP6/eqCuDvUCV%2Bs1ZwjLg6512Vj9dgKKO0iEmE%3D' (2024-11-08) • Updated input 'neorocks/neovim-nightly/nixpkgs': 'github:NixOS/nixpkgs/d4f247e89f6e10120f911e2e2d2254a050d0f732?narHash=sha256-DZBO2465PL5V89e8hFSJewyH4QbCPpW3ssws7ckT/0A%3D' (2024-10-13) → 'github:NixOS/nixpkgs/85f7e662eda4fa3a995556527c87b2524b691933?narHash=sha256-JwQZIGSYnRNOgDDoIgqKITrPVil%2BRMWHsZH1eE1VGN0%3D' (2024-11-07) • Updated input 'neorocks/nixpkgs': 'github:nixos/nixpkgs/2d2a9ddbe3f2c00747398f3dc9b05f7f2ebb0f53?narHash=sha256-B5WRZYsRlJgwVHIV6DvidFN7VX7Fg9uuwkRW9Ha8z%2Bw%3D' (2024-10-30) → 'github:nixos/nixpkgs/85f7e662eda4fa3a995556527c87b2524b691933?narHash=sha256-JwQZIGSYnRNOgDDoIgqKITrPVil%2BRMWHsZH1eE1VGN0%3D' (2024-11-07) • Updated input 'nixpkgs': 'github:nixos/nixpkgs/2d2a9ddbe3f2c00747398f3dc9b05f7f2ebb0f53?narHash=sha256-B5WRZYsRlJgwVHIV6DvidFN7VX7Fg9uuwkRW9Ha8z%2Bw%3D' (2024-10-30) → 'github:nixos/nixpkgs/85f7e662eda4fa3a995556527c87b2524b691933?narHash=sha256-JwQZIGSYnRNOgDDoIgqKITrPVil%2BRMWHsZH1eE1VGN0%3D' (2024-11-07) • Updated input 'pre-commit-hooks': 'github:cachix/pre-commit-hooks.nix/af8a16fe5c264f5e9e18bcee2859b40a656876cf?narHash=sha256-W1MIJpADXQCgosJZT8qBYLRuZls2KSiKdpnTVdKBuvU%3D' (2024-10-30) → 'github:cachix/pre-commit-hooks.nix/d70155fdc00df4628446352fc58adc640cd705c2?narHash=sha256-fWPHyhYE6xvMI1eGY3pwBTq85wcy1YXqdzTZF%2B06nOg%3D' (2024-11-05) • Updated input 'pre-commit-hooks/nixpkgs': 'github:NixOS/nixpkgs/9693852a2070b398ee123a329e68f0dab5526681?narHash=sha256-jHJSUH619zBQ6WdC21fFAlDxHErKVDJ5fpN0Hgx4sjs%3D' (2024-06-22) → 'github:NixOS/nixpkgs/a04d33c0c3f1a59a2c1cb0c6e34cd24500e5a1dc?narHash=sha256-8AKquNnnSaJRXZxc5YmF/WfmxiHX6MMZZasRP6RRQkE%3D' (2024-11-05) • Updated input 'pre-commit-hooks/nixpkgs-stable': 'github:NixOS/nixpkgs/194846768975b7ad2c4988bdb82572c00222c0d7?narHash=sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo%3D' (2024-07-07) → 'github:NixOS/nixpkgs/d063c1dd113c91ab27959ba540c0d9753409edf3?narHash=sha256-edm8WG19kWozJ/GqyYx2VjW99EdhjKwbY3ZwdlPAAlo%3D' (2024-11-04) --- flake.lock | 90 +++++++++++++++++++++++++++--------------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/flake.lock b/flake.lock index 6eda420c..4fd66436 100644 --- a/flake.lock +++ b/flake.lock @@ -175,11 +175,11 @@ ] }, "locked": { - "lastModified": 1727826117, - "narHash": "sha256-K5ZLCyfO/Zj9mPFldf3iwS6oZStJcU4tSpiXTMYaaL0=", + "lastModified": 1730504689, + "narHash": "sha256-hgmguH29K2fvs9szpq2r3pz2/8cJd2LPS+b4tfNFCwE=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "3d04084d54bedc3d6b8b736c70ef449225c361b1", + "rev": "506278e768c2a08bec68eb62932193e341f55c90", "type": "github" }, "original": { @@ -281,11 +281,11 @@ "nixpkgs-stable": "nixpkgs-stable_2" }, "locked": { - "lastModified": 1730302582, - "narHash": "sha256-W1MIJpADXQCgosJZT8qBYLRuZls2KSiKdpnTVdKBuvU=", + "lastModified": 1730814269, + "narHash": "sha256-fWPHyhYE6xvMI1eGY3pwBTq85wcy1YXqdzTZF+06nOg=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "af8a16fe5c264f5e9e18bcee2859b40a656876cf", + "rev": "d70155fdc00df4628446352fc58adc640cd705c2", "type": "github" }, "original": { @@ -310,11 +310,11 @@ ] }, "locked": { - "lastModified": 1729104314, - "narHash": "sha256-pZRZsq5oCdJt3upZIU4aslS9XwFJ+/nVtALHIciX/BI=", + "lastModified": 1730814269, + "narHash": "sha256-fWPHyhYE6xvMI1eGY3pwBTq85wcy1YXqdzTZF+06nOg=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "3c3e88f0f544d6bb54329832616af7eb971b6be6", + "rev": "d70155fdc00df4628446352fc58adc640cd705c2", "type": "github" }, "original": { @@ -468,11 +468,11 @@ ] }, "locked": { - "lastModified": 1724947644, - "narHash": "sha256-MHHrHasTngp7EYQOObHJ1a/IsRF+wodHqOckhH6uZbk=", + "lastModified": 1730903510, + "narHash": "sha256-mnynlrPeiW0nUQ8KGZHb3WyxAxA3Ye/BH8gMjdoKP6E=", "owner": "hercules-ci", "repo": "hercules-ci-effects", - "rev": "dba4367b9a9d9615456c430a6d6af716f6e84cef", + "rev": "b89ac4d66d618b915b1f0a408e2775fe3821d141", "type": "github" }, "original": { @@ -506,11 +506,11 @@ "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1730525028, - "narHash": "sha256-50Brt47i3P1DE/3mXw5NQZnW2ObI86xMwWOT7V+a1ck=", + "lastModified": 1731129910, + "narHash": "sha256-oyDV65S7QY7uhzb2sADIvwPPkw2vwhqV8CIv0WAt1Kg=", "owner": "nvim-neorocks", "repo": "neorocks", - "rev": "d7d0bac66ca4712d40bf8ad30a79ba2353bcde7a", + "rev": "c1b3c1188de859d12a610a1c46d03558cc763634", "type": "github" }, "original": { @@ -529,11 +529,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1730088025, - "narHash": "sha256-FIdIaN7f6karwtDV65VXTV8VThNrR63nwykfgXpm4p4=", + "lastModified": 1731111231, + "narHash": "sha256-8u8k3hnU5OxlXfhDLD3XEwAqv/M9Tb5USLCEPvXCPcM=", "owner": "nix-community", "repo": "neovim-nightly-overlay", - "rev": "f35afbe60a4ff71fd65fec3839fc38943f961951", + "rev": "702364e6ec794961483eba5220ca531917d03784", "type": "github" }, "original": { @@ -545,11 +545,11 @@ "neovim-src": { "flake": false, "locked": { - "lastModified": 1729121305, - "narHash": "sha256-c94xkA/RuszC4PfmB+MWqOo2vbO66GTO6XKer0mbltA=", + "lastModified": 1731083384, + "narHash": "sha256-0uH8SSP6/eqCuDvUCV+s1ZwjLg6512Vj9dgKKO0iEmE=", "owner": "neovim", "repo": "neovim", - "rev": "852954ff6d96adce0158f74ca494fdcef3aa1921", + "rev": "ad3472e291694b6c589d8a664459b03962eaac95", "type": "github" }, "original": { @@ -640,11 +640,11 @@ }, "nixpkgs-stable_2": { "locked": { - "lastModified": 1720386169, - "narHash": "sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo=", + "lastModified": 1730741070, + "narHash": "sha256-edm8WG19kWozJ/GqyYx2VjW99EdhjKwbY3ZwdlPAAlo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "194846768975b7ad2c4988bdb82572c00222c0d7", + "rev": "d063c1dd113c91ab27959ba540c0d9753409edf3", "type": "github" }, "original": { @@ -656,11 +656,11 @@ }, "nixpkgs-stable_3": { "locked": { - "lastModified": 1720386169, - "narHash": "sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo=", + "lastModified": 1730741070, + "narHash": "sha256-edm8WG19kWozJ/GqyYx2VjW99EdhjKwbY3ZwdlPAAlo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "194846768975b7ad2c4988bdb82572c00222c0d7", + "rev": "d063c1dd113c91ab27959ba540c0d9753409edf3", "type": "github" }, "original": { @@ -688,11 +688,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1719082008, - "narHash": "sha256-jHJSUH619zBQ6WdC21fFAlDxHErKVDJ5fpN0Hgx4sjs=", + "lastModified": 1730768919, + "narHash": "sha256-8AKquNnnSaJRXZxc5YmF/WfmxiHX6MMZZasRP6RRQkE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "9693852a2070b398ee123a329e68f0dab5526681", + "rev": "a04d33c0c3f1a59a2c1cb0c6e34cd24500e5a1dc", "type": "github" }, "original": { @@ -704,11 +704,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1728863046, - "narHash": "sha256-DZBO2465PL5V89e8hFSJewyH4QbCPpW3ssws7ckT/0A=", + "lastModified": 1730958623, + "narHash": "sha256-JwQZIGSYnRNOgDDoIgqKITrPVil+RMWHsZH1eE1VGN0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "d4f247e89f6e10120f911e2e2d2254a050d0f732", + "rev": "85f7e662eda4fa3a995556527c87b2524b691933", "type": "github" }, "original": { @@ -720,11 +720,11 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1730272153, - "narHash": "sha256-B5WRZYsRlJgwVHIV6DvidFN7VX7Fg9uuwkRW9Ha8z+w=", + "lastModified": 1730958623, + "narHash": "sha256-JwQZIGSYnRNOgDDoIgqKITrPVil+RMWHsZH1eE1VGN0=", "owner": "nixos", "repo": "nixpkgs", - "rev": "2d2a9ddbe3f2c00747398f3dc9b05f7f2ebb0f53", + "rev": "85f7e662eda4fa3a995556527c87b2524b691933", "type": "github" }, "original": { @@ -736,11 +736,11 @@ }, "nixpkgs_5": { "locked": { - "lastModified": 1730272153, - "narHash": "sha256-B5WRZYsRlJgwVHIV6DvidFN7VX7Fg9uuwkRW9Ha8z+w=", + "lastModified": 1730958623, + "narHash": "sha256-JwQZIGSYnRNOgDDoIgqKITrPVil+RMWHsZH1eE1VGN0=", "owner": "nixos", "repo": "nixpkgs", - "rev": "2d2a9ddbe3f2c00747398f3dc9b05f7f2ebb0f53", + "rev": "85f7e662eda4fa3a995556527c87b2524b691933", "type": "github" }, "original": { @@ -752,11 +752,11 @@ }, "nixpkgs_6": { "locked": { - "lastModified": 1719082008, - "narHash": "sha256-jHJSUH619zBQ6WdC21fFAlDxHErKVDJ5fpN0Hgx4sjs=", + "lastModified": 1730768919, + "narHash": "sha256-8AKquNnnSaJRXZxc5YmF/WfmxiHX6MMZZasRP6RRQkE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "9693852a2070b398ee123a329e68f0dab5526681", + "rev": "a04d33c0c3f1a59a2c1cb0c6e34cd24500e5a1dc", "type": "github" }, "original": { @@ -790,11 +790,11 @@ "nixpkgs-stable": "nixpkgs-stable_3" }, "locked": { - "lastModified": 1730302582, - "narHash": "sha256-W1MIJpADXQCgosJZT8qBYLRuZls2KSiKdpnTVdKBuvU=", + "lastModified": 1730814269, + "narHash": "sha256-fWPHyhYE6xvMI1eGY3pwBTq85wcy1YXqdzTZF+06nOg=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "af8a16fe5c264f5e9e18bcee2859b40a656876cf", + "rev": "d70155fdc00df4628446352fc58adc640cd705c2", "type": "github" }, "original": { From 0b401909394d15898e4a8fcf959f74cbcba5d3ca Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Mon, 11 Nov 2024 20:12:30 +0100 Subject: [PATCH 60/84] fix: compatibility with nvim-nightly --- doc/rustaceanvim.txt | 2 +- ftplugin/rust.lua | 4 +++- lua/rustaceanvim/cached_commands.lua | 1 + lua/rustaceanvim/commands/code_action_group.lua | 2 +- lua/rustaceanvim/commands/debuggables.lua | 2 ++ lua/rustaceanvim/commands/open_cargo_toml.lua | 4 +++- lua/rustaceanvim/commands/parent_module.lua | 3 ++- lua/rustaceanvim/commands/rustc_unpretty.lua | 1 + lua/rustaceanvim/commands/ssr.lua | 3 +++ lua/rustaceanvim/compat.lua | 13 +++++++++++++ lua/rustaceanvim/config/init.lua | 2 +- lua/rustaceanvim/config/internal.lua | 1 + lua/rustaceanvim/dap.lua | 1 + lua/rustaceanvim/executors/quickfix.lua | 2 +- lua/rustaceanvim/neotest/init.lua | 1 + 15 files changed, 35 insertions(+), 7 deletions(-) diff --git a/doc/rustaceanvim.txt b/doc/rustaceanvim.txt index 98058101..bf26be2c 100644 --- a/doc/rustaceanvim.txt +++ b/doc/rustaceanvim.txt @@ -392,7 +392,7 @@ rustaceanvim.dap.adapter.types.server *rustaceanvim.dap.adapter.types.server* *rustaceanvim.dap.client.Config* -rustaceanvim.dap.client.Config : Configuration +rustaceanvim.dap.client.Config : dap.Configuration Fields: ~ {type} (string) The dap adapter to use diff --git a/ftplugin/rust.lua b/ftplugin/rust.lua index ecf7852d..24e903d9 100644 --- a/ftplugin/rust.lua +++ b/ftplugin/rust.lua @@ -1,5 +1,6 @@ ---@type rustaceanvim.Config local config = require('rustaceanvim.config.internal') +local compat = require('rustaceanvim.compat') if not vim.g.loaded_rustaceanvim then require('rustaceanvim.config.check').check_for_lspconfig_conflict(vim.schedule_wrap(function(warn) @@ -22,7 +23,7 @@ if not vim.g.loaded_rustaceanvim then vim.lsp.commands['rust-analyzer.gotoLocation'] = function(command, ctx) local client = vim.lsp.get_client_by_id(ctx.client_id) if client then - vim.lsp.util.jump_to_location(command.arguments[1], client.offset_encoding) + compat.show_document(command.arguments[1], client.offset_encoding) end end @@ -37,6 +38,7 @@ if not vim.g.loaded_rustaceanvim then local cached_commands = require('rustaceanvim.cached_commands') cached_commands.set_last_debuggable(args) local rt_dap = require('rustaceanvim.dap') + ---@diagnostic disable-next-line: invisible rt_dap.start(args) end diff --git a/lua/rustaceanvim/cached_commands.lua b/lua/rustaceanvim/cached_commands.lua index 79121676..f9f54518 100644 --- a/lua/rustaceanvim/cached_commands.lua +++ b/lua/rustaceanvim/cached_commands.lua @@ -43,6 +43,7 @@ M.execute_last_debuggable = function(executableArgsOverride) args.executableArgs = executableArgsOverride end local rt_dap = require('rustaceanvim.dap') + ---@diagnostic disable-next-line: invisible rt_dap.start(args) else local debuggables = require('rustaceanvim.commands.debuggables') diff --git a/lua/rustaceanvim/commands/code_action_group.lua b/lua/rustaceanvim/commands/code_action_group.lua index 356e8ac3..4a063a90 100644 --- a/lua/rustaceanvim/commands/code_action_group.lua +++ b/lua/rustaceanvim/commands/code_action_group.lua @@ -15,7 +15,7 @@ local M = {} ---@field arguments? any[] ---@param action rustaceanvim.RACodeAction | rustaceanvim.RACommand ----@param client lsp.Client +---@param client vim.lsp.Client ---@param ctx table function M.apply_action(action, client, ctx) if action.edit then diff --git a/lua/rustaceanvim/commands/debuggables.lua b/lua/rustaceanvim/commands/debuggables.lua index acb7b893..4d6c6b58 100644 --- a/lua/rustaceanvim/commands/debuggables.lua +++ b/lua/rustaceanvim/commands/debuggables.lua @@ -86,6 +86,7 @@ local function dap_run(args) local rt_dap = require('rustaceanvim.dap') local ok, dap = pcall(require, 'dap') if ok then + ---@diagnostic disable-next-line: invisible rt_dap.start(args, true, dap.run) local cached_commands = require('rustaceanvim.cached_commands') cached_commands.set_last_debuggable(args) @@ -131,6 +132,7 @@ local function add_debuggables_to_nvim_dap(debuggables) if not debuggable then return end + ---@diagnostic disable-next-line: invisible rt_dap.start(debuggable.args, false, function(configuration) local name = 'Cargo: ' .. build_label(debuggable.args) if not _dap_configuration_added[name] then diff --git a/lua/rustaceanvim/commands/open_cargo_toml.lua b/lua/rustaceanvim/commands/open_cargo_toml.lua index 20b0cff2..904dbb97 100644 --- a/lua/rustaceanvim/commands/open_cargo_toml.lua +++ b/lua/rustaceanvim/commands/open_cargo_toml.lua @@ -1,5 +1,7 @@ local M = {} +local compat = require('rustaceanvim.compat') + local function get_params() return { textDocument = vim.lsp.util.make_text_document_params(0), @@ -13,7 +15,7 @@ local function handler(_, result, ctx) local client = vim.lsp.get_client_by_id(ctx.client_id) if client then - vim.lsp.util.jump_to_location(result, client.offset_encoding) + compat.show_document(result, client.offset_encoding) end end diff --git a/lua/rustaceanvim/commands/parent_module.lua b/lua/rustaceanvim/commands/parent_module.lua index 616da5f6..ec624d07 100644 --- a/lua/rustaceanvim/commands/parent_module.lua +++ b/lua/rustaceanvim/commands/parent_module.lua @@ -1,6 +1,7 @@ local M = {} local rl = require('rustaceanvim.rust_analyzer') +local compat = require('rustaceanvim.compat') local function get_params() return vim.lsp.util.make_position_params(0, nil) @@ -20,7 +21,7 @@ local function handler(_, result, ctx) local client = vim.lsp.get_client_by_id(ctx.client_id) if client then - vim.lsp.util.jump_to_location(location, client.offset_encoding) + compat.show_document(location, client.offset_encoding) end end diff --git a/lua/rustaceanvim/commands/rustc_unpretty.lua b/lua/rustaceanvim/commands/rustc_unpretty.lua index 1858937f..73b51c9e 100644 --- a/lua/rustaceanvim/commands/rustc_unpretty.lua +++ b/lua/rustaceanvim/commands/rustc_unpretty.lua @@ -51,6 +51,7 @@ local function get_vim_range(range, buf) -- Use the value of the last col of the previous row instead. erow = erow - 1 if not buf or buf == 0 then + ---@diagnostic disable-next-line: assign-type-mismatch ecol = vim.fn.col { erow, '$' } - 1 else ecol = #vim.api.nvim_buf_get_lines(buf, erow - 1, erow, false)[1] diff --git a/lua/rustaceanvim/commands/ssr.lua b/lua/rustaceanvim/commands/ssr.lua index 66b7026e..b2724bfb 100644 --- a/lua/rustaceanvim/commands/ssr.lua +++ b/lua/rustaceanvim/commands/ssr.lua @@ -5,8 +5,11 @@ local M = {} local function get_opts(query, visual_mode) local opts = vim.lsp.util.make_position_params() local range = (visual_mode and vim.lsp.util.make_given_range_params() or vim.lsp.util.make_range_params()).range + ---@diagnostic disable-next-line: inject-field opts.query = query + ---@diagnostic disable-next-line: inject-field opts.parseOnly = false + ---@diagnostic disable-next-line: inject-field opts.selections = { range } return opts end diff --git a/lua/rustaceanvim/compat.lua b/lua/rustaceanvim/compat.lua index 229d929e..a9013bf8 100644 --- a/lua/rustaceanvim/compat.lua +++ b/lua/rustaceanvim/compat.lua @@ -1,3 +1,5 @@ +---@diagnostic disable: deprecated, duplicate-doc-alias + ---@mod rustaceanvim.compat compativility layer for ---API calls that are deprecated or removed in nvim nightly @@ -15,4 +17,15 @@ function compat.get_line_diagnostics() return vim.lsp.diagnostic.get_line_diagnostics() end +---@param location lsp.Location|lsp.LocationLink +---@param offset_encoding 'utf-8'|'utf-16'|'utf-32'? +---@return boolean `true` if the jump succeeded +function compat.show_document(location, offset_encoding) + local show_document = vim.lsp.show_document + if not show_document then + vim.lsp.util.jump_to_location(location, offset_encoding) + end + return show_document(location, offset_encoding, { focus = true }) +end + return compat diff --git a/lua/rustaceanvim/config/init.lua b/lua/rustaceanvim/config/init.lua index 89150687..cbb5042e 100644 --- a/lua/rustaceanvim/config/init.lua +++ b/lua/rustaceanvim/config/init.lua @@ -253,7 +253,7 @@ vim.g.rustaceanvim = vim.g.rustaceanvim ---@alias rustaceanvim.dap.adapter.types.executable "executable" ---@alias rustaceanvim.dap.adapter.types.server "server" ----@class rustaceanvim.dap.client.Config: Configuration +---@class rustaceanvim.dap.client.Config: dap.Configuration ---@field type string The dap adapter to use ---@field name string ---@field request rustaceanvim.dap.config.requests.launch | rustaceanvim.dap.config.requests.attach | rustaceanvim.dap.config.requests.custom The type of dap session diff --git a/lua/rustaceanvim/config/internal.lua b/lua/rustaceanvim/config/internal.lua index f9dfbceb..4c736845 100644 --- a/lua/rustaceanvim/config/internal.lua +++ b/lua/rustaceanvim/config/internal.lua @@ -44,6 +44,7 @@ local function load_dap_configuration(type) stopOnEntry = false, } if type == 'lldb' then + ---@diagnostic disable-next-line: inject-field dap_config.runInTerminal = true end ---@diagnostic disable-next-line: different-requires diff --git a/lua/rustaceanvim/dap.lua b/lua/rustaceanvim/dap.lua index 2ae16114..a6d8436f 100644 --- a/lua/rustaceanvim/dap.lua +++ b/lua/rustaceanvim/dap.lua @@ -315,6 +315,7 @@ function M.start(args, verbose, callback, on_error) ---@param value string :map(function(value) local is_json, artifact = pcall(vim.fn.json_decode, value) + ---@diagnostic disable-next-line: redundant-return-value return is_json, artifact end) ---@param is_json boolean diff --git a/lua/rustaceanvim/executors/quickfix.lua b/lua/rustaceanvim/executors/quickfix.lua index 16b8de84..f416bfcf 100644 --- a/lua/rustaceanvim/executors/quickfix.lua +++ b/lua/rustaceanvim/executors/quickfix.lua @@ -10,7 +10,7 @@ end ---@param lines string[] local function append_qf(lines) - vim.fn.setqflist({}, 'a', { lines = { lines } }) + vim.fn.setqflist({}, 'a', { lines = lines }) scroll_qf() end diff --git a/lua/rustaceanvim/neotest/init.lua b/lua/rustaceanvim/neotest/init.lua index 2465d177..a2e7448d 100644 --- a/lua/rustaceanvim/neotest/init.lua +++ b/lua/rustaceanvim/neotest/init.lua @@ -273,6 +273,7 @@ function NeotestAdapter.build_spec(run_args) local dap = require('rustaceanvim.dap') overrides.sanitize_command_for_debugging(runnable.args.cargoArgs) local future = nio.control.future() + ---@diagnostic disable-next-line: invisible dap.start(runnable.args, false, function(strategy) future.set(strategy) end, function(err) From d8cd8f2fd6862618125ea48b8c82b150e6311ca4 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Mon, 11 Nov 2024 20:32:52 +0100 Subject: [PATCH 61/84] chore: update .gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 34a72b84..1b988b9f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ -result/ +result +result-* .direnv .luarc.json .repro From e1745ddbb379c84c699b34c82d376ffc61129f1c Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Mon, 11 Nov 2024 21:24:05 +0100 Subject: [PATCH 62/84] ci: fix release-please config --- .github/workflows/release-please-config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-please-config.json b/.github/workflows/release-please-config.json index b7be3ef1..c6c61165 100644 --- a/.github/workflows/release-please-config.json +++ b/.github/workflows/release-please-config.json @@ -1,3 +1,3 @@ { - "bootstrap-sha": "42a6d3342608dcbe0986919753385f3dea00ac14" + "bootstrap-sha": "a187a1395edceb1b60b6632fb0cdf7bc0a79fa27" } From 24da817e737669850d1d96aa18fc64093dc98ee4 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Tue, 12 Nov 2024 00:31:40 +0100 Subject: [PATCH 63/84] ci: remove release-please config --- .github/workflows/release-please-config.json | 3 --- .github/workflows/release-please.yml | 1 - 2 files changed, 4 deletions(-) delete mode 100644 .github/workflows/release-please-config.json diff --git a/.github/workflows/release-please-config.json b/.github/workflows/release-please-config.json deleted file mode 100644 index c6c61165..00000000 --- a/.github/workflows/release-please-config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "bootstrap-sha": "a187a1395edceb1b60b6632fb0cdf7bc0a79fa27" -} diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index b36c6eff..8f2d6016 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -20,4 +20,3 @@ jobs: with: release-type: simple token: ${{ secrets.PAT }} - config-file: .github/workflows/release-please-config.json From 5c4a25d0aab042ee67a5cf68b06ec350918d8c18 Mon Sep 17 00:00:00 2001 From: AppleSheeple <68065381+AppleSheeple@users.noreply.github.com> Date: Tue, 12 Nov 2024 11:32:01 +0300 Subject: [PATCH 64/84] chore(fixup): compatibility with nvim release (#576) Signed-off-by: Mohammad AlSaleh Co-authored-by: Mohammad AlSaleh --- lua/rustaceanvim/compat.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/rustaceanvim/compat.lua b/lua/rustaceanvim/compat.lua index a9013bf8..5e4db56b 100644 --- a/lua/rustaceanvim/compat.lua +++ b/lua/rustaceanvim/compat.lua @@ -23,7 +23,7 @@ end function compat.show_document(location, offset_encoding) local show_document = vim.lsp.show_document if not show_document then - vim.lsp.util.jump_to_location(location, offset_encoding) + return vim.lsp.util.jump_to_location(location, offset_encoding) end return show_document(location, offset_encoding, { focus = true }) end From 8ece53be36515cb9e76f3d03511643636469502d Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Tue, 12 Nov 2024 10:19:25 +0100 Subject: [PATCH 65/84] chore(master): release 5.14.1 (#579) --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12a0fe20..01600b51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [5.14.1](https://github.com/mrcjkb/rustaceanvim/compare/v5.14.0...v5.14.1) (2024-11-12) + + +### Bug Fixes + +* compatibility with nvim-nightly ([0b40190](https://github.com/mrcjkb/rustaceanvim/commit/0b401909394d15898e4a8fcf959f74cbcba5d3ca)) + ## [5.14.0](https://github.com/mrcjkb/rustaceanvim/compare/v5.13.2...v5.14.0) (2024-11-10) From 23816979bff466df22e4978f5fd8b4a200ea2af9 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Sun, 17 Nov 2024 01:21:48 +0100 Subject: [PATCH 66/84] chore: update flake.lock (#581) Co-authored-by: github-actions[bot] --- flake.lock | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/flake.lock b/flake.lock index 4fd66436..dcf09972 100644 --- a/flake.lock +++ b/flake.lock @@ -281,11 +281,11 @@ "nixpkgs-stable": "nixpkgs-stable_2" }, "locked": { - "lastModified": 1730814269, - "narHash": "sha256-fWPHyhYE6xvMI1eGY3pwBTq85wcy1YXqdzTZF+06nOg=", + "lastModified": 1731363552, + "narHash": "sha256-vFta1uHnD29VUY4HJOO/D6p6rxyObnf+InnSMT4jlMU=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "d70155fdc00df4628446352fc58adc640cd705c2", + "rev": "cd1af27aa85026ac759d5d3fccf650abe7e1bbf0", "type": "github" }, "original": { @@ -310,11 +310,11 @@ ] }, "locked": { - "lastModified": 1730814269, - "narHash": "sha256-fWPHyhYE6xvMI1eGY3pwBTq85wcy1YXqdzTZF+06nOg=", + "lastModified": 1731363552, + "narHash": "sha256-vFta1uHnD29VUY4HJOO/D6p6rxyObnf+InnSMT4jlMU=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "d70155fdc00df4628446352fc58adc640cd705c2", + "rev": "cd1af27aa85026ac759d5d3fccf650abe7e1bbf0", "type": "github" }, "original": { @@ -506,11 +506,11 @@ "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1731129910, - "narHash": "sha256-oyDV65S7QY7uhzb2sADIvwPPkw2vwhqV8CIv0WAt1Kg=", + "lastModified": 1731648623, + "narHash": "sha256-kL0qF6ETmWSeN0Nzjg7GtSbe/7AcNmuX2U6Mb7xLIOA=", "owner": "nvim-neorocks", "repo": "neorocks", - "rev": "c1b3c1188de859d12a610a1c46d03558cc763634", + "rev": "b82f112cb43020ab23a2816dfc7a3453aafd754f", "type": "github" }, "original": { @@ -529,11 +529,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1731111231, - "narHash": "sha256-8u8k3hnU5OxlXfhDLD3XEwAqv/M9Tb5USLCEPvXCPcM=", + "lastModified": 1731629313, + "narHash": "sha256-rCTdc6oHM4Ostt6IR66QiDrPQNjCsxC2r00GfU0bADU=", "owner": "nix-community", "repo": "neovim-nightly-overlay", - "rev": "702364e6ec794961483eba5220ca531917d03784", + "rev": "81a983160c1acae623482e082a94a46c931d0261", "type": "github" }, "original": { @@ -545,11 +545,11 @@ "neovim-src": { "flake": false, "locked": { - "lastModified": 1731083384, - "narHash": "sha256-0uH8SSP6/eqCuDvUCV+s1ZwjLg6512Vj9dgKKO0iEmE=", + "lastModified": 1731607016, + "narHash": "sha256-EjIQ7ok02IfDHDMKdKELuvFRHlZhzhymDGGx3jg6nvQ=", "owner": "neovim", "repo": "neovim", - "rev": "ad3472e291694b6c589d8a664459b03962eaac95", + "rev": "05d354e2165c2c331a33949d49095eef3503a32f", "type": "github" }, "original": { @@ -704,11 +704,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1730958623, - "narHash": "sha256-JwQZIGSYnRNOgDDoIgqKITrPVil+RMWHsZH1eE1VGN0=", + "lastModified": 1731531548, + "narHash": "sha256-sz8/v17enkYmfpgeeuyzniGJU0QQBfmAjlemAUYhfy8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "85f7e662eda4fa3a995556527c87b2524b691933", + "rev": "24f0d4acd634792badd6470134c387a3b039dace", "type": "github" }, "original": { @@ -720,11 +720,11 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1730958623, - "narHash": "sha256-JwQZIGSYnRNOgDDoIgqKITrPVil+RMWHsZH1eE1VGN0=", + "lastModified": 1731531548, + "narHash": "sha256-sz8/v17enkYmfpgeeuyzniGJU0QQBfmAjlemAUYhfy8=", "owner": "nixos", "repo": "nixpkgs", - "rev": "85f7e662eda4fa3a995556527c87b2524b691933", + "rev": "24f0d4acd634792badd6470134c387a3b039dace", "type": "github" }, "original": { @@ -736,11 +736,11 @@ }, "nixpkgs_5": { "locked": { - "lastModified": 1730958623, - "narHash": "sha256-JwQZIGSYnRNOgDDoIgqKITrPVil+RMWHsZH1eE1VGN0=", + "lastModified": 1731763621, + "narHash": "sha256-ddcX4lQL0X05AYkrkV2LMFgGdRvgap7Ho8kgon3iWZk=", "owner": "nixos", "repo": "nixpkgs", - "rev": "85f7e662eda4fa3a995556527c87b2524b691933", + "rev": "c69a9bffbecde46b4b939465422ddc59493d3e4d", "type": "github" }, "original": { @@ -790,11 +790,11 @@ "nixpkgs-stable": "nixpkgs-stable_3" }, "locked": { - "lastModified": 1730814269, - "narHash": "sha256-fWPHyhYE6xvMI1eGY3pwBTq85wcy1YXqdzTZF+06nOg=", + "lastModified": 1731363552, + "narHash": "sha256-vFta1uHnD29VUY4HJOO/D6p6rxyObnf+InnSMT4jlMU=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "d70155fdc00df4628446352fc58adc640cd705c2", + "rev": "cd1af27aa85026ac759d5d3fccf650abe7e1bbf0", "type": "github" }, "original": { From cd7deac3ccab1a1073b7678b98b743b88171ea72 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Sun, 17 Nov 2024 01:47:47 +0100 Subject: [PATCH 67/84] chore(neotest): remove duplicate `--color=never` arg --- lua/rustaceanvim/neotest/init.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/rustaceanvim/neotest/init.lua b/lua/rustaceanvim/neotest/init.lua index a2e7448d..08b506b7 100644 --- a/lua/rustaceanvim/neotest/init.lua +++ b/lua/rustaceanvim/neotest/init.lua @@ -298,7 +298,6 @@ function NeotestAdapter.build_spec(run_args) local is_cargo_test = args[1] == 'test' local insert_pos = is_cargo_test and 2 or 3 table.insert(args, insert_pos, '--no-fail-fast') - table.insert(args, insert_pos, '--color=never') if is_cargo_test then -- cargo test needs to pass --color=never to the test runner too table.insert(args, '--color=never') From 900c6c5214b0fcec9a71309d7b05186bbaa3fa48 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Mon, 18 Nov 2024 22:05:18 +0100 Subject: [PATCH 68/84] feat(lsp): pass `client_id` to `on_initialized` (#584) --- doc/rustaceanvim.txt | 38 ++++++++++++++-------------- lua/rustaceanvim/config/init.lua | 2 +- lua/rustaceanvim/config/internal.lua | 2 +- lua/rustaceanvim/server_status.lua | 2 +- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/doc/rustaceanvim.txt b/doc/rustaceanvim.txt index bf26be2c..690e2419 100644 --- a/doc/rustaceanvim.txt +++ b/doc/rustaceanvim.txt @@ -156,35 +156,35 @@ rustaceanvim.tools.Opts *rustaceanvim.tools.Opts* Fields: ~ {executor?} (rustaceanvim.Executor|rustaceanvim.executor_alias) - The executor to use for runnables/debuggables + The executor to use for runnables/debuggables {test_executor?} (rustaceanvim.Executor|rustaceanvim.test_executor_alias) - The executor to use for runnables that are tests / testables + The executor to use for runnables that are tests / testables {crate_test_executor?} (rustaceanvim.Executor|rustaceanvim.test_executor_alias) - The executor to use for runnables that are crate test suites (--all-targets) + The executor to use for runnables that are crate test suites (--all-targets) {cargo_override?} (string) - Set this to override the 'cargo' command for runnables, debuggables (etc., e.g. to 'cross'). - If set, this takes precedence over 'enable_nextest'. + Set this to override the 'cargo' command for runnables, debuggables (etc., e.g. to 'cross'). + If set, this takes precedence over 'enable_nextest'. {enable_nextest?} (boolean) - Whether to enable nextest. If enabled, `cargo test` commands will be transformed to `cargo nextest run` commands. - Defaults to `true` if cargo-nextest is detected. Ignored if `cargo_override` is set. + Whether to enable nextest. If enabled, `cargo test` commands will be transformed to `cargo nextest run` commands. + Defaults to `true` if cargo-nextest is detected. Ignored if `cargo_override` is set. {enable_clippy?} (boolean) - Whether to enable clippy checks on save if a clippy installation is detected. - Default: `true` - {on_initialized?} (fun(health:rustaceanvim.RAInitializedStatus)) - Function that is invoked when the LSP server has finished initializing + Whether to enable clippy checks on save if a clippy installation is detected. + Default: `true` + {on_initialized?} (fun(health:rustaceanvim.RAInitializedStatus,client_id:integer)) + Function that is invoked when the LSP server has finished initializing {reload_workspace_from_cargo_toml?} (boolean) - Automatically call `RustReloadWorkspace` when writing to a Cargo.toml file - {hover_actions?} (rustaceanvim.hover-actions.Opts) Options for hover actions - {code_actions?} (rustaceanvim.code-action.Opts) Options for code actions + Automatically call `RustReloadWorkspace` when writing to a Cargo.toml file + {hover_actions?} (rustaceanvim.hover-actions.Opts) Options for hover actions + {code_actions?} (rustaceanvim.code-action.Opts) Options for code actions {float_win_config?} (rustaceanvim.FloatWinConfig) - Options applied to floating windows. - See |api-win_config|. + Options applied to floating windows. + See |api-win_config|. {create_graph?} (rustaceanvim.crate-graph.Opts) - Options for showing the crate graph based on graphviz and the dot + Options for showing the crate graph based on graphviz and the dot {open_url?} (fun(url:string):nil) - If set, overrides how to open URLs + If set, overrides how to open URLs {rustc?} (rustaceanvim.rustc.Opts) - Options for `rustc` + Options for `rustc` rustaceanvim.Executor *rustaceanvim.Executor* diff --git a/lua/rustaceanvim/config/init.lua b/lua/rustaceanvim/config/init.lua index cbb5042e..252306be 100644 --- a/lua/rustaceanvim/config/init.lua +++ b/lua/rustaceanvim/config/init.lua @@ -78,7 +78,7 @@ vim.g.rustaceanvim = vim.g.rustaceanvim ---@field enable_clippy? boolean --- ---Function that is invoked when the LSP server has finished initializing ----@field on_initialized? fun(health:rustaceanvim.RAInitializedStatus) +---@field on_initialized? fun(health:rustaceanvim.RAInitializedStatus, client_id:integer) --- ---Automatically call `RustReloadWorkspace` when writing to a Cargo.toml file ---@field reload_workspace_from_cargo_toml? boolean diff --git a/lua/rustaceanvim/config/internal.lua b/lua/rustaceanvim/config/internal.lua index 4c736845..68852f93 100644 --- a/lua/rustaceanvim/config/internal.lua +++ b/lua/rustaceanvim/config/internal.lua @@ -106,7 +106,7 @@ local RustaceanDefaultConfig = { --- callback to execute once rust-analyzer is done initializing the workspace --- The callback receives one parameter indicating the `health` of the server: "ok" | "warning" | "error" - ---@type fun(health:rustaceanvim.RAInitializedStatus) | nil + ---@type fun(health:rustaceanvim.RAInitializedStatus, client_id:integer) | nil on_initialized = nil, --- automatically call RustReloadWorkspace when writing to a Cargo.toml file. diff --git a/lua/rustaceanvim/server_status.lua b/lua/rustaceanvim/server_status.lua index fb3d2177..dbe59db8 100644 --- a/lua/rustaceanvim/server_status.lua +++ b/lua/rustaceanvim/server_status.lua @@ -58,7 +58,7 @@ see ':h rustaceanvim.lsp.ClientOpts'. end -- Load user on_initialized if config.tools.on_initialized then - config.tools.on_initialized(result) + config.tools.on_initialized(result, ctx.client_id) end if config.dap.autoload_configurations then require('rustaceanvim.commands.debuggables').add_dap_debuggables() From 6e742b9fc6a37e46181879f6c32cecfa8cd2cebf Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Mon, 18 Nov 2024 22:15:36 +0100 Subject: [PATCH 69/84] chore(master): release 5.15.0 (#585) --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01600b51..16dcd705 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [5.15.0](https://github.com/mrcjkb/rustaceanvim/compare/v5.14.1...v5.15.0) (2024-11-18) + + +### Features + +* **lsp:** pass `client_id` to `on_initialized` ([#584](https://github.com/mrcjkb/rustaceanvim/issues/584)) ([900c6c5](https://github.com/mrcjkb/rustaceanvim/commit/900c6c5214b0fcec9a71309d7b05186bbaa3fa48)) + ## [5.14.1](https://github.com/mrcjkb/rustaceanvim/compare/v5.14.0...v5.14.1) (2024-11-12) From b4e35d5b18b77f0304c2949941ad75644cb9ce23 Mon Sep 17 00:00:00 2001 From: Markus Pettersson Date: Mon, 25 Nov 2024 12:03:46 +0100 Subject: [PATCH 70/84] fix: expose `target` scommand in `:RustAnalyzer` command completion (#589) --- lua/rustaceanvim/lsp/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/rustaceanvim/lsp/init.lua b/lua/rustaceanvim/lsp/init.lua index 07e9294e..d22837f5 100644 --- a/lua/rustaceanvim/lsp/init.lua +++ b/lua/rustaceanvim/lsp/init.lua @@ -363,7 +363,7 @@ vim.api.nvim_create_user_command('RustAnalyzer', rust_analyzer_cmd, { complete = function(arg_lead, cmdline, _) local clients = rust_analyzer.get_active_rustaceanvim_clients() ---@type RustAnalyzerCmd[] - local commands = #clients == 0 and { 'start' } or { 'stop', 'restart', 'reloadSettings' } + local commands = #clients == 0 and { 'start' } or { 'stop', 'restart', 'reloadSettings', 'target' } if cmdline:match('^RustAnalyzer%s+%w*$') then return vim.tbl_filter(function(command) return command:find(arg_lead) ~= nil From 761a2b6410d2ad34f366447741ec404083ac2463 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Mon, 25 Nov 2024 12:06:05 +0100 Subject: [PATCH 71/84] chore(master): release 5.15.1 (#590) --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16dcd705..ed7eec73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [5.15.1](https://github.com/mrcjkb/rustaceanvim/compare/v5.15.0...v5.15.1) (2024-11-25) + + +### Bug Fixes + +* expose `target` scommand in `:RustAnalyzer` command completion ([#589](https://github.com/mrcjkb/rustaceanvim/issues/589)) ([b4e35d5](https://github.com/mrcjkb/rustaceanvim/commit/b4e35d5b18b77f0304c2949941ad75644cb9ce23)) + ## [5.15.0](https://github.com/mrcjkb/rustaceanvim/compare/v5.14.1...v5.15.0) (2024-11-18) From 4f62c30d80a52ea41a4c0d1f12195aa01c89c2eb Mon Sep 17 00:00:00 2001 From: Markus Pettersson Date: Mon, 25 Nov 2024 21:05:07 +0100 Subject: [PATCH 72/84] fix: various `:RustAnalyzer target` regressions (#591) Co-authored-by: Marc Jakobi --- lua/rustaceanvim/lsp/init.lua | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lua/rustaceanvim/lsp/init.lua b/lua/rustaceanvim/lsp/init.lua index d22837f5..1a60549a 100644 --- a/lua/rustaceanvim/lsp/init.lua +++ b/lua/rustaceanvim/lsp/init.lua @@ -311,12 +311,18 @@ M.set_target_arch = function(bufnr, target) restart(bufnr, { exclude_rustc_target = target }, function(client) rustc.with_rustc_target_architectures(function(rustc_targets) if rustc_targets[target] then - client.settings['rust-analyzer'].cargo.target = target + local ra = client.config.settings['rust-analyzer'] + ra.cargo = ra.cargo or {} + ra.cargo.target = target client.notify('workspace/didChangeConfiguration', { settings = client.config.settings }) - vim.notify('Target architecture updated successfully to: ' .. target, vim.log.levels.INFO) + vim.schedule(function() + vim.notify('Target architecture updated successfully to: ' .. target, vim.log.levels.INFO) + end) return else - vim.notify('Invalid target architecture provided: ' .. tostring(target), vim.log.levels.ERROR) + vim.schedule(function() + vim.notify('Invalid target architecture provided: ' .. tostring(target), vim.log.levels.ERROR) + end) return end end) @@ -353,7 +359,7 @@ local function rust_analyzer_cmd(opts) M.reload_settings() elseif cmd == RustAnalyzerCmd.target then local target_arch = fargs[2] - M.set_target_arch(target_arch) + M.set_target_arch(nil, target_arch) end end From fee0aa094b0c9f93fffe5a385b3d5d2386c2b072 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Mon, 25 Nov 2024 21:09:33 +0100 Subject: [PATCH 73/84] chore(master): release 5.15.2 (#592) --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed7eec73..fd963005 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [5.15.2](https://github.com/mrcjkb/rustaceanvim/compare/v5.15.1...v5.15.2) (2024-11-25) + + +### Bug Fixes + +* various `:RustAnalyzer target` regressions ([#591](https://github.com/mrcjkb/rustaceanvim/issues/591)) ([4f62c30](https://github.com/mrcjkb/rustaceanvim/commit/4f62c30d80a52ea41a4c0d1f12195aa01c89c2eb)) + ## [5.15.1](https://github.com/mrcjkb/rustaceanvim/compare/v5.15.0...v5.15.1) (2024-11-25) From 1f97e08765a6149f87abe3aad6c8d03d9884a628 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Wed, 27 Nov 2024 21:49:51 +0100 Subject: [PATCH 74/84] fix(lsp): schedule notification if lsp restart times out --- lua/rustaceanvim/lsp/init.lua | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lua/rustaceanvim/lsp/init.lua b/lua/rustaceanvim/lsp/init.lua index 1a60549a..e04558a5 100644 --- a/lua/rustaceanvim/lsp/init.lua +++ b/lua/rustaceanvim/lsp/init.lua @@ -104,10 +104,13 @@ local function restart(bufnr, filter, callback) local clients = M.stop(bufnr, filter) local timer, _, _ = vim.uv.new_timer() if not timer then - vim.notify('Failed to init timer for LSP client restart.', vim.log.levels.ERROR) + vim.schedule(function() + vim.notify('rustaceanvim.lsp: Failed to initialise timer for LSP client restart.', vim.log.levels.ERROR) + end) return end - local attempts_to_live = 50 + local max_attempts = 50 + local attempts_to_live = max_attempts local stopped_client_count = 0 timer:start(200, 100, function() for _, client in ipairs(clients) do @@ -126,7 +129,12 @@ local function restart(bufnr, filter, callback) timer:stop() attempts_to_live = 0 elseif attempts_to_live <= 0 then - vim.notify('rustaceanvim.lsp: Could not restart all LSP clients.', vim.log.levels.ERROR) + vim.schedule(function() + vim.notify( + ('rustaceanvim.lsp: Could not restart all LSP clients after %d attempts.'):format(max_attempts), + vim.log.levels.ERROR + ) + end) timer:stop() attempts_to_live = 0 end @@ -207,11 +215,15 @@ M.start = function(bufnr) -- end if #rust_analyzer_cmd == 0 then - vim.notify('rust-analyzer command is not set!', vim.log.levels.ERROR) + vim.schedule(function() + vim.notify('rust-analyzer command is not set!', vim.log.levels.ERROR) + end) return end if vim.fn.executable(rust_analyzer_cmd[1]) ~= 1 then - vim.notify(('%s is not executable'):format(rust_analyzer_cmd[1]), vim.log.levels.ERROR) + vim.schedule(function() + vim.notify(('%s is not executable'):format(rust_analyzer_cmd[1]), vim.log.levels.ERROR) + end) return end ---@cast rust_analyzer_cmd string[] From b2df0caa67d41c63a7284b03e80aeff15d8e31ca Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Wed, 27 Nov 2024 22:11:00 +0100 Subject: [PATCH 75/84] chore(master): release 5.15.3 (#594) --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd963005..63fd3936 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [5.15.3](https://github.com/mrcjkb/rustaceanvim/compare/v5.15.2...v5.15.3) (2024-11-27) + + +### Bug Fixes + +* **lsp:** schedule notification if lsp restart times out ([1f97e08](https://github.com/mrcjkb/rustaceanvim/commit/1f97e08765a6149f87abe3aad6c8d03d9884a628)) + ## [5.15.2](https://github.com/mrcjkb/rustaceanvim/compare/v5.15.1...v5.15.2) (2024-11-25) From f116a555d3d30d2aabf74f1e5f1c1b2b377e6516 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Fri, 29 Nov 2024 22:07:14 +0100 Subject: [PATCH 76/84] =?UTF-8?q?fix(lsp/nightly):=20avoid=20deprecations?= =?UTF-8?q?=20with=20no=20alternative=20in=20stable=20(=E2=95=AF=C2=B0?= =?UTF-8?q?=E2=96=A1=C2=B0)=E2=95=AF=EF=B8=B5=20=E2=94=BB=E2=94=81?= =?UTF-8?q?=E2=94=BB=20(#587)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: github-actions[bot] --- flake.lock | 54 +++++++++---------- .../commands/code_action_group.lua | 11 +++- lua/rustaceanvim/commands/expand_macro.lua | 14 +++-- lua/rustaceanvim/commands/external_docs.lua | 22 +++++--- lua/rustaceanvim/commands/hover_range.lua | 19 ++++--- lua/rustaceanvim/commands/init.lua | 20 ++++--- lua/rustaceanvim/commands/join_lines.lua | 38 ++++++++----- lua/rustaceanvim/commands/move_item.lua | 25 ++++----- lua/rustaceanvim/commands/parent_module.lua | 13 ++--- lua/rustaceanvim/commands/ssr.lua | 52 +++++++++++------- lua/rustaceanvim/commands/syntax_tree.lua | 14 ++--- lua/rustaceanvim/commands/view_ir.lua | 7 ++- lua/rustaceanvim/compat.lua | 54 +++++++++++++++++++ lua/rustaceanvim/hover_actions.lua | 14 ++--- lua/rustaceanvim/lsp/init.lua | 7 +-- lua/rustaceanvim/runnables.lua | 7 ++- lua/rustaceanvim/rust_analyzer.lua | 7 +-- 17 files changed, 247 insertions(+), 131 deletions(-) diff --git a/flake.lock b/flake.lock index dcf09972..51603447 100644 --- a/flake.lock +++ b/flake.lock @@ -281,11 +281,11 @@ "nixpkgs-stable": "nixpkgs-stable_2" }, "locked": { - "lastModified": 1731363552, - "narHash": "sha256-vFta1uHnD29VUY4HJOO/D6p6rxyObnf+InnSMT4jlMU=", + "lastModified": 1732021966, + "narHash": "sha256-mnTbjpdqF0luOkou8ZFi2asa1N3AA2CchR/RqCNmsGE=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "cd1af27aa85026ac759d5d3fccf650abe7e1bbf0", + "rev": "3308484d1a443fc5bc92012435d79e80458fe43c", "type": "github" }, "original": { @@ -310,11 +310,11 @@ ] }, "locked": { - "lastModified": 1731363552, - "narHash": "sha256-vFta1uHnD29VUY4HJOO/D6p6rxyObnf+InnSMT4jlMU=", + "lastModified": 1732021966, + "narHash": "sha256-mnTbjpdqF0luOkou8ZFi2asa1N3AA2CchR/RqCNmsGE=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "cd1af27aa85026ac759d5d3fccf650abe7e1bbf0", + "rev": "3308484d1a443fc5bc92012435d79e80458fe43c", "type": "github" }, "original": { @@ -506,11 +506,11 @@ "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1731648623, - "narHash": "sha256-kL0qF6ETmWSeN0Nzjg7GtSbe/7AcNmuX2U6Mb7xLIOA=", + "lastModified": 1732253278, + "narHash": "sha256-/ONdyXzZ0dK+GlV6lKq9+efY0BsXxUJ2cQp5LbL0MVA=", "owner": "nvim-neorocks", "repo": "neorocks", - "rev": "b82f112cb43020ab23a2816dfc7a3453aafd754f", + "rev": "76c80c100d549c0674cf2d6721cf27cc44412e65", "type": "github" }, "original": { @@ -529,11 +529,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1731629313, - "narHash": "sha256-rCTdc6oHM4Ostt6IR66QiDrPQNjCsxC2r00GfU0bADU=", + "lastModified": 1732234033, + "narHash": "sha256-94yZ7eJiLvW+UknI5RZBCV6OMHtoSv1oWyOwKjTmS88=", "owner": "nix-community", "repo": "neovim-nightly-overlay", - "rev": "81a983160c1acae623482e082a94a46c931d0261", + "rev": "10e11c32a4f4f7c9d64f45413642ded11fc538b6", "type": "github" }, "original": { @@ -545,11 +545,11 @@ "neovim-src": { "flake": false, "locked": { - "lastModified": 1731607016, - "narHash": "sha256-EjIQ7ok02IfDHDMKdKELuvFRHlZhzhymDGGx3jg6nvQ=", + "lastModified": 1732229552, + "narHash": "sha256-7tA7IeOjx1wgDQnY7RxIhIuwcFeSZu4Yc3WtLh+22TE=", "owner": "neovim", "repo": "neovim", - "rev": "05d354e2165c2c331a33949d49095eef3503a32f", + "rev": "ff75f345ab5fa57c6560db021e8eb099aff90472", "type": "github" }, "original": { @@ -704,11 +704,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1731531548, - "narHash": "sha256-sz8/v17enkYmfpgeeuyzniGJU0QQBfmAjlemAUYhfy8=", + "lastModified": 1731890469, + "narHash": "sha256-D1FNZ70NmQEwNxpSSdTXCSklBH1z2isPR84J6DQrJGs=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "24f0d4acd634792badd6470134c387a3b039dace", + "rev": "5083ec887760adfe12af64830a66807423a859a7", "type": "github" }, "original": { @@ -720,11 +720,11 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1731531548, - "narHash": "sha256-sz8/v17enkYmfpgeeuyzniGJU0QQBfmAjlemAUYhfy8=", + "lastModified": 1731890469, + "narHash": "sha256-D1FNZ70NmQEwNxpSSdTXCSklBH1z2isPR84J6DQrJGs=", "owner": "nixos", "repo": "nixpkgs", - "rev": "24f0d4acd634792badd6470134c387a3b039dace", + "rev": "5083ec887760adfe12af64830a66807423a859a7", "type": "github" }, "original": { @@ -736,11 +736,11 @@ }, "nixpkgs_5": { "locked": { - "lastModified": 1731763621, - "narHash": "sha256-ddcX4lQL0X05AYkrkV2LMFgGdRvgap7Ho8kgon3iWZk=", + "lastModified": 1731890469, + "narHash": "sha256-D1FNZ70NmQEwNxpSSdTXCSklBH1z2isPR84J6DQrJGs=", "owner": "nixos", "repo": "nixpkgs", - "rev": "c69a9bffbecde46b4b939465422ddc59493d3e4d", + "rev": "5083ec887760adfe12af64830a66807423a859a7", "type": "github" }, "original": { @@ -790,11 +790,11 @@ "nixpkgs-stable": "nixpkgs-stable_3" }, "locked": { - "lastModified": 1731363552, - "narHash": "sha256-vFta1uHnD29VUY4HJOO/D6p6rxyObnf+InnSMT4jlMU=", + "lastModified": 1732021966, + "narHash": "sha256-mnTbjpdqF0luOkou8ZFi2asa1N3AA2CchR/RqCNmsGE=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "cd1af27aa85026ac759d5d3fccf650abe7e1bbf0", + "rev": "3308484d1a443fc5bc92012435d79e80458fe43c", "type": "github" }, "original": { diff --git a/lua/rustaceanvim/commands/code_action_group.lua b/lua/rustaceanvim/commands/code_action_group.lua index 4a063a90..555f3f53 100644 --- a/lua/rustaceanvim/commands/code_action_group.lua +++ b/lua/rustaceanvim/commands/code_action_group.lua @@ -1,5 +1,6 @@ local ui = require('rustaceanvim.ui') local config = require('rustaceanvim.config.internal') +local compat = require('rustaceanvim.compat') local M = {} ---@class rustaceanvim.RACodeAction @@ -47,7 +48,7 @@ function M.on_user_choice(action_tuple, ctx) return end if not action.edit and type(code_action_provider) == 'table' and code_action_provider.resolveProvider then - client.request('codeAction/resolve', action, function(err, resolved_action) + compat.client_request(client, 'codeAction/resolve', action, function(err, resolved_action) ---@cast resolved_action rustaceanvim.RACodeAction|rustaceanvim.RACommand if err then vim.notify(err.code .. ': ' .. err.message, vim.log.levels.ERROR) @@ -377,7 +378,13 @@ M.state = { M.code_action_group = function() local context = {} context.diagnostics = require('rustaceanvim.compat').get_line_diagnostics() - local params = vim.lsp.util.make_range_params() + local ra = require('rustaceanvim.rust_analyzer') + local clients = ra.get_active_rustaceanvim_clients(0) + if #clients == 0 then + return + end + local params = vim.lsp.util.make_range_params(0, clients[1].offset_encoding) + ---@diagnostic disable-next-line: inject-field params.context = context vim.lsp.buf_request_all(0, 'textDocument/codeAction', params, function(results) diff --git a/lua/rustaceanvim/commands/expand_macro.lua b/lua/rustaceanvim/commands/expand_macro.lua index 26c21d67..a403f81b 100644 --- a/lua/rustaceanvim/commands/expand_macro.lua +++ b/lua/rustaceanvim/commands/expand_macro.lua @@ -3,8 +3,9 @@ local ui = require('rustaceanvim.ui') local M = {} ---@return lsp_position_params -local function get_params() - return vim.lsp.util.make_position_params() +---@param offset_encoding 'utf-8'|'utf-16'|'utf-32' +local function get_params(offset_encoding) + return vim.lsp.util.make_position_params(0, offset_encoding) end ---@type integer | nil @@ -70,11 +71,14 @@ local function handler(_, result) ui.resize(true, '-25') end -local rl = require('rustaceanvim.rust_analyzer') - --- Sends the request to rust-analyzer to expand the macro under the cursor function M.expand_macro() - rl.buf_request(0, 'rust-analyzer/expandMacro', get_params(), handler) + local ra = require('rustaceanvim.rust_analyzer') + local clients = ra.get_active_rustaceanvim_clients(0) + if #clients == 0 then + return + end + ra.buf_request(0, 'rust-analyzer/expandMacro', get_params(clients[1].offset_encoding), handler) end return M.expand_macro diff --git a/lua/rustaceanvim/commands/external_docs.lua b/lua/rustaceanvim/commands/external_docs.lua index 0f644a61..98764c81 100644 --- a/lua/rustaceanvim/commands/external_docs.lua +++ b/lua/rustaceanvim/commands/external_docs.lua @@ -1,14 +1,22 @@ local M = {} -local rl = require('rustaceanvim.rust_analyzer') - function M.open_external_docs() - rl.buf_request(0, 'experimental/externalDocs', vim.lsp.util.make_position_params(), function(_, url) - if url then - local config = require('rustaceanvim.config.internal') - config.tools.open_url(url) + local ra = require('rustaceanvim.rust_analyzer') + local clients = ra.get_active_rustaceanvim_clients(0) + if #clients == 0 then + return + end + ra.buf_request( + 0, + 'experimental/externalDocs', + vim.lsp.util.make_position_params(0, clients[1].offset_encoding), + function(_, url) + if url then + local config = require('rustaceanvim.config.internal') + config.tools.open_url(url) + end end - end) + ) end return M.open_external_docs diff --git a/lua/rustaceanvim/commands/hover_range.lua b/lua/rustaceanvim/commands/hover_range.lua index 75d8a876..ae0c8eb0 100644 --- a/lua/rustaceanvim/commands/hover_range.lua +++ b/lua/rustaceanvim/commands/hover_range.lua @@ -42,18 +42,17 @@ local function get_visual_selected_range() return make_lsp_position(row1, math.min(col1, col2), row1, math.max(col1, col2)) end ----@return lsp_range_params -local function get_opts() - local params = vim.lsp.util.make_range_params() +function M.hover_range() + local ra = require('rustaceanvim.rust_analyzer') + local clients = ra.get_active_rustaceanvim_clients(0) + if #clients == 0 then + return + end + local params = vim.lsp.util.make_range_params(0, clients[1].offset_encoding) + ---@diagnostic disable-next-line: inject-field params.position = get_visual_selected_range() params.range = nil - return params -end - -local rl = require('rustaceanvim.rust_analyzer') - -function M.hover_range() - rl.buf_request(0, 'textDocument/hover', get_opts()) + ra.buf_request(0, 'textDocument/hover', params) end return M.hover_range diff --git a/lua/rustaceanvim/commands/init.lua b/lua/rustaceanvim/commands/init.lua index 7ec07ecb..93788964 100644 --- a/lua/rustaceanvim/commands/init.lua +++ b/lua/rustaceanvim/commands/init.lua @@ -159,9 +159,13 @@ local rustlsp_command_tbl = { }, joinLines = { impl = function(_, opts) + local cmds = require('rustaceanvim.commands.join_lines') ---@cast opts vim.api.keyset.user_command - local visual_mode = opts.range and opts.range ~= 0 or false - require('rustaceanvim.commands.join_lines')(visual_mode) + if opts.range and opts.range ~= 0 then + cmds.join_lines_visual() + else + cmds.join_lines() + end end, }, moveItem = { @@ -171,9 +175,9 @@ local rustlsp_command_tbl = { return end if args[1] == 'down' then - require('rustaceanvim.commands.move_item')() + require('rustaceanvim.commands.move_item')('Down') elseif args[1] == 'up' then - require('rustaceanvim.commands.move_item')(true) + require('rustaceanvim.commands.move_item')('Up') else vim.notify( 'moveItem: unexpected argument: ' .. vim.inspect(args) .. " expected 'up' or 'down'", @@ -203,9 +207,13 @@ local rustlsp_command_tbl = { ssr = { impl = function(args, opts) ---@cast opts vim.api.keyset.user_command - local visual_mode = opts.range and opts.range > 0 or false local query = args and #args > 0 and table.concat(args, ' ') or nil - require('rustaceanvim.commands.ssr')(query, visual_mode) + local cmds = require('rustaceanvim.commands.ssr') + if opts.range and opts.range > 0 then + cmds.ssr_visual(query) + else + cmds.ssr(query) + end end, }, reloadWorkspace = { diff --git a/lua/rustaceanvim/commands/join_lines.lua b/lua/rustaceanvim/commands/join_lines.lua index 89f42181..1cc8d8a7 100644 --- a/lua/rustaceanvim/commands/join_lines.lua +++ b/lua/rustaceanvim/commands/join_lines.lua @@ -1,16 +1,13 @@ local M = {} ----@alias lsp_join_lines_params { textDocument: lsp_text_document, ranges: lsp_range[] } - ----@param visual_mode boolean ----@return lsp_join_lines_params -local function get_params(visual_mode) - local params = visual_mode and vim.lsp.util.make_given_range_params() or vim.lsp.util.make_range_params() +---@param params { textDocument: lsp_text_document, range: lsp_range } +---@return { textDocument: lsp_text_document, ranges: lsp_range[] } +local function modify_params(params) local range = params.range - params.range = nil + ---@diagnostic disable-next-line: inject-field params.ranges = { range } - + ---@diagnostic disable-next-line: return-type-mismatch return params end @@ -18,13 +15,28 @@ local function handler(_, result, ctx) vim.lsp.util.apply_text_edits(result, ctx.bufnr, vim.lsp.get_client_by_id(ctx.client_id).offset_encoding) end -local rl = require('rustaceanvim.rust_analyzer') +local ra = require('rustaceanvim.rust_analyzer') + +--- Sends the request to rust-analyzer to get the TextEdits to join the lines +--- under the cursor and applies them (for use in visual mode) +function M.join_lines_visual() + local clients = ra.get_active_rustaceanvim_clients(0) + if #clients == 0 then + return + end + local params = modify_params(vim.lsp.util.make_given_range_params(nil, nil, 0, clients[1].offset_encoding)) + ra.buf_request(0, 'experimental/joinLines', params, handler) +end --- Sends the request to rust-analyzer to get the TextEdits to join the lines --- under the cursor and applies them ----@param visual_mode boolean -function M.join_lines(visual_mode) - rl.buf_request(0, 'experimental/joinLines', get_params(visual_mode), handler) +function M.join_lines() + local clients = ra.get_active_rustaceanvim_clients(0) + if #clients == 0 then + return + end + local params = modify_params(vim.lsp.util.make_range_params(0, clients[1].offset_encoding)) + ra.buf_request(0, 'experimental/joinLines', params, handler) end -return M.join_lines +return M diff --git a/lua/rustaceanvim/commands/move_item.lua b/lua/rustaceanvim/commands/move_item.lua index 457b57a4..3d1b18ca 100644 --- a/lua/rustaceanvim/commands/move_item.lua +++ b/lua/rustaceanvim/commands/move_item.lua @@ -2,16 +2,6 @@ local M = {} ---@alias lsp_move_items_params { textDocument: lsp_text_document, range: lsp_range, direction: 'Up' | 'Down' } ----@param up boolean ----@return lsp_move_items_params -local function get_params(up) - local direction = up and 'Up' or 'Down' - local params = vim.lsp.util.make_range_params() - params.direction = direction - - return params -end - ---@param prev_text_edit rustaceanvim.lsp.TextEdit ---@param text_edit rustaceanvim.lsp.TextEdit local function text_edit_line_range_diff(prev_text_edit, text_edit) @@ -55,11 +45,18 @@ local function handler(_, text_edits, ctx) vim.api.nvim_win_set_cursor(0, cursor) end -local rl = require('rustaceanvim.rust_analyzer') - -- Sends the request to rust-analyzer to move the item and handle the response -function M.move_item(up) - rl.buf_request(0, 'experimental/moveItem', get_params(up or false), handler) +---@param direction 'Up' | 'Down' +function M.move_item(direction) + local ra = require('rustaceanvim.rust_analyzer') + local clients = ra.get_active_rustaceanvim_clients(0) + if #clients == 0 then + return + end + local params = vim.lsp.util.make_range_params(0, clients[1].offset_encoding) + ---@diagnostic disable-next-line: inject-field + params.direction = direction + ra.buf_request(0, 'experimental/moveItem', params, handler) end return M.move_item diff --git a/lua/rustaceanvim/commands/parent_module.lua b/lua/rustaceanvim/commands/parent_module.lua index ec624d07..12294b87 100644 --- a/lua/rustaceanvim/commands/parent_module.lua +++ b/lua/rustaceanvim/commands/parent_module.lua @@ -1,12 +1,7 @@ local M = {} -local rl = require('rustaceanvim.rust_analyzer') local compat = require('rustaceanvim.compat') -local function get_params() - return vim.lsp.util.make_position_params(0, nil) -end - local function handler(_, result, ctx) if result == nil or vim.tbl_isempty(result) then vim.api.nvim_out_write("Can't find parent module\n") @@ -27,7 +22,13 @@ end --- Sends the request to rust-analyzer to get the parent modules location and open it function M.parent_module() - rl.buf_request(0, 'experimental/parentModule', get_params(), handler) + local ra = require('rustaceanvim.rust_analyzer') + local clients = ra.get_active_rustaceanvim_clients(0) + if #clients == 0 then + return + end + local params = vim.lsp.util.make_position_params(0, clients[1].offset_encoding) + ra.buf_request(0, 'experimental/parentModule', params, handler) end return M.parent_module diff --git a/lua/rustaceanvim/commands/ssr.lua b/lua/rustaceanvim/commands/ssr.lua index b2724bfb..7e1e8fee 100644 --- a/lua/rustaceanvim/commands/ssr.lua +++ b/lua/rustaceanvim/commands/ssr.lua @@ -1,17 +1,14 @@ local M = {} ----@param query string ----@param visual_mode boolean -local function get_opts(query, visual_mode) - local opts = vim.lsp.util.make_position_params() - local range = (visual_mode and vim.lsp.util.make_given_range_params() or vim.lsp.util.make_range_params()).range - ---@diagnostic disable-next-line: inject-field - opts.query = query - ---@diagnostic disable-next-line: inject-field - opts.parseOnly = false - ---@diagnostic disable-next-line: inject-field - opts.selections = { range } - return opts +local ra = require('rustaceanvim.rust_analyzer') + +---@params table +---@query string +---@param range table +local function modify_params(params, query, range) + params.query = query + params.parseOnly = false + params.selections = { range } end local function handler(err, result, ctx) @@ -26,19 +23,36 @@ local function handler(err, result, ctx) end end -local rl = require('rustaceanvim.rust_analyzer') - ----@param query string | nil ----@param visual_mode boolean -function M.ssr(query, visual_mode) +---@param query? string +---@param make_range_params fun(bufnr: integer, offset_encoding: string):{ range: table } +local function ssr(query, make_range_params) + local clients = ra.get_active_rustaceanvim_clients(0) + if #clients == 0 then + return + end + local params = vim.lsp.util.make_position_params(0, clients[1].offset_encoding) + local range = make_range_params(0, clients[1].offset_encoding).range if not query then vim.ui.input({ prompt = 'Enter query: ' }, function(input) query = input end) end + modify_params(params, query, range) if query then - rl.buf_request(0, 'experimental/ssr', get_opts(query, visual_mode), handler) + ra.buf_request(0, 'experimental/ssr', params, handler) end end -return M.ssr +---@param query? string +M.ssr = function(query) + ssr(query, vim.lsp.util.make_range_params) +end + +---@param query string | nil +function M.ssr_visual(query) + ssr(query, function(winnr, offset_encoding) + return vim.lsp.util.make_given_range_params(nil, nil, winnr, offset_encoding) + end) +end + +return M diff --git a/lua/rustaceanvim/commands/syntax_tree.lua b/lua/rustaceanvim/commands/syntax_tree.lua index ba89594d..7571d8f1 100644 --- a/lua/rustaceanvim/commands/syntax_tree.lua +++ b/lua/rustaceanvim/commands/syntax_tree.lua @@ -2,11 +2,6 @@ local ui = require('rustaceanvim.ui') local M = {} ----@return lsp_range_params -local function get_params() - return vim.lsp.util.make_range_params() -end - ---@type integer | nil local latest_buf_id = nil @@ -29,9 +24,14 @@ local function handler(_, result) ui.resize(true, '-25') end -local rl = require('rustaceanvim.rust_analyzer') function M.syntax_tree() - rl.buf_request(0, 'rust-analyzer/syntaxTree', get_params(), handler) + local ra = require('rustaceanvim.rust_analyzer') + local clients = ra.get_active_rustaceanvim_clients(0) + if #clients == 0 then + return + end + local params = vim.lsp.util.make_range_params(0, clients[1].offset_encoding) + ra.buf_request(0, 'rust-analyzer/syntaxTree', params, handler) end return M.syntax_tree diff --git a/lua/rustaceanvim/commands/view_ir.lua b/lua/rustaceanvim/commands/view_ir.lua index 617db33f..7471a61f 100644 --- a/lua/rustaceanvim/commands/view_ir.lua +++ b/lua/rustaceanvim/commands/view_ir.lua @@ -41,7 +41,12 @@ end ---@param level rustaceanvim.ir.level function M.viewIR(level) - local position_params = vim.lsp.util.make_position_params(0, nil) + local ra = require('rustaceanvim.rust_analyzer') + local clients = ra.get_active_rustaceanvim_clients(0) + if #clients == 0 then + return + end + local position_params = vim.lsp.util.make_position_params(0, clients[1].offset_encoding) rl.buf_request(0, 'rust-analyzer/view' .. level, position_params, function(...) return handler(level, ...) end) diff --git a/lua/rustaceanvim/compat.lua b/lua/rustaceanvim/compat.lua index 5e4db56b..46138181 100644 --- a/lua/rustaceanvim/compat.lua +++ b/lua/rustaceanvim/compat.lua @@ -28,4 +28,58 @@ function compat.show_document(location, offset_encoding) return show_document(location, offset_encoding, { focus = true }) end +--- @param client vim.lsp.Client +--- @param method string LSP method name. +--- @param params? table LSP request params. +--- @param handler? lsp.Handler Response |lsp-handler| for this method. +--- @param bufnr? integer Buffer handle. 0 for current (default). +--- @return boolean status indicates whether the request was successful. +--- If it is `false`, then it will always be `false` (the client has shutdown). +--- @return integer? request_id Can be used with |Client:cancel_request()|. +--- `nil` is request failed. +--- to cancel the-request. +function compat.client_request(client, method, params, handler, bufnr) + local info = debug.getinfo(client.request, 'u') + if info.nparams > 0 then + ---@diagnostic disable-next-line: param-type-mismatch + return client:request(method, params, handler, bufnr) + else + ---@diagnostic disable-next-line: param-type-mismatch + return client.request(method, params, handler, bufnr) + end +end + +--- @param client vim.lsp.Client +--- @param method string LSP method name. +--- @param params table? LSP request params. +--- @return boolean status indicating if the notification was successful. +--- If it is false, then the client has shutdown. +function compat.client_notify(client, method, params) + -- Nothing brings me more joy than updating Neovim nightly + -- and discovering that my perfectly functioning plugin has been obliterated because + -- a feature was deprecated without an alternative in stable. + -- Truly, it's the chaos I live for. (╯°□°)╯︵ ┻━┻ + local info = debug.getinfo(client.notify, 'u') + if info.nparams > 0 then + ---@diagnostic disable-next-line: param-type-mismatch + return client:notify(method, params) + else + ---@diagnostic disable-next-line: param-type-mismatch + return client.notify(method, params) + end +end + +---@param client vim.lsp.Client +---@return boolean +function compat.client_is_stopped(client) + local info = debug.getinfo(client.is_stopped, 'u') + if info.nparams > 0 then + ---@diagnostic disable-next-line: param-type-mismatch + return client:is_stopped() + else + ---@diagnostic disable-next-line: missing-parameter + return client.is_stopped() + end +end + return compat diff --git a/lua/rustaceanvim/hover_actions.lua b/lua/rustaceanvim/hover_actions.lua index 586ea0a8..a84c5fcd 100644 --- a/lua/rustaceanvim/hover_actions.lua +++ b/lua/rustaceanvim/hover_actions.lua @@ -3,10 +3,6 @@ local lsp_util = vim.lsp.util local M = {} -local function get_params() - return lsp_util.make_position_params(0, nil) -end - ---@class rustaceanvim.hover_actions.State local _state = { ---@type integer @@ -140,11 +136,15 @@ function M.handler(_, result, ctx) end, { buffer = vim.api.nvim_get_current_buf(), noremap = true, silent = true }) end -local rl = require('rustaceanvim.rust_analyzer') - --- Sends the request to rust-analyzer to get hover actions and handle it function M.hover_actions() - rl.buf_request(0, 'textDocument/hover', get_params(), M.handler) + local ra = require('rustaceanvim.rust_analyzer') + local clients = ra.get_active_rustaceanvim_clients(0) + if #clients == 0 then + return + end + local params = lsp_util.make_position_params(0, clients[1].offset_encoding) + ra.buf_request(0, 'textDocument/hover', params, M.handler) end return M diff --git a/lua/rustaceanvim/lsp/init.lua b/lua/rustaceanvim/lsp/init.lua index e04558a5..b4014e1d 100644 --- a/lua/rustaceanvim/lsp/init.lua +++ b/lua/rustaceanvim/lsp/init.lua @@ -7,6 +7,7 @@ local server_status = require('rustaceanvim.server_status') local cargo = require('rustaceanvim.cargo') local os = require('rustaceanvim.os') local rustc = require('rustaceanvim.rustc') +local compat = require('rustaceanvim.compat') local function override_apply_text_edits() local old_func = vim.lsp.util.apply_text_edits @@ -114,7 +115,7 @@ local function restart(bufnr, filter, callback) local stopped_client_count = 0 timer:start(200, 100, function() for _, client in ipairs(clients) do - if client:is_stopped() then + if compat.client_is_stopped(client) then stopped_client_count = stopped_client_count + 1 vim.schedule(function() -- Execute the callback, if provided, for additional actions before restarting @@ -307,7 +308,7 @@ M.reload_settings = function(bufnr) local settings = get_start_settings(vim.api.nvim_buf_get_name(bufnr), client.config.root_dir, config.server) ---@diagnostic disable-next-line: inject-field client.settings = settings - client.notify('workspace/didChangeConfiguration', { + compat.client_notify(client, 'workspace/didChangeConfiguration', { settings = client.settings, }) end @@ -326,7 +327,7 @@ M.set_target_arch = function(bufnr, target) local ra = client.config.settings['rust-analyzer'] ra.cargo = ra.cargo or {} ra.cargo.target = target - client.notify('workspace/didChangeConfiguration', { settings = client.config.settings }) + compat.client_notify(client, 'workspace/didChangeConfiguration', { settings = client.config.settings }) vim.schedule(function() vim.notify('Target architecture updated successfully to: ' .. target, vim.log.levels.INFO) end) diff --git a/lua/rustaceanvim/runnables.lua b/lua/rustaceanvim/runnables.lua index f5b89c24..519532fe 100644 --- a/lua/rustaceanvim/runnables.lua +++ b/lua/rustaceanvim/runnables.lua @@ -185,8 +185,13 @@ end ---@param runnables rustaceanvim.RARunnable ---@return integer | nil choice function M.get_runnable_at_cursor_position(runnables) + local ra = require('rustaceanvim.rust_analyzer') + local clients = ra.get_active_rustaceanvim_clients(0) + if #clients == 0 then + return + end ---@type lsp.Position - local position = vim.lsp.util.make_position_params().position + local position = vim.lsp.util.make_position_params(0, clients[1].offset_encoding).position ---@type integer|nil, integer|nil local choice, fallback for idx, runnable in ipairs(runnables) do diff --git a/lua/rustaceanvim/rust_analyzer.lua b/lua/rustaceanvim/rust_analyzer.lua index 219600fa..3851bac2 100644 --- a/lua/rustaceanvim/rust_analyzer.lua +++ b/lua/rustaceanvim/rust_analyzer.lua @@ -2,6 +2,7 @@ local os = require('rustaceanvim.os') local rustc = require('rustaceanvim.rustc') +local compat = require('rustaceanvim.compat') ---@class rustaceanvim.rust-analyzer.ClientAdapter local M = {} @@ -60,7 +61,7 @@ M.any_buf_request = function(method, params, handler) end -- No buffer found. Try any client. for _, client in ipairs(M.get_active_rustaceanvim_clients(nil, { method = method })) do - client.request(method, params, handler, 0) + compat.client_request(client, method, params, handler, 0) end end @@ -76,7 +77,7 @@ M.buf_request = function(bufnr, method, params, handler) end local client_found = false for _, client in ipairs(M.get_active_rustaceanvim_clients(bufnr, { method = method })) do - client.request(method, params, handler, bufnr) + compat.client_request(client, method, params, handler, 0) client_found = true end return client_found @@ -99,7 +100,7 @@ end M.notify = function(method, params) local client_found = false for _, client in ipairs(M.get_active_rustaceanvim_clients(0, { method = method })) do - client.notify(method, params) + compat.client_notify(client, method, params) client_found = true end if not client_found then From db8fb7c0679f6b8bc6638b8239481fa600fc0432 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Fri, 29 Nov 2024 22:11:27 +0100 Subject: [PATCH 77/84] chore: follow-up on previous commit --- lua/rustaceanvim/lsp/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/rustaceanvim/lsp/init.lua b/lua/rustaceanvim/lsp/init.lua index b4014e1d..06d4bd07 100644 --- a/lua/rustaceanvim/lsp/init.lua +++ b/lua/rustaceanvim/lsp/init.lua @@ -197,7 +197,7 @@ M.start = function(bufnr) removed = {}, }, } - client.rpc.notify('workspace/didChangeWorkspaceFolders', params) + compat.client_notify(client, 'workspace/didChangeWorkspaceFolders', params) if not client.workspace_folders then client.workspace_folders = {} end From 7a565dce677278a83419e01ecd630d135590dfe2 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Fri, 29 Nov 2024 22:12:44 +0100 Subject: [PATCH 78/84] fix(lsp): remove info notification when switching target architecture --- lua/rustaceanvim/lsp/init.lua | 3 --- 1 file changed, 3 deletions(-) diff --git a/lua/rustaceanvim/lsp/init.lua b/lua/rustaceanvim/lsp/init.lua index 06d4bd07..96774bf7 100644 --- a/lua/rustaceanvim/lsp/init.lua +++ b/lua/rustaceanvim/lsp/init.lua @@ -328,9 +328,6 @@ M.set_target_arch = function(bufnr, target) ra.cargo = ra.cargo or {} ra.cargo.target = target compat.client_notify(client, 'workspace/didChangeConfiguration', { settings = client.config.settings }) - vim.schedule(function() - vim.notify('Target architecture updated successfully to: ' .. target, vim.log.levels.INFO) - end) return else vim.schedule(function() From 0790912df13835ca9bdd5e17efc91a58629f2a23 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Fri, 29 Nov 2024 22:15:18 +0100 Subject: [PATCH 79/84] chore(master): release 5.15.4 (#596) --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63fd3936..396cf01f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [5.15.4](https://github.com/mrcjkb/rustaceanvim/compare/v5.15.3...v5.15.4) (2024-11-29) + + +### Bug Fixes + +* **lsp/nightly:** avoid deprecations with no alternative in stable (╯°□°)╯︵ ┻━┻ ([#587](https://github.com/mrcjkb/rustaceanvim/issues/587)) ([f116a55](https://github.com/mrcjkb/rustaceanvim/commit/f116a555d3d30d2aabf74f1e5f1c1b2b377e6516)) +* **lsp:** remove info notification when switching target architecture ([7a565dc](https://github.com/mrcjkb/rustaceanvim/commit/7a565dce677278a83419e01ecd630d135590dfe2)) + ## [5.15.3](https://github.com/mrcjkb/rustaceanvim/compare/v5.15.2...v5.15.3) (2024-11-27) From 03623143c2cd9fa54c9769702c458b087c5b9863 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Fri, 29 Nov 2024 23:07:28 +0100 Subject: [PATCH 80/84] feat(lsp): info log when starting client in standalone mode --- lua/rustaceanvim/lsp/init.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lua/rustaceanvim/lsp/init.lua b/lua/rustaceanvim/lsp/init.lua index 96774bf7..c8f2cc70 100644 --- a/lua/rustaceanvim/lsp/init.lua +++ b/lua/rustaceanvim/lsp/init.lua @@ -167,7 +167,14 @@ M.start = function(bufnr) local lsp_start_config = vim.tbl_deep_extend('force', {}, client_config) local root_dir = cargo.get_config_root_dir(client_config, bufname) if not root_dir then - --- No project root found. Start in detached/standalone mode. + vim.notify( + [[ +rustaceanvim: +No project root found. +Starting rust-analyzer client in detached/standalone mode (with reduced functionality). +]], + vim.log.levels.INFO + ) root_dir = vim.fs.dirname(bufname) lsp_start_config.init_options = { detachedFiles = { bufname } } end From 4ac7a3c6cca9e393229651cc90733afbdc7c6395 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Fri, 29 Nov 2024 23:18:38 +0100 Subject: [PATCH 81/84] fix(lsp): fall back to default offset encoding if not set --- ftplugin/rust.lua | 2 +- lua/rustaceanvim/commands/code_action_group.lua | 4 ++-- lua/rustaceanvim/commands/expand_macro.lua | 9 ++------- lua/rustaceanvim/commands/external_docs.lua | 2 +- lua/rustaceanvim/commands/hover_range.lua | 2 +- lua/rustaceanvim/commands/join_lines.lua | 6 +++--- lua/rustaceanvim/commands/move_item.lua | 8 ++++++-- lua/rustaceanvim/commands/open_cargo_toml.lua | 2 +- lua/rustaceanvim/commands/parent_module.lua | 4 ++-- lua/rustaceanvim/commands/ssr.lua | 8 ++++---- lua/rustaceanvim/commands/syntax_tree.lua | 2 +- lua/rustaceanvim/commands/view_ir.lua | 2 +- lua/rustaceanvim/compat.lua | 4 ++-- lua/rustaceanvim/hover_actions.lua | 2 +- lua/rustaceanvim/lsp/init.lua | 2 +- lua/rustaceanvim/runnables.lua | 2 +- 16 files changed, 30 insertions(+), 31 deletions(-) diff --git a/ftplugin/rust.lua b/ftplugin/rust.lua index 24e903d9..5b8a92dc 100644 --- a/ftplugin/rust.lua +++ b/ftplugin/rust.lua @@ -23,7 +23,7 @@ if not vim.g.loaded_rustaceanvim then vim.lsp.commands['rust-analyzer.gotoLocation'] = function(command, ctx) local client = vim.lsp.get_client_by_id(ctx.client_id) if client then - compat.show_document(command.arguments[1], client.offset_encoding) + compat.show_document(command.arguments[1], client.offset_encoding or 'utf-8') end end diff --git a/lua/rustaceanvim/commands/code_action_group.lua b/lua/rustaceanvim/commands/code_action_group.lua index 555f3f53..6603958c 100644 --- a/lua/rustaceanvim/commands/code_action_group.lua +++ b/lua/rustaceanvim/commands/code_action_group.lua @@ -20,7 +20,7 @@ local M = {} ---@param ctx table function M.apply_action(action, client, ctx) if action.edit then - vim.lsp.util.apply_workspace_edit(action.edit, client.offset_encoding) + vim.lsp.util.apply_workspace_edit(action.edit, client.offset_encoding or 'utf-8') end if action.command then local command = type(action.command) == 'table' and action.command or action @@ -383,7 +383,7 @@ M.code_action_group = function() if #clients == 0 then return end - local params = vim.lsp.util.make_range_params(0, clients[1].offset_encoding) + local params = vim.lsp.util.make_range_params(0, clients[1].offset_encoding or 'utf-8') ---@diagnostic disable-next-line: inject-field params.context = context diff --git a/lua/rustaceanvim/commands/expand_macro.lua b/lua/rustaceanvim/commands/expand_macro.lua index a403f81b..cbb7536a 100644 --- a/lua/rustaceanvim/commands/expand_macro.lua +++ b/lua/rustaceanvim/commands/expand_macro.lua @@ -2,12 +2,6 @@ local ui = require('rustaceanvim.ui') local M = {} ----@return lsp_position_params ----@param offset_encoding 'utf-8'|'utf-16'|'utf-32' -local function get_params(offset_encoding) - return vim.lsp.util.make_position_params(0, offset_encoding) -end - ---@type integer | nil local latest_buf_id = nil @@ -78,7 +72,8 @@ function M.expand_macro() if #clients == 0 then return end - ra.buf_request(0, 'rust-analyzer/expandMacro', get_params(clients[1].offset_encoding), handler) + local params = vim.lsp.util.make_position_params(0, clients[1].offset_encoding or 'utf-8') + ra.buf_request(0, 'rust-analyzer/expandMacro', params, handler) end return M.expand_macro diff --git a/lua/rustaceanvim/commands/external_docs.lua b/lua/rustaceanvim/commands/external_docs.lua index 98764c81..41a43404 100644 --- a/lua/rustaceanvim/commands/external_docs.lua +++ b/lua/rustaceanvim/commands/external_docs.lua @@ -9,7 +9,7 @@ function M.open_external_docs() ra.buf_request( 0, 'experimental/externalDocs', - vim.lsp.util.make_position_params(0, clients[1].offset_encoding), + vim.lsp.util.make_position_params(0, clients[1].offset_encoding or 'utf-8'), function(_, url) if url then local config = require('rustaceanvim.config.internal') diff --git a/lua/rustaceanvim/commands/hover_range.lua b/lua/rustaceanvim/commands/hover_range.lua index ae0c8eb0..7554035b 100644 --- a/lua/rustaceanvim/commands/hover_range.lua +++ b/lua/rustaceanvim/commands/hover_range.lua @@ -48,7 +48,7 @@ function M.hover_range() if #clients == 0 then return end - local params = vim.lsp.util.make_range_params(0, clients[1].offset_encoding) + local params = vim.lsp.util.make_range_params(0, clients[1].offset_encoding or 'utf-8') ---@diagnostic disable-next-line: inject-field params.position = get_visual_selected_range() params.range = nil diff --git a/lua/rustaceanvim/commands/join_lines.lua b/lua/rustaceanvim/commands/join_lines.lua index 1cc8d8a7..6cb8ab4c 100644 --- a/lua/rustaceanvim/commands/join_lines.lua +++ b/lua/rustaceanvim/commands/join_lines.lua @@ -12,7 +12,7 @@ local function modify_params(params) end local function handler(_, result, ctx) - vim.lsp.util.apply_text_edits(result, ctx.bufnr, vim.lsp.get_client_by_id(ctx.client_id).offset_encoding) + vim.lsp.util.apply_text_edits(result, ctx.bufnr, vim.lsp.get_client_by_id(ctx.client_id).offset_encoding or 'utf-8') end local ra = require('rustaceanvim.rust_analyzer') @@ -24,7 +24,7 @@ function M.join_lines_visual() if #clients == 0 then return end - local params = modify_params(vim.lsp.util.make_given_range_params(nil, nil, 0, clients[1].offset_encoding)) + local params = modify_params(vim.lsp.util.make_given_range_params(nil, nil, 0, clients[1].offset_encoding or 'utf-8')) ra.buf_request(0, 'experimental/joinLines', params, handler) end @@ -35,7 +35,7 @@ function M.join_lines() if #clients == 0 then return end - local params = modify_params(vim.lsp.util.make_range_params(0, clients[1].offset_encoding)) + local params = modify_params(vim.lsp.util.make_range_params(0, clients[1].offset_encoding or 'utf-8')) ra.buf_request(0, 'experimental/joinLines', params, handler) end diff --git a/lua/rustaceanvim/commands/move_item.lua b/lua/rustaceanvim/commands/move_item.lua index 3d1b18ca..8a44931d 100644 --- a/lua/rustaceanvim/commands/move_item.lua +++ b/lua/rustaceanvim/commands/move_item.lua @@ -41,7 +41,11 @@ local function handler(_, text_edits, ctx) local cursor = extract_cursor_position(text_edits) local overrides = require('rustaceanvim.overrides') overrides.snippet_text_edits_to_text_edits(text_edits) - vim.lsp.util.apply_text_edits(text_edits, ctx.bufnr, vim.lsp.get_client_by_id(ctx.client_id).offset_encoding) + vim.lsp.util.apply_text_edits( + text_edits, + ctx.bufnr, + vim.lsp.get_client_by_id(ctx.client_id).offset_encoding or 'utf-8' + ) vim.api.nvim_win_set_cursor(0, cursor) end @@ -53,7 +57,7 @@ function M.move_item(direction) if #clients == 0 then return end - local params = vim.lsp.util.make_range_params(0, clients[1].offset_encoding) + local params = vim.lsp.util.make_range_params(0, clients[1].offset_encoding or 'utf-8') ---@diagnostic disable-next-line: inject-field params.direction = direction ra.buf_request(0, 'experimental/moveItem', params, handler) diff --git a/lua/rustaceanvim/commands/open_cargo_toml.lua b/lua/rustaceanvim/commands/open_cargo_toml.lua index 904dbb97..817fd878 100644 --- a/lua/rustaceanvim/commands/open_cargo_toml.lua +++ b/lua/rustaceanvim/commands/open_cargo_toml.lua @@ -15,7 +15,7 @@ local function handler(_, result, ctx) local client = vim.lsp.get_client_by_id(ctx.client_id) if client then - compat.show_document(result, client.offset_encoding) + compat.show_document(result, client.offset_encoding or 'utf-8') end end diff --git a/lua/rustaceanvim/commands/parent_module.lua b/lua/rustaceanvim/commands/parent_module.lua index 12294b87..56127253 100644 --- a/lua/rustaceanvim/commands/parent_module.lua +++ b/lua/rustaceanvim/commands/parent_module.lua @@ -16,7 +16,7 @@ local function handler(_, result, ctx) local client = vim.lsp.get_client_by_id(ctx.client_id) if client then - compat.show_document(location, client.offset_encoding) + compat.show_document(location, client.offset_encoding or 'utf-8') end end @@ -27,7 +27,7 @@ function M.parent_module() if #clients == 0 then return end - local params = vim.lsp.util.make_position_params(0, clients[1].offset_encoding) + local params = vim.lsp.util.make_position_params(0, clients[1].offset_encoding or 'utf-8') ra.buf_request(0, 'experimental/parentModule', params, handler) end diff --git a/lua/rustaceanvim/commands/ssr.lua b/lua/rustaceanvim/commands/ssr.lua index 7e1e8fee..4eee1085 100644 --- a/lua/rustaceanvim/commands/ssr.lua +++ b/lua/rustaceanvim/commands/ssr.lua @@ -19,7 +19,7 @@ local function handler(err, result, ctx) local client = vim.lsp.get_client_by_id(ctx.client_id) if client then - vim.lsp.util.apply_workspace_edit(result, client.offset_encoding) + vim.lsp.util.apply_workspace_edit(result, client.offset_encoding or 'utf-8') end end @@ -30,8 +30,8 @@ local function ssr(query, make_range_params) if #clients == 0 then return end - local params = vim.lsp.util.make_position_params(0, clients[1].offset_encoding) - local range = make_range_params(0, clients[1].offset_encoding).range + local params = vim.lsp.util.make_position_params(0, clients[1].offset_encoding or 'utf-8') + local range = make_range_params(0, clients[1].offset_encoding or 'utf-8').range if not query then vim.ui.input({ prompt = 'Enter query: ' }, function(input) query = input @@ -51,7 +51,7 @@ end ---@param query string | nil function M.ssr_visual(query) ssr(query, function(winnr, offset_encoding) - return vim.lsp.util.make_given_range_params(nil, nil, winnr, offset_encoding) + return vim.lsp.util.make_given_range_params(nil, nil, winnr, offset_encoding or 'utf-8') end) end diff --git a/lua/rustaceanvim/commands/syntax_tree.lua b/lua/rustaceanvim/commands/syntax_tree.lua index 7571d8f1..51a21754 100644 --- a/lua/rustaceanvim/commands/syntax_tree.lua +++ b/lua/rustaceanvim/commands/syntax_tree.lua @@ -30,7 +30,7 @@ function M.syntax_tree() if #clients == 0 then return end - local params = vim.lsp.util.make_range_params(0, clients[1].offset_encoding) + local params = vim.lsp.util.make_range_params(0, clients[1].offset_encoding or 'utf-8') ra.buf_request(0, 'rust-analyzer/syntaxTree', params, handler) end diff --git a/lua/rustaceanvim/commands/view_ir.lua b/lua/rustaceanvim/commands/view_ir.lua index 7471a61f..4f588a90 100644 --- a/lua/rustaceanvim/commands/view_ir.lua +++ b/lua/rustaceanvim/commands/view_ir.lua @@ -46,7 +46,7 @@ function M.viewIR(level) if #clients == 0 then return end - local position_params = vim.lsp.util.make_position_params(0, clients[1].offset_encoding) + local position_params = vim.lsp.util.make_position_params(0, clients[1].offset_encoding or 'utf-8') rl.buf_request(0, 'rust-analyzer/view' .. level, position_params, function(...) return handler(level, ...) end) diff --git a/lua/rustaceanvim/compat.lua b/lua/rustaceanvim/compat.lua index 46138181..e4a57d28 100644 --- a/lua/rustaceanvim/compat.lua +++ b/lua/rustaceanvim/compat.lua @@ -23,9 +23,9 @@ end function compat.show_document(location, offset_encoding) local show_document = vim.lsp.show_document if not show_document then - return vim.lsp.util.jump_to_location(location, offset_encoding) + return vim.lsp.util.jump_to_location(location, offset_encoding or 'utf-8') end - return show_document(location, offset_encoding, { focus = true }) + return show_document(location, offset_encoding or 'utf-8', { focus = true }) end --- @param client vim.lsp.Client diff --git a/lua/rustaceanvim/hover_actions.lua b/lua/rustaceanvim/hover_actions.lua index a84c5fcd..9967df7c 100644 --- a/lua/rustaceanvim/hover_actions.lua +++ b/lua/rustaceanvim/hover_actions.lua @@ -143,7 +143,7 @@ function M.hover_actions() if #clients == 0 then return end - local params = lsp_util.make_position_params(0, clients[1].offset_encoding) + local params = lsp_util.make_position_params(0, clients[1].offset_encoding or 'utf-8') ra.buf_request(0, 'textDocument/hover', params, M.handler) end diff --git a/lua/rustaceanvim/lsp/init.lua b/lua/rustaceanvim/lsp/init.lua index c8f2cc70..ab1b207d 100644 --- a/lua/rustaceanvim/lsp/init.lua +++ b/lua/rustaceanvim/lsp/init.lua @@ -15,7 +15,7 @@ local function override_apply_text_edits() vim.lsp.util.apply_text_edits = function(edits, bufnr, offset_encoding) local overrides = require('rustaceanvim.overrides') overrides.snippet_text_edits_to_text_edits(edits) - old_func(edits, bufnr, offset_encoding) + old_func(edits, bufnr, offset_encoding or 'utf-8') end end diff --git a/lua/rustaceanvim/runnables.lua b/lua/rustaceanvim/runnables.lua index 519532fe..8cc0faf7 100644 --- a/lua/rustaceanvim/runnables.lua +++ b/lua/rustaceanvim/runnables.lua @@ -191,7 +191,7 @@ function M.get_runnable_at_cursor_position(runnables) return end ---@type lsp.Position - local position = vim.lsp.util.make_position_params(0, clients[1].offset_encoding).position + local position = vim.lsp.util.make_position_params(0, clients[1].offset_encoding or 'utf-8').position ---@type integer|nil, integer|nil local choice, fallback for idx, runnable in ipairs(runnables) do From 40c2e3de6e96464d6562880a005581e23dd197e3 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Mon, 2 Dec 2024 21:10:08 +0100 Subject: [PATCH 82/84] tests: fix broken test case --- spec/lsp_spec.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/spec/lsp_spec.lua b/spec/lsp_spec.lua index 7c73d492..ea02f115 100644 --- a/spec/lsp_spec.lua +++ b/spec/lsp_spec.lua @@ -1,8 +1,13 @@ --- load RustAnalyzer command -require('rustaceanvim.lsp') - local stub = require('luassert.stub') describe('LSP client API', function() + vim.g.rustaceanvim = { + server = { + -- Prevent start in detached mode + root_dir = vim.fn.tempname(), + }, + } + -- load RustAnalyzer command + require('rustaceanvim.lsp') local RustaceanConfig = require('rustaceanvim.config.internal') local Types = require('rustaceanvim.types.internal') local ra_bin = Types.evaluate(RustaceanConfig.server.cmd)[1] From 236b476f4d48f212675aeeb7618a0487d9785ba8 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Mon, 2 Dec 2024 21:15:15 +0100 Subject: [PATCH 83/84] chore: update flake.lock (#598) Co-authored-by: github-actions[bot] --- flake.lock | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/flake.lock b/flake.lock index 51603447..c989f8d1 100644 --- a/flake.lock +++ b/flake.lock @@ -19,11 +19,11 @@ "flake-compat_2": { "flake": false, "locked": { - "lastModified": 1696426674, - "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "lastModified": 1732722421, + "narHash": "sha256-HRJ/18p+WoXpWJkcdsk9St5ZiukCqSDgbOGFa8Okehg=", "owner": "edolstra", "repo": "flake-compat", - "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "rev": "9ed2ac151eada2306ca8c418ebd97807bb08f6ac", "type": "github" }, "original": { @@ -51,11 +51,11 @@ "flake-compat_4": { "flake": false, "locked": { - "lastModified": 1696426674, - "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "lastModified": 1732722421, + "narHash": "sha256-HRJ/18p+WoXpWJkcdsk9St5ZiukCqSDgbOGFa8Okehg=", "owner": "edolstra", "repo": "flake-compat", - "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "rev": "9ed2ac151eada2306ca8c418ebd97807bb08f6ac", "type": "github" }, "original": { @@ -506,11 +506,11 @@ "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1732253278, - "narHash": "sha256-/ONdyXzZ0dK+GlV6lKq9+efY0BsXxUJ2cQp5LbL0MVA=", + "lastModified": 1732944430, + "narHash": "sha256-RxJyXmeLMxwlkkDynaHOy/rrYNuIK61R/nbzoUH2xlM=", "owner": "nvim-neorocks", "repo": "neorocks", - "rev": "76c80c100d549c0674cf2d6721cf27cc44412e65", + "rev": "f7fe2c43b5bf0c8840963d96dda1fe65e963ade8", "type": "github" }, "original": { @@ -529,11 +529,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1732234033, - "narHash": "sha256-94yZ7eJiLvW+UknI5RZBCV6OMHtoSv1oWyOwKjTmS88=", + "lastModified": 1732925246, + "narHash": "sha256-MjqyzOEa6s9OGO8SMh5C2kqo57+iSNsgDbzPBbpi4QU=", "owner": "nix-community", "repo": "neovim-nightly-overlay", - "rev": "10e11c32a4f4f7c9d64f45413642ded11fc538b6", + "rev": "7461a0b228bb48bb02af086f8b9ee9a83583120b", "type": "github" }, "original": { @@ -545,11 +545,11 @@ "neovim-src": { "flake": false, "locked": { - "lastModified": 1732229552, - "narHash": "sha256-7tA7IeOjx1wgDQnY7RxIhIuwcFeSZu4Yc3WtLh+22TE=", + "lastModified": 1732903628, + "narHash": "sha256-JF8zmoLdqmbKCSS5Smf/Yj0jEl5f+qKhSubhPo/BvUM=", "owner": "neovim", "repo": "neovim", - "rev": "ff75f345ab5fa57c6560db021e8eb099aff90472", + "rev": "2833925cfc688786759d6a980a1ad62b62d20570", "type": "github" }, "original": { @@ -704,11 +704,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1731890469, - "narHash": "sha256-D1FNZ70NmQEwNxpSSdTXCSklBH1z2isPR84J6DQrJGs=", + "lastModified": 1732617236, + "narHash": "sha256-PYkz6U0bSEaEB1al7O1XsqVNeSNS+s3NVclJw7YC43w=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "5083ec887760adfe12af64830a66807423a859a7", + "rev": "af51545ec9a44eadf3fe3547610a5cdd882bc34e", "type": "github" }, "original": { @@ -720,11 +720,11 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1731890469, - "narHash": "sha256-D1FNZ70NmQEwNxpSSdTXCSklBH1z2isPR84J6DQrJGs=", + "lastModified": 1732780316, + "narHash": "sha256-NskLIz0ue4Uqbza+1+8UGHuPVr8DrUiLfZu5VS4VQxw=", "owner": "nixos", "repo": "nixpkgs", - "rev": "5083ec887760adfe12af64830a66807423a859a7", + "rev": "226216574ada4c3ecefcbbec41f39ce4655f78ef", "type": "github" }, "original": { @@ -736,11 +736,11 @@ }, "nixpkgs_5": { "locked": { - "lastModified": 1731890469, - "narHash": "sha256-D1FNZ70NmQEwNxpSSdTXCSklBH1z2isPR84J6DQrJGs=", + "lastModified": 1732937961, + "narHash": "sha256-B5pYT+IVaqcrfOekkwKvx/iToDnuQWzc2oyDxzzBDc4=", "owner": "nixos", "repo": "nixpkgs", - "rev": "5083ec887760adfe12af64830a66807423a859a7", + "rev": "4703b8d2c708e13a8cab03d865f90973536dcdf5", "type": "github" }, "original": { From 9032904f60bd01cab22cf0291d2f5832277618b8 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Mon, 2 Dec 2024 21:15:22 +0100 Subject: [PATCH 84/84] chore(master): release 5.16.0 (#597) --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 396cf01f..2106cd46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [5.16.0](https://github.com/mrcjkb/rustaceanvim/compare/v5.15.4...v5.16.0) (2024-12-02) + + +### Features + +* **lsp:** info log when starting client in standalone mode ([0362314](https://github.com/mrcjkb/rustaceanvim/commit/03623143c2cd9fa54c9769702c458b087c5b9863)) + + +### Bug Fixes + +* **lsp:** fall back to default offset encoding if not set ([4ac7a3c](https://github.com/mrcjkb/rustaceanvim/commit/4ac7a3c6cca9e393229651cc90733afbdc7c6395)) + ## [5.15.4](https://github.com/mrcjkb/rustaceanvim/compare/v5.15.3...v5.15.4) (2024-11-29)