hrsh7th / cmp-path

nvim-cmp source for path
MIT License
599 stars 55 forks source link

[Feature request] syntax highlighting in file preview #36

Closed registerGen closed 2 years ago

registerGen commented 2 years ago

And I also viewed the code and came up with a naive idea to implement this.

Since the &ft of preview window is always markdown, so we can't change &ft (am I right?). But the preview content is actually a markdown code block, so we can make use of that.

Create a new buffer which is named after the file name, check the &ft of that buffer, and delete that buffer. The &ft is what we want.

Note: for some unknown reason, treesitter highlight is not available, but the regex-based highlight is loaded.

A better solution is greatly appreciated.

registerGen commented 2 years ago

Of course we can also change the code in nvim-cmp so that this issue can be closed right after that.

hrsh7th commented 2 years ago

I don't want to create new pseudo buffer (it has big side effect). I'm expecting to able to use the vim.filetype API but it would'nt usavle at the moment.

registerGen commented 2 years ago

I'm expecting to able to use the vim.filetype API but it would'nt usavle at the moment.

Yes you are right. It doesn't have a function that can return the &ft by giving it the file name.