Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add code snippet to show features popup and documentation with crates.nvim #527

Open
1 task done
KaminariOS opened this issue Jan 5, 2025 · 0 comments
Open
1 task done

Comments

@KaminariOS
Copy link

⚠️ Please verify that this feature request has NOT been suggested before.

  • I checked and didn't find a similar feature request

🏷️ Feature Type

New Command

🔖 Feature description

See lua code

✔️ Solution

    local crates = require('crates')
    local opts = { silent = true }
    crates.setup {
      null_ls = {
        enabled = ${boolToString cfg.crates.codeActions},
        name = "crates.nvim",
      }
    }
    local function show_documentation()
        local filetype = vim.bo.filetype
        if filetype == "vim" or filetype == "help" then
            vim.cmd('h '..vim.fn.expand('<cword>'))
        elseif filetype == "man" then
            vim.cmd('Man '..vim.fn.expand('<cword>'))
        elseif vim.fn.expand('%:t') == 'Cargo.toml' and require('crates').popup_available() then
            crates.show_popup()
        else
            vim.lsp.buf.hover()
        end
    end
    vim.keymap.set("n", "<leader>cf", crates.show_features_popup, opts)
    vim.keymap.set('n', 'K', show_documentation, opts)

❓ Alternatives

No response

📝 Additional Context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant