glacambre / firenvim

Embed Neovim in Chrome, Firefox & others.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Possible to set colorscheme based on url/domain?

benlieb opened this issue · comments

I'd like to be able to set colorscheme and potentially other things based on url.

Is this possible?

Yes, this is described in the section about using different settings depending on the page/element being edited. Let me know if it answers your question, if it doesn't I'll provide additional details :)

I read that but it doesn't say explicitly how to run vim config by url. Those config options seem to be firenvim specific, not vim config or vimscript/lua.

Are you saying I can put vim-specific config in here?

vim.g.firenvim_config = {
    localSettings = {
        [".*"] = {
            colorscheme = "torte",
            spell = true,
        }
    }
}

In my local config I'm detecting firenvim this way:

if vim.g.started_by_firenvim == true then
  vim.cmd.colorscheme "whitebox"
  vim.opt.guifont = { "Monaco", "h12" }
end

But some per-url config would be lovely. Mostly for now light/dark colorschemes to match light/dark themed websites.

Thanks for your help!

Are you saying I can put vim-specific config in here?

No, as explained in the documentation the URL of the website is encoded into the buffer's name. This means you can create autocommands that match different buffer names in order to apply different settings to different websites and this is what the snippet of code linked does.

I read that but it doesn't say explicitly how to run vim config by url.

Actually, it does, or at least tries to. Here's the important part of the link I gave you:

If you want to use different settings depending on the textarea you're currently editing, you can use autocommands to do that too. All buffers are named like this: domainname_page_selector.txt

How would you reword this to make it easier to understand?

Ok, I get it now! Thanks for helping me catch up!

I think I glazed over that part because it said "depending on the textarea". Once you've explained it, it makes sense.

I'll take a shot at some re-wording that might make it clearer in a PR.

As promised: #1551