mrcjkb / rustaceanvim

🦀 Supercharge your Rust experience in Neovim! A heavily modified fork of rust-tools.nvim
GNU General Public License v2.0
1.79k stars 69 forks source link

Project fails to run and debug when the file path contains space #212

Closed absarrahman closed 9 months ago

absarrahman commented 9 months ago

Neovim version (nvim -v)

v0.9.4

Operating system/version

Mac OS 14.3

Output of :checkhealth rustaceanvim

Checking for Lua dependencies ~
- OK [mfussenegger/nvim-dap](https://github.com/mfussenegger/nvim-dap) installed.

Checking external dependencies ~
- OK rust-analyzer: found rust-analyzer 1.75.0 (82e1608d 2023-12-21)
- OK Cargo: found cargo 1.75.0 (1d8b05cdd 2023-11-20)
- OK rustc: found rustc 1.75.0 (82e1608df 2023-12-21)
- OK debug adapter: found codelldb 

Checking config ~
- OK No errors found in config.

Checking for conflicting plugins ~
- OK No conflicting plugins detected.

Checking for tree-sitter parser ~
- OK tree-sitter parser for Rust detected.

How to reproduce the issue

mkdir "test is test" && cd $_
cargo new foo
cd foo
nvim .
:RustLsp runnables
1: run foo

Expected behaviour

Hello World

Actual behaviour

zsh:cd:1: too many arguments

[Process exited 1]

The minimal config used to reproduce this issue.

{
        "mrcjkb/rustaceanvim",
        ft = "rust",
        config = function()
            vim.g.rustaceanvim = function()
                local mason_registry = require("mason-registry")

                -- Need codelldb dap from mason
                local codelldb = mason_registry.get_package("codelldb")
                local extension_path = codelldb:get_install_path() .. "/extension/"
                local codelldb_path = extension_path .. "adapter/codelldb"
                local liblldb_path = extension_path .. "lldb/lib/liblldb.dylib"
                return {
                    dap = {
                        adapter = require('rustaceanvim.config').get_codelldb_adapter(codelldb_path, liblldb_path),
                    },

                    server = {
                        on_attach = function(_, bufnr)
                            vim.lsp.inlay_hint.enable(bufnr, true)
                            vim.keymap.set("n", "K", "<cmd>RustLSP hover actions<cr>", { buffer = bufnr })
                            -- Code action groups
                            vim.keymap.set("n", "<Leader>vca", "<cmd>RustLsp codeAction<cr>", { buffer = bufnr })
                            vim.keymap.set(
                                "n",
                                "<leader>dr",
                                "<cmd>RustLsp debuggables<cr>",
                                { desc = "Run Debuggables (Rust)" }
                            )
                        end,
                        settings = {
                            -- rust-analyzer language server configuration
                            ["rust-analyzer"] = {
                                cargo = {
                                    allFeatures = true,
                                    loadOutDirsFromCheck = true,
                                    runBuildScripts = true,
                                },
                                -- Add clippy lints for Rust.
                                checkOnSave = {
                                    allFeatures = true,
                                    command = "clippy",
                                    extraArgs = { "--no-deps" },
                                },
                                procMacro = {
                                    enable = true,
                                    ignored = {
                                        ["async-trait"] = { "async_trait" },
                                        ["napi-derive"] = { "napi" },
                                        ["async-recursion"] = { "async_recursion" },
                                    },
                                },
                            },
                        },
                    },
                    tools = {
                        on_initialized = function()
                            vim.cmd([[
                  augroup RustLSP
                    autocmd CursorHold                      *.rs silent! lua vim.lsp.buf.document_highlight()
                    autocmd CursorMoved,InsertEnter         *.rs silent! lua vim.lsp.buf.clear_references()
                    autocmd BufEnter,CursorHold,InsertLeave *.rs silent! lua vim.lsp.codelens.refresh()
                  augroup END
                ]])
                        end,
                    },
                }
            end
        end
    },
absarrahman commented 9 months ago

Screenshot 2024-02-06 at 6 05 00 PM

The project runs and debugs fine if your project directory path does not contain any spaces

absarrahman commented 9 months ago

I have fixed this issue for RustLsp runnables and it is working fine. However, I am not sure how to fix the debugging issue.

This is the commit which I did for the fix https://github.com/absarrahman/rustaceanvim/commit/ee0cb377875d43e444908600a513e465785cfc3e