From cb797dc785de2f18e4c84aaa7940946e26bd6cf5 Mon Sep 17 00:00:00 2001 From: Amaan Q Date: Mon, 9 Jan 2023 19:23:02 -0500 Subject: [PATCH 1/5] feat(lang): added extra for c/c++ --- lua/lazyvim/plugins/extras/lang/clangd.lua | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 lua/lazyvim/plugins/extras/lang/clangd.lua diff --git a/lua/lazyvim/plugins/extras/lang/clangd.lua b/lua/lazyvim/plugins/extras/lang/clangd.lua new file mode 100644 index 00000000..6fff218a --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/clangd.lua @@ -0,0 +1,58 @@ +return { + + -- add c/c++ to treesitter + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + vim.list_extend(opts.ensure_installed, { "c", "cpp" }) + end, + }, + + -- correctly setup lspconfig + { + "neovim/nvim-lspconfig", + dependencies = { + "p00f/clangd_extensions.nvim", + dependencies = { + "hrsh7th/cmp-nvim-lsp", + }, + }, + opts = { + -- make sure mason installs the server + servers = { + clangd = {}, + }, + setup = { + clangd = function(_, opts) + require("clangd_extensions").setup({ + server = opts, + extensions = { + ast = { + --These require codicons (https://github.com/microsoft/vscode-codicons) + role_icons = { + type = "", + declaration = "", + expression = "", + specifier = "", + statement = "", + ["template argument"] = "", + }, + + kind_icons = { + Compound = "", + Recovery = "", + TranslationUnit = "", + PackExpansion = "", + TemplateTypeParm = "", + TemplateTemplateParm = "", + TemplateParamObject = "", + }, + }, + }, + }) + return true + end, + }, + }, + }, +} From acf52ae84ba31c7a30652f35794d7c1e7fc88965 Mon Sep 17 00:00:00 2001 From: Amaan Q Date: Mon, 9 Jan 2023 19:23:11 -0500 Subject: [PATCH 2/5] feat(lang): added extras for rust --- lua/lazyvim/plugins/extras/lang/rust.lua | 66 ++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 lua/lazyvim/plugins/extras/lang/rust.lua diff --git a/lua/lazyvim/plugins/extras/lang/rust.lua b/lua/lazyvim/plugins/extras/lang/rust.lua new file mode 100644 index 00000000..d643e4d3 --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/rust.lua @@ -0,0 +1,66 @@ +return { + + -- add rust to treesitter + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + table.insert(opts.ensure_installed, "rust") + end, + }, + + -- correctly setup lspconfig for Rust 🚀 + { + "neovim/nvim-lspconfig", + dependencies = { + "simrat39/rust-tools.nvim", + init = function() + require("lazyvim.util").on_attach(function(_, buffer) + -- stylua: ignore + vim.keymap.set("n", "", "RustHoverActions", { buffer = buffer, desc = "Hover Actions (Rust)" }) + vim.keymap.set("n", "a", "RustCodeActionGroup", { buffer = buffer, desc = "Code Action (Rust)" }) + end) + end, + }, + opts = { + servers = { + rust_analyzer = { + settings = { + ["rust-analyzer"] = { + cargo = { + allFeatures = true, + }, + checkOnSave = { + allFeatures = true, + command = "clippy", + extraArgs = { "--no-deps" }, + }, + procMacro = { + ignored = { + ["async-trait"] = { "async_trait" }, + ["napi-derive"] = { "napi" }, + ["async-recursion"] = { "async_recursion" }, + }, + }, + }, + }, + }, + }, + setup = { + rust_analyzer = function(_, opts) + local rust_opts = { + server = vim.tbl_deep_extend("force", {}, opts, opts.server or {}), + tools = { -- rust-tools options + -- options same as lsp hover / vim.lsp.util.open_floating_preview() + hover_actions = { + -- whether the hover action window gets automatically focused + auto_focus = true, + }, + }, + } + require("rust-tools").setup(rust_opts) + return true + end, + }, + }, + }, +} From 2d4fe35af183d87ce271afa1480446c105bedfdf Mon Sep 17 00:00:00 2001 From: Amaan Q Date: Mon, 9 Jan 2023 19:28:12 -0500 Subject: [PATCH 3/5] fix: stops notif "warning: multiple different client offset_encodings detected for buffer, this is not supported yet" with c/c++ lsps --- lua/lazyvim/plugins/lsp/init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/lazyvim/plugins/lsp/init.lua b/lua/lazyvim/plugins/lsp/init.lua index 518c89ee..1f5142f3 100644 --- a/lua/lazyvim/plugins/lsp/init.lua +++ b/lua/lazyvim/plugins/lsp/init.lua @@ -70,6 +70,7 @@ return { local servers = opts.servers local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) + capabilities.offsetEncoding = { "utf-16" } require("mason-lspconfig").setup({ ensure_installed = vim.tbl_keys(servers) }) require("mason-lspconfig").setup_handlers({ From 7bd91b782a46bf6a5aae63ddea2097459dc30c35 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 10 Jan 2023 00:30:20 +0000 Subject: [PATCH 4/5] chore(build): auto-generate vimdoc --- doc/LazyVim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index 01aaf9e7..51026b9e 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 January 09 +*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 January 10 ============================================================================== Table of Contents *LazyVim-table-of-contents* From c9c6bc56f03605b349ffa6ceb95ab2aba34db661 Mon Sep 17 00:00:00 2001 From: Amaan Q Date: Tue, 10 Jan 2023 14:08:55 -0500 Subject: [PATCH 5/5] refactor(rust-tools): check for client name and use different keymaps to not interfere with cmp for --- lua/lazyvim/plugins/extras/lang/rust.lua | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lua/lazyvim/plugins/extras/lang/rust.lua b/lua/lazyvim/plugins/extras/lang/rust.lua index d643e4d3..5b35419b 100644 --- a/lua/lazyvim/plugins/extras/lang/rust.lua +++ b/lua/lazyvim/plugins/extras/lang/rust.lua @@ -11,16 +11,7 @@ return { -- correctly setup lspconfig for Rust 🚀 { "neovim/nvim-lspconfig", - dependencies = { - "simrat39/rust-tools.nvim", - init = function() - require("lazyvim.util").on_attach(function(_, buffer) - -- stylua: ignore - vim.keymap.set("n", "", "RustHoverActions", { buffer = buffer, desc = "Hover Actions (Rust)" }) - vim.keymap.set("n", "a", "RustCodeActionGroup", { buffer = buffer, desc = "Code Action (Rust)" }) - end) - end, - }, + dependencies = { "simrat39/rust-tools.nvim" }, opts = { servers = { rust_analyzer = { @@ -47,6 +38,13 @@ return { }, setup = { rust_analyzer = function(_, opts) + require("lazyvim.util").on_attach(function(client, buffer) + if client.name == "rust_analyzer" then + -- stylua: ignore + vim.keymap.set("n", "co", "RustHoverActions", { buffer = buffer, desc = "Hover Actions (Rust)" }) + vim.keymap.set("n", "cR", "RustCodeActionGroup", { buffer = buffer, desc = "Code Action (Rust)" }) + end + end) local rust_opts = { server = vim.tbl_deep_extend("force", {}, opts, opts.server or {}), tools = { -- rust-tools options