Skip to content

[Bug] Give a proper error message for buffers that don't evaluate #2

@wildwestrom

Description

@wildwestrom

Usually when I need a scratch buffer, it's to put information that I don't intend to execute.
I used to use Emacs for notetaking but I'm using neovim now.

Right now, if I try to open a scratch buffer of type markdown, it gives me a cryptic error message.

Seems like you've sort of hardcoded that functionality. I'm not sure how you would like it to be instead though.

function buffer.eval()
local lines = vim.api.nvim_buf_get_lines(buffer.bufnr, 0, -1, true)
local filetype = vim.api.nvim_buf_get_option(buffer.bufnr, "filetype")
require("scratch.eval")[filetype](lines)
end

Can you add filetypes for markdown, org, asciidoc, and plaintext? That should cover the major ones.
Maybe also add json, yaml, xml, and other information types that also don't evaluate.

Steps:

  1. Run ex command :Telescope scratch md

Expected:

Open the buffer without issue.

Actual:

A cryptic error message is shown to me.

Workaround:

Just use :ScratchNew md

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions