From a503d05212bf2ae2f5feb788e371c5cbddd100e5 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Sat, 27 Jan 2024 12:20:23 +0100 Subject: [PATCH] perf: don't run `ftplugin/rust.lua` more than once per buffer --- CHANGELOG.md | 11 ++++++++--- ftplugin/rust.lua | 7 +++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c040c2c..5311e22e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,15 +6,20 @@ 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] +## [4.0.1] - 2024-01-27 ### Fixed -- LSP: Only setup `vim.lsp.commands` for rust-analyzer on the first - initialization. - LSP: Fix resetting client state on `:RustAnalyzer stop` if only one client is attached. +### Performance + +- Only setup `vim.lsp.commands` for rust-analyzer on the first + initialization. +- Don't run `ftplugin/rust.lua` more than once on the same + buffer. + ## [4.0.0] - 2024-01-25 ### BREAKING CHANGES diff --git a/ftplugin/rust.lua b/ftplugin/rust.lua index 59152915..c34c5306 100644 --- a/ftplugin/rust.lua +++ b/ftplugin/rust.lua @@ -1,3 +1,8 @@ +local bufnr = vim.api.nvim_get_current_buf() +if vim.b[bufnr].did_rustaceanvim_ftplugin then + return +end + ---@type RustaceanConfig local config = require('rustaceanvim.config.internal') local types = require('rustaceanvim.types.internal') @@ -42,3 +47,5 @@ if not auto_attach then end lsp.start() + +vim.b[bufnr].did_rustaceanvim_ftplugin = true