piersolenski / telescope-import.nvim

Import modules with ease
189 stars 7 forks source link

Feat: c / cpp #3

Closed Dimfred closed 1 year ago

Dimfred commented 1 year ago

Hey I have played around with the C++ integration. This is what I do in the config part to achieve this. Before submitting a PR I would like to test it a bit in the field. But for anyone interested, guess you could also try using it.

{
    "piersolenski/telescope-import.nvim",
    dependencies = { "nvim-telescope/telescope.nvim" },
    config = function()
        local fts = require("import.filetypes")
        table.insert(fts, {
            regex = [[^(?:#include <.*>)]],
            filetypes = { "c", "cpp" },
            extensions = { "h", "c", "cpp" },
        })

        require("telescope").load_extension("import")
    end,
}

@piersolenski I tried also putting hpp, and cpp into extensions, which kinda tells me: unrecognized file type: hpp, not sure why? I guess the extensions, are filter params forwarded to rg right? In general it seems to work with h and c, will test it more over the next days.

EDIT: okay saw the rg --type-list that hpp is part of h, tho cpp should also be included.

Btw thanks for the plugin, wanted something like this for a long time <3

piersolenski commented 1 year ago

Hey, glad you're enjoying it so far! Initially I was wondering whether to make it so you could easily add custom filetypes via the API, however I wanted to encourage people to create PRs to grow the amount of language support. Maybe this would still be useful for testing purposes 🤔 Either way, kudos for finding a way around it! 😉 I've added your code to filetypes, C++ is now officially supported. Thanks for the issue!

Dimfred commented 1 year ago

I discovered some things over the weeks, will create a PR to fix that ;) Thanks for putting it in tho.