camspiers / snap

A fast finder system for neovim.
The Unlicense
490 stars 17 forks source link

File loses filetype where I select them through snap #7

Closed weizheheng closed 3 years ago

weizheheng commented 3 years ago

Hi, thank you for this plugin, I tried to play around with it, managed to install it through vim-plug. However, I am facing this issue where the file loses the filetype hence the syntax highlighting when I open the file through snap. I have this in my config:

local preview_file = snap.get'preview.file'
snap.register.map({"n"}, {"<Leader>pp"}, function ()
  snap.run {
    producer = snap.get'consumer.fzf'(snap.get'producer.ripgrep.file'),
    select = snap.get'select.file'.select,
    multiselect = snap.get'select.file'.multiselect,
    views = {preview_file}
  }
end)
camspiers commented 3 years ago

Are you sure it loses filetype? It might be that you have treesitter enabled but not activated for the language of the file? Unsure.

camspiers commented 3 years ago

@marcushwz can you try again now?

weizheheng commented 3 years ago

@camspiers , Hi, thanks for the reply. I can confirm it's working now.

beardedsakimonkey commented 3 years ago

This is still an issue for me pretty frequently. Unfortunately I haven't managed to consistently reproduce it. It seems like neither the filetype or syntax options are set.

I've tried tweaking the commands used to open the file, but I'm still running into the issue.

diff --git a/lua/snap/select/file.lua b/lua/snap/select/file.lua
index 9ada17d..c0ef93d 100644
--- a/lua/snap/select/file.lua
+++ b/lua/snap/select/file.lua
@@ -51,17 +51,21 @@ do
       local _3_ = type
       if (_3_ == nil) then
         if (winnr ~= false) then
-          return vim.api.nvim_win_set_buf(winnr, buffer)
+          vim.api.nvim_command("buffer" .. buffer)
         end
       elseif (_3_ == "vsplit") then
-        vim.api.nvim_command("vsplit")
-        return vim.api.nvim_win_set_buf(0, buffer)
+        vim.api.nvim_command("vert sbuffer" .. buffer)
       elseif (_3_ == "split") then
-        vim.api.nvim_command("split")
-        return vim.api.nvim_win_set_buf(0, buffer)
+        vim.api.nvim_command("sbuffer" .. buffer)
       elseif (_3_ == "tab") then
-        vim.api.nvim_command("tabnew")
-        return vim.api.nvim_win_set_buf(0, buffer)
+        vim.api.nvim_command("tab sbuffer" .. buffer)
       end
     end
     v_0_0 = select0